Skip to content

Conversation

@xezon
Copy link

@xezon xezon commented Jul 20, 2025

This change implements the following debug command to be usable in Multiplayer

Command Key Mapping What it does
Ignore Prerequisites ALT + P All humans can build whole tech tree
Instant Build ALT + F All humans can build everything in 1 second
Free Build ALT + B All humans can build everything for free
Give all Sciences SHIFT + ALT + CTRL + K All humans get all sciences aka generals powers

All players need to enable the commands at about the same time, otherwise the game would rightfully mismatch. For "Instant Build" I added some safe guards to avoid toggling it in Multiplayer when unfavorable conditions exist that would prevent a successful toggle.

These commands are very useful for testing things quicker in Multiplayer.

TODO

  • Replicate in Generals

@xezon xezon added Minor Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour Debug Is mostly debug functionality labels Jul 20, 2025
@xezon xezon changed the title [ZH] Implement the "Ignore Prerequisites", "Instant Build", "Free Build" and "Give all Sciences" debug commands for Multiplayer [ZH] Implement the 'Ignore Prerequisites', 'Instant Build', 'Free Build' and 'Give all Sciences' debug commands for Multiplayer Jul 20, 2025
@xezon xezon requested a review from Skyaero42 July 21, 2025 10:29
Copy link

@Skyaero42 Skyaero42 left a comment

Choose a reason for hiding this comment

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

Ok

@xezon xezon force-pushed the xezon/implement-remove-prereq-instant-build-free-build-multiplayer branch from 48f1354 to b1f7f8b Compare July 22, 2025 20:02
@xezon
Copy link
Author

xezon commented Jul 22, 2025

Replicated in Generals with conflicts

D:\Projects\TheSuperHackers\GeneralsGameCode>.replicate_fixes_in_generals.bat

D:\Projects\TheSuperHackers\GeneralsGameCode>FOR /F "delims=" %b IN ('git merge-base --fork-point main') DO git diff %b  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git diff 09ca272e384990c546c1d5767d6f619aa4611b9c  1>changes.patch

D:\Projects\TheSuperHackers\GeneralsGameCode>git apply -p2 --directory=Generals --reject --whitespace=fix changes.patch
changes.patch:111: trailing whitespace.
#include "GameLogic/Object.h"
changes.patch:128: trailing whitespace.
        for (size_t i = 0; i < v.size(); ++i)
Checking patch Generals/Code/GameEngine/Include/Common/MessageStream.h...
Hunk #1 succeeded at 315 (offset -25 lines).
Hunk #2 succeeded at 377 (offset -27 lines).
Checking patch Generals/Code/GameEngine/Include/Common/Player.h...
error: while searching for:
#if defined(RTS_DEBUG)
        /// Prereq disabling cheat key
        void toggleIgnorePrereqs(){ m_DEMO_ignorePrereqs = !m_DEMO_ignorePrereqs; }
        Bool ignoresPrereqs() const { return m_DEMO_ignorePrereqs; }

        /// No cost building cheat key
        void toggleFreeBuild(){ m_DEMO_freeBuild = !m_DEMO_freeBuild; }
        Bool buildsForFree() const { return m_DEMO_freeBuild; }

#endif

error: patch failed: Generals/Code/GameEngine/Include/Common/Player.h:330
error: while searching for:
#if defined(RTS_DEBUG) || defined(_ALLOW_DEBUG_CHEATS_IN_RELEASE)
        /// No time building cheat key
        void toggleInstantBuild(){ m_DEMO_instantBuild = !m_DEMO_instantBuild; }
        Bool buildsInstantly() const { return m_DEMO_instantBuild; }
#endif


error: patch failed: Generals/Code/GameEngine/Include/Common/Player.h:341
Checking patch Generals/Code/GameEngine/Source/Common/MessageStream.cpp...
error: while searching for:
        {
                switch (t)
                {
                case GameMessage::MSG_META_DEMO_SWITCH_TEAMS:
                case GameMessage::MSG_META_DEMO_SWITCH_TEAMS_BETWEEN_CHINA_USA:
                case GameMessage::MSG_META_DEMO_KILL_ALL_ENEMIES:

error: patch failed: Generals/Code/GameEngine/Source/Common/MessageStream.cpp:1019
Hunk #2 succeeded at 997 (offset -38 lines).
Hunk #3 succeeded at 1010 (offset -38 lines).
Hunk #4 succeeded at 1032 (offset -38 lines).
Checking patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp...
Hunk #2 succeeded at 124 (offset -4 lines).
error: while searching for:
                        {
                                Player *player = ThePlayerList->getLocalPlayer();
                                if (player)
                                {
                                        // cheese festival: do NOT imitate this code. it is for debug purposes only.
                                        std::vector<AsciiString> v = TheScienceStore->friend_getScienceNames();
                                        for (int i = 0; i < v.size(); ++i)
                                        {
                                                ScienceType st = TheScienceStore->getScienceFromInternalName(v[i]);
                                                if (st != SCIENCE_INVALID && TheScienceStore->isScienceGrantable(st))
                                                {
                                                        player->grantScience(st);
                                                }
                                        }
                                }
                                TheInGameUI->messageNoFormat( TheGameText->FETCH_OR_SUBSTITUTE("GUI:DebugGiveAllSciences", L"Granting all sciences!" ) );
                                disp = DESTROY_MESSAGE;

error: patch failed: Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp:3420
Hunk #4 succeeded at 4178 (offset -398 lines).
Hunk #5 succeeded at 4202 (offset -398 lines).
Hunk #6 succeeded at 4229 (offset -398 lines).
Hunk #7 succeeded at 4435 (offset -416 lines).
Applied patch Generals/Code/GameEngine/Include/Common/MessageStream.h cleanly.
Applying patch Generals/Code/GameEngine/Include/Common/Player.h with 2 rejects...
Rejected hunk #1.
Rejected hunk #2.
Applying patch Generals/Code/GameEngine/Source/Common/MessageStream.cpp with 1 reject...
Rejected hunk #1.
Hunk #2 applied cleanly.
Hunk #3 applied cleanly.
Hunk #4 applied cleanly.
Applying patch Generals/Code/GameEngine/Source/GameClient/MessageStream/CommandXlat.cpp with 1 reject...
Hunk #1 applied cleanly.
Hunk #2 applied cleanly.
Rejected hunk #3.
Hunk #4 applied cleanly.
Hunk #5 applied cleanly.
Hunk #6 applied cleanly.
Hunk #7 applied cleanly.

@xezon xezon changed the title [ZH] Implement the 'Ignore Prerequisites', 'Instant Build', 'Free Build' and 'Give all Sciences' debug commands for Multiplayer [GEN][ZH] Implement the 'Ignore Prerequisites', 'Instant Build', 'Free Build' and 'Give all Sciences' debug commands for Multiplayer Jul 22, 2025
@xezon xezon merged commit dd2a936 into TheSuperHackers:main Jul 22, 2025
16 checks passed
@xezon xezon deleted the xezon/implement-remove-prereq-instant-build-free-build-multiplayer branch July 22, 2025 20:19
fbraz3 pushed a commit to fbraz3/GeneralsX that referenced this pull request Nov 10, 2025
…e Build' and 'Give all Sciences' debug commands for Multiplayer (TheSuperHackers#1314)
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 Minor Severity: Minor < Major < Critical < Blocker ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants