Skip to content

Commit 765c35e

Browse files
xezonChapter5780
authored andcommitted
feat: Remove CD management code
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.
1 parent 44083eb commit 765c35e

File tree

31 files changed

+12
-2016
lines changed

31 files changed

+12
-2016
lines changed

Core/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ set(GAMEENGINE_SRC
1919
# Include/Common/BitFlagsIO.h
2020
# Include/Common/BorderColors.h
2121
# Include/Common/BuildAssistant.h
22-
# Include/Common/CDManager.h
2322
# Include/Common/ClientUpdateModule.h
2423
# Include/Common/CommandLine.h
2524
Include/Common/crc.h
@@ -144,7 +143,6 @@ set(GAMEENGINE_SRC
144143
# Include/GameClient/Anim2D.h
145144
# Include/GameClient/AnimateWindowManager.h
146145
# Include/GameClient/CampaignManager.h
147-
# Include/GameClient/CDCheck.h
148146
Include/GameClient/ChallengeGenerals.h
149147
# Include/GameClient/ClientInstance.h
150148
Include/GameClient/ClientRandomValue.h
@@ -643,7 +641,6 @@ set(GAMEENGINE_SRC
643641
Source/Common/System/ArchiveFileSystem.cpp
644642
Source/Common/System/AsciiString.cpp
645643
# Source/Common/System/BuildAssistant.cpp
646-
# Source/Common/System/CDManager.cpp
647644
# Source/Common/System/CriticalSection.cpp
648645
# Source/Common/System/DataChunk.cpp
649646
Source/Common/System/Debug.cpp

Core/GameEngine/Include/Common/FileSystem.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,6 @@ class FileSystem : public SubsystemInterface
155155

156156
Bool createDirectory(AsciiString directory); ///< create a directory of the given name.
157157

158-
Bool areMusicFilesOnCD();
159-
void loadMusicFilesFromCD();
160-
void unloadMusicFilesFromCD();
161158

162159
static AsciiString normalizePath(const AsciiString& path); ///< normalizes a file path. The path can refer to a directory. File path must be absolute, but does not need to exist. Returns an empty string on failure.
163160
static Bool isPathInDirectory(const AsciiString& testPath, const AsciiString& basePath); ///< determines if a file path is within a base path. Both paths must be absolute, but do not need to exist.

Core/GameEngine/Include/Common/GameAudio.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ class AudioManager : public SubsystemInterface
297297
virtual void closeAnySamplesUsingFile( const void *fileToClose ) = 0;
298298

299299
virtual Bool isMusicAlreadyLoaded(void) const;
300-
virtual Bool isMusicPlayingFromCD(void) const { return m_musicPlayingFromCD; }
301300

302301
Bool getDisallowSpeech( void ) const { return m_disallowSpeech; }
303302
void setDisallowSpeech( Bool disallowSpeech ) { m_disallowSpeech = disallowSpeech; }
@@ -381,7 +380,6 @@ class AudioManager : public SubsystemInterface
381380
Bool m_volumeHasChanged : 1;
382381
Bool m_hardwareAccel : 1;
383382
Bool m_surroundSpeakers : 1;
384-
Bool m_musicPlayingFromCD : 1;
385383

386384
// Next 8
387385
Bool m_disallowSpeech : 1;

Core/GameEngine/Source/Common/Audio/GameAudio.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ AudioManager::AudioManager() :
153153
m_music(nullptr),
154154
m_sound(nullptr),
155155
m_surroundSpeakers(FALSE),
156-
m_hardwareAccel(FALSE),
157-
m_musicPlayingFromCD(FALSE)
156+
m_hardwareAccel(FALSE)
158157
{
159158
static_assert(ARRAY_SIZE(AudioManager::MuteAudioReasonNames) == MuteAudioReason_Count, "Incorrect array size");
160159

@@ -231,34 +230,6 @@ void AudioManager::init()
231230
// do the miscellaneous sound files last so that we find the AudioEventRTS associated with the events.
232231
ini.loadFileDirectory( "Data\\INI\\MiscAudio", INI_LOAD_OVERWRITE, nullptr);
233232

234-
// determine if one of the music tracks exists. Since their now BIGd, one implies all.
235-
// If they don't exist, then attempt to load them from the CD.
236-
if (!TheGlobalData->m_headless && !isMusicAlreadyLoaded())
237-
{
238-
m_musicPlayingFromCD = TRUE;
239-
while (TRUE)
240-
{
241-
// @todo Unload any files from CD first. - jkmcd
242-
243-
TheFileSystem->loadMusicFilesFromCD();
244-
if (isMusicAlreadyLoaded())
245-
{
246-
break;
247-
}
248-
// We loop infinitely on the splash screen if we don't allow breaking out of this loop.
249-
//#if !defined( RTS_DEBUG )
250-
else
251-
{
252-
// Display the warning.
253-
254-
if (OSDisplayWarningBox("GUI:InsertCDPrompt", "GUI:InsertCDMessage", OSDBT_OK | OSDBT_CANCEL, OSDOF_SYSTEMMODAL | OSDOF_EXCLAMATIONICON) == OSDBT_CANCEL) {
255-
//TheGameEngine->setQuitting(TRUE); // Can't do this to WorldBuilder
256-
break;
257-
}
258-
}
259-
//#endif
260-
}
261-
}
262233

263234
m_music = NEW MusicManager;
264235
m_sound = NEW SoundManager;

Core/GameEngine/Source/Common/System/FileSystem.cpp

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include "Common/FileSystem.h"
5151

5252
#include "Common/ArchiveFileSystem.h"
53-
#include "Common/CDManager.h"
5453
#include "Common/GameAudio.h"
5554
#include "Common/LocalFileSystem.h"
5655
#include "Common/PerfTimer.h"
@@ -330,84 +329,6 @@ Bool FileSystem::createDirectory(AsciiString directory)
330329
return FALSE;
331330
}
332331

333-
//============================================================================
334-
// FileSystem::areMusicFilesOnCD
335-
//============================================================================
336-
Bool FileSystem::areMusicFilesOnCD()
337-
{
338-
#if 1
339-
return TRUE;
340-
#else
341-
if (!TheCDManager) {
342-
DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - No CD Manager; returning false"));
343-
return FALSE;
344-
}
345-
346-
AsciiString cdRoot;
347-
Int dc = TheCDManager->driveCount();
348-
for (Int i = 0; i < dc; ++i) {
349-
DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking drive %d", i));
350-
CDDriveInterface *cdi = TheCDManager->getDrive(i);
351-
if (!cdi) {
352-
continue;
353-
}
354-
355-
cdRoot = cdi->getPath();
356-
if (!cdRoot.endsWith("\\"))
357-
cdRoot.concat("\\");
358-
#if RTS_GENERALS
359-
cdRoot.concat("gensec.big");
360-
#elif RTS_ZEROHOUR
361-
cdRoot.concat("genseczh.big");
362-
#endif
363-
DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - checking for %s", cdRoot.str()));
364-
File *musicBig = TheLocalFileSystem->openFile(cdRoot.str());
365-
if (musicBig)
366-
{
367-
DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - found it!"));
368-
musicBig->close();
369-
return TRUE;
370-
}
371-
}
372-
return FALSE;
373-
#endif
374-
}
375-
//============================================================================
376-
// FileSystem::loadMusicFilesFromCD
377-
//============================================================================
378-
void FileSystem::loadMusicFilesFromCD()
379-
{
380-
if (!TheCDManager) {
381-
return;
382-
}
383-
384-
AsciiString cdRoot;
385-
Int dc = TheCDManager->driveCount();
386-
for (Int i = 0; i < dc; ++i) {
387-
CDDriveInterface *cdi = TheCDManager->getDrive(i);
388-
if (!cdi) {
389-
continue;
390-
}
391-
392-
cdRoot = cdi->getPath();
393-
if (TheArchiveFileSystem->loadBigFilesFromDirectory(cdRoot, MUSIC_BIG)) {
394-
break;
395-
}
396-
}
397-
}
398-
399-
//============================================================================
400-
// FileSystem::unloadMusicFilesFromCD
401-
//============================================================================
402-
void FileSystem::unloadMusicFilesFromCD()
403-
{
404-
if (!(TheAudio && TheAudio->isMusicPlayingFromCD())) {
405-
return;
406-
}
407-
408-
TheArchiveFileSystem->closeArchiveFile( MUSIC_BIG );
409-
}
410-
411332
//============================================================================
412333
// FileSystem::normalizePath
413334
//============================================================================

Generals/Code/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ set(GAMEENGINE_SRC
1616
Include/Common/BitFlags.h
1717
Include/Common/BitFlagsIO.h
1818
Include/Common/BuildAssistant.h
19-
Include/Common/CDManager.h
2019
Include/Common/ClientUpdateModule.h
2120
Include/Common/CommandLine.h
2221
# Include/Common/crc.h
@@ -134,7 +133,6 @@ set(GAMEENGINE_SRC
134133
Include/GameClient/AnimateWindowManager.h
135134
# Include/GameClient/ChallengeGenerals.h
136135
Include/GameClient/CampaignManager.h
137-
Include/GameClient/CDCheck.h
138136
Include/GameClient/ClientInstance.h
139137
# Include/GameClient/ClientRandomValue.h
140138
Include/GameClient/Color.h
@@ -592,7 +590,6 @@ set(GAMEENGINE_SRC
592590
# Source/Common/System/ArchiveFileSystem.cpp
593591
# Source/Common/System/AsciiString.cpp
594592
Source/Common/System/BuildAssistant.cpp
595-
Source/Common/System/CDManager.cpp
596593
Source/Common/System/CriticalSection.cpp
597594
Source/Common/System/DataChunk.cpp
598595
# Source/Common/System/Debug.cpp

Generals/Code/GameEngine/Include/Common/CDManager.h

Lines changed: 0 additions & 185 deletions
This file was deleted.

0 commit comments

Comments
 (0)