aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/server/game/Entities/Player/Player.cpp5
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.cpp45
-rwxr-xr-xsrc/server/game/Entities/Unit/Unit.h2
-rwxr-xr-xsrc/server/game/Movement/MotionMaster.cpp3
4 files changed, 50 insertions, 5 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 53bafbd4521..31bd17ffc8f 100755
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -6830,11 +6830,6 @@ bool Player::UpdatePosition(float x, float y, float z, float orientation, bool t
if (GetGroup())
SetGroupUpdateFlag(GROUP_UPDATE_FLAG_POSITION);
- // code block for underwater state update
- // Unit::UpdatePosition() checks for validity and updates our coordinates
- // so we re-fetch them instead of using "raw" coordinates from function params
- UpdateUnderwaterState(GetMap(), GetPositionX(), GetPositionY(), GetPositionZ());
-
if (GetTrader() && !IsWithinDistInMap(GetTrader(), INTERACTION_DISTANCE))
GetSession()->SendCancelTrade();
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 4da56b72017..259f428dfb4 100755
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -3089,6 +3089,48 @@ bool Unit::IsUnderWater() const
return GetBaseMap()->IsUnderWater(GetPositionX(), GetPositionY(), GetPositionZ());
}
+void Unit::UpdateUnderwaterState(Map* m, float x, float y, float z)
+{
+ if (!isPet() && !IsVehicle())
+ return;
+
+ LiquidData liquid_status;
+ ZLiquidStatus res = m->getLiquidStatus(x, y, z, MAP_ALL_LIQUIDS, &liquid_status);
+ if (!res)
+ {
+ if (_lastLiquid && _lastLiquid->SpellId)
+ RemoveAurasDueToSpell(_lastLiquid->SpellId);
+
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_UNDERWATER);
+ _lastLiquid = NULL;
+ return;
+ }
+
+ if (uint32 liqEntry = liquid_status.entry)
+ {
+ LiquidTypeEntry const* liquid = sLiquidTypeStore.LookupEntry(liqEntry);
+ if (_lastLiquid && _lastLiquid->SpellId && _lastLiquid->Id != liqEntry)
+ RemoveAurasDueToSpell(_lastLiquid->SpellId);
+
+ if (liquid && liquid->SpellId)
+ {
+ if (res & (LIQUID_MAP_UNDER_WATER | LIQUID_MAP_IN_WATER))
+ CastSpell(this, liquid->SpellId, true);
+ else
+ RemoveAurasDueToSpell(liquid->SpellId);
+ }
+
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_ABOVEWATER);
+ _lastLiquid = liquid;
+ }
+ else if (_lastLiquid && _lastLiquid->SpellId)
+ {
+ RemoveAurasDueToSpell(_lastLiquid->SpellId);
+ RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_NOT_UNDERWATER);
+ _lastLiquid = NULL;
+ }
+}
+
void Unit::DeMorph()
{
SetDisplayId(GetNativeDisplayId());
@@ -17255,6 +17297,9 @@ bool Unit::UpdatePosition(float x, float y, float z, float orientation, bool tel
else if (turn)
UpdateOrientation(orientation);
+ // code block for underwater state update
+ UpdateUnderwaterState(GetMap(), x, y, z);
+
return (relocated || turn);
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 00d66518d3f..828d87216df 100755
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1580,6 +1580,7 @@ class Unit : public WorldObject
virtual bool IsInWater() const;
virtual bool IsUnderWater() const;
+ virtual void UpdateUnderwaterState(Map* m, float x, float y, float z);
bool isInAccessiblePlaceFor(Creature const* c) const;
void SendHealSpellLog(Unit* victim, uint32 SpellID, uint32 Damage, uint32 OverHeal, uint32 Absorb, bool critical = false);
@@ -2353,6 +2354,7 @@ class Unit : public WorldObject
uint32 m_state; // Even derived shouldn't modify
uint32 m_CombatTimer;
uint32 m_lastManaUse; // msecs
+ LiquidTypeEntry const* _lastLiquid;
TimeTrackerSmall m_movesplineTimer;
Diminishing m_Diminishing;
diff --git a/src/server/game/Movement/MotionMaster.cpp b/src/server/game/Movement/MotionMaster.cpp
index b0ac0b710c1..c0e1eb842ae 100755
--- a/src/server/game/Movement/MotionMaster.cpp
+++ b/src/server/game/Movement/MotionMaster.cpp
@@ -114,6 +114,9 @@ void MotionMaster::UpdateMotion(uint32 diff)
_cleanFlag &= ~MMCF_RESET;
}
+
+ // probably not the best place to pu this but im not really sure where else to put it.
+ _owner->UpdateUnderwaterState(_owner->GetMap(), _owner->GetPositionX(), _owner->GetPositionY(), _owner->GetPositionZ());
}
void MotionMaster::DirectClean(bool reset)