Skip to content

fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch and optimize the MSG#2408

Open
stephanmeesters wants to merge 3 commits intoTheSuperHackers:mainfrom
stephanmeesters:fix/gamelogicdispatch-retaliation
Open

fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch and optimize the MSG#2408
stephanmeesters wants to merge 3 commits intoTheSuperHackers:mainfrom
stephanmeesters:fix/gamelogicdispatch-retaliation

Conversation

@stephanmeesters
Copy link

@stephanmeesters stephanmeesters commented Mar 4, 2026

Simplifies the code and prevents other players from setting each others retaliation mode. Tested with 1k replays and with own replay where I swap the retaliation mode on both sides couple times and test with some combat.

Generals (not Zero Hour) does not have a retaliation mode

Null check of thisPlayer will be handled by #2383

@greptile-apps
Copy link

greptile-apps bot commented Mar 4, 2026

Greptile Summary

This PR fixes a logic bug in MSG_ENABLE_RETALIATION_MODE handling where a crafted message could supply an arbitrary player index as argument 0 and toggle another player's retaliation mode. The fix correctly uses thisPlayer (derived from msg->getPlayerIndex(), i.e., the actual message sender) instead of a user-supplied argument.

Key improvements:

  • Security fix: Retaliation mode is now always applied to the message sender, preventing cross-player manipulation via replayed or malicious messages.
  • RETAIL_COMPATIBLE_CRC compatibility: A preprocessor guard in Player.cpp conditionally prepends the legacy player-index argument for replay CRC compatibility, while the dispatch correctly reads the boolean from argument 1 in compatible builds and argument 0 otherwise.
  • Acknowledged deferral: The PR description notes that a null check for thisPlayer will be addressed by fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher #2383.

The changes are consistent and correct in their intent.

Confidence Score: 5/5

  • The PR implements a correct security fix with proper replay CRC compatibility; safe to merge.
  • All changes verified: the security fix correctly prevents cross-player manipulation by using the message sender's identity from metadata rather than user-supplied arguments, the RETAIL_COMPATIBLE_CRC handling is consistent between producer and consumer, and the code logic is sound. The acknowledged deferral of a null check to fix(logic): Add nullptr check to thisPlayer in GameLogic::logicMessageDispatcher #2383 is handled intentionally by the author and does not create a merge risk for this PR.
  • No files require special attention.

Last reviewed commit: 1b1cd37

@stephanmeesters stephanmeesters changed the title fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch and optimize the MSG for non-retail mode Mar 4, 2026
@stephanmeesters stephanmeesters changed the title fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch and optimize the MSG for non-retail mode fix(logic): Improve handling of ENABLE_RETALIATION_MODE in GameLogicDispatch and optimize the MSG Mar 4, 2026
{
//Logically turns on or off retaliation mode for a specified player.
Int playerIndex = msg->getArgument( 0 )->integer;
#if RETAIL_COMPATIBLE_CRC
Copy link
Author

Choose a reason for hiding this comment

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

Probably actually use RETAIL_COMPATIBLE_NETWORKING here because it doesn't change the CRC

Copy link

Choose a reason for hiding this comment

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

I expect it can still be part of replays if it was recorded while someone used a Control Hack.

Copy link
Author

@stephanmeesters stephanmeesters Mar 5, 2026

Choose a reason for hiding this comment

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

OK but those will still mismatch with current patch as we don't read the player index from the msg argument anymore

Copy link
Author

Choose a reason for hiding this comment

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

So it's the same question as in #2380 about whether to allow the control hack in retail compat mode

@Caball009
Copy link

I'm fine with the current code, but I do think either the comment could be more informative and / or there could be an assertion like DEBUG_ASSERTCRASH(ThePlayerList->getNthPlayer(msg->getArgument(0)->integer) == thisPlayer.

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.

3 participants