diff --git a/lib/CPathfinder.cpp b/lib/CPathfinder.cpp index 2eae0500c..df7fadb53 100644 --- a/lib/CPathfinder.cpp +++ b/lib/CPathfinder.cpp @@ -479,11 +479,12 @@ CPathsInfo::~CPathsInfo() delete [] nodes; } -const CGPathNode * CPathsInfo::getPathInfo( int3 tile ) const +const CGPathNode * CPathsInfo::getPathInfo(const int3& tile) const { boost::unique_lock pathLock(pathMx); - if(tile.x >= sizes.x || tile.y >= sizes.y || tile.z >= sizes.z) + if(tile.x >= sizes.x || tile.y >= sizes.y || tile.z >= sizes.z + || tile.x < 0 || tile.y < 0 || tile.z < 0) return nullptr; return &nodes[tile.x][tile.y][tile.z]; } diff --git a/lib/CPathfinder.h b/lib/CPathfinder.h index 38d13821e..43615456d 100644 --- a/lib/CPathfinder.h +++ b/lib/CPathfinder.h @@ -61,7 +61,7 @@ struct DLL_LINKAGE CPathsInfo CPathsInfo(const int3 &Sizes); ~CPathsInfo(); - const CGPathNode * getPathInfo( int3 tile ) const; + const CGPathNode * getPathInfo(const int3& tile) const; bool getPath(const int3 &dst, CGPath &out) const; int getDistance( int3 tile ) const; };