Fix Path_NearestNodeNotCrossPlanes.

Also fix pathlocal_t struct.
This commit is contained in:
JezuzLizard 2023-03-31 11:15:28 -07:00
parent 6461aa85d3
commit f0ffd59c58
4 changed files with 27 additions and 19 deletions

View File

@ -223,20 +223,23 @@ namespace ai
{
int result; // eax
int returnCount = 0; // [esp+2Ch] [ebp-304h] BYREF
//game::pathsort_t nodes[64] = {}; // [esp+30h] [ebp-300h] BYREF
std::unique_ptr<game::pathsort_t[], void (*)(game::pathsort_t*)> nodes(new game::pathsort_t[64], [](game::pathsort_t* ptr) { delete[] ptr; });
const int maxNodes = 64;
const float maxHeightSq = 8.0f * 8.0f;
//printf("Path_FindPath_stub() \n");
game::pathnode_t* pNodeTo = game::Path_NearestNodeNotCrossPlanes(NAN, maxHeightSq, vGoalPos, nodes.get(), 192.0, 0, 0, 0, &returnCount, 0);
game::pathnode_t* pNodeFrom = game::Path_NearestNodeNotCrossPlanes(NAN, maxHeightSq, vStartPos, nodes.get(), 192.0, 0, 0, 0, &returnCount, 0);
if (pNodeTo && pNodeFrom != 0)
result = Path_FindPathFromTo_custom(vStartPos, pNodeTo, pPath, eTeam, pNodeFrom, vGoalPos, bAllowNegotiationLinks, 0);
game::pathnode_t* pNodeTo = game::Path_NearestNodeNotCrossPlanes(-2, maxNodes, vGoalPos, nodes.get(), 192.0f, 0.0f, 0.0f, 0.0f, &returnCount, game::NEAREST_NODE_DO_HEIGHT_CHECK);
if (!pNodeTo)
{
printf("Couldn't find the node to\n");
}
game::pathnode_t* pNodeFrom = game::Path_NearestNodeNotCrossPlanes(-2, maxNodes, vStartPos, nodes.get(), 192.0f, 0.0f, 0.0f, 0.0f, &returnCount, game::NEAREST_NODE_DO_HEIGHT_CHECK);
if (pNodeTo && pNodeFrom)
{
result = game::Path_FindPathFromTo(vStartPos, pNodeTo, pPath, eTeam, pNodeFrom, vGoalPos, bAllowNegotiationLinks, 0);
}
else
{
result = 0;
}
return result;
}
}

View File

@ -441,7 +441,7 @@ namespace game
return answer;
}
pathnode_t* Path_NearestNodeNotCrossPlanes(float maxDistSq, float maxHeightSq, float* vOrigin, pathsort_t* nodes, float a5, int a6, int a7, int a8, int* returnCount, int a10)
pathnode_t* Path_NearestNodeNotCrossPlanes(int typeFlags, int maxNodes, float* vOrigin, pathsort_t* nodes, float fMaxDist, float a6, float a7, int iPlaneCount, int* returnCount, nearestNodeHeightCheck heightCheck)
{
static const auto call_addr = SELECT(0x0, 0x55C210);
@ -449,16 +449,16 @@ namespace game
__asm
{
push a10;
push heightCheck;
push returnCount;
push a8;
push iPlaneCount;
push a7;
push a6;
push a5;
push fMaxDist;
push nodes;
push vOrigin;
movss xmm0, maxHeightSq;
movss xmm1, maxDistSq;
mov ecx, maxNodes;
mov edx, typeFlags;
call call_addr;
add esp, 0x20;
mov answer, eax;

View File

@ -57,7 +57,7 @@ namespace game
const char* SL_ConvertToString(scriptInstance_t inst, int id);
int Path_FindPath(path_t* pPath, team_t eTeam, float* vStartPos, float* vGoalPos, int bAllowNegotiationLinks);
pathnode_t* Path_NearestNodeNotCrossPlanes(float maxDistSq, float maxHeightSq, float* vOrigin, pathsort_t* nodes, float a5, int a6, int a7, int a8, int* returnCount, int a10);
pathnode_t* Path_NearestNodeNotCrossPlanes(int typeFlags, int maxNodes, float* vOrigin, pathsort_t* nodes, float fMaxDist, float a6, float a7, int iPlaneCount, int* returnCount, nearestNodeHeightCheck heightCheck);
int Path_FindPathFromTo(float* startPos, pathnode_t* pNodeTo, path_t* pPath, team_t eTeam, pathnode_t* pNodeFrom, float* vGoalPos, int bAllowNegotiationLinks, int bIgnoreBadplaces);
template <typename T>

View File

@ -1572,12 +1572,12 @@ namespace game
float origin[3];
float maxDist;
float maxDistSq;
float maxHeight;
float maxHeightSq;
int typeFlags;
pathsort_t* nodes;
int maxNodes;
int nodeCount;
float maxHeight;
};
struct __declspec(align(128)) pathlocal_t
@ -1585,9 +1585,9 @@ namespace game
PathLinkInfo pathLinkInfoArray[2048];
int pathLinkInfoArrayInited;
unsigned int actualNodeCount;
pathlocal_t_circle circle;
unsigned int extraNodes;
unsigned int originErrors;
pathlocal_t_circle circle;
};
struct CustomSearchInfo_FindPath
@ -1597,6 +1597,11 @@ namespace game
float negotiationOverlapCost;
};
enum nearestNodeHeightCheck
{
NEAREST_NODE_DO_HEIGHT_CHECK = 0x0,
NEAREST_NODE_DONT_DO_HEIGHT_CHECK = 0x1,
};
enum VariableType
{