From 948ad8caf10eeebaee980589a7602d92ce2f927f Mon Sep 17 00:00:00 2001 From: Flugente Date: Mon, 1 Jun 2020 20:53:22 +0000 Subject: [PATCH] Fix: crash after heli landing in UB (by Asdow) Fix: unnecessary town initialization in UB (by Asdow) git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8816 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Strategic/Game Init.cpp | 2 +- Tactical/Dialogue Control.cpp | 52 +++++++++++++++++++---------------- 2 files changed, 29 insertions(+), 25 deletions(-) diff --git a/Strategic/Game Init.cpp b/Strategic/Game Init.cpp index 00d0fd3f..c31f87e1 100644 --- a/Strategic/Game Init.cpp +++ b/Strategic/Game Init.cpp @@ -463,7 +463,7 @@ void InitStrategicLayer( void ) #ifdef JA2UB ////if ( gGameUBOptions.InitTownLoyalty_UB == TRUE ) - InitTownLoyalty(); //Ja25 no loyalty + //InitTownLoyalty(); //Ja25 no loyalty #else // init town loyalty InitTownLoyalty(); //Ja25 no loyalty diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index 7bb02a38..80575753 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -1396,34 +1396,38 @@ void HandleDialogue( ) // grab soldier ptr from profile ID pSoldier = FindSoldierByProfileID( (UINT8)QItem->uiSpecialEventData, FALSE ); - // Now, wake these sluts up and have them say quote... - pSoldier->fIgnoreGetupFromCollapseCheck = FALSE; - - //Get the soldier up - pSoldier->bCollapsed = FALSE; - pSoldier->ChangeSoldierStance( ANIM_STAND ); - - //if the soldier is Jerry - if( FindSoldierByProfileID( JERRY_MILO_UB, FALSE ) == pSoldier ) //JERRY + // FindSoldier was returning a lot of nullptrs which would crash the game very quickly after Jerry gets up. This check is here to circumvent that. + if (pSoldier != nullptr) { - //Play the sound of the Antena breaking - PlayJA2SampleFromFile( "SOUNDS\\Metal Antenna Crunch.wav", RATE_11025, HIGHVOLUME, 1, MIDDLE ); - } + // Now, wake these sluts up and have them say quote... + pSoldier->fIgnoreGetupFromCollapseCheck = FALSE; - //Turn off the flag saying we are doing the initial heli crash - gfFirstTimeInGameHeliCrash = FALSE; + //Get the soldier up + pSoldier->bCollapsed = FALSE; + pSoldier->ChangeSoldierStance( ANIM_STAND ); - //if all the mercs are done their talk - if( AreAllTheMercsFinishedSayingThereInitialHeliCrashQuotes() ) - { - //Trigger Jerry Milo's script record 10 ( call action 301 ) - //AA - //if ( gGameUBOptions.InGameHeliCrash == TRUE ) - if ( gGameUBOptions.JerryQuotes == TRUE ) - DelayedMercQuote( JERRY_MILO_UB , 0xffff, 4 ); //JERRY + //if the soldier is Jerry + if (FindSoldierByProfileID( JERRY_MILO_UB, FALSE ) == pSoldier) //JERRY + { + //Play the sound of the Antena breaking + PlayJA2SampleFromFile( "SOUNDS\\Metal Antenna Crunch.wav", RATE_11025, HIGHVOLUME, 1, MIDDLE ); + } - //End the ui Lock - guiPendingOverrideEvent = LU_ENDUILOCK; + //Turn off the flag saying we are doing the initial heli crash + gfFirstTimeInGameHeliCrash = FALSE; + + //if all the mercs are done their talk + if (AreAllTheMercsFinishedSayingThereInitialHeliCrashQuotes()) + { + //Trigger Jerry Milo's script record 10 ( call action 301 ) + //AA + //if ( gGameUBOptions.InGameHeliCrash == TRUE ) + if (gGameUBOptions.JerryQuotes == TRUE) + DelayedMercQuote( JERRY_MILO_UB, 0xffff, 4 ); //JERRY + + //End the ui Lock + guiPendingOverrideEvent = LU_ENDUILOCK; + } } } }