diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2020-01-09 19:38:45 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-09 19:38:45 +0100 |
| commit | 29bf280e3496cf13c24ccb20e37da29d3bfa74d9 (patch) | |
| tree | 06d03127439ac2f050aee937ef89f4d3944eb4c9 /src/server/game | |
| parent | 43b247e17e8f5df4eda74578499f5a9758c3852b (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
Diffstat (limited to 'src/server/game')
| -rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 11 | ||||
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 2 |
2 files changed, 4 insertions, 9 deletions
diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index 0bfdde918eb..3c61f531de0 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -245,19 +245,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 03ded265b6b..0be841208e6 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -5509,7 +5509,7 @@ SpellCastResult Spell::CheckCast(bool strict, uint32* param1 /*= nullptr*/, uint // 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 |
