Core/PathGenerator: Fix path generator returning shortcuts when start and end are on the same polygon (#24036)

* Core/PathGenerator: Fix path generator returning shortcuts when start and end are on the same polygon

Fix path generator returning shortcuts when start and end are on the same polygon by handling this case as if start and end were on 2 different polygons. This will ensure BuildPointPath() gets called which calls FindSmoothPath(), making sure each step is not longer than SMOOTH_PATH_STEP_SIZE (4 yards)

* Change ingame cast error message to SPELL_FAILED_NOPATH from SPELL_FAILED_OUT_OF_RANGE if the generated path is too long
This commit is contained in:
Giacomo Pozzoni authored and Ovahlord committed 2020-02-20 21:29:46 +01:00
1 parent fbe4abf3be
commit cad41332ba
4 files changed
+21 -17

No files matched your search

+3 -6
View File
@@ -247,7 +247,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
// *** poly path generating logic ***
// start and end are on same polygon
// just need to move in straight line
// handle this case as if they were 2 different polygons, building a line path split in some few points
if (startPoly == endPoly)
{
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: (startPoly == endPoly)");
@@ -255,11 +255,8 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con
BuildShortcut();
_pathPolyRefs[0] = startPoly;
_polyLength = 1;
_type = farFromPoly ? PATHFIND_INCOMPLETE : PATHFIND_NORMAL;
TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: path type %d", _type);
return;
_pathPolyRefs[1] = endPoly;
_polyLength = 2;
}
// look for startPoly/endPoly in current path