From f5a7c32bff82ab0f673066e8ed9675212bb5c188 Mon Sep 17 00:00:00 2001 From: Asdow <20314541+Asdow@users.noreply.github.com> Date: Thu, 25 Sep 2025 22:29:45 +0300 Subject: [PATCH] Use SoldierID instead of pSoldier ContinueDialogue was possible to be called with pSoldier that isn't null but is not valid pointer to MercPtrs array resulting in debugger catching an illegal memory access. --- Strategic/mapscreen.cpp | 12 ++++-------- Tactical/Dialogue Control.cpp | 7 +++---- 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Strategic/mapscreen.cpp b/Strategic/mapscreen.cpp index 079343b0..eb08ea0a 100644 --- a/Strategic/mapscreen.cpp +++ b/Strategic/mapscreen.cpp @@ -863,7 +863,7 @@ extern BOOLEAN CanPlayerUseSectorInventory( SOLDIERTYPE *pSelectedSoldier ); // handle talking void HandleSpontanousTalking( void ); -BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ); +BOOLEAN ContinueDialogue(SoldierID id, BOOLEAN fDone ); extern void CreateDestroyMilitiaSectorButtons( void ); extern void CreateDestroySupplySectorButtons(); @@ -13098,17 +13098,13 @@ void UpdatePausedStatesDueToTimeCompression( void ) } -BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ) +BOOLEAN ContinueDialogue(SoldierID id, BOOLEAN fDone ) { // continue this grunts dialogue, restore when done static INT16 bOldSelectedInfoChar = -1; static BOOLEAN fTalkingingGuy = FALSE; - UINT16 bCounter = 0; - - - if( fDone == TRUE ) { if( fTalkingingGuy == TRUE ) @@ -13131,7 +13127,7 @@ BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ) } // check if valid character talking? - if( pSoldier == NULL ) + if( id >= NOBODY ) { return FALSE; } @@ -13141,7 +13137,7 @@ BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ) { if( gCharactersList[bCounter].fValid == TRUE ) { - if( gCharactersList[bCounter].usSolID == pSoldier->ubID ) + if( gCharactersList[bCounter].usSolID == id ) { if( bSelectedInfoChar != bCounter ) { diff --git a/Tactical/Dialogue Control.cpp b/Tactical/Dialogue Control.cpp index cf81581a..0bbd0ecf 100644 --- a/Tactical/Dialogue Control.cpp +++ b/Tactical/Dialogue Control.cpp @@ -203,7 +203,7 @@ void RenderSubtitleBoxOverlay( VIDEO_OVERLAY *pBlitter ); void RenderFaceOverlay( VIDEO_OVERLAY *pBlitter ); -extern BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ); +extern BOOLEAN ContinueDialogue(SoldierID id, BOOLEAN fDone ); extern void HandlePendingInitConv( ); extern BOOLEAN WillMercRenew( SOLDIERTYPE *pSoldier, BOOLEAN fSayQuote ); extern void DrawFace( INT16 sCharNumber ); @@ -253,7 +253,7 @@ void HandleExternNPCSpeechFace( INT32 iIndex ); -extern BOOLEAN ContinueDialogue(SOLDIERTYPE *pSoldier, BOOLEAN fDone ); +extern BOOLEAN ContinueDialogue(SoldierID id, BOOLEAN fDone ); extern BOOLEAN DoSkiMessageBox( UINT8 ubStyle, STR16 zString, UINT32 uiExitScreen, UINT8 ubFlags, MSGBOX_CALLBACK ReturnCallback ); @@ -3005,10 +3005,9 @@ void HandleTacticalSpeechUI( UINT8 ubCharacterNum, INT32 iFaceIndex ) // If so, set current guy active to talk..... if ( pSoldier != NULL ) { - ContinueDialogue( pSoldier, FALSE ); + ContinueDialogue( pSoldier->ubID, FALSE ); } } - }