Skip to content

Commit 68c9b1c

Browse files
Chapter5780Chapter5780
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. This plan assumes the Music.big(zh) archive is located in the local game directory. If it is missing from the local folder, music will simply not play instead of prompting the user. Tested all parts (init, singleplayer, skirmish) where this code was active, didn't find any problems.
1 parent 95cc1be commit 68c9b1c

File tree

31 files changed

+11
-2014
lines changed

31 files changed

+11
-2014
lines changed

Core/GameEngine/CMakeLists.txt

Lines changed: 0 additions & 2 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
@@ -643,7 +642,6 @@ set(GAMEENGINE_SRC
643642
Source/Common/System/ArchiveFileSystem.cpp
644643
Source/Common/System/AsciiString.cpp
645644
# Source/Common/System/BuildAssistant.cpp
646-
# Source/Common/System/CDManager.cpp
647645
# Source/Common/System/CriticalSection.cpp
648646
# Source/Common/System/DataChunk.cpp
649647
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
@@ -287,7 +287,6 @@ class AudioManager : public SubsystemInterface
287287
virtual void closeAnySamplesUsingFile( const void *fileToClose ) = 0;
288288

289289
virtual Bool isMusicAlreadyLoaded(void) const;
290-
virtual Bool isMusicPlayingFromCD(void) const { return m_musicPlayingFromCD; }
291290

292291
Bool getDisallowSpeech( void ) const { return m_disallowSpeech; }
293292
void setDisallowSpeech( Bool disallowSpeech ) { m_disallowSpeech = disallowSpeech; }
@@ -370,7 +369,6 @@ class AudioManager : public SubsystemInterface
370369
Bool m_volumeHasChanged : 1;
371370
Bool m_hardwareAccel : 1;
372371
Bool m_surroundSpeakers : 1;
373-
Bool m_musicPlayingFromCD : 1;
374372

375373
// Next 8
376374
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
@@ -149,8 +149,7 @@ AudioManager::AudioManager() :
149149
m_music(nullptr),
150150
m_sound(nullptr),
151151
m_surroundSpeakers(FALSE),
152-
m_hardwareAccel(FALSE),
153-
m_musicPlayingFromCD(FALSE)
152+
m_hardwareAccel(FALSE)
154153
{
155154
m_adjustedVolumes.clear();
156155
m_audioRequests.clear();
@@ -224,34 +223,6 @@ void AudioManager::init()
224223
// do the miscellaneous sound files last so that we find the AudioEventRTS associated with the events.
225224
ini.loadFileDirectory( "Data\\INI\\MiscAudio", INI_LOAD_OVERWRITE, nullptr);
226225

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

256227
m_music = NEW MusicManager;
257228
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)