From afab9c2206782ce1edb8f3c5a3ac061eea3efc6e Mon Sep 17 00:00:00 2001 From: Kawe Mazidjatari <48657826+Mauler125@users.noreply.github.com> Date: Mon, 2 Sep 2024 18:02:47 +0200 Subject: [PATCH] Recast: fix crash in dtPathCorridor Must alloc the jumpTypes array, currently not fully implemented yet. --- .../recast/Detour/Source/DetourNavMeshQuery.cpp | 2 +- .../recast/DetourCrowd/Source/DetourPathCorridor.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp index 0b93396a..ecc7aa66 100644 --- a/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp +++ b/src/thirdparty/recast/Detour/Source/DetourNavMeshQuery.cpp @@ -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; diff --git a/src/thirdparty/recast/DetourCrowd/Source/DetourPathCorridor.cpp b/src/thirdparty/recast/DetourCrowd/Source/DetourPathCorridor.cpp index 3ba05f2c..0b7cf2f7 100644 --- a/src/thirdparty/recast/DetourCrowd/Source/DetourPathCorridor.cpp +++ b/src/thirdparty/recast/DetourCrowd/Source/DetourPathCorridor.cpp @@ -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