Skip to content

chore(gamemessage): Clean up GameMessage::getCommandTypeAsString#2695

Merged
xezon merged 6 commits into
TheSuperHackers:mainfrom
Caball009:fix_switch_getCommandTypeAsString
May 13, 2026
Merged

chore(gamemessage): Clean up GameMessage::getCommandTypeAsString#2695
xezon merged 6 commits into
TheSuperHackers:mainfrom
Caball009:fix_switch_getCommandTypeAsString

Conversation

@Caball009
Copy link
Copy Markdown

@Caball009 Caball009 commented May 9, 2026

This PR cleans up the switch statement in GameMessage::getCommandTypeAsString to make it exactly like the GameMessage enum.

Checks commits for clean diff.

TODO:

  • Replicate in Generals.

@Caball009 Caball009 added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Fix Is fixing something, but is not user facing labels May 9, 2026
@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 9, 2026

Greptile Summary

This PR aligns the getCommandTypeAsString switch statement in both Generals and GeneralsMD MessageStream.cpp files with their respective GameMessage::Type enum definitions, correcting the order of entries, adding previously missing case labels, consolidating scattered #ifdef ALLOW_SURRENDER blocks, and cleaning up #endif// comment style.

  • Generals: Adds MSG_IMPOSSIBLE_ATTACK_HINT, MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION_HINT, MSG_DO_SPECIAL_POWER_OVERRIDE_DESTINATION, MSG_SET_MINE_CLEARING_DETAIL, and MSG_BEGIN_DEBUG_NETWORK_MESSAGES; repositions MSG_DO_ATTACK_OBJECT_AFTER_MOVING_HINT and MSG_HACK_HINT; and consolidates the three ALLOW_SURRENDER network-message case labels into one block.
  • GeneralsMD: Applies the same changes plus moves the fast-forward/pause/step-frame meta messages to their correct enum position, adds MSG_ENABLE_RETALIATION_MODE, and corrects the debug-network guard from #if defined(RTS_DEBUG) to #if defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE) to match the header enum.

Confidence Score: 5/5

This PR is safe to merge; it only touches a debug/logging string function and carries no runtime risk.

The changes are purely additive and reordering within a read-only string-lookup function. Every added case label corresponds to an enum value already present in the respective header, and the consolidation of ALLOW_SURRENDER guards is a straightforward grouping of pre-existing code. There is no logic, serialization, or network behaviour affected.

No files require special attention.

Important Files Changed

Filename Overview
Generals/Code/GameEngine/Source/Common/MessageStream.cpp Switch statement cleaned up to match enum order; missing case labels added and ALLOW_SURRENDER blocks consolidated. Changes are correct relative to the Generals header enum.
GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Switch statement fully re-synced with the ZH enum: fast-forward/pause messages moved earlier, ALLOW_SURRENDER consolidated, MSG_ENABLE_RETALIATION_MODE added, and debug-network guard extended to include _ALLOW_DEBUG_CHEATS_IN_RELEASE.

Reviews (4): Last reviewed commit: "Replicated in Generals (manually)." | Re-trigger Greptile

Copy link
Copy Markdown

@xezon xezon left a comment

Choose a reason for hiding this comment

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

Makes sense for the most part.

Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp Outdated
#ifdef ALLOW_SURRENDER
CASE_LABEL(MSG_DO_SURRENDER)
CASE_LABEL(MSG_RETURN_TO_PRISON)
CASE_LABEL(MSG_PICK_UP_PRISONER)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

They are referenced in GameLogicDispatch.cpp and CommandXlat.cpp however. Maybe add the enum values instead?

Copy link
Copy Markdown
Author

@Caball009 Caball009 May 9, 2026

Choose a reason for hiding this comment

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

These look like network messages, though. They can't be behind a macro, and I'm also reluctant to add them without a macro.

I could just keep them in the switch statement and leave it for another time.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

They can just be treated like any other META message

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

META indicates Client side only, and these are Logic messages. I've put them back in.

Comment thread GeneralsMD/Code/GameEngine/Source/Common/MessageStream.cpp
@Caball009 Caball009 force-pushed the fix_switch_getCommandTypeAsString branch from 86c5a7c to 9041515 Compare May 10, 2026 14:36
@Caball009
Copy link
Copy Markdown
Author

Caball009 commented May 13, 2026

Replicated in Generals by hand.

Gen code is now the same except for 28 ZH specific enum values (and _ALLOW_DEBUG_CHEATS_IN_RELEASE macro):

MSG_META_TOGGLE_CAMERA_TRACKING_DRAWABLE

MSG_CHEAT_RUNSCRIPT1
MSG_CHEAT_RUNSCRIPT2
MSG_CHEAT_RUNSCRIPT3
MSG_CHEAT_RUNSCRIPT4
MSG_CHEAT_RUNSCRIPT5
MSG_CHEAT_RUNSCRIPT6
MSG_CHEAT_RUNSCRIPT7
MSG_CHEAT_RUNSCRIPT8
MSG_CHEAT_RUNSCRIPT9
MSG_CHEAT_TOGGLE_SPECIAL_POWER_DELAYS
MSG_CHEAT_SWITCH_TEAMS
MSG_CHEAT_KILL_SELECTION
MSG_CHEAT_TOGGLE_HAND_OF_GOD_MODE
MSG_CHEAT_INSTANT_BUILD
MSG_CHEAT_DESHROUD
MSG_CHEAT_ADD_CASH
MSG_CHEAT_GIVE_ALL_SCIENCES
MSG_CHEAT_GIVE_SCIENCEPURCHASEPOINTS
MSG_CHEAT_SHOW_HEALTH
MSG_CHEAT_TOGGLE_MESSAGE_TEXT

MSG_META_DEBUG_SHOW_AUDIO_LOCATIONS

MSG_META_DEMO_TOGGLE_SUPPLY_CENTER_PLACEMENT

MSG_META_DEBUG_OBJECT_ID_PERFORMANCE
MSG_META_DEBUG_DRAWABLE_ID_PERFORMANCE
MSG_META_DEBUG_SLEEPY_UPDATE_PERFORMANCE

MSG_SABOTAGE_HINT

MSG_ENABLE_RETALIATION_MODE

@xezon xezon merged commit c8b5f61 into TheSuperHackers:main May 13, 2026
17 checks passed
@Caball009 Caball009 deleted the fix_switch_getCommandTypeAsString branch May 13, 2026 18:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix Is fixing something, but is not user facing Gen Relates to Generals Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants