Skip to content

fix(commandxlat): Consume the cheat and demo messages consistently when handled - #3138

Open
bas-slats wants to merge 1 commit into
TheSuperHackers:mainfrom
bas-slats:fix/2769-consume-add-cash-message
Open

fix(commandxlat): Consume the cheat and demo messages consistently when handled#3138
bas-slats wants to merge 1 commit into
TheSuperHackers:mainfrom
bas-slats:fix/2769-consume-add-cash-message

Conversation

@bas-slats

@bas-slats bas-slats commented Aug 14, 2026

Copy link
Copy Markdown

CommandTranslator::translateGameMessage has several cheat and demo cases that perform their action without consuming the message, unlike their sibling cases, which set disp = DESTROY_MESSAGE when handled. This change consumes the message in all of them:

  • MSG_CHEAT_ADD_CASH (the issue's subject)
  • MSG_CHEAT_SHOW_HEALTH
  • MSG_META_DEMO_ADD_CASH
  • MSG_META_DEMO_TOGGLE_RENDER
  • MSG_META_DEMO_KILL_AREA_SELECTION
  • MSG_META_DEMO_TOGGLE_METRICS (PERF_TIMERS builds)
  • MSG_META_DEMO_PERFORM_STATISTICAL_DUMP (DUMP_PERF_STATS builds)

Found by sweeping the whole switch for cheat/demo cases that lack a disp assignment; the stacked RUNSCRIPT and OBJECTIVE_MOVIE blocks and the remaining cheat/demo cases already consume. Code comments are removed per review.

Testing

Compiles with the win32 preset (VS2019 16.11, Ninja Multi-Config, Release); CommandXlat.cpp builds without warnings and generalszh.exe links. The two #ifdef-guarded sites are not compiled by this preset and are syntax-identical one-liners; the debug/profile CI presets exercise them.

An earlier build of this branch (with the two add cash changes) was smoke tested in game against retail Steam Zero Hour 1.04 data: boots, loads and plays a skirmish normally. The cheat messages are not bound in normal builds, so the disposition change is verified by inspection against the sibling cases.


This change was developed with AI assistance (Claude), human-directed: every case in the switch was checked by hand for the missing disposition, and the change was verified to compile as above. No gameplay simulation code is touched.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

PR Summary by Qodo

Fix: consume Add Cash cheat/demo messages after handling

🐞 Bug fix 🕐 10-20 Minutes

Grey Divider

AI Description

• Consume Add Cash cheat message after single-player handling.
• Align demo Add Cash behavior with other demo debug messages.
• Prevent repeated processing of handled cheat/debug messages.
Diagram

graph TD
  A["GameMessage"] --> B["CommandTranslator"] --> C{"Cheat/AddCash?"}
  C -->|"Yes (SP)"| D["Deposit + UI msg"] --> E["disp=DESTROY_MESSAGE"]
  C -->|"No"| F["Other handlers"]

  subgraph Legend
    direction LR
    _msg["Message"] ~~~ _mod["Module"] ~~~ _dec{"Decision"} ~~~ _act["Action"]
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Centralize cheat-message disposition policy
  • ➕ Ensures all cheat/debug handlers consistently consume (or not) via a single helper.
  • ➕ Reduces risk of future inconsistencies across similar switch cases.
  • ➖ More refactor surface area than needed for a targeted bug fix.
  • ➖ May be harder to validate without broader gameplay/message-routing tests.

Recommendation: Current approach is appropriate for a scoped parity bug fix: set disp=DESTROY_MESSAGE in the two affected cases to match sibling cheat/demo handlers. A follow-up refactor could centralize disposition behavior for cheat/debug messages, but it’s not necessary to resolve the reported inconsistency.

Files changed (1) +6 / -0

Bug fix (1) +6 / -0
CommandXlat.cppConsume Add Cash cheat/demo messages after handling +6/-0

Consume Add Cash cheat/demo messages after handling

• Sets the message disposition to DESTROY_MESSAGE after handling the Add Cash cheat and the corresponding demo message. This aligns behavior with other cheat/debug message handlers in single-player paths to avoid leaving handled messages unconsumed.

Core/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Tip of the day
💡 Did you know, you can describe a rule in plain language on the Rules page and Qodo drafts it for you

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Qodo Logo

@Skyaero42

Copy link
Copy Markdown

There are more places where the message isn't consumed, like MSG_META_DEMO_TOGGLE_RENDER. Shouldn't it be consumed there as well?

money->deposit( 10000 );
TheInGameUI->messageNoFormat( TheGameText->FETCH_OR_SUBSTITUTE("GUI:DebugAddCash", L"Add Cash") );

// TheSuperHackers @fix Consume the message consistently with the other cheat messages.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Needs no comment. Debug functionality. No one will look back at it.

@xezon

xezon commented Aug 14, 2026

Copy link
Copy Markdown

There are more places where the message isn't consumed, like MSG_META_DEMO_TOGGLE_RENDER. Shouldn't it be consumed there as well?

Yes looks like there are a couple more.

@bas-slats bas-slats changed the title fix(commandxlat): Consume the add cash cheat messages when handled fix(commandxlat): Consume the cheat and demo messages consistently when handled Aug 15, 2026
@bas-slats
bas-slats force-pushed the fix/2769-consume-add-cash-message branch from 4bcfd6f to 49682fe Compare August 15, 2026 17:59
@bas-slats

Copy link
Copy Markdown
Author

Swept the whole translateGameMessage switch for cheat and demo cases that perform their action without setting a disposition. Five more cases consume the message now: MSG_CHEAT_SHOW_HEALTH, MSG_META_DEMO_TOGGLE_RENDER, MSG_META_DEMO_KILL_AREA_SELECTION, MSG_META_DEMO_TOGGLE_METRICS (PERF_TIMERS builds) and MSG_META_DEMO_PERFORM_STATISTICAL_DUMP (DUMP_PERF_STATS builds). The stacked RUNSCRIPT and OBJECTIVE_MOVIE blocks and the remaining cheat/demo cases already consume. The code comments are removed.

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.

GameMessage::MSG_CHEAT_ADD_CASH in CommandXlat does not consume message

3 participants