Core/Maps: use m_parrentTerrainMap for GetWaterOrGroundLevel and added another difference fixup from 335 branch

This commit is contained in:
Ovahlord
2019-02-24 12:50:46 +01:00
parent 333df54ced
commit 65fd7ce282

View File

@@ -2432,7 +2432,7 @@ bool Map::HasGrid(uint32 mapId, int32 gx, int32 gy) const
float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y, float z, float* ground /*= nullptr*/, bool /*swim = false*/, float collisionHeight /*= DEFAULT_COLLISION_HEIGHT*/) const
{
if (const_cast<Map*>(this)->GetGrid(x, y))
if (m_parentTerrainMap->GetGrid(x, y))
{
// we need ground level (including grid height version) for proper return water level in point
float ground_z = GetHeight(phaseShift, x, y, z + collisionHeight, true, 50.0f);
@@ -2442,7 +2442,15 @@ float Map::GetWaterOrGroundLevel(PhaseShift const& phaseShift, float x, float y,
LiquidData liquid_status;
ZLiquidStatus res = GetLiquidStatus(phaseShift, x, y, ground_z, MAP_ALL_LIQUIDS, &liquid_status, collisionHeight);
return res ? liquid_status.level : ground_z;
switch (res)
{
case LIQUID_MAP_ABOVE_WATER:
return std::max<float>(liquid_status.level, ground_z);
case LIQUID_MAP_NO_WATER:
return ground_z;
default:
return liquid_status.level;
}
}
return VMAP_INVALID_HEIGHT_VALUE;