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.
This commit is contained in:
Asdow
2025-09-25 22:47:51 +03:00
parent e14a337e03
commit f5a7c32bff
2 changed files with 7 additions and 12 deletions
+4 -8
View File
@@ -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 )
{