From 3acb96f8e6f85623e43806b03cf7e1ccf0be2e68 Mon Sep 17 00:00:00 2001 From: Shadooow Date: Thu, 24 Jun 2021 18:07:46 +0000 Subject: [PATCH] fixed memory leak inside corpse placement code causing various issues when entering a town sector git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@9102 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/Tactical Save.cpp | 91 +++++++++++++++++++------------------- 1 file changed, 46 insertions(+), 45 deletions(-) diff --git a/Tactical/Tactical Save.cpp b/Tactical/Tactical Save.cpp index db537be99..dee427531 100644 --- a/Tactical/Tactical Save.cpp +++ b/Tactical/Tactical Save.cpp @@ -1845,12 +1845,12 @@ BOOLEAN LoadRottingCorpsesFromTempCorpseFile( INT16 sMapX, INT16 sMapY, INT8 bMa if (uiNumberOfCorpses > 10000) uiNumberOfCorpses = 0; - // Get town ID for use later.... + // Get town ID for use later.... bTownId = GetTownIdForSector( gWorldSectorX, gWorldSectorY ); for( cnt=0; cnt= 30 ) + { + fDontAddCorpse = TRUE; + } + } + } + } + } - // If not from loading a save.... - if( !(gTacticalStatus.uiFlags & LOADING_SAVED_GAME ) ) - { - // ATE: Don't place corpses if - // a ) in a town and b) indoors - if ( gbWorldSectorZ == 0 ) - { - if ( bTownId != BLANK_SECTOR ) - { - // Are we indoors? - if( FloorAtGridNo( def.sGridNo ) ) - { - // OK, finally, check TOC vs game time to see if at least some time has passed - if ( ( GetWorldTotalMin( ) - def.uiTimeOfDeath ) >= 30 ) - { - fDontAddCorpse = TRUE; - } - } - } - } - } - - if ( !fDontAddCorpse ) - { - //add the rotting corpse info - if( AddRottingCorpse( &def ) == -1 ) - { - DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Failed to add a corpse to GridNo # %d", def.sGridNo ) ); - - /* - Assert( 0 ); - FileClose( hFile ); - return( FALSE ); - */ - } - } + if ( !fDontAddCorpse ) + { + //add the rotting corpse info + if( AddRottingCorpse( &def ) == -1 ) + { + DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String("Failed to add a corpse to GridNo # %d", def.sGridNo ) ); + /* + Assert( 0 ); + FileClose( hFile ); + return( FALSE ); + */ + } + } } FileClose( hFile );