2
0
Эх сурвалжийг харах

Apply fixes to pathfinder

AlexVinS 10 жил өмнө
parent
commit
1bcfa986e4

+ 3 - 2
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<boost::mutex> 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];
 }

+ 1 - 1
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;
 };