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
2020-01-09 19:38:45 +01:00
committed by GitHub
parent 43b247e17e
commit 29bf280e34
4 changed files with 21 additions and 19 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -877,16 +877,8 @@ namespace MMAP
return static_cast<uint32>(m_mapid) != mapID;
if (m_skipContinents)
switch (mapID)
{
case 0:
case 1:
case 530:
case 571:
return true;
default:
break;
}
if (isContinentMap(mapID))
return true;
if (m_skipJunkMaps)
switch (mapID)
@@ -966,6 +958,20 @@ namespace MMAP
}
}
bool MapBuilder::isContinentMap(uint32 mapID)
{
switch (mapID)
{
case 0:
case 1:
case 530:
case 571:
return true;
default:
return false;
}
}
/**************************************************************************/
bool MapBuilder::shouldSkipTile(uint32 mapID, uint32 tileX, uint32 tileY)
{

View File

@@ -143,6 +143,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);