Skip to content
Open
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
24 changes: 21 additions & 3 deletions GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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" ) );
Expand Down Expand Up @@ -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();
Expand Down
Loading