From 92b7bd84172fcb3d6c265c6cfc970b715e1121f1 Mon Sep 17 00:00:00 2001 From: Lesh Date: Fri, 7 Jul 2006 20:37:08 +0000 Subject: [PATCH] -CTD fix in Tixa in function FindBestPath in PathaAi.cpp git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@334 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- Tactical/PATHAI.H | 5 ++++- Tactical/PATHAI.cpp | 7 +++++-- TacticalAI/FindLocations.cpp | 7 +++++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Tactical/PATHAI.H b/Tactical/PATHAI.H index f8da7e7d..1106b1a8 100644 --- a/Tactical/PATHAI.H +++ b/Tactical/PATHAI.H @@ -28,8 +28,11 @@ UINT8 InternalDoorTravelCost( SOLDIERTYPE * pSoldier, INT32 iGridNo, UINT8 ubMov INT16 RecalculatePathCost( SOLDIERTYPE *pSoldier, UINT16 usMovementMode ); +// Lesh: setup max length of path +#define MAX_PATH_DATA_LENGTH 512 + // Exporting these global variables -extern UINT32 guiPathingData[256]; +extern UINT32 guiPathingData[MAX_PATH_DATA_LENGTH]; extern UINT8 gubNPCAPBudget; extern UINT16 gusNPCMovementMode; extern UINT8 gubNPCDistLimit; diff --git a/Tactical/PATHAI.cpp b/Tactical/PATHAI.cpp index 249fa83b..34421260 100644 --- a/Tactical/PATHAI.cpp +++ b/Tactical/PATHAI.cpp @@ -400,8 +400,11 @@ BOOLEAN gfPlotDirectPath = FALSE; BOOLEAN gfEstimatePath = FALSE; BOOLEAN gfPathAroundObstacles = TRUE; -static UINT32 guiPlottedPath[256]; -UINT32 guiPathingData[256]; +// Lesh: fix CTD in Tixa +// The game was trying to store very long path (270 cells) in 256-cell array and corrupted +// some data, not belonged to array. It was ordinary array boundary break. +static UINT32 guiPlottedPath[MAX_PATH_DATA_LENGTH]; +UINT32 guiPathingData[MAX_PATH_DATA_LENGTH]; static INT32 giPathDataSize; static INT32 giPlotCnt; static UINT32 guiEndPlotGridNo; diff --git a/TacticalAI/FindLocations.cpp b/TacticalAI/FindLocations.cpp index b033bcac..03d90f9d 100644 --- a/TacticalAI/FindLocations.cpp +++ b/TacticalAI/FindLocations.cpp @@ -1228,8 +1228,11 @@ INT16 FindSpotMaxDistFromOpponents(SOLDIERTYPE *pSoldier) // assume we have to stand up! // use the min macro here to make sure we don't wrap the UINT8 to 255... - - gubNPCAPBudget = gubNPCAPBudget = __min( gubNPCAPBudget, gubNPCAPBudget - GetAPsToChangeStance( pSoldier, ANIM_STAND ) ); + // Lesh: for some reason this code still allows to wrap UINT8 at low values of gubNPCAPBudget + //gubNPCAPBudget = gubNPCAPBudget = __min( gubNPCAPBudget, gubNPCAPBudget - GetAPsToChangeStance( pSoldier, ANIM_STAND ) ); + // Lesh: will be using this form + if ( gubNPCAPBudget > GetAPsToChangeStance( pSoldier, ANIM_STAND ) ) + gubNPCAPBudget = gubNPCAPBudget - GetAPsToChangeStance( pSoldier, ANIM_STAND ); //NumMessage("Search Range = ",iSearchRange); //NumMessage("gubNPCAPBudget = ",gubNPCAPBudget);