aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGiacomo Pozzoni <giacomopoz@gmail.com>2020-01-09 19:38:45 +0100
committerShauren <shauren.trinity@gmail.com>2021-12-20 20:35:37 +0100
commitdd929665e564e01b5346844adb96d8fd0eb710c4 (patch)
tree7dd195d37d2902bec87823b13910db349a8911d7 /src
parentfd265269720e64bf39dae205b670b25a677a3938 (diff)
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 (cherry picked from commit 29bf280e3496cf13c24ccb20e37da29d3bfa74d9)
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Movement/PathGenerator.cpp11
-rw-r--r--src/server/game/Spells/Spell.cpp2
-rw-r--r--src/tools/mmaps_generator/MapBuilder.cpp35
-rw-r--r--src/tools/mmaps_generator/MapBuilder.h1
4 files changed, 27 insertions, 22 deletions
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp
index e6b4e79ebb5..f7101cdd6de 100644
--- a/src/server/game/Movement/PathGenerator.cpp
+++ b/src/server/game/Movement/PathGenerator.cpp
@@ -246,19 +246,14 @@ 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)");
- 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
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 38b81819ffc..69a8488d2b3 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -5683,7 +5683,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
// first try with raycast, if it fails fall back to normal path
bool result = m_preGeneratedPath->CalculatePath(target->GetPositionX(), target->GetPositionY(), target->GetPositionZ(), false, false);
if (m_preGeneratedPath->GetPathType() & PATHFIND_SHORT)
- return SPELL_FAILED_OUT_OF_RANGE;
+ return SPELL_FAILED_NOPATH;
else if (!result || m_preGeneratedPath->GetPathType() & (PATHFIND_NOPATH | PATHFIND_INCOMPLETE))
return SPELL_FAILED_NOPATH;
else if (m_preGeneratedPath->IsInvalidDestinationZ(target)) // Check position z, if not in a straight line
diff --git a/src/tools/mmaps_generator/MapBuilder.cpp b/src/tools/mmaps_generator/MapBuilder.cpp
index a36503e5750..f7f5dcc3102 100644
--- a/src/tools/mmaps_generator/MapBuilder.cpp
+++ b/src/tools/mmaps_generator/MapBuilder.cpp
@@ -876,19 +876,8 @@ namespace MMAP
return static_cast<uint32>(m_mapid) != mapID;
if (m_skipContinents)
- switch (mapID)
- {
- case 0:
- case 1:
- case 530:
- case 571:
- case 870:
- case 1116:
- case 1220:
- return true;
- default:
- break;
- }
+ if (isContinentMap(mapID))
+ return true;
if (m_skipJunkMaps)
switch (mapID)
@@ -1054,6 +1043,26 @@ namespace MMAP
}
}
+ bool MapBuilder::isContinentMap(uint32 mapID)
+ {
+ switch (mapID)
+ {
+ case 0:
+ case 1:
+ case 530:
+ case 571:
+ case 870:
+ case 1116:
+ case 1220:
+ case 1642:
+ case 1643:
+ case 2222:
+ return true;
+ default:
+ return false;
+ }
+ }
+
/**************************************************************************/
bool MapBuilder::shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY)
{
diff --git a/src/tools/mmaps_generator/MapBuilder.h b/src/tools/mmaps_generator/MapBuilder.h
index 8181f4e9b55..8942ad68d11 100644
--- a/src/tools/mmaps_generator/MapBuilder.h
+++ b/src/tools/mmaps_generator/MapBuilder.h
@@ -145,6 +145,7 @@ namespace MMAP
bool shouldSkipMap(uint32 mapID);
bool isTransportMap(uint32 mapID);
+ bool isContinentMap(uint32 mapID);
bool shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY);
rcConfig GetMapSpecificConfig(uint32 mapID, float bmin[3], float bmax[3], const TileConfig &tileConfig);