Skip to content

bugfix: Remove superfluous CD checks and related code#2261

Merged
xezon merged 2 commits intoTheSuperHackers:mainfrom
githubawn:feature/no-cd-patch
Feb 14, 2026
Merged

bugfix: Remove superfluous CD checks and related code#2261
xezon merged 2 commits 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

Removed ~2,000 lines of legacy CD management code that has been non-functional since the original release. The changes eliminate SafeDisc copy protection infrastructure, CD drive scanning, runtime Music.big loading from optical media, and user-facing "Insert CD" prompts.

Major Changes:

  • Deleted CD manager subsystem (CDManager, Win32CDManager) across Core, Generals, and GeneralsMD variants
  • Removed CD-based music loading loop from AudioManager::init() that previously blocked startup
  • Eliminated three FileSystem methods: areMusicFilesOnCD(), loadMusicFilesFromCD(), unloadMusicFilesFromCD()
  • Simplified campaign and skirmish game start flows by removing checkCDBeforeCampaign() and CheckForCDAtGameStart()
  • Removed device change handler that attempted to unload music when drives were ejected
  • Cleaned up includes and build system references across 32 files

Impact:
Music.big is now expected to be present at startup (loaded from local filesystem via standard BIG file mechanism). Games launch directly without CD prompts. The engine no longer monitors optical drives or attempts runtime CD operations.

Confidence Score: 5/5

  • This PR is safe to merge with no identified risks
  • The changes are pure deletions of dead code with no behavioral impact on functional systems. The CD management infrastructure was already non-functional (SafeDisc copy protection), and Music.big is now loaded through the existing standard BIG file system. All CD manager references have been cleanly removed with no orphaned calls. The changes are symmetric across Generals and Zero Hour variants, and the author reports successful testing of init, singleplayer, and skirmish modes. No logic errors, security issues, or incomplete cleanup detected.
  • No files require special attention

Important Files Changed

Filename Overview
Core/GameEngine/Source/Common/Audio/GameAudio.cpp Removed CD-based music loading loop and m_musicPlayingFromCD flag initialization
Core/GameEngine/Include/Common/GameAudio.h Removed isMusicPlayingFromCD() method and m_musicPlayingFromCD member variable
Core/GameEngine/Source/Common/System/FileSystem.cpp Removed implementations of three CD-related methods (79 lines of dead code)
Generals/Code/GameEngine/Source/Common/GameEngine.cpp Removed TheCDManager initialization and update calls
GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp Removed TheCDManager initialization and update calls, fixed perf comment to reference TheGlobalLanguageData
Generals/Code/GameEngine/Source/Common/System/CDManager.cpp Deleted entire CD manager implementation (294 lines)
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/MainMenu.cpp Removed CD check callbacks and replaced checkCDBeforeCampaign() calls with direct prepareCampaignGame() calls
Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp Removed IsFirstCDPresent() and CheckForCDAtGameStart() implementations, simplified game start flow
Generals/Code/GameEngineDevice/Source/Win32Device/Common/Win32CDManager.cpp Deleted Win32-specific CD manager implementation (236 lines)
GeneralsMD/Code/GameEngine/Source/Common/System/CDManager.cpp Deleted entire CD manager implementation (294 lines)

Flowchart

flowchart TD
    A[Game Initialization] --> B[FileSystem Init]
    A --> C[AudioManager Init]
    
    B -.->|REMOVED| D[CDManager Init]
    D -.->|REMOVED| E[Scan CD Drives]
    
    C --> F{Music Files<br/>Already Loaded?}
    F -->|No - OLD BEHAVIOR| G[Enter CD Check Loop]
    G -.->|REMOVED| H[Load Music from CD]
    H -.->|REMOVED| I{Music Found?}
    I -.->|No - REMOVED| J[Show Insert CD Dialog]
    J -.->|OK - REMOVED| G
    I -->|Yes - REMOVED| K[Create MusicManager]
    
    F -->|Yes - NEW BEHAVIOR| K
    F -->|No - NEW BEHAVIOR| L[setQuitting TRUE]
    
    K --> M[Game Running]
    
    M --> N[Game Update Loop]
    N -.->|REMOVED| O[CDManager UPDATE]
    
    P[Device Change Event] -.->|REMOVED| Q[unloadMusicFilesFromCD]
    
    R[Campaign Start] -.->|REMOVED| S[checkCDBeforeCampaign]
    S -.->|REMOVED| T{CD Present?}
    T -.->|No - REMOVED| U[Show CD Prompt]
    T -->|Yes - REMOVED| V[prepareCampaignGame]
    
    R -->|NEW BEHAVIOR| V
    
    style D fill:#f99,stroke:#f00
    style E fill:#f99,stroke:#f00
    style G fill:#f99,stroke:#f00
    style H fill:#f99,stroke:#f00
    style I fill:#f99,stroke:#f00
    style J fill:#f99,stroke:#f00
    style O fill:#f99,stroke:#f00
    style Q fill:#f99,stroke:#f00
    style S fill:#f99,stroke:#f00
    style T fill:#f99,stroke:#f00
    style U fill:#f99,stroke:#f00
Loading

Last reviewed commit: 3b0c6a8

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.

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

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

@githubawn
Copy link
Author

resolved outstanding comments

@xezon xezon changed the title bugfix: Remove superfluous CD management code bugfix: Remove superfluous CD checks and related code Feb 14, 2026
@xezon xezon merged commit 182bf28 into TheSuperHackers:main Feb 14, 2026
25 checks passed
@githubawn githubawn deleted the feature/no-cd-patch branch February 14, 2026 21:19
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