Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ void AudioManager::init()
// do the miscellaneous sound files last so that we find the AudioEventRTS associated with the events.
ini.loadFileDirectory( "Data\\INI\\MiscAudio", INI_LOAD_OVERWRITE, nullptr);

#if RTS_CD_SUPPORT
// determine if one of the music tracks exists. Since their now BIGd, one implies all.
// If they don't exist, then attempt to load them from the CD.
Comment on lines +227 to 229
Copy link

Choose a reason for hiding this comment

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

Startup still blocks on CD

Even with the new #if RTS_CD_SUPPORT gating, the while (TRUE) loop still displays a system-modal Insert CD dialog and will keep re-showing it until either the CD is found or the user clicks Cancel. This still blocks splash-screen init in the no-CD / portable-install scenario described in the PR. If the goal is to avoid blocking during init, this loop needs a non-blocking exit path (e.g., single attempt without dialog, or break after first failure and leave music unloaded).

Prompt To Fix With AI
This is a comment left during a code review.
Path: Core/GameEngine/Source/Common/Audio/GameAudio.cpp
Line: 227:229

Comment:
**Startup still blocks on CD**

Even with the new `#if RTS_CD_SUPPORT` gating, the `while (TRUE)` loop still displays a *system-modal* Insert CD dialog and will keep re-showing it until either the CD is found or the user clicks Cancel. This still blocks splash-screen init in the no-CD / portable-install scenario described in the PR. If the goal is to avoid blocking during init, this loop needs a non-blocking exit path (e.g., single attempt without dialog, or break after first failure and leave music unloaded).

How can I resolve this? If you propose a fix, please make it concise.

if (!TheGlobalData->m_headless && !isMusicAlreadyLoaded())
Expand All @@ -239,7 +240,7 @@ void AudioManager::init()
break;
}
// We loop infinitely on the splash screen if we don't allow breaking out of this loop.
//#if !defined( RTS_DEBUG )

else
{
// Display the warning.
Expand All @@ -249,9 +250,9 @@ void AudioManager::init()
break;
}
}
//#endif
}
}
#endif

m_music = NEW MusicManager;
m_sound = NEW SoundManager;
Expand Down
4 changes: 0 additions & 4 deletions Core/GameEngine/Source/Common/System/FileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,6 @@ Bool FileSystem::createDirectory(AsciiString directory)
//============================================================================
Bool FileSystem::areMusicFilesOnCD()
{
#if 1
return TRUE;
#else
if (!TheCDManager) {
DEBUG_LOG(("FileSystem::areMusicFilesOnCD() - No CD Manager; returning false"));
return FALSE;
Expand Down Expand Up @@ -370,7 +367,6 @@ Bool FileSystem::areMusicFilesOnCD()
}
}
return FALSE;
#endif
}
//============================================================================
// FileSystem::loadMusicFilesFromCD
Expand Down
2 changes: 2 additions & 0 deletions Generals/Code/GameEngine/Source/Common/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,10 @@ void GameEngine::init()
TheGlobalLanguageData->parseCustomDefinition();
initSubsystem(TheCDManager,"TheCDManager", CreateCDManager(), nullptr);
initSubsystem(TheAudio,"TheAudio", TheGlobalData->m_headless ? NEW AudioManagerDummy : createAudioManager(), nullptr);
#if RTS_CD_SUPPORT
if (!TheAudio->isMusicAlreadyLoaded())
setQuitting(TRUE);
#endif
initSubsystem(TheFunctionLexicon,"TheFunctionLexicon", createFunctionLexicon(), nullptr);
initSubsystem(TheModuleFactory,"TheModuleFactory", createModuleFactory(), nullptr);
initSubsystem(TheMessageStream,"TheMessageStream", createMessageStream(), nullptr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,14 @@ static MessageBoxReturnType cancelStartBecauseOfNoCD( void *userData )

Bool IsFirstCDPresent(void)
{
#if !defined(RTS_DEBUG)
return TheFileSystem->areMusicFilesOnCD();
#if RTS_CD_SUPPORT
#if defined(RTS_DEBUG)
return TRUE;
#else
return TheFileSystem->areMusicFilesOnCD();
#endif
#else
// CD support disabled: always assume CD is not needed
return TRUE;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void Win32CDManager::init( void )

destroyAllDrives();

#if RTS_CD_SUPPORT
// detect CD Drives
for ( Char driveLetter = 'a'; driveLetter <= 'z'; driveLetter++ )
{
Expand All @@ -187,6 +188,7 @@ void Win32CDManager::init( void )
newDrive( drivePath.str() );
}
}
#endif

refreshDrives();
}
Expand Down
2 changes: 2 additions & 0 deletions GeneralsMD/Code/GameEngine/Source/Common/GameEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,10 @@ void GameEngine::init()
DEBUG_LOG(("%s", Buf));////////////////////////////////////////////////////////////////////////////
#endif/////////////////////////////////////////////////////////////////////////////////////////////
initSubsystem(TheAudio,"TheAudio", TheGlobalData->m_headless ? NEW AudioManagerDummy : createAudioManager(), nullptr);
#if RTS_CD_SUPPORT
if (!TheAudio->isMusicAlreadyLoaded())
setQuitting(TRUE);
#endif

#ifdef DUMP_PERF_STATS///////////////////////////////////////////////////////////////////////////
GetPrecisionTimer(&endTime64);//////////////////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -467,9 +467,14 @@ static MessageBoxReturnType cancelStartBecauseOfNoCD( void *userData )

Bool IsFirstCDPresent(void)
{
#if !defined(RTS_DEBUG)
return TheFileSystem->areMusicFilesOnCD();
#if RTS_CD_SUPPORT
#if defined(RTS_DEBUG)
return TRUE;
#else
return TheFileSystem->areMusicFilesOnCD();
#endif
#else
Comment on lines +473 to 476
Copy link

Choose a reason for hiding this comment

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

Redundant CD check call

Same pattern as Generals: in checkCDCallback, when !IsFirstCDPresent() is true you call IsFirstCDPresent() again in the ternary return. This duplicates CD detection work per callback. Cache the value once and base both the if and return on that.

Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/SkirmishGameOptionsMenu.cpp
Line: 473:476

Comment:
**Redundant CD check call**

Same pattern as Generals: in `checkCDCallback`, when `!IsFirstCDPresent()` is true you call `IsFirstCDPresent()` again in the ternary return. This duplicates CD detection work per callback. Cache the value once and base both the `if` and return on that.

How can I resolve this? If you propose a fix, please make it concise.

// CD support disabled: always assume CD is not needed
return TRUE;
#endif
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ void Win32CDManager::init( void )

destroyAllDrives();

#if RTS_CD_SUPPORT
// detect CD Drives
for ( Char driveLetter = 'a'; driveLetter <= 'z'; driveLetter++ )
{
Expand All @@ -187,6 +188,7 @@ void Win32CDManager::init( void )
newDrive( drivePath.str() );
}
}
#endif

refreshDrives();
}
Expand Down
8 changes: 8 additions & 0 deletions cmake/config-build.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ option(RTS_BUILD_OPTION_DEBUG "Build code with the \"Debug\" configuration." OFF
option(RTS_BUILD_OPTION_ASAN "Build code with Address Sanitizer." OFF)
option(RTS_BUILD_OPTION_VC6_FULL_DEBUG "Build VC6 with full debug info." OFF)
option(RTS_BUILD_OPTION_FFMPEG "Enable FFmpeg support" OFF)
option(RTS_CD_SUPPORT "Enable CD detection and checks (legacy copy-protection)" OFF)

if(NOT RTS_BUILD_ZEROHOUR AND NOT RTS_BUILD_GENERALS)
set(RTS_BUILD_ZEROHOUR TRUE)
Expand All @@ -23,6 +24,7 @@ add_feature_info(DebugBuild RTS_BUILD_OPTION_DEBUG "Building as a \"Debug\" buil
add_feature_info(AddressSanitizer RTS_BUILD_OPTION_ASAN "Building with address sanitizer")
add_feature_info(Vc6FullDebug RTS_BUILD_OPTION_VC6_FULL_DEBUG "Building VC6 with full debug info")
add_feature_info(FFmpegSupport RTS_BUILD_OPTION_FFMPEG "Building with FFmpeg support")
add_feature_info(CDSupport RTS_CD_SUPPORT "CD detection and legacy copy-protection checks")

if(RTS_BUILD_ZEROHOUR)
option(RTS_BUILD_ZEROHOUR_TOOLS "Build tools for Zero Hour" ON)
Expand Down Expand Up @@ -73,3 +75,9 @@ endif()
if(RTS_BUILD_OPTION_PROFILE)
target_compile_definitions(core_config INTERFACE RTS_PROFILE)
endif()

if(RTS_CD_SUPPORT)
target_compile_definitions(core_config INTERFACE RTS_CD_SUPPORT=1)
else()
target_compile_definitions(core_config INTERFACE RTS_CD_SUPPORT=0)
endif()
Loading