Skip to content

Commit b771edf

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 22d757f commit b771edf

File tree

35 files changed

+144
-2033
lines changed

35 files changed

+144
-2033
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
//============================================================================

Core/GameEngineDevice/Include/W3DDevice/Common/W3DRadar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ class W3DRadar : public Radar
110110
SurfaceClass *m_shroudSurface; ///< surface to shroud texture
111111
void *m_shroudSurfaceBits; ///< shroud surface bits
112112
int m_shroudSurfacePitch; ///< shroud surface pitch
113+
WW3DFormat m_shroudSurfaceFormat; ///< shroud surface format
113114
UnsignedInt m_shroudSurfacePixelSize; ///< shroud surface pixel size
114115

115116
Int m_textureWidth; ///< width for all radar textures

Core/GameEngineDevice/Source/W3DDevice/Common/System/W3DRadar.cpp

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -700,9 +700,11 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
700700

701701
Player *player = rts::getObservedOrLocalPlayer();
702702

703+
SurfaceClass::SurfaceDescription surfaceDesc;
704+
surface->Get_Description(surfaceDesc);
703705
int pitch;
704706
void *pBits = surface->Lock(&pitch);
705-
const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel();
707+
const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format);
706708

707709
for( const RadarObject *rObj = listHead; rObj; rObj = rObj->friend_getNext() )
708710
{
@@ -718,7 +720,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
718720
radarPoint.y = pos->y / (m_mapExtent.height() / RADAR_CELL_HEIGHT);
719721

720722
// get the color we're going to draw in
721-
Color c = rObj->getColor();
723+
Color argbColor = rObj->getColor();
722724

723725
// adjust the alpha for stealth units so they "fade/blink" on the radar for the controller
724726
// if( obj->getRadarPriority() == RADAR_PRIORITY_LOCAL_UNIT_ONLY )
@@ -727,7 +729,7 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
727729
if( obj->testStatus( OBJECT_STATUS_STEALTHED ) )
728730
{
729731
UnsignedByte r, g, b, a;
730-
GameGetColorComponents( c, &r, &g, &b, &a );
732+
GameGetColorComponents( argbColor, &r, &g, &b, &a );
731733

732734
const UnsignedInt framesForTransition = LOGICFRAMES_PER_SECOND;
733735
const UnsignedByte minAlpha = 32;
@@ -737,25 +739,27 @@ void W3DRadar::renderObjectList( const RadarObject *listHead, TextureClass *text
737739
a = REAL_TO_UNSIGNEDBYTE( ((alphaScale - 1.0f) * (255.0f - minAlpha)) + minAlpha );
738740
else
739741
a = REAL_TO_UNSIGNEDBYTE( (alphaScale * (255.0f - minAlpha)) + minAlpha );
740-
c = GameMakeColor( r, g, b, a );
742+
argbColor = GameMakeColor( r, g, b, a );
741743

742744
}
743745

746+
const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor);
747+
744748
// draw the blip, but make sure the points are legal
745749
if( legalRadarPoint( radarPoint.x, radarPoint.y ) )
746-
surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch );
750+
surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch );
747751

748752
radarPoint.y++;
749753
if( legalRadarPoint( radarPoint.x, radarPoint.y ) )
750-
surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch );
754+
surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch );
751755

752756
radarPoint.x++;
753757
if( legalRadarPoint( radarPoint.x, radarPoint.y ) )
754-
surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch );
758+
surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch );
755759

756760
radarPoint.y--;
757761
if( legalRadarPoint( radarPoint.x, radarPoint.y ) )
758-
surface->Draw_Pixel( radarPoint.x, radarPoint.y, c, bytesPerPixel, pBits, pitch );
762+
surface->Draw_Pixel( radarPoint.x, radarPoint.y, pixelColor, bytesPerPixel, pBits, pitch );
759763

760764
}
761765

@@ -860,6 +864,7 @@ W3DRadar::W3DRadar( void )
860864
m_shroudSurface = nullptr;
861865
m_shroudSurfaceBits = nullptr;
862866
m_shroudSurfacePitch = 0;
867+
m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN;
863868
m_shroudSurfacePixelSize = 0;
864869

865870
m_textureWidth = RADAR_CELL_WIDTH;
@@ -1078,9 +1083,11 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain )
10781083
Coord3D worldPoint;
10791084
Bridge *bridge;
10801085

1086+
SurfaceClass::SurfaceDescription surfaceDesc;
1087+
surface->Get_Description(surfaceDesc);
10811088
int pitch;
10821089
void *pBits = surface->Lock(&pitch);
1083-
const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel();
1090+
const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format);
10841091

10851092
for( y = 0; y < m_textureHeight; y++ )
10861093
{
@@ -1269,7 +1276,8 @@ void W3DRadar::buildTerrainTexture( TerrainLogic *terrain )
12691276

12701277
// draw the pixel for the terrain at this point, note that because of the orientation
12711278
// of our world we draw it with positive y in the "up" direction
1272-
Color pixelColor = GameMakeColor( color.red * 255, color.green * 255, color.blue * 255, 255 );
1279+
const Color argbColor = GameMakeColor( color.red * 255, color.green * 255, color.blue * 255, 255 );
1280+
const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor);
12731281
surface->Draw_Pixel( x, y, pixelColor, bytesPerPixel, pBits, pitch );
12741282

12751283
}
@@ -1364,16 +1372,19 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting
13641372
// This is expensive.
13651373
SurfaceClass* surface = m_shroudTexture->Get_Surface_Level();
13661374
DEBUG_ASSERTCRASH( surface, ("W3DRadar: Can't get surface for Shroud texture") );
1375+
SurfaceClass::SurfaceDescription surfaceDesc;
1376+
surface->Get_Description(surfaceDesc);
13671377
int pitch;
13681378
void *pBits = surface->Lock(&pitch);
1369-
const unsigned int bytesPerPixel = surface->Get_Bytes_Per_Pixel();
1370-
const Color color = GameMakeColor( 0, 0, 0, alpha );
1379+
const unsigned int bytesPerPixel = Get_Bytes_Per_Pixel(surfaceDesc.Format);
1380+
const Color argbColor = GameMakeColor( 0, 0, 0, alpha );
1381+
const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(surfaceDesc.Format, argbColor);
13711382

13721383
for( Int y = radarMinY; y <= radarMaxY; ++y )
13731384
{
13741385
for( Int x = radarMinX; x <= radarMaxX; ++x )
13751386
{
1376-
surface->Draw_Pixel( x, y, color, bytesPerPixel, pBits, pitch );
1387+
surface->Draw_Pixel( x, y, pixelColor, bytesPerPixel, pBits, pitch );
13771388
}
13781389
}
13791390

@@ -1384,14 +1395,16 @@ void W3DRadar::setShroudLevel(Int shroudX, Int shroudY, CellShroudStatus setting
13841395
{
13851396
// This is cheap.
13861397
DEBUG_ASSERTCRASH(m_shroudSurfaceBits != nullptr, ("W3DRadar::setShroudLevel: m_shroudSurfaceBits is not expected null"));
1398+
DEBUG_ASSERTCRASH(m_shroudSurfaceFormat != WW3D_FORMAT_UNKNOWN, ("W3DRadar::setShroudLevel: m_shroudSurfaceFormat is not expected UNKNOWN"));
13871399
DEBUG_ASSERTCRASH(m_shroudSurfacePixelSize != 0, ("W3DRadar::setShroudLevel: m_shroudSurfacePixelSize is not expected 0"));
1388-
const Color color = GameMakeColor( 0, 0, 0, alpha );
1400+
const Color argbColor = GameMakeColor( 0, 0, 0, alpha );
1401+
const unsigned int pixelColor = ARGB_Color_To_WW3D_Color(m_shroudSurfaceFormat, argbColor);
13891402

13901403
for( Int y = radarMinY; y <= radarMaxY; ++y )
13911404
{
13921405
for( Int x = radarMinX; x <= radarMaxX; ++x )
13931406
{
1394-
m_shroudSurface->Draw_Pixel( x, y, color, m_shroudSurfacePixelSize, m_shroudSurfaceBits, m_shroudSurfacePitch );
1407+
m_shroudSurface->Draw_Pixel( x, y, pixelColor, m_shroudSurfacePixelSize, m_shroudSurfaceBits, m_shroudSurfacePitch );
13951408
}
13961409
}
13971410
}
@@ -1403,10 +1416,11 @@ void W3DRadar::beginSetShroudLevel()
14031416
m_shroudSurface = m_shroudTexture->Get_Surface_Level();
14041417
DEBUG_ASSERTCRASH( m_shroudSurface != nullptr, ("W3DRadar::beginSetShroudLevel: Can't get surface for Shroud texture") );
14051418

1406-
SurfaceClass::SurfaceDescription sd;
1407-
m_shroudSurface->Get_Description(sd);
1419+
SurfaceClass::SurfaceDescription surfaceDesc;
1420+
m_shroudSurface->Get_Description(surfaceDesc);
14081421
m_shroudSurfaceBits = m_shroudSurface->Lock(&m_shroudSurfacePitch);
1409-
m_shroudSurfacePixelSize = Get_Bytes_Per_Pixel(sd.Format);
1422+
m_shroudSurfaceFormat = surfaceDesc.Format;
1423+
m_shroudSurfacePixelSize = Get_Bytes_Per_Pixel(surfaceDesc.Format);
14101424
}
14111425

14121426
void W3DRadar::endSetShroudLevel()
@@ -1417,6 +1431,7 @@ void W3DRadar::endSetShroudLevel()
14171431
m_shroudSurface->Unlock();
14181432
m_shroudSurfaceBits = nullptr;
14191433
m_shroudSurfacePitch = 0;
1434+
m_shroudSurfaceFormat = WW3D_FORMAT_UNKNOWN;
14201435
m_shroudSurfacePixelSize = 0;
14211436
}
14221437
REF_PTR_RELEASE(m_shroudSurface);

0 commit comments

Comments
 (0)