diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp index e40bfa50f90..9c54518398f 100644 --- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp +++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp @@ -758,6 +758,10 @@ Int updateTeletypeText( Int num_chars, GameWindow* window, UnicodeString full_te void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent ) { + // Safety check - if generalOpponent is NULL, we can't proceed with opponent-related operations + if (!generalOpponent) + return; + static Int textPosBigNameRight = 0; static Int textPosNameRight = 0; static Int textPosAgeRight = 0; @@ -888,6 +892,10 @@ void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *gener void ChallengeLoadScreen::activatePiecesMinSpec(const GeneralPersona *generalPlayer, const GeneralPersona *generalOpponent) { + // Safety check - if generalOpponent is NULL, we can't proceed with opponent-related operations + if (!generalOpponent) + return; + m_bioNameLeft->winHide(FALSE); // m_bioAgeLeft->winHide(FALSE); m_bioBirthplaceLeft->winHide(FALSE); @@ -940,6 +948,13 @@ void ChallengeLoadScreen::init( GameInfo *game ) // the opponent general is tied to the mission DEBUG_ASSERTCRASH(mission->m_generalName.isNotEmpty(), ("No GeneralName associated with this mission, check Campaign.ini")); const GeneralPersona* generalOpponent = TheChallengeGenerals->getGeneralByGeneralName( mission->m_generalName ); + + // Check if we found a valid opponent general - if not, log error and return to avoid crash + if (!generalOpponent) + { + DEBUG_LOG(("ERROR: Could not find GeneralPersona for general name '%s' in mission. Check ChallengeMode INI files.", mission->m_generalName.str())); + return; + } // create the layout of the load screen m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ChallengeLoadScreen.wnd" ) ); @@ -1135,9 +1150,12 @@ void ChallengeLoadScreen::init( GameInfo *game ) } setFPMode(); - - AudioEventRTS event( generalOpponent->getRandomTauntSound() ); - TheAudio->addAudioEvent( &event ); + // Play opponent taunt sound if generalOpponent is valid + if (generalOpponent) + { + AudioEventRTS event( generalOpponent->getRandomTauntSound() ); + TheAudio->addAudioEvent( &event ); + } m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop); TheAudio->update();