Skip to content

Zero Hour rebuilt from EA's source: x64, Direct3D 11, VS2022/CMake, ~60 original bugs fixed, an AI that builds a base. Bring your own game.

fix(gameclient): challenge load screen survives a general it cannot find

Olcay Seygan66395f94ff7b
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b09305154..839a19463 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2061,6 +2061,7 @@ The whole HUD is on the hardware. Four colours carry it, and they mean the same
## It does not crash
- A GLA tunnel that belongs to no player no longer crashes the game when a unit near it looks for a target. With no owner there is no tunnel network behind it, and the check for hidden men inside asked that missing network for its first passenger. Three crash reports from 3.5.1 came from it, two of them the same network match seen from both machines.
+- Loading a save could crash on the Generals' Challenge loading screen, the one with two generals facing each other, when the mission named a general the screen could not find. Its right half now stays empty and the mission loads.
- A sound cut off in the middle no longer takes the game down a moment later. The game stopped the sound and freed it, but Windows' audio mixer only stops reading on its next pass, a hundredth of a second on, and two players' games died with the mixer reading what had just been freed. Every sound now plays from a copy the mixer gives back itself when it is done. A load screen movie skipped to its last frame threw its sound away the same way, and now leaves it to the mixer too.
- That copy did not end the mixer crash: two 3.3.0 players still met it. Each sound channel was reused for the next sound by stopping it, emptying it and handing it new audio, and now and then Windows' mixer carried its place in the old sound over as one step before the start of the new one, then read eight gigabytes past it. Every sound now gets a fresh channel that nothing has played before, which is how Windows' mixer is normally used.
- The game no longer crashes now and then as a match starts or a new unit comes on the field. Since 3.2.0 the battle runs beside the picture, and both sides ask the game's files whether a model or a texture is there. The answers go into one shared list, and two answers written at once tore it, which took the game down later in some unrelated place. Two reads from the same game archive at once could also hand one of them the other's bytes. Each now waits its turn.
diff --git a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
index 217889518..3ef7de110 100644
--- a/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
+++ b/GeneralsMD/Code/GameEngine/Source/GameClient/GUI/LoadScreen.cpp
@@ -1631,7 +1631,7 @@ void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *gener
AudioEventRTS eventLeftGeneral( generalPlayer->getNameSound() );
AudioEventRTS eventVS("Taunts_GCAnnouncer12");
- AudioEventRTS eventRightGeneral( generalOpponent->getNameSound() );
+ AudioEventRTS eventRightGeneral( generalOpponent ? generalOpponent->getNameSound() : AsciiString::TheEmptyString );
switch (frame)
{
@@ -1684,9 +1684,12 @@ void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *gener
case FRAME_PORTRAITS_START:
m_wndVideoManager->playMovie( m_portraitMovieLeft, generalPlayer->getPortraitMovieLeftName(), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
- m_wndVideoManager->playMovie( m_portraitMovieRight, generalOpponent->getPortraitMovieRightName(), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
m_portraitMovieLeft->winHide(FALSE);
- m_portraitMovieRight->winHide(FALSE);
+ if (generalOpponent)
+ {
+ m_wndVideoManager->playMovie( m_portraitMovieRight, generalOpponent->getPortraitMovieRightName(), WINDOW_PLAY_MOVIE_SHOW_LAST_FRAME);
+ m_portraitMovieRight->winHide(FALSE);
+ }
TheAudio->addAudioEvent( &eventLeftGeneral );
@@ -1738,11 +1741,14 @@ void ChallengeLoadScreen::activatePieces( Int frame, const GeneralPersona *gener
textPosBirthplaceLeft = updateTeletypeText( 1, m_bioBirthplaceEntryLeft, TheGameText->fetch(generalPlayer->getBioRank()), textPosBirthplaceLeft);
textPosStrategyLeft = updateTeletypeText( 1, m_bioStrategyEntryLeft, TheGameText->fetch(generalPlayer->getBioStrategy()), textPosStrategyLeft);
- textPosNameRight = updateTeletypeText( 1, m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosNameRight);
- textPosBigNameRight = updateTeletypeText( 1, m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosBigNameRight);
-// textPosAgeRight = updateTeletypeText( 1, m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()), textPosAgeRight);
- textPosBirthplaceRight = updateTeletypeText( 1, m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()), textPosBirthplaceRight);
- textPosStrategyRight = updateTeletypeText( 1, m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()), textPosStrategyRight);
+ if (generalOpponent)
+ {
+ textPosNameRight = updateTeletypeText( 1, m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosNameRight);
+ textPosBigNameRight = updateTeletypeText( 1, m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()), textPosBigNameRight);
+// textPosAgeRight = updateTeletypeText( 1, m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()), textPosAgeRight);
+ textPosBirthplaceRight = updateTeletypeText( 1, m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()), textPosBirthplaceRight);
+ textPosStrategyRight = updateTeletypeText( 1, m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()), textPosStrategyRight);
+ }
}
}
@@ -1771,15 +1777,18 @@ void ChallengeLoadScreen::activatePiecesMinSpec(const GeneralPersona *generalPla
// m_bioAgeEntryRight->winHide(FALSE);
m_bioBirthplaceEntryRight->winHide(FALSE);
m_bioStrategyEntryRight->winHide(FALSE);
- GadgetStaticTextSetText( m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
- GadgetStaticTextSetText( m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
-// GadgetStaticTextSetText( m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()) );
- GadgetStaticTextSetText( m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()) );
- GadgetStaticTextSetText( m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()) );
m_portraitLeft->winSetEnabledImage(0, generalPlayer->getBioPortraitLarge() );
- m_portraitRight->winSetEnabledImage(0, generalOpponent->getBioPortraitLarge() );
m_portraitLeft->winHide(FALSE);
- m_portraitRight->winHide(FALSE);
+ if (generalOpponent)
+ {
+ GadgetStaticTextSetText( m_bioBigNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
+ GadgetStaticTextSetText( m_bioNameEntryRight, TheGameText->fetch(generalOpponent->getBioName()) );
+// GadgetStaticTextSetText( m_bioAgeEntryRight, TheGameText->fetch(generalOpponent->getBioDOB()) );
+ GadgetStaticTextSetText( m_bioBirthplaceEntryRight, TheGameText->fetch(generalOpponent->getBioRank()) );
+ GadgetStaticTextSetText( m_bioStrategyEntryRight, TheGameText->fetch(generalOpponent->getBioStrategy()) );
+ m_portraitRight->winSetEnabledImage(0, generalOpponent->getBioPortraitLarge() );
+ m_portraitRight->winHide(FALSE);
+ }
m_overlayReticleCircleAlphaOuter->winHide(FALSE);
m_overlayReticleCircleAlphaInner->winHide(FALSE);
m_overlayVsBackdrop->winHide(FALSE);
@@ -1800,6 +1809,11 @@ 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 );
+ // A mission can name a general the challenge data does not have. The challenge menu leaves such a
+ // general out of its list, but a saved game does not pass through that menu. The screen then keeps its
+ // right side empty: no portrait, no bio, no voice.
+ if (generalOpponent == NULL)
+ DEBUG_LOG(("ChallengeLoadScreen: the data has no general '%s' for this mission\n", mission->m_generalName.str()));
// create the layout of the load screen
m_loadScreen = TheWindowManager->winCreateFromScript( AsciiString( "Menus/ChallengeLoadScreen.wnd" ) );
@@ -1998,7 +2012,7 @@ void ChallengeLoadScreen::init( GameInfo *game )
setFPMode();
- AudioEventRTS event( generalOpponent->getRandomTauntSound() );
+ AudioEventRTS event( generalOpponent ? generalOpponent->getRandomTauntSound() : AsciiString::TheEmptyString );
TheAudio->addAudioEvent( &event );
m_ambientLoopHandle = TheAudio->addAudioEvent(&m_ambientLoop);