From 0c4f5c5df5521f93fba7f27c6292ddd909fd8ae1 Mon Sep 17 00:00:00 2001 From: Flugente Date: Sun, 26 Jan 2014 18:15:09 +0000 Subject: [PATCH] Merged revision(s) 6833 from branches/ja2_source_official_2014: Fix: on certain conditions, gpCurrentTalkingFace gets garbage values assigned. If BOOLEAN fTalking then does get a value > 0, the incorrect face does not get cleaned. This worked until now, but we cannot rely on garbage values alone. git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6834 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Dialogue Control.cpp | 63 +++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 13 deletions(-) diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index 88c8011e9..23f86e608 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -918,9 +918,14 @@ void HandleDialogue( ) gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem->usQuoteNum; gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem->ubCharacterNum; + + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; gubCurrentTalkingID = QItem->ubCharacterNum; #ifdef JA2UB //Ja25: test @@ -979,9 +984,14 @@ void HandleDialogue( ) if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_USE_ALTERNATE_FILES ) { gfUseAlternateDialogueFile = TRUE; + + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; gubCurrentTalkingID = QItem->ubCharacterNum; ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); @@ -992,8 +1002,13 @@ void HandleDialogue( ) // We could have a special flag, but dialogue as well else if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_PCTRIGGERNPC ) { - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } + gubCurrentTalkingID = QItem->ubCharacterNum; ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); @@ -1037,7 +1052,13 @@ void HandleDialogue( ) // Slide to location! SlideToLocation( 0, QItem->uiSpecialEventData ); - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } + gubCurrentTalkingID = QItem->ubCharacterNum; ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); @@ -1081,8 +1102,13 @@ void HandleDialogue( ) } if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_BEGINPREBATTLEINTERFACE ) { - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } + gubCurrentTalkingID = QItem->ubCharacterNum; ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, QItem->bUIHandlerID, QItem->fFromSoldier ); @@ -1198,8 +1224,13 @@ void HandleDialogue( ) if ( QItem->uiSpecialEventFlag & DIALOGUE_SPECIAL_EVENT_MINESECTOREVENT ) { - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } + gubCurrentTalkingID = QItem->ubCharacterNum; // set up the mine highlgith events @@ -1323,8 +1354,14 @@ void HandleDialogue( ) { gTacticalStatus.ubLastQuoteSaid = (UINT8)QItem->usQuoteNum; gTacticalStatus.ubLastQuoteProfileNUm = (UINT8)QItem->ubCharacterNum; - // Setup face pointer - gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + + // Flugente: only set up face if we can access correctly + if ( QItem->iFaceIndex > 0 ) + { + // Setup face pointer + gpCurrentTalkingFace = &gFacesData[ QItem->iFaceIndex ]; + } + gubCurrentTalkingID = QItem->iFaceIndex; //ExecuteCharacterDialogue( QItem->ubCharacterNum, QItem->usQuoteNum, QItem->iFaceIndex, DIALOGUE_TACTICAL_UI, TRUE );