Prisoner feature bugfix#110
Conversation
- Quests were ended prematurely if one had prisoners in both alma and tixa - Strategic status flags for rescue/escape were not set properly - Only the maximum amount a prison can hold will be taken as POWs, rest of the mercs will either escape or have to fight to the death, to prevent a player having unrescuable POWs - Capturing a mercenary had a lot of functions called that should not have been, IF the merc is not going to be captured after all
Incapacitated mercs left behind will die. Should probably prioritize incapacitated mercs to be captured by the enemy to prevent needless deaths
| bool escaped = false; | ||
| // Look for an escape direction for remaining mercs | ||
| std::vector<WorldDirections> possibleEscapeDirections{ NORTH, EAST, SOUTH, WEST }; | ||
| std::random_shuffle(possibleEscapeDirections.begin(), possibleEscapeDirections.end()); |
There was a problem hiding this comment.
random_shuffle is deprecated, use std::shuffle with a std::mt19937 generator instead
There was a problem hiding this comment.
Like this?
std::shuffle(possibleEscapeDirections.begin(), possibleEscapeDirections.end(), std::mt19937(time(nullptr)));
There was a problem hiding this comment.
https://en.cppreference.com/w/cpp/algorithm/random_shuffle see the examples
| void AttemptToCapturePlayerSoldiers() | ||
| { | ||
| #ifdef JA2UB | ||
| ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_REFUSE_TAKE_PRISONERS]); |
There was a problem hiding this comment.
we probably should just skip the whole surrender codepath if it's UB, no?
There was a problem hiding this comment.
This was the easiest way to deal with offering to surrender ourselves to the enemy. No need to disable or delete the button from UI, enemy simply wants you dead, always.
AI routines and quests related to POW are skipped via compiler switches.
| enum PowQuestState | ||
| { | ||
| Q_FAIL, | ||
| Q_SUCCESS, | ||
| Q_RESET, | ||
| Q_END, | ||
| Q_LEFT_SECTOR | ||
| }; |
There was a problem hiding this comment.
consider using enum class for this if you don't need them to implicity convert to int
There was a problem hiding this comment.
I'm getting identifier "Q_END" is undefined errors in strategicmap.cpp after changing this to enum class
Will close #43 and #56
Mercs that are not captured by the enemy when surrendering have a chance to escape to fight another day. Any captured POW can be rescued from the prison they got sent to.