Skip to content

Prisoner feature bugfix#110

Merged
Asdow merged 10 commits into
masterfrom
prisoner-rework
Jan 22, 2023
Merged

Prisoner feature bugfix#110
Asdow merged 10 commits into
masterfrom
prisoner-rework

Conversation

@Asdow
Copy link
Copy Markdown
Contributor

@Asdow Asdow commented Jan 22, 2023

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.

Asdow added 9 commits January 22, 2023 02:09
- 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
@Asdow Asdow requested a review from majcosta January 22, 2023 01:08
Comment thread Tactical/Overhead.cpp
Comment thread Tactical/Overhead.cpp Outdated
Comment thread Tactical/Overhead.cpp Outdated
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());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

random_shuffle is deprecated, use std::shuffle with a std::mt19937 generator instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?
std::shuffle(possibleEscapeDirections.begin(), possibleEscapeDirections.end(), std::mt19937(time(nullptr)));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread Tactical/Overhead.cpp Outdated
Comment thread Tactical/Overhead.cpp
void AttemptToCapturePlayerSoldiers()
{
#ifdef JA2UB
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, szPrisonerTextStr[STR_PRISONER_REFUSE_TAKE_PRISONERS]);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we probably should just skip the whole surrender codepath if it's UB, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Strategic/Queen Command.cpp Outdated
Comment thread Strategic/Queen Command.cpp
Comment thread Strategic/Queen Command.cpp Outdated
Comment thread Strategic/Queen Command.cpp Outdated
Comment thread Strategic/Quests.h
Comment on lines +759 to +766
enum PowQuestState
{
Q_FAIL,
Q_SUCCESS,
Q_RESET,
Q_END,
Q_LEFT_SECTOR
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider using enum class for this if you don't need them to implicity convert to int

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting identifier "Q_END" is undefined errors in strategicmap.cpp after changing this to enum class

Comment thread Strategic/strategicmap.cpp
Comment thread Tactical/Overhead.cpp
@majcosta
Copy link
Copy Markdown
Contributor

concluding: https://twitter.com/iamdevloper/status/397664295875805184

Copy link
Copy Markdown
Contributor

@majcosta majcosta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🙃

@Asdow Asdow merged commit ae1fd0a into master Jan 22, 2023
@Asdow Asdow deleted the prisoner-rework branch January 22, 2023 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rework or Revert r9095 - if POW, any mercs above 3 are removed from game permanent (not avoidable if more than 3 mercs)

2 participants