Core/Movement: ported some undermap fixups from a TC pull request

This commit is contained in:
Ovahlord
2019-02-23 22:37:17 +01:00
parent 326f604c74
commit b0c37b25cc
6 changed files with 11 additions and 16 deletions

View File

@@ -2454,11 +2454,7 @@ float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float
float mapHeight = VMAP_INVALID_HEIGHT_VALUE;
uint32 terrainMapId = PhasingHandler::GetTerrainMapId(phaseShift, this, x, y);
if (GridMap* gmap = m_parentTerrainMap->GetGrid(terrainMapId, x, y))
{
float gridHeight = gmap->getHeight(x, y);
if (G3D::fuzzyGe(z, gridHeight - GROUND_HEIGHT_TOLERANCE))
mapHeight = gridHeight;
}
float mapHeight = gmap->getHeight(x, y);
float vmapHeight = VMAP_INVALID_HEIGHT_VALUE;
if (checkVMap)
@@ -2480,11 +2476,11 @@ float Map::GetStaticHeight(PhaseShift const& phaseShift, float x, float y, float
// or if the distance of the vmap height is less the land height distance
if (vmapHeight > mapHeight || std::fabs(mapHeight - z) > std::fabs(vmapHeight - z))
return vmapHeight;
else
return mapHeight; // better use .map surface height
return mapHeight; // better use .map surface height
}
else
return vmapHeight; // we have only vmapHeight (if have)
return vmapHeight; // we have only vmapHeight (if have)
}
return mapHeight; // explicitly use map data

View File

@@ -82,7 +82,7 @@ bool ConfusedMovementGenerator<T>::DoUpdate(T* owner, uint32 diff)
_path->SetPathLengthLimit(30.0f);
bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
if (!result || (_path->GetPathType() & PATHFIND_NOPATH))
if (!result || (_path->GetPathType() & PATHFIND_NOPATH) || (_path->GetPathType() & PATHFIND_SHORTCUT))
{
_timer.Reset(100);
return true;

View File

@@ -128,7 +128,7 @@ void FleeingMovementGenerator<T>::SetTargetLocation(T* owner)
_path->SetPathLengthLimit(30.0f);
bool result = _path->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ());
if (!result || (_path->GetPathType() & PATHFIND_NOPATH))
if (!result || (_path->GetPathType() & PATHFIND_NOPATH) || (_path->GetPathType() & PATHFIND_SHORTCUT))
{
_timer.Reset(100);
return;

View File

@@ -102,7 +102,7 @@ void RandomMovementGenerator<Creature>::SetRandomLocation(Creature* owner)
_path->SetPathLengthLimit(30.0f);
bool result = _path->CalculatePath(position.GetPositionX(), position.GetPositionY(), position.GetPositionZ());
if (!result || (_path->GetPathType() & PATHFIND_NOPATH))
if (!result || (_path->GetPathType() & PATHFIND_NOPATH) || (_path->GetPathType() & PATHFIND_SHORTCUT))
{
_timer.Reset(100);
return;

View File

@@ -538,14 +538,14 @@ void PathGenerator::BuildPointPath(const float *startPoint, const float *endPoin
/// @todo check the exact cases
TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned\n", pointCount);
BuildShortcut();
_type = PATHFIND_NOPATH;
_type = PathType(_type | PATHFIND_NOPATH);
return;
}
else if (pointCount == _pointPathLimit)
{
TC_LOG_DEBUG("maps", "++ PathGenerator::BuildPointPath FAILED! path sized %d returned, lower than limit set to %d\n", pointCount, _pointPathLimit);
BuildShortcut();
_type = PATHFIND_SHORT;
_type = PathType(_type | PATHFIND_SHORT);
return;
}

View File

@@ -1379,9 +1379,8 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici
pos.m_positionX = m_preGeneratedPath->GetActualEndPosition().x;
pos.m_positionY = m_preGeneratedPath->GetActualEndPosition().y;
pos.m_positionZ = m_preGeneratedPath->GetActualEndPosition().z;
dest.Relocate(pos);
}
dest.Relocate(pos);
break;
}
default: