mirror of
https://github.com/1dot13/source.git
synced 2026-09-02 14:36:06 +02:00
Fixed appearance of save game corruption when a game with different inventory set is loaded. Note that such games can still cause odd behavior and CTD's
Fixed old-style behavior when creating a soldier struct (caused memory corruption and leaks) Fixed soldiers unable to fire if an error happened while firing the off-hand weapon Fix animation system problems with soldiers interrupted while changing stance, such as twitching and not being able to navigate around obstacles Prevent splitting money while an item is in the hand, which would result in losing the original item Fix reverse of X,Y when checking visibility through a roof, which could make soldiers falsely visible/invisible Prevent militia from simply waiting on the border when enemies are known to be in the sector Fix stack overflow for soldier inventory debug display Optimized A* pathing and cleaned up VS2K5 specific code AI can now use all climb points for climbable buildings, not just a random few Fix to not allow flat roof butted against slanted roof to be identified as a climb point Prevent soldiers who cause an interrupt from a special action from continuing on their path after being interrupted Prevent soldiers who enter or leave deep water from moving a space too far and turning back Prevent soldiers from trying to crouch while in shallow water Make soldier turn in the closest direction when he must get up from prone and turn then fall back to prone Allow a soldier to swat for a tile before returning to prone if unable to return to prone immediately after a turn Fix civilians that should show up in a sector, missing because of others that aren't Fix a memset on a C++ class Place Skyrider in a sector near his helecopter once available and the helicopter is present Fix soldier corruption if too many shots burst-spread into too few tiles Include both first and last tile in spread when some locations must be skipped Fix to shoot at last location in burst Fix to remove other previous spread locations when calculating a new spread Fix to reload or rechamber off-hand when necessary, such as having a pistol shotgun in that hand git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@1532 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
+69
-63
@@ -10,6 +10,7 @@
|
||||
#define _PATHAI_H
|
||||
#include "isometric utils.h"
|
||||
|
||||
|
||||
#define USE_ASTAR_PATHS
|
||||
|
||||
#ifdef USE_ASTAR_PATHS
|
||||
@@ -30,30 +31,25 @@ class AStar_Data
|
||||
public:
|
||||
AStar_Data()
|
||||
{
|
||||
cost = f = APCost = direction = prevCost = 0;
|
||||
#ifdef ASTAR_USING_EXTRACOVER
|
||||
cost = directionFromPrev = 0;
|
||||
extraGCoverCost = -1;//-1 means we have not stopped at this node
|
||||
#endif
|
||||
wasBackwards = false;
|
||||
status = AStar_Init;
|
||||
parent = GridNode(-1,-1);
|
||||
parent = -1;
|
||||
};
|
||||
//no H
|
||||
int cost;//G
|
||||
int f;//F
|
||||
int APCost;//the APs spent to get here
|
||||
#ifdef ASTAR_USING_EXTRACOVER
|
||||
// h is calculated on the fly
|
||||
INT16 cost;//G
|
||||
//int f;//F is also calculated on the fly
|
||||
//int APCost;//the APs spent to get here // Isn't this the same as "cost"?
|
||||
int extraGCoverCost;//an extra cost that makes stopping in midpath at a node with little cover worse
|
||||
#endif
|
||||
GridNode parent;
|
||||
INT16 parent;
|
||||
eAStar status;
|
||||
int prevCost;
|
||||
//int prevCost;
|
||||
bool wasBackwards;
|
||||
int direction;
|
||||
UINT8 directionFromPrev;
|
||||
int numSteps;
|
||||
};
|
||||
|
||||
typedef HEAP<int, GridNode> AStarHeap;
|
||||
|
||||
class AStarPathfinder
|
||||
{
|
||||
public:
|
||||
@@ -68,13 +64,19 @@ public:
|
||||
|
||||
private:
|
||||
static AStarPathfinder* pThis;
|
||||
std::vector<GridNode> ClosedList;
|
||||
CBinaryHeap<int, GridNode> OpenHeap;
|
||||
CBinaryHeap<int, INT16> OpenHeap;
|
||||
|
||||
int direction;//current direction
|
||||
int startDir;
|
||||
int endDir;
|
||||
int lastDir;
|
||||
// The "closed list" is the AStarData array below which is also the path backtrace when a path is found.
|
||||
|
||||
// For PythSpacesAway, we do not really need the distance, but rather something to compare against.
|
||||
// So I will eliminate the sqrt function from the result for the sake of speed. This means that when comparing against
|
||||
// input distances, we should square them. This is one of the variables that needs to hold the squared value.
|
||||
int gubNPCDistLimitSq;
|
||||
|
||||
UINT8 direction;//current direction
|
||||
UINT8 startDir;
|
||||
UINT8 endDir;
|
||||
UINT8 lastDir;
|
||||
bool startingLoop;
|
||||
|
||||
SOLDIERTYPE* pSoldier;
|
||||
@@ -84,7 +86,7 @@ private:
|
||||
bool fPathingForPlayer;
|
||||
bool fPathAroundPeople;
|
||||
bool fGoingThroughDoor;
|
||||
int bOKToAddStructID;
|
||||
INT16 bOKToAddStructID;
|
||||
int bLoopState;
|
||||
bool bWaterToWater;
|
||||
bool fVisitSpotsOnlyOnce;
|
||||
@@ -95,13 +97,16 @@ private:
|
||||
bool fConsiderPersonAtDestAsObstacle;
|
||||
bool fCopyReachable;
|
||||
bool fCopyPathCosts;
|
||||
bool fFindClimbPoints;
|
||||
|
||||
int maxAPBudget;//the gubNPCAPBudget
|
||||
int mercsMaxAPs;//the merc only has so many points to move with
|
||||
int movementMode;
|
||||
int sClosePathLimit;
|
||||
UINT16 movementMode;
|
||||
int sClosePathLimitSq;
|
||||
|
||||
int PATHAI_VISIBLE_DEBUG_Counter;
|
||||
int travelcostDiag;
|
||||
int travelcostOrth;
|
||||
INT16 PATHAI_VISIBLE_DEBUG_Counter;
|
||||
|
||||
//vehicle defined in cpp
|
||||
//#ifdef VEHICLE
|
||||
@@ -110,20 +115,18 @@ private:
|
||||
//#endif
|
||||
|
||||
// member variables to prevent passing them around
|
||||
GridNode StartNode;
|
||||
GridNode DestNode;
|
||||
GridNode CurrentNode;
|
||||
GridNode ParentNode;
|
||||
INT16 ParentNodeIndex;
|
||||
INT16 CurrentNodeIndex;
|
||||
INT16 StartNode;
|
||||
INT16 DestNode;
|
||||
INT16 CurrentNode;
|
||||
INT16 ParentNode;
|
||||
|
||||
AStar_Data AStarData[WORLD_COLS][WORLD_ROWS];
|
||||
AStar_Data AStarData[WORLD_MAX];
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
AStarHeap AStar ();
|
||||
INT16 AStar ();
|
||||
|
||||
void ExecuteAStarLogic();
|
||||
|
||||
@@ -131,49 +134,49 @@ private:
|
||||
|
||||
int TerrainCostToAStarG(int const terrainCost);
|
||||
int CalcG (int* pPrevCost);
|
||||
int CalcAP (int const terrainCost);
|
||||
INT16 CalcAP (int const terrainCost, UINT8 const direction);
|
||||
int CalcH ();
|
||||
int CalcGCover (int const NodeIndex,
|
||||
int const APCost);
|
||||
int CalcStartingAP ();
|
||||
INT16 CalcStartingAP ();
|
||||
|
||||
//including THREATTYPE was a pain, so pass by value
|
||||
int CalcCoverValue (INT16 sMyGridNo, INT32 iMyThreat, INT32 iMyAPsLeft,
|
||||
INT32 myThreatsiOrigRange, INT16 myThreatssGridNo, SOLDIERTYPE* myThreatspOpponent,
|
||||
INT32 myThreatsiValue, INT32 myThreatsiAPs, INT32 myThreatsiCertainty);
|
||||
|
||||
eAStar GetAStarStatus (const GridNode node) const {return AStarData[node.x][node.y].status;};
|
||||
GridNode GetAStarParent (const GridNode node) const {return AStarData[node.x][node.y].parent;};
|
||||
int GetAStarG (const GridNode node) const {return AStarData[node.x][node.y].cost;};
|
||||
int GetAStarF (const GridNode node) const {return AStarData[node.x][node.y].f;};
|
||||
int GetActionPoints (const GridNode node) const {return AStarData[node.x][node.y].APCost;};
|
||||
bool GetLoopState (const GridNode node) const {return AStarData[node.x][node.y].wasBackwards;};
|
||||
int GetPrevCost (const GridNode node) const {return AStarData[node.x][node.y].prevCost;};
|
||||
int GetDirection (const GridNode node) const {return AStarData[node.x][node.y].direction;};
|
||||
#ifdef ASTAR_USING_EXTRACOVER
|
||||
int GetExtraGCover (const GridNode node) const {return AStarData[node.x][node.y].extraGCoverCost;};
|
||||
eAStar GetAStarStatus (const INT16 node) const {return AStarData[node].status;};
|
||||
INT16 GetAStarParent (const INT16 node) const {return AStarData[node].parent;};
|
||||
INT16 GetAStarG (INT16 node) const {return AStarData[node].cost;};
|
||||
int GetExtraGCover (const INT16 node) const {return AStarData[node].extraGCoverCost;};
|
||||
//int GetAStarF (const INT16 node) const {return AStarData[node].f;};
|
||||
//int GetActionPoints (const INT16 node) const {return AStarData[node].APCost;};
|
||||
bool GetLoopState (const INT16 node) const {return AStarData[node].wasBackwards;};
|
||||
//int GetPrevCost (const INT16 node) const {return AStarData[node].prevCost;};
|
||||
UINT8 GetDirection (const INT16 node) const {return AStarData[node].directionFromPrev;};
|
||||
int GetNumSteps (const INT16 node) const {return AStarData[node].numSteps;};
|
||||
|
||||
void SetExtraGCover (const GridNode node, const int extraGCoverCost) {AStarData[node.x][node.y].extraGCoverCost = extraGCoverCost;};
|
||||
#endif
|
||||
void SetAStarStatus (const GridNode node, const eAStar status) {AStarData[node.x][node.y].status = status;};
|
||||
void SetAStarParent (const GridNode node, const GridNode parent) {AStarData[node.x][node.y].parent = parent;};
|
||||
void SetAStarG (const GridNode node, const int cost) {AStarData[node.x][node.y].cost = cost;};
|
||||
void SetAStarF (const GridNode node, const int f) {AStarData[node.x][node.y].f = f;};
|
||||
void SetActionPoints (const GridNode node, const int APCost) {AStarData[node.x][node.y].APCost = APCost;};
|
||||
void SetLoopState (const GridNode node, const int loopState);
|
||||
void SetPrevCost (const GridNode node, const int prevCost) {AStarData[node.x][node.y].prevCost = prevCost;};
|
||||
void SetDirection (const GridNode node, const int direction) {AStarData[node.x][node.y].direction = direction;};
|
||||
void SetAStarStatus (const INT16 node, const eAStar status) {AStarData[node].status = status;};
|
||||
void SetAStarParent (const INT16 node, const INT16 parent) {AStarData[node].parent = parent;};
|
||||
void SetAStarG (const INT16 node, const INT16 cost) {AStarData[node].cost = cost;};
|
||||
void SetExtraGCover (const INT16 node, const int extraGCoverCost) {AStarData[node].extraGCoverCost = extraGCoverCost;};
|
||||
//void SetAStarF (const INT16 node, const int f) {AStarData[node].f = f;};
|
||||
//void SetActionPoints (const INT16 node, const int APCost) {AStarData[node].APCost = APCost;};
|
||||
void SetLoopState (const INT16 node, const int loopState);
|
||||
//void SetPrevCost (const INT16 node, const int prevCost) {AStarData[node].prevCost = prevCost;};
|
||||
void SetDirection (const INT16 node, const UINT8 direction) {AStarData[node].directionFromPrev = direction;};
|
||||
void SetNumSteps (const INT16 node, const int steps) {AStarData[node].numSteps = steps;};
|
||||
|
||||
INT16 PythSpacesAway (GridNode const node1,
|
||||
GridNode const node2);
|
||||
INT16 SpacesAway (GridNode const node1,
|
||||
GridNode const node2);
|
||||
//bool IsDiagonal (GridNode const node1,
|
||||
// GridNode const node2) {return (abs(node1.x - node2.x) && abs(node1.y - node2.y));};
|
||||
int PythSpacesAway (const INT16 node1,
|
||||
const INT16 node2);
|
||||
INT16 SpacesAway (const INT16 node1,
|
||||
const INT16 node2);
|
||||
//bool IsDiagonal (const INT16 node1,
|
||||
// const INT16 node2) {return (abs(node1.x - node2.x) && abs(node1.y - node2.y));};
|
||||
bool IsDiagonal (int const direction) {return (direction & 1);};
|
||||
void InitVehicle ();
|
||||
int VehicleObstacleCheck();
|
||||
bool CanTraverse ();
|
||||
bool WantToTraverse (); // Renamed this because it doesn't mean "can we traverse" but rather, if it is profitable to.
|
||||
bool IsSomeoneInTheWay();
|
||||
void IncrementLoop ();
|
||||
void InitLoop ();
|
||||
@@ -182,7 +185,7 @@ private:
|
||||
|
||||
};//end namespace ASTAR
|
||||
|
||||
#endif//end #ifdef USE_ASTAR_PATHS
|
||||
#endif// USE_ASTAR_PATHS
|
||||
|
||||
|
||||
BOOLEAN InitPathAI( void );
|
||||
@@ -289,12 +292,15 @@ extern UINT8 gubGlobalPathFlags;
|
||||
#define COPYROUTE 1
|
||||
#define COPYREACHABLE 2
|
||||
#define COPYREACHABLE_AND_APS 3
|
||||
#define FINDCLIMBPOINTS 4
|
||||
|
||||
#define PATH_THROUGH_PEOPLE 0x01
|
||||
#define PATH_IGNORE_PERSON_AT_DEST 0x02
|
||||
#define PATH_CLOSE_GOOD_ENOUGH 0x04
|
||||
|
||||
|
||||
#define PATH_CLOSE_RADIUS 5
|
||||
#define PATH_CLOSE_RADIUS_SQ 25
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user