Fixed a crash in FindCornerNodeForExactPath

This commit is contained in:
smallmodel 2023-10-19 20:19:43 +02:00
parent e9ffb4b9b5
commit a6f6cbd9b5
No known key found for this signature in database
GPG key ID: 9F2D623CEDF08512

View file

@ -3238,25 +3238,25 @@ PathNode *PathSearch::FindCornerNodeForExactPath
) )
{ {
PathNode *pPathNode[4096]; PathNode *pPathNode[4096];
PathNode *pParentNode;
size_t i, iDepth, index;
if (!PathSearch::FindPath(enemy->origin, pSelf->origin, pSelf, fMaxPath, 0, 0.0, 100)) if (!PathSearch::FindPath(enemy->origin, pSelf->origin, pSelf, fMaxPath, 0, 0.0, 100))
return NULL; return NULL;
size_t iDepth = 0; for (pParentNode = Node->Parent, i = 0; pParentNode; pParentNode = pParentNode->Parent, i++)
for (PathNode* pParentNode = Node->Parent; pParentNode; pParentNode = pParentNode->Parent, iDepth++)
{ {
pPathNode[iDepth] = pParentNode; pPathNode[i] = pParentNode;
}
iDepth = i;
if (!iDepth) {
return NULL;
} }
Node = pPathNode[iDepth -1]; Node = pPathNode[iDepth -1];
for (i = 1; i < iDepth; i += 2)
if (iDepth == 0)
{
return NULL;
}
size_t i;
for (i = 0; i < iDepth; i += 2)
{ {
if (!G_SightTrace( if (!G_SightTrace(
pSelf->EyePosition(), pSelf->EyePosition(),
@ -3273,7 +3273,7 @@ PathNode *PathSearch::FindCornerNodeForExactPath
} }
} }
size_t index = i - 1; index = i - 1;
if (index < iDepth) if (index < iDepth)
{ {
if (index) if (index)
@ -3282,7 +3282,7 @@ PathNode *PathSearch::FindCornerNodeForExactPath
pSelf->EyePosition(), pSelf->EyePosition(),
vec_zero, vec_zero,
vec_zero, vec_zero,
pSelf->EyePosition() - pSelf->origin + pPathNode[i]->m_PathPos, pSelf->EyePosition() - pSelf->origin + pPathNode[index]->m_PathPos,
pSelf, pSelf,
enemy, enemy,
0x2040B19, 0x2040B19,