Skip to content

[GEN][ZH] Polish ui messages for debug commands #1258

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 18, 2025

Conversation

xezon
Copy link

@xezon xezon commented Jul 10, 2025

Merge with Rebase

This change has 2 commits.

The first commit adds localization labels to the existing ui messages for debug commands.

And the second commit adds new ui messages for more debug commands. This way there is more feedback when toggling this.

TODO

  • Replicate in Generals

@xezon xezon added GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Debug Is mostly debug functionality labels Jul 10, 2025

// This function is not performance tuned.. Its really only for Worldbuilder. jkmcd
virtual AsciiStringVec& getStringsWithLabelPrefix(AsciiString label) = 0;

virtual void initMapStringFile( const AsciiString& filename ) = 0;

#if __cplusplus < 201103L // TheSuperHackers @todo Remove function when abandoning VC6
inline UnicodeString FETCH_OR_SUBSTITUTE_FORMAT( const Char *label, const WideChar *substituteFormat, ... )
Copy link
Author

Choose a reason for hiding this comment

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

I had to do this because VC6 does not support variadic macros.

@xezon xezon force-pushed the xezon/polish-debug-messages branch from 0d1c29e to 7faea62 Compare July 10, 2025 21:37
@xezon
Copy link
Author

xezon commented Jul 15, 2025

After this change: Move debug command code into smaller functions, then make some of them multiplayer compatible.

@xezon xezon force-pushed the xezon/polish-debug-messages branch from 7faea62 to 47e30e8 Compare July 16, 2025 20:23
Copy link

@Mauller Mauller left a comment

Choose a reason for hiding this comment

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

Looks good overall

@xezon xezon force-pushed the xezon/polish-debug-messages branch from 47e30e8 to 309fee9 Compare July 18, 2025 21:32
@xezon
Copy link
Author

xezon commented Jul 18, 2025

Replicated in Generals with a number of conflicts.

$ git diff 18d8a82c471a7093ef49f588c7c4087cfde6b288..93f6fea2fa381a792a961e133d66351e49fbe278 > changes.patch

$ git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch                                 changes.patch:165: trailing whitespace.
}  // end
changes.patch:265: trailing whitespace.

changes.patch:367: trailing whitespace.

changes.patch:414: trailing whitespace.
                }
changes.patch:425: trailing whitespace.
                }
Checking patch Generals/Code/GameEngine/Include/GameClient/GameText.h...
Checking patch Generals/Code/GameEngine/Include/GameClient/InGameUI.h...
Hunk #1 succeeded at 362 (offset -15 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/GameText.cpp...
Checking patch Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp...
Hunk #1 succeeded at 2029 (offset -56 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp...
Hunk #1 succeeded at 2818 (offset -147 lines).
Hunk #2 succeeded at 2833 (offset -147 lines).
Hunk #3 succeeded at 3095 (offset -150 lines).
error: while searching for:
                                {

                                        TheWritableGlobalData->m_specialPowerUsesDelay = 1 - TheGlobalData->m_specialPowerUsesDelay;
                                        TheInGameUI->message( UnicodeString( L"Special Power (Superweapon) Delay: %s" ),
                                                                                                            TheGlobalData->m_specialPowerUsesDelay ? L"ON" : L"OFF" );

                                }  // end if


error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3322
error: while searching for:
                                                }
                                        }
                                }
                                TheInGameUI->message( UnicodeString( L"Granting all sciences!" ));
                                disp = DESTROY_MESSAGE;
                        }
                        break;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3424
error: while searching for:
                                Player *player = ThePlayerList->getLocalPlayer();
                                if (player)
                                        player->addSciencePurchasePoints(1);
                                TheInGameUI->message( UnicodeString( L"Adding a SciencePurchasePoint" ));
                                disp = DESTROY_MESSAGE;
                        }
                        break;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3436
error: while searching for:
                        if ( !TheGameLogic->isInMultiplayerGame() )
                        {
                                TheWritableGlobalData->m_showObjectHealth = 1 - TheGlobalData->m_showObjectHealth;
                                TheInGameUI->message( UnicodeString( L"Object Health %s" ),
                                                                                                            TheGlobalData->m_showObjectHealth ? L"ON" : L"OFF" );
                        }
                        break;


error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3446
error: while searching for:

                                // when messages get turned on, display a message
                                if( TheInGameUI->isMessagesOn() )
                                        TheInGameUI->message( TheGameText->fetch( "GUI:MessagesOn" ) );

                                disp = DESTROY_MESSAGE;
                        }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3462
Hunk #9 succeeded at 3647 (offset -395 lines).
Hunk #10 succeeded at 3783 (offset -395 lines).
Hunk #11 succeeded at 3893 (offset -399 lines).
Hunk #12 succeeded at 3902 (offset -399 lines).
Hunk #13 succeeded at 3911 (offset -399 lines).
Hunk #14 succeeded at 3973 (offset -399 lines).
Hunk #15 succeeded at 4217 (offset -402 lines).
Hunk #16 succeeded at 4236 (offset -402 lines).
Hunk #17 succeeded at 4246 (offset -402 lines).
Hunk #18 succeeded at 4273 (offset -402 lines).
error: while searching for:
                {
                        TheWritableGlobalData->m_debugSupplyCenterPlacement = !TheWritableGlobalData->m_debugSupplyCenterPlacement;

                        TheInGameUI->message( UnicodeString( L"Log SupplyCenter Placement is %s" ), TheGlobalData->m_debugSupplyCenterPlacement ? L"ON" : L"OFF" );
                        disp = DESTROY_MESSAGE;
                        break;
                }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:4679
Hunk #20 succeeded at 4291 (offset -417 lines).
Hunk #21 succeeded at 4315 (offset -417 lines).
Hunk #22 succeeded at 4327 (offset -417 lines).
Hunk #23 succeeded at 4341 (offset -417 lines).
Hunk #24 succeeded at 4353 (offset -417 lines).
Hunk #25 succeeded at 4432 (offset -417 lines).
Hunk #26 succeeded at 4447 (offset -417 lines).
Hunk #27 succeeded at 4465 (offset -417 lines).
Hunk #28 succeeded at 4483 (offset -417 lines).
error: while searching for:
                //-----------------------------------------------------------------------------------------
                case GameMessage::MSG_META_DEBUG_SHOW_EXTENTS:
                        TheWritableGlobalData->m_showCollisionExtents = 1 - TheGlobalData->m_showCollisionExtents;
                        TheInGameUI->message( UnicodeString( L"Show Object Extents %s" ),
                                                    TheGlobalData->m_showCollisionExtents ? L"ON" : L"OFF" );
                        break;

    //------------------------------------------------------------------------------- DEMO MESSAGES
    //-----------------------------------------------------------------------------------------
    case GameMessage::MSG_META_DEBUG_SHOW_AUDIO_LOCATIONS:
      TheWritableGlobalData->m_showAudioLocations = 1 - TheGlobalData->m_showAudioLocations;
      TheInGameUI->message( UnicodeString( L"Show AudioLocations %s" ),
                            TheGlobalData->m_showAudioLocations ? L"ON" : L"OFF" );
      break;

    //------------------------------------------------------------------------------- DEMO MESSAGES

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:4876
Hunk #30 succeeded at 4516 (offset -433 lines).
Hunk #31 succeeded at 4549 (offset -433 lines).
Hunk #32 succeeded at 4571 (offset -433 lines).
Hunk #33 succeeded at 4622 (offset -433 lines).
Hunk #34 succeeded at 4633 (offset -433 lines).
Hunk #35 succeeded at 4642 (offset -433 lines).
Hunk #36 succeeded at 4655 (offset -433 lines).
error: while searching for:
                //-----------------------------------------------------------------------------------------
                case GameMessage::MSG_META_DEBUG_SLEEPY_UPDATE_PERFORMANCE:
                {
                        TheInGameUI->message( UnicodeString(L"Number of Sleepy Modules: %d."), TheGameLogic->getNumberSleepyUpdates() );
                        break;
                }


error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5047
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        double timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d ObjectID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameLogic->getObjectIDCounter() );


                        QueryPerformanceCounter((LARGE_INTEGER *)&startTime64);

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5069
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d ObjectID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameLogic->getObjectIDCounter() );


                        QueryPerformanceCounter((LARGE_INTEGER *)&startTime64);

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5083
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d ObjectID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameLogic->getObjectIDCounter() );

                        break;
                }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5097
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        double timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d DrawableID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameClient->getDrawableIDCounter() );


                        QueryPerformanceCounter((LARGE_INTEGER *)&startTime64);

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5120
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d DrawableID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameClient->getDrawableIDCounter() );


                        QueryPerformanceCounter((LARGE_INTEGER *)&startTime64);

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5134
error: while searching for:
                        QueryPerformanceCounter((LARGE_INTEGER *)&endTime64);
                        timeToUpdate = ((double)(endTime64-startTime64) / (double)(freq64));

                        TheInGameUI->message( UnicodeString(L"Time to run %d DrawableID lookups is %f.  Next index is %d."), numberLookups, timeToUpdate, (Int)TheGameClient->getDrawableIDCounter() );

                        break;
                }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:5148
Hunk #44 succeeded at 4699 (offset -550 lines).
Applied patch Generals/Code/GameEngine/Include/GameClient/GameText.h cleanly.
Applied patch Generals/Code/GameEngine/Include/GameClient/InGameUI.h cleanly.
Applied patch Generals/Code/GameEngine/Source/GameClient/GameText.cpp cleanly.
Applied patch Generals/Code/GameEngine/Source/GameClient/InGameUI.cpp cleanly.
Applying patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp with 14 rejects...
Hunk #1 applied cleanly.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Rejected hunk #4.
Rejected hunk #5.
Rejected hunk #6.
Rejected hunk #7.
Rejected hunk #8.
Hunk #9 applied cleanly.
Hunk #10 applied cleanly.
Hunk #11 applied cleanly.
Hunk #12 applied cleanly.
Hunk #13 applied cleanly.
Hunk #14 applied cleanly.
Hunk #15 applied cleanly.
Hunk #16 applied cleanly.
Hunk #17 applied cleanly.
Hunk #18 applied cleanly.
Rejected hunk #19.
Hunk #20 applied cleanly.
Hunk #21 applied cleanly.
Hunk #22 applied cleanly.
Hunk #23 applied cleanly.
Hunk #24 applied cleanly.
Hunk #25 applied cleanly.
Hunk #26 applied cleanly.
Hunk #27 applied cleanly.
Hunk #28 applied cleanly.
Rejected hunk #29.
Hunk #30 applied cleanly.
Hunk #31 applied cleanly.
Hunk #32 applied cleanly.
Hunk #33 applied cleanly.
Hunk #34 applied cleanly.
Hunk #35 applied cleanly.
Hunk #36 applied cleanly.
Rejected hunk #37.
Rejected hunk #38.
Rejected hunk #39.
Rejected hunk #40.
Rejected hunk #41.
Rejected hunk #42.
Rejected hunk #43.
Hunk #44 applied cleanly.
$ git diff 93f6fea2fa381a792a961e133d66351e49fbe278..ea7dd73f65500e5d0d04c75397537aa00522428e > changes.patch

$ git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch                                 changes.patch:41: trailing whitespace.
                }
changes.patch:49: trailing whitespace.
                }
changes.patch:62: trailing whitespace.
                }
changes.patch:75: trailing whitespace.
                }
changes.patch:101: trailing whitespace.
                }
Checking patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp...
error: while searching for:
                                        AsciiString scriptName;
                                        scriptName.format("KEY_F%d", script);
                                        TheScriptEngine->runScript(scriptName);
                                }
                                disp = DESTROY_MESSAGE;
                        }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3304
error: while searching for:
                                // Doesn't make a valid network message
                                Player *localPlayer = ThePlayerList->getLocalPlayer();
                                localPlayer->toggleInstantBuild();
                                disp = DESTROY_MESSAGE;
                        }
                        break;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3391
error: while searching for:
                                Player *localPlayer = ThePlayerList->getLocalPlayer();
                                Money *money = localPlayer->getMoney();
                                money->deposit( 10000 );
                        }
                        break;
                }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3402
Hunk #4 succeeded at 3549 (offset -403 lines).
Hunk #5 succeeded at 3559 (offset -403 lines).
Hunk #6 succeeded at 3807 (offset -403 lines).
Hunk #7 succeeded at 3822 (offset -403 lines).
Hunk #8 succeeded at 4043 (offset -407 lines).
Hunk #9 succeeded at 4059 (offset -407 lines).
Hunk #10 succeeded at 4074 (offset -407 lines).
Hunk #11 succeeded at 4089 (offset -407 lines).
error: while searching for:
                                                        d->clearAndSetModelConditionFlags(empty, empty);
                                                }
                                        }
        }
                        }
                        disp = DESTROY_MESSAGE;
                        break;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:4477
error: while searching for:
                        // Doesn't make a valid network message
                        Player *localPlayer = ThePlayerList->getLocalPlayer();
                        localPlayer->toggleIgnorePrereqs();
                        disp = DESTROY_MESSAGE;
                        break;
    }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:4490
Hunk #14 succeeded at 4130 (offset -414 lines).
Hunk #15 succeeded at 4147 (offset -414 lines).
error: while searching for:
                                Player *localPlayer = ThePlayerList->getLocalPlayer();
                                Money *money = localPlayer->getMoney();
                                money->deposit( 10000 );
                        }
                        break;
                }

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:4533
Hunk #17 succeeded at 4193 (offset -418 lines).
Hunk #18 succeeded at 4239 (offset -418 lines).
Applying patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp with 6 rejects...
Rejected hunk #1.
Rejected hunk #2.
Rejected hunk #3.
Hunk #4 applied cleanly.
Hunk #5 applied cleanly.
Hunk #6 applied cleanly.
Hunk #7 applied cleanly.
Hunk #8 applied cleanly.
Hunk #9 applied cleanly.
Hunk #10 applied cleanly.
Hunk #11 applied cleanly.
Rejected hunk #12.
Rejected hunk #13.
Hunk #14 applied cleanly.
Hunk #15 applied cleanly.
Rejected hunk #16.
Hunk #17 applied cleanly.
Hunk #18 applied cleanly.

@xezon xezon merged commit 3477320 into TheSuperHackers:main Jul 18, 2025
15 checks passed
@xezon xezon deleted the xezon/polish-debug-messages branch July 18, 2025 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Debug Is mostly debug functionality Gen Relates to Generals GUI For graphical user interface Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add gui messages for all debug cheats
2 participants