From 1080b6c2492a6d47bef4f0967c2f98636279ebfb Mon Sep 17 00:00:00 2001 From: Mikko Mononen Date: Wed, 9 Feb 2011 18:52:25 +0000 Subject: [PATCH] Fix for Issue 162. --- Detour/Source/DetourNavMesh.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Detour/Source/DetourNavMesh.cpp b/Detour/Source/DetourNavMesh.cpp index e806eae..44bbd22 100644 --- a/Detour/Source/DetourNavMesh.cpp +++ b/Detour/Source/DetourNavMesh.cpp @@ -206,7 +206,8 @@ dtStatus dtNavMesh::init(const dtNavMeshParams* params) // Init ID generator values. m_tileBits = dtIlog2(dtNextPow2((unsigned int)params->maxTiles)); m_polyBits = dtIlog2(dtNextPow2((unsigned int)params->maxPolys)); - m_saltBits = 32 - m_tileBits - m_polyBits; + // Only allow 31 salt bits, since the salt mask is calculated using 32bit uint and it will overflow. + m_saltBits = dtMin((unsigned int)31, 32 - m_tileBits - m_polyBits); if (m_saltBits < 10) return DT_FAILURE | DT_INVALID_PARAM;