Core/MMaps: Added a little workaround to prevent the crash.

ref issue #7631
This commit is contained in:
Subv committed 2012-09-09 15:14:02 -05:00
1 parent 50327363ca
commit 8966347a41
1 file changed
+9 -2
+9 -2
View File
@@ -584,12 +584,19 @@ NavTerrain PathGenerator::GetNavTerrain(float x, float y, float z)
}
}
bool PathGenerator::HaveTile(Vector3 const& p) const
bool PathGenerator::HaveTile(const Vector3& p) const
{
int tx, ty;
int tx = -1, ty = -1;
float point[VERTEX_SIZE] = {p.y, p.z, p.x};
_navMesh->calcTileLoc(point, &tx, &ty);
/// Workaround
/// For some reason, often the tx and ty variables wont get a valid value
/// Use this check to prevent getting negative tile coords and crashing on getTileAt
if (tx < 0 || ty < 0)
return false;
return (_navMesh->getTileAt(tx, ty) != NULL);
}