Skip to content

bugfix: Remove superfluous CD management code#2261

Open
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:feature/no-cd-patch
Open

bugfix: Remove superfluous CD management code#2261
githubawn wants to merge 1 commit intoTheSuperHackers:mainfrom
githubawn:feature/no-cd-patch

Conversation

@githubawn
Copy link

@githubawn githubawn commented Feb 6, 2026

The Pull Request #2203 made by @fbraz3 inspired a deeper audit of the legacy CD requirements in the engine. Beyond merely skipping the startup prompt, it was discovered that large portions of the engine's CD-management infrastructure have become vestigial in modern execution environments.

This commit implements a comprehensive modernization by pruning approximately 2,000 lines of dead code across the Core, Generals, and Zero Hour variants.

Investigations (thanks to tomsons26) revealed that the Music.big handling was primarily a copy protection mechanism (SafeDisc) rather than for streaming audio. The engine attempted to read a specific file (often generalsa.sec) from the archive to verify a hash. Failure to read this file would trigger copy protection. This mechanism has been non-functional from the start and is now removed.

Tested all parts (init, singleplayer, skirmish) where this code was active, didn't find any problems.

@greptile-apps
Copy link

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

This PR removes the legacy CD-management subsystem across Core, Generals, and GeneralsMD (Zero Hour): CDManager/Win32CDManager implementations and headers are deleted, CD-check UI flows are removed from menus, and CD-music loading helpers are removed from FileSystem/GameAudio.

All call sites in engine init/update loops and GUI start paths appear to be updated to invoke the underlying start functions directly (e.g., prepareCampaignGame() / reallyDoStart()), and CMake source lists are updated to stop compiling the removed files. Net effect is a modernized startup/game-start flow with vestigial SafeDisc-era checks pruned.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk.
  • Changes are a consistent removal of CD-management code and related call sites across all variants; build files and includes are updated accordingly and no orphan references were found in the reviewed diff.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngine/CMakeLists.txt Removes commented-out CDManager/CDCheck/CDManager.cpp entries from the engine source list; no functional build impact expected.
Core/GameEngine/Include/Common/FileSystem.h Deletes declarations for music-on-CD helpers (are/load/unloadMusicFilesFromCD) to match implementation removal.
Core/GameEngine/Include/Common/GameAudio.h Removes isMusicPlayingFromCD() accessor and m_musicPlayingFromCD bitfield; aligns with deleted CD-music logic.
Core/GameEngine/Source/Common/Audio/GameAudio.cpp Removes CD-based music loading path and associated member init; remaining audio init path is unchanged.
Core/GameEngine/Source/Common/System/FileSystem.cpp Removes CDManager include and deletes music-on-CD helper functions; no remaining references in this PR.
Generals/Code/GameEngine/CMakeLists.txt Drops CD-related headers/sources from the Generals engine build file lists to match removed code.
Generals/Code/GameEngine/Include/Common/CDManager.h Removes legacy CDManager interface header; call sites removed elsewhere in PR.
Generals/Code/GameEngine/Include/GameClient/CDCheck.h Removes CD check UI/flow header; callers replaced with direct start/prepare functions.
Generals/Code/GameEngine/Source/Common/GameEngine.cpp Removes CDManager subsystem init/update and include; engine loop continues without CD subsystem.
Generals/Code/GameEngine/Source/Common/System/CDManager.cpp Deletes legacy CDManager implementation; no remaining build references in CMake or includes in this PR.
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp Removes CD gating callbacks and CDCheck include; menu actions now directly call prepareCampaignGame().
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp Removes CD check include and replaces CheckForCDAtGameStart() with direct startNextCampaignGame() call.
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Deletes CD presence checks and callback plumbing; start flow now calls reallyDoStart() directly.
Generals/Code/GameEngineDevice/CMakeLists.txt Removes Win32CDManager sources from device build lists to match deleted implementation.
Generals/Code/GameEngineDevice/Include/Win32Device/Common/Win32CDManager.h Deletes Win32 CD manager header; no remaining references after subsystem removal.
Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32CDManager.cpp Deletes Win32 CD manager implementation; removed from build and no longer included.
Generals/Code/Main/WinMain.cpp Removes CDManager include/usage from WinMain startup path; startup continues without CD checks.
Generals/Code/Tools/WorldBuilder/src/WorldBuilder.cpp Removes CDManager include/usage from WorldBuilder entrypoint; tool startup no longer touches CD logic.
GeneralsMD/Code/GameEngine/CMakeLists.txt Drops CD-related headers/sources from Zero Hour build lists to match removed code.
GeneralsMD/Code/GameEngine/Include/Common/CDManager.h Removes legacy CDManager interface header for Zero Hour; references removed in engine and UI.
GeneralsMD/Code/GameEngine/Include/GameClient/CDCheck.h Removes Zero Hour CD check header; call sites in UI updated to bypass CD gating.
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Removes CDManager subsystem init/update and adjusts debug marker string; avoids stale TheCDManager reference (previously commented on).
GeneralsMD/Code/GameEngine/Source/Common/System/CDManager.cpp Deletes Zero Hour CDManager implementation; removed from build and no longer referenced.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp Removes CD gating callbacks and include; campaign selection directly prepares/starts games.
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ScoreScreen.cpp Removes CD check call and include; directly invokes startNextCampaignGame().
GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Deletes CD presence checks and callback plumbing; start flow now calls reallyDoStart() directly.
GeneralsMD/Code/GameEngineDevice/CMakeLists.txt Removes Win32CDManager sources from Zero Hour device build lists.
GeneralsMD/Code/GameEngineDevice/Include/Win32Device/Common/Win32CDManager.h Deletes Zero Hour Win32CDManager header; no remaining references.
GeneralsMD/Code/GameEngineDevice/Source/Win32Device/Common/Win32CDManager.cpp Deletes Zero Hour Win32CDManager implementation; removed from build.
GeneralsMD/Code/Main/WinMain.cpp Removes CDManager include/usage from Zero Hour WinMain startup; continues without CD checks.
GeneralsMD/Code/Tools/WorldBuilder/src/WorldBuilder.cpp Removes CDManager include/usage from Zero Hour WorldBuilder entrypoint; tool startup no longer touches CD logic.

Sequence Diagram

sequenceDiagram
    participant WinMain
    participant GE as GameEngine
    participant UI as GUI Menus
    participant Audio as GameAudio
    participant FS as FileSystem

    WinMain->>GE: "init()"
    Note over GE: "CDManager subsystem init removed"

    GE->>Audio: "initAudio()"
    Note over Audio: "CD music load path removed"
    Note over FS: "FileSystem CD-music helpers removed"

    UI->>GE: "Start Campaign/Skirmish"
    Note over UI: "CD gating callbacks removed"
    UI->>GE: "prepareCampaignGame()/reallyDoStart()"

    GE->>GE: "runFrame()"
    Note over GE: "CDManager->UPDATE() removed"
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

5 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@fbraz3
Copy link

fbraz3 commented Feb 6, 2026

I believe the maintainers should decide whether it’s better for the project to completely remove the CD logic (this PR) or to keep it behind a feature flag (my PR).

IMHO, this PR might be better than mine, since CD is barely used nowadays.

@githubawn githubawn marked this pull request as draft February 6, 2026 03:07
@xezon
Copy link

xezon commented Feb 7, 2026

Ok I just realize this is the real pull... copying the texts:

Removing all the CD Check code around Campaign and Skirmish is good and correct.

As for Loading Music from CD, was that actually a supported Install option from CD? I cannot recall that the Music.big would have resided on the CD. It is copied to HDD, but perhaps there are exceptions when it detected very small HDD size?

I think we can split this change in 2.

1 for removing all the piracy CD checks
1 for removing the rest

@xezon xezon added the Refactor Edits the code with insignificant behavior changes, is never user facing label Feb 7, 2026
@xezon
Copy link

xezon commented Feb 8, 2026

Please also check MUSIC_BIG macro. I think that can also be removed.

@xezon
Copy link

xezon commented Feb 8, 2026

Please advance this Pull

@githubawn githubawn force-pushed the feature/no-cd-patch branch 2 times, most recently from b771edf to 39954bd Compare February 8, 2026 18:36
@githubawn
Copy link
Author

ignore this commit i pushed the wrong button sorry

@githubawn githubawn force-pushed the feature/no-cd-patch branch 2 times, most recently from f0980aa to db30f41 Compare February 8, 2026 20:05
@githubawn
Copy link
Author

changed the missing line:

sprintf(Buf,"----------------------------------------------------------------------------After TheCDManager = %f seconds",((double)(endTime64-startTime64)/(double)(freq64)));
sprintf(Buf,"----------------------------------------------------------------------------After TheGlobalLanguageData = %f seconds",((double)(endTime64-startTime64)/(double)(freq64)));

Thanks for the suggestion. I looked into MUSIC_BIG and while I agree it should be removed, it touches the audio system and core file closing logic which is outside the scope of my current changes. I'd prefer to handle that cleanup in a separate PR to ensure I can verify it properly without delaying this one.

@githubawn githubawn marked this pull request as ready for review February 8, 2026 20:16
@Caball009
Copy link

Please try to do the changes for Generals last, unless they're meaningfully different. This makes it easier to review, at least for me.

@stephanmeesters
Copy link

Looks good to me, one line extra that could be removed

diff --git a/Core/GameEngine/CMakeLists.txt b/Core/GameEngine/CMakeLists.txt
index 9cf234c3a..c41ed211a 100644
--- a/Core/GameEngine/CMakeLists.txt
+++ b/Core/GameEngine/CMakeLists.txt
@@ -143,7 +143,6 @@ set(GAMEENGINE_SRC
 #    Include/GameClient/Anim2D.h
 #    Include/GameClient/AnimateWindowManager.h
 #    Include/GameClient/CampaignManager.h
-#    Include/GameClient/CDCheck.h
     Include/GameClient/ChallengeGenerals.h
 #    Include/GameClient/ClientInstance.h
     Include/GameClient/ClientRandomValue.h

The Pull Request TheSuperHackers#2203 made by @fbraz3 on the upstream repository inspired a deeper audit of the legacy CD requirements in the engine. Beyond merely skipping the startup prompt, it was discovered that large portions of the engine's CD-management infrastructure have become vestigial in modern execution environments.

This commit implements a comprehensive modernization by pruning approximately 2,000 lines of dead code across the Core, Generals, and Zero Hour variants.

Community investigations (thanks to tomsons26) revealed that the Music.big handling was primarily a copy protection mechanism (SafeDisc) rather than for streaming audio. The engine attempted to read a specific file (often generalsa.sec) from the archive to verify a hash. Failure to read this file would trigger copy protection. This mechanism has been non-functional from the start and is now removed.

Tested all parts (init, singleplayer, skirmish) where this code was active, didn't find any problems.
@githubawn githubawn force-pushed the feature/no-cd-patch branch from db30f41 to 765c35e Compare February 9, 2026 22:07
@githubawn
Copy link
Author

added #2261 (comment)

requesting review

@xezon
Copy link

xezon commented Feb 10, 2026

Curious why the commit shows xezon as author...

@xezon xezon changed the title feat: Remove CD management code refactor: Remove superfluous CD management code Feb 10, 2026
@xezon xezon added Major Severity: Minor < Major < Critical < Blocker Gen Relates to Generals ZH Relates to Zero Hour labels Feb 10, 2026
@xezon xezon changed the title refactor: Remove superfluous CD management code bugfix: Remove superfluous CD management code Feb 10, 2026
@xezon xezon added the Bug Something is not working right, typically is user facing label Feb 10, 2026
Copy link

@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.

Looks good to me.

Bool m_surroundSpeakers : 1;
Bool m_musicPlayingFromCD : 1;

// Next 8

Choose a reason for hiding this comment

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

Maybe the comment and the blank line can be removed here.

@xezon xezon added this to the Major bug fixes milestone Feb 10, 2026
Copy link

@Caball009 Caball009 left a comment

Choose a reason for hiding this comment

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

Good effort.

I'm going to nitpick here for a moment and point out a bunch of blank lines that can be removed.

Bool areMusicFilesOnCD();
void loadMusicFilesFromCD();
void unloadMusicFilesFromCD();

Choose a reason for hiding this comment

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

Can also remove blank line.

//#endif
}
}

Choose a reason for hiding this comment

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

Also this blank line.

@@ -731,7 +729,6 @@ void GameEngine::update( void )
TheNetwork->UPDATE();
}

Choose a reason for hiding this comment

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

Another blank line.

callback();
}
}

Choose a reason for hiding this comment

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

Another blank line.

@@ -375,8 +374,6 @@ BOOL CWorldBuilderApp::InitInstance()

initSubsystem(TheScriptEngine, (ScriptEngine*)(new ScriptEngine()));

Choose a reason for hiding this comment

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

Another blank line.

@@ -898,7 +896,6 @@ void GameEngine::update( void )
TheNetwork->UPDATE();
}

Choose a reason for hiding this comment

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

Another blank line.

callback();
}
}

Choose a reason for hiding this comment

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

Another blank line.

@Caball009
Copy link

Caball009 commented Feb 10, 2026

There's also this one:

EDIT, and these:
Core\GameEngineDevice\CMakeLists.txt: # Include/Win32Device/Common/Win32CDManager.h
Core\GameEngineDevice\CMakeLists.txt: # Source/Win32Device/Common/Win32CDManager.cpp

@MohmmadQunibi
Copy link

MohmmadQunibi commented Feb 12, 2026

why not merge this?

@xezon
Copy link

xezon commented Feb 13, 2026

There are outstanding comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something is not working right, typically is user facing Gen Relates to Generals Major Severity: Minor < Major < Critical < Blocker Refactor Edits the code with insignificant behavior changes, is never user facing ZH Relates to Zero Hour

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants