Core/Objects: cache current liquid status of objects when updating position data and use it to replace unnecessary vmap lookups
Port From (https://github.com/TrinityCore/TrinityCore/commit/d18d2b84f2c3e6e1005316625da80c99dd414bcc)
This commit is contained in:
@@ -104,7 +104,6 @@ namespace Game.Entities
|
||||
|
||||
PlayerUnderwaterState m_MirrorTimerFlags;
|
||||
PlayerUnderwaterState m_MirrorTimerFlagsLast;
|
||||
bool m_isInWater;
|
||||
|
||||
//Stats
|
||||
uint m_baseSpellPower;
|
||||
|
||||
@@ -787,42 +787,42 @@ namespace Game.Entities
|
||||
SendPacket(raidInstanceMessage);
|
||||
}
|
||||
|
||||
public override void ProcessTerrainStatusUpdate(ZLiquidStatus status, Optional<LiquidData> liquidData)
|
||||
public override void ProcessTerrainStatusUpdate(ZLiquidStatus oldLiquidStatus, Optional<LiquidData> newLiquidData)
|
||||
{
|
||||
// process liquid auras using generic unit code
|
||||
base.ProcessTerrainStatusUpdate(status, liquidData);
|
||||
base.ProcessTerrainStatusUpdate(oldLiquidStatus, newLiquidData);
|
||||
|
||||
// player specific logic for mirror timers
|
||||
if (status != 0 && liquidData.HasValue)
|
||||
if (GetLiquidStatus() != 0 && newLiquidData.HasValue)
|
||||
{
|
||||
// Breath bar state (under water in any liquid type)
|
||||
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.AllLiquids))
|
||||
if (newLiquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.AllLiquids))
|
||||
{
|
||||
if (status.HasAnyFlag(ZLiquidStatus.UnderWater))
|
||||
if (GetLiquidStatus().HasAnyFlag(ZLiquidStatus.UnderWater))
|
||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InWater;
|
||||
else
|
||||
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InWater;
|
||||
}
|
||||
|
||||
// Fatigue bar state (if not on flight path or transport)
|
||||
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.DarkWater) && !IsInFlight() && !GetTransport())
|
||||
if (newLiquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.DarkWater) && !IsInFlight() && !GetTransport())
|
||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InDarkWater;
|
||||
else
|
||||
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InDarkWater;
|
||||
|
||||
// Lava state (any contact)
|
||||
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Magma))
|
||||
if (newLiquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Magma))
|
||||
{
|
||||
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
||||
if (GetLiquidStatus().HasAnyFlag(ZLiquidStatus.InContact))
|
||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InLava;
|
||||
else
|
||||
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InLava;
|
||||
}
|
||||
|
||||
// Slime state (any contact)
|
||||
if (liquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Slime))
|
||||
if (newLiquidData.Value.type_flags.HasAnyFlag(LiquidHeaderTypeFlags.Slime))
|
||||
{
|
||||
if (status.HasAnyFlag(ZLiquidStatus.InContact))
|
||||
if (GetLiquidStatus().HasAnyFlag(ZLiquidStatus.InContact))
|
||||
m_MirrorTimerFlags |= PlayerUnderwaterState.InSlime;
|
||||
else
|
||||
m_MirrorTimerFlags &= ~PlayerUnderwaterState.InSlime;
|
||||
|
||||
@@ -1914,30 +1914,6 @@ namespace Game.Entities
|
||||
return startLevel;
|
||||
}
|
||||
|
||||
public override bool IsUnderWater()
|
||||
{
|
||||
return IsInWater() &&
|
||||
GetPositionZ() < (GetMap().GetWaterLevel(GetPhaseShift(), GetPositionX(), GetPositionY()) - 2);
|
||||
}
|
||||
public override bool IsInWater()
|
||||
{
|
||||
return m_isInWater;
|
||||
}
|
||||
public override void SetInWater(bool inWater)
|
||||
{
|
||||
if (m_isInWater == inWater)
|
||||
return;
|
||||
|
||||
//define player in water by opcodes
|
||||
//move player's guid into HateOfflineList of those mobs
|
||||
//which can't swim and move guid back into ThreatList when
|
||||
//on surface.
|
||||
// @todo exist also swimming mobs, and function must be symmetric to enter/leave water
|
||||
m_isInWater = inWater;
|
||||
|
||||
// Call base
|
||||
base.SetInWater(inWater);
|
||||
}
|
||||
public void ValidateMovementInfo(MovementInfo mi)
|
||||
{
|
||||
var RemoveViolatingFlags = new Action<bool, MovementFlag>((check, maskToRemove) =>
|
||||
|
||||
Reference in New Issue
Block a user