Recast: fix crash in dtPathCorridor

Must alloc the jumpTypes array, currently not fully implemented yet.
This commit is contained in:
Kawe Mazidjatari 2024-09-02 18:02:47 +02:00
parent 652d8f9da0
commit afab9c2206
2 changed files with 10 additions and 2 deletions

View File

@ -1805,7 +1805,7 @@ dtStatus dtNavMeshQuery::findStraightPath(const float* startPos, const float* en
if (!startPos || !rdVisfinite(startPos) ||
!endPos || !rdVisfinite(endPos) ||
!path || pathSize <= 0 || !path[0] ||
!path || !jumpTypes || pathSize <= 0 || !path[0] ||
maxStraightPath <= 0)
{
return DT_FAILURE | DT_INVALID_PARAM;

View File

@ -221,6 +221,12 @@ bool dtPathCorridor::init(const int maxPath)
m_path = (dtPolyRef*)rdAlloc(sizeof(dtPolyRef)*maxPath, RD_ALLOC_PERM);
if (!m_path)
return false;
rdAssert(!m_jumpTypes);
m_jumpTypes = (unsigned char*)rdAlloc(sizeof(unsigned char)*maxPath, RD_ALLOC_PERM);
if (!m_jumpTypes)
return false;
m_npath = 0;
m_maxPath = maxPath;
return true;
@ -233,9 +239,11 @@ bool dtPathCorridor::init(const int maxPath)
void dtPathCorridor::reset(dtPolyRef ref, const float* pos)
{
rdAssert(m_path);
rdAssert(m_jumpTypes);
rdVcopy(m_pos, pos);
rdVcopy(m_target, pos);
m_path[0] = ref;
m_jumpTypes[0] = DT_NULL_TRAVERSE_TYPE;
m_npath = 1;
}
@ -529,9 +537,9 @@ bool dtPathCorridor::fixPathStart(dtPolyRef safeRef, const float* safePos)
rdVcopy(m_pos, safePos);
if (m_npath < 3 && m_npath > 0)
{
m_path[2] = m_path[m_npath-1];
m_path[0] = safeRef;
m_path[1] = 0;
m_path[2] = m_path[m_npath-1];
m_npath = 3;
}
else