diff options
-rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 19 | ||||
-rw-r--r-- | src/tools/mmaps_generator/PathGenerator.cpp | 4 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index a02eb0a9a84..62ab0be4630 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -30,7 +30,7 @@ PathGenerator::PathGenerator(const Unit* owner) : m_polyLength(0), m_type(PATHFIND_BLANK), m_useStraightPath(false), m_forceDestination(false), m_pointPathLimit(MAX_POINT_PATH_LENGTH), - m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL) + m_sourceUnit(owner), m_navMesh(NULL), m_navMeshQuery(NULL), m_endPosition(Vector3::zero()) { sLog->outDebug(LOG_FILTER_MAPS, "++ PathGenerator::PathGenerator for %u \n", m_sourceUnit->GetGUIDLow()); @@ -52,16 +52,16 @@ PathGenerator::~PathGenerator() bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool forceDest) { - if (!Trinity::IsValidMapCoord(destX, destY, destZ) || - !Trinity::IsValidMapCoord(m_sourceUnit->GetPositionX(), m_sourceUnit->GetPositionY(), m_sourceUnit->GetPositionZ())) + float x, y, z; + m_sourceUnit->GetPosition(x, y, z); + + if (!Trinity::IsValidMapCoord(destX, destY, destZ) || !Trinity::IsValidMapCoord(x, y, z)) return false; Vector3 oldDest = getEndPosition(); Vector3 dest(destX, destY, destZ); setEndPosition(dest); - float x, y, z; - m_sourceUnit->GetPosition(x, y, z); Vector3 start(x, y, z); setStartPosition(start); @@ -84,7 +84,7 @@ bool PathGenerator::CalculatePath(float destX, float destY, float destZ, bool fo // check if destination moved - if not we can optimize something here // we are following old, precalculated path? float dist = m_sourceUnit->GetObjectSize(); - if (inRange(oldDest, dest, dist, dist) && m_pathPoints.size() > 2) + if (oldDest != Vector3::zero() && inRange(oldDest, dest, dist, dist) && m_pathPoints.size() > 2) { // our target is not moving - we just coming closer // we are moving on precalculated path - enjoy the ride @@ -192,7 +192,7 @@ void PathGenerator::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos if (waterPath) { // Check both start and end points, if they're both in water, then we can *safely* let the creature move - for (int i = 0; i < m_pathPoints.size(); ++i) + for (uint32 i = 0; i < m_pathPoints.size(); ++i) { LiquidData data; m_sourceUnit->GetBaseMap()->getLiquidStatus(m_pathPoints[i].x, m_pathPoints[i].y, m_pathPoints[i].z, MAP_ALL_LIQUIDS, &data); @@ -277,11 +277,12 @@ void PathGenerator::BuildPolyPath(const Vector3 &startPos, const Vector3 &endPos // TODO: we can merge it with getPathPolyByPosition() loop bool startPolyFound = false; bool endPolyFound = false; - uint32 pathStartIndex, pathEndIndex; + uint32 pathStartIndex = 0; + uint32 pathEndIndex = 0; if (m_polyLength) { - for (pathStartIndex = 0; pathStartIndex < m_polyLength; ++pathStartIndex) + for (; pathStartIndex < m_polyLength; ++pathStartIndex) { // here to carch few bugs ASSERT(m_pathPolyRefs[pathStartIndex] != INVALID_POLYREF); diff --git a/src/tools/mmaps_generator/PathGenerator.cpp b/src/tools/mmaps_generator/PathGenerator.cpp index 026bf957ec4..9707cb4160a 100644 --- a/src/tools/mmaps_generator/PathGenerator.cpp +++ b/src/tools/mmaps_generator/PathGenerator.cpp @@ -26,14 +26,14 @@ bool checkDirectories(bool debugOutput) { vector<string> dirFiles; - if (getDirContents(dirFiles, "maps") == LISTFILE_DIRECTORY_NOT_FOUND || !dirFiles.size()) + if (getDirContents(dirFiles, "maps") == LISTFILE_DIRECTORY_NOT_FOUND || dirFiles.empty()) { printf("'maps' directory is empty or does not exist\n"); return false; } dirFiles.clear(); - if (getDirContents(dirFiles, "vmaps", "*.vmtree") == LISTFILE_DIRECTORY_NOT_FOUND || !dirFiles.size()) + if (getDirContents(dirFiles, "vmaps", "*.vmtree") == LISTFILE_DIRECTORY_NOT_FOUND || dirFiles.empty()) { printf("'vmaps' directory is empty or does not exist\n"); return false; |