diff options
author | Shauren <shauren.trinity@gmail.com> | 2013-06-18 16:47:12 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2013-06-18 16:47:12 +0200 |
commit | d9df460694fe878f57c3603cc7613903f7f8d194 (patch) | |
tree | bb1f3b0dfbf40eae4b9b589253d2e926646f1b52 /src | |
parent | 779f3c2f08a2bb46a86659ead6502672590386ed (diff) |
Core/Movement
* Added wrapper methods for setting various movement flags and sending correct movement opcodes
* Made flying and falling spline flags exclusive with each other
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Creature/Creature.cpp | 65 | ||||
-rw-r--r-- | src/server/game/Entities/Creature/Creature.h | 6 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 70 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 13 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 122 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 22 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSpline.cpp | 17 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSpline.h | 19 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSplineFlag.h | 4 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInit.h | 2 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MoveSplineInitArgs.h | 9 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MovementTypedefs.h | 4 | ||||
-rw-r--r-- | src/server/game/Movement/Spline/MovementUtil.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 49 |
15 files changed, 225 insertions, 199 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp index f893eecd9d2..33f29820b12 100644 --- a/src/server/game/Entities/Creature/Creature.cpp +++ b/src/server/game/Entities/Creature/Creature.cpp @@ -2441,9 +2441,65 @@ bool Creature::SetDisableGravity(bool disable, bool packetOnly/*=false*/) return true; } -bool Creature::SetHover(bool enable) +bool Creature::SetSwim(bool enable) { - if (!Unit::SetHover(enable)) + if (!Unit::SetSwim(enable)) + return false; + + if (!movespline->Initialized()) + return true; + + WorldPacket data(enable ? SMSG_SPLINE_MOVE_START_SWIM : SMSG_SPLINE_MOVE_STOP_SWIM); + data.append(GetPackGUID()); + SendMessageToSet(&data, true); + return true; +} + +bool Creature::SetCanFly(bool enable) +{ + if (!Unit::SetCanFly(enable)) + return false; + + if (!movespline->Initialized()) + return true; + + WorldPacket data(enable ? SMSG_SPLINE_MOVE_SET_FLYING : SMSG_SPLINE_MOVE_UNSET_FLYING, 9); + data.append(GetPackGUID()); + SendMessageToSet(&data, false); + return true; +} + +bool Creature::SetWaterWalking(bool enable, bool packetOnly /* = false */) +{ + if (!packetOnly && !Unit::SetWaterWalking(enable)) + return false; + + if (!movespline->Initialized()) + return true; + + WorldPacket data(enable ? SMSG_SPLINE_MOVE_WATER_WALK : SMSG_SPLINE_MOVE_LAND_WALK); + data.append(GetPackGUID()); + SendMessageToSet(&data, true); + return true; +} + +bool Creature::SetFeatherFall(bool enable, bool packetOnly /* = false */) +{ + if (!packetOnly && !Unit::SetFeatherFall(enable)) + return false; + + if (!movespline->Initialized()) + return true; + + WorldPacket data(enable ? SMSG_SPLINE_MOVE_FEATHER_FALL : SMSG_SPLINE_MOVE_NORMAL_FALL); + data.append(GetPackGUID()); + SendMessageToSet(&data, true); + return true; +} + +bool Creature::SetHover(bool enable, bool packetOnly /*= false*/) +{ + if (!packetOnly && !Unit::SetHover(enable)) return false; //! Unconfirmed for players: @@ -2548,10 +2604,7 @@ void Creature::UpdateMovementFlags() SetDisableGravity(false); } - if (GetCreatureTemplate()->InhabitType & INHABIT_WATER && IsInWater()) - AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); - else - RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); + SetSwim(GetCreatureTemplate()->InhabitType & INHABIT_WATER && IsInWater()); } void Creature::SetObjectScale(float scale) diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h index 056b8c26713..216e9246c0f 100644 --- a/src/server/game/Entities/Creature/Creature.h +++ b/src/server/game/Entities/Creature/Creature.h @@ -506,7 +506,11 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature bool SetWalk(bool enable); bool SetDisableGravity(bool disable, bool packetOnly = false); - bool SetHover(bool enable); + bool SetSwim(bool enable); + bool SetCanFly(bool enable); + bool SetWaterWalking(bool enable, bool packetOnly = false); + bool SetFeatherFall(bool enable, bool packetOnly = false); + bool SetHover(bool enable, bool packetOnly = false); uint32 GetShieldBlockValue() const; diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 04f246d716d..c1fad6c175f 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -22890,13 +22890,13 @@ void Player::SendAurasForTarget(Unit* target) These movement packets are usually found in SMSG_COMPRESSED_MOVES */ if (target->HasAuraType(SPELL_AURA_FEATHER_FALL)) - target->SendMovementFeatherFall(); + target->SetFeatherFall(true, true); if (target->HasAuraType(SPELL_AURA_WATER_WALK)) - target->SendMovementWaterWalking(); + target->SetWaterWalking(true, true); if (target->HasAuraType(SPELL_AURA_HOVER)) - target->SendMovementHover(); + target->SetHover(true, true); WorldPacket data(SMSG_AURA_UPDATE_ALL); data.append(target->GetPackGUID()); @@ -26138,53 +26138,95 @@ void Player::_SaveInstanceTimeRestrictions(SQLTransaction& trans) bool Player::IsInWhisperWhiteList(uint64 guid) { for (WhisperListContainer::const_iterator itr = WhisperList.begin(); itr != WhisperList.end(); ++itr) - { if (*itr == guid) return true; - } + return false; } -void Player::SendMovementSetCanFly(bool apply) +bool Player::SetDisableGravity(bool disable, bool packetOnly /*= false*/) { - WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12); + if (!packetOnly && !Unit::SetDisableGravity(disable)) + return false; + + WorldPacket data(disable ? SMSG_MOVE_GRAVITY_DISABLE : SMSG_MOVE_GRAVITY_ENABLE, 12); data.append(GetPackGUID()); data << uint32(0); //! movement counter SendDirectMessage(&data); + + data.Initialize(MSG_MOVE_GRAVITY_CHNG, 64); + data.append(GetPackGUID()); + BuildMovementPacket(&data); + SendMessageToSet(&data, false); + return true; } -void Player::SendMovementSetCanTransitionBetweenSwimAndFly(bool apply) +bool Player::SetCanFly(bool apply) { - WorldPacket data(apply ? - SMSG_MOVE_SET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY : - SMSG_MOVE_UNSET_CAN_TRANSITION_BETWEEN_SWIM_AND_FLY, 12); + if (!Unit::SetCanFly(apply)) + return false; + + WorldPacket data(apply ? SMSG_MOVE_SET_CAN_FLY : SMSG_MOVE_UNSET_CAN_FLY, 12); data.append(GetPackGUID()); data << uint32(0); //! movement counter SendDirectMessage(&data); + + data.Initialize(MSG_MOVE_UPDATE_CAN_FLY, 64); + data.append(GetPackGUID()); + BuildMovementPacket(&data); + SendMessageToSet(&data, false); + return true; } -void Player::SendMovementSetHover(bool apply) +bool Player::SetHover(bool apply, bool packetOnly /*= false*/) { + if (!packetOnly && !Unit::SetHover(apply)) + return false; + WorldPacket data(apply ? SMSG_MOVE_SET_HOVER : SMSG_MOVE_UNSET_HOVER, 12); data.append(GetPackGUID()); data << uint32(0); //! movement counter SendDirectMessage(&data); + + data.Initialize(MSG_MOVE_HOVER, 64); + data.append(GetPackGUID()); + BuildMovementPacket(&data); + SendMessageToSet(&data, false); + return true; } -void Player::SendMovementSetWaterWalking(bool apply) +bool Player::SetWaterWalking(bool apply, bool packetOnly /*= false*/) { + if (!packetOnly && !Unit::SetWaterWalking(apply)) + return false; + WorldPacket data(apply ? SMSG_MOVE_WATER_WALK : SMSG_MOVE_LAND_WALK, 12); data.append(GetPackGUID()); data << uint32(0); //! movement counter SendDirectMessage(&data); + + data.Initialize(MSG_MOVE_WATER_WALK, 64); + data.append(GetPackGUID()); + BuildMovementPacket(&data); + SendMessageToSet(&data, false); + return true; } -void Player::SendMovementSetFeatherFall(bool apply) +bool Player::SetFeatherFall(bool apply, bool packetOnly /*= false*/) { + if (!packetOnly && !Unit::SetFeatherFall(apply)) + return false; + WorldPacket data(apply ? SMSG_MOVE_FEATHER_FALL : SMSG_MOVE_NORMAL_FALL, 12); data.append(GetPackGUID()); data << uint32(0); //! movement counter SendDirectMessage(&data); + + data.Initialize(MSG_MOVE_FEATHER_FALL, 64); + data.append(GetPackGUID()); + BuildMovementPacket(&data); + SendMessageToSet(&data, false); + return true; } float Player::GetCollisionHeight(bool mounted) const diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 9e5347dee03..2058f521f7c 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -2280,14 +2280,11 @@ class Player : public Unit, public GridObject<Player> bool IsInWhisperWhiteList(uint64 guid); void RemoveFromWhisperWhiteList(uint64 guid) { WhisperList.remove(guid); } - /*! These methods send different packets to the client in apply and unapply case. - These methods are only sent to the current unit. - */ - void SendMovementSetCanFly(bool apply); - void SendMovementSetCanTransitionBetweenSwimAndFly(bool apply); - void SendMovementSetHover(bool apply); - void SendMovementSetWaterWalking(bool apply); - void SendMovementSetFeatherFall(bool apply); + bool SetDisableGravity(bool disable, bool packetOnly /* = false */); + bool SetCanFly(bool apply); + bool SetWaterWalking(bool apply, bool packetOnly = false); + bool SetFeatherFall(bool apply, bool packetOnly = false); + bool SetHover(bool enable, bool packetOnly = false); bool CanFly() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_CAN_FLY); } diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index e274c40e336..18b4790f13a 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -17014,14 +17014,6 @@ bool Unit::IsFalling() const return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FALLING | MOVEMENTFLAG_FALLING_FAR) || movespline->isFalling(); } -void Unit::SetCanFly(bool apply) -{ - if (apply) - AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); - else - RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); -} - void Unit::NearTeleportTo(float x, float y, float z, float orientation, bool casting /*= false*/) { DisableSpline(); @@ -17421,96 +17413,82 @@ bool Unit::SetDisableGravity(bool disable, bool /*packetOnly = false*/) return true; } -bool Unit::SetHover(bool enable) +bool Unit::SetSwim(bool enable) { - if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_SWIMMING)) return false; if (enable) - { - //! No need to check height on ascent - AddUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (float hh = GetFloatValue(UNIT_FIELD_HOVERHEIGHT)) - UpdateHeight(GetPositionZ() + hh); - } + AddUnitMovementFlag(MOVEMENTFLAG_SWIMMING); else - { - RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (float hh = GetFloatValue(UNIT_FIELD_HOVERHEIGHT)) - { - float newZ = GetPositionZ() - hh; - UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); - UpdateHeight(newZ); - } - } + RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING); return true; } -void Unit::SendMovementHover() +bool Unit::SetCanFly(bool enable) { - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SendMovementSetHover(HasUnitMovementFlag(MOVEMENTFLAG_HOVER)); + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)) + return false; - WorldPacket data(MSG_MOVE_HOVER, 64); - data.append(GetPackGUID()); - BuildMovementPacket(&data); - SendMessageToSet(&data, false); + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_CAN_FLY); + + return true; } -void Unit::SendMovementWaterWalking() +bool Unit::SetWaterWalking(bool enable, bool packetOnly /* = false */) { - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SendMovementSetWaterWalking(HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING)); + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING)) + return false; - WorldPacket data(MSG_MOVE_WATER_WALK, 64); - data.append(GetPackGUID()); - BuildMovementPacket(&data); - SendMessageToSet(&data, false); + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); + + return true; } -void Unit::SendMovementFeatherFall() +bool Unit::SetFeatherFall(bool enable, bool packetOnly /* = false */) { - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SendMovementSetFeatherFall(HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW)); + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW)) + return false; - WorldPacket data(MSG_MOVE_FEATHER_FALL, 64); - data.append(GetPackGUID()); - BuildMovementPacket(&data); - SendMessageToSet(&data, false); -} + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); -void Unit::SendMovementGravityChange() -{ - WorldPacket data(MSG_MOVE_GRAVITY_CHNG, 64); - data.append(GetPackGUID()); - BuildMovementPacket(&data); - SendMessageToSet(&data, false); + return true; } -void Unit::SendMovementCanFlyChange() +bool Unit::SetHover(bool enable, bool /*packetOnly = false*/) { - /*! - if ( a3->MoveFlags & MOVEMENTFLAG_CAN_FLY ) - { - v4->MoveFlags |= 0x1000000u; - result = 1; - } - else + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) + return false; + + if (enable) + { + //! No need to check height on ascent + AddUnitMovementFlag(MOVEMENTFLAG_HOVER); + if (float hh = GetFloatValue(UNIT_FIELD_HOVERHEIGHT)) + UpdateHeight(GetPositionZ() + hh); + } + else + { + RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER); + if (float hh = GetFloatValue(UNIT_FIELD_HOVERHEIGHT)) { - if ( v4->MoveFlags & MOVEMENTFLAG_FLYING ) - CMovement::DisableFlying(v4); - v4->MoveFlags &= 0xFEFFFFFFu; - result = 1; + float newZ = GetPositionZ() - hh; + UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); + UpdateHeight(newZ); } - */ - if (GetTypeId() == TYPEID_PLAYER) - ToPlayer()->SendMovementSetCanFly(CanFly()); + } - WorldPacket data(MSG_MOVE_UPDATE_CAN_FLY, 64); - data.append(GetPackGUID()); - BuildMovementPacket(&data); - SendMessageToSet(&data, false); + return true; } void Unit::SetTarget(uint64 guid) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 04950cfdcbd..b2d96941edd 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1591,22 +1591,15 @@ class Unit : public WorldObject //void SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, uint8 type, uint32 MovementFlags, uint32 Time, Player* player = NULL); void SendMovementFlagUpdate(bool self = false); - /*! These methods send the same packet to the client in apply and unapply case. - The client-side interpretation of this packet depends on the presence of relevant movementflags - which are sent with movementinfo. Furthermore, these packets are broadcast to nearby players as well - as the current unit. - */ - void SendMovementHover(); - void SendMovementFeatherFall(); - void SendMovementWaterWalking(); - void SendMovementGravityChange(); - void SendMovementCanFlyChange(); - - bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY);} - bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING);} + bool IsLevitating() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); } + bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); } virtual bool SetWalk(bool enable); virtual bool SetDisableGravity(bool disable, bool packetOnly = false); - virtual bool SetHover(bool enable); + virtual bool SetSwim(bool enable); + virtual bool SetCanFly(bool enable); + virtual bool SetWaterWalking(bool enable, bool packetOnly = false); + virtual bool SetFeatherFall(bool enable, bool packetOnly = false); + virtual bool SetHover(bool enable, bool packetOnly = false); void SetInFront(WorldObject const* target); void SetFacingTo(float ori); @@ -2114,7 +2107,6 @@ class Unit : public WorldObject virtual bool CanFly() const = 0; bool IsFlying() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_FLYING | MOVEMENTFLAG_DISABLE_GRAVITY); } bool IsFalling() const; - void SetCanFly(bool apply); void RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker); diff --git a/src/server/game/Movement/Spline/MoveSpline.cpp b/src/server/game/Movement/Spline/MoveSpline.cpp index 748ae1221ce..e786b78143a 100644 --- a/src/server/game/Movement/Spline/MoveSpline.cpp +++ b/src/server/game/Movement/Spline/MoveSpline.cpp @@ -23,10 +23,6 @@ namespace Movement{ -extern float computeFallTime(float path_length, bool isSafeFall); -extern float computeFallElevation(float time_passed, bool isSafeFall, float start_velocity); -extern float computeFallElevation(float time_passed); - Location MoveSpline::ComputePosition() const { ASSERT(Initialized()); @@ -84,12 +80,9 @@ void MoveSpline::computeParabolicElevation(float& el) const void MoveSpline::computeFallElevation(float& el) const { - float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed)); + float z_now = spline.getPoint(spline.first()).z - Movement::computeFallElevation(MSToSec(time_passed), false); float final_z = FinalDestination().z; - if (z_now < final_z) - el = final_z; - else - el = z_now; + el = std::max(z_now, final_z); } inline uint32 computeDuration(float length, float velocity) @@ -160,7 +153,7 @@ void MoveSpline::init_spline(const MoveSplineInitArgs& args) point_Idx = spline.first(); } -void MoveSpline::Initialize(const MoveSplineInitArgs& args) +void MoveSpline::Initialize(MoveSplineInitArgs const& args) { splineflags = args.flags; facing = args.facing; @@ -168,7 +161,6 @@ void MoveSpline::Initialize(const MoveSplineInitArgs& args) point_Idx_offset = args.path_Idx_offset; initialOrientation = args.initialOrientation; - onTransport = false; time_passed = 0; vertical_acceleration = 0.f; effect_start_time = 0; @@ -189,7 +181,8 @@ void MoveSpline::Initialize(const MoveSplineInitArgs& args) } MoveSpline::MoveSpline() : m_Id(0), time_passed(0), - vertical_acceleration(0.f), initialOrientation(0.f), effect_start_time(0), point_Idx(0), point_Idx_offset(0) + vertical_acceleration(0.f), initialOrientation(0.f), effect_start_time(0), point_Idx(0), point_Idx_offset(0), + onTransport(false) { splineflags.done = true; } diff --git a/src/server/game/Movement/Spline/MoveSpline.h b/src/server/game/Movement/Spline/MoveSpline.h index a76c552079b..75ea89bee81 100644 --- a/src/server/game/Movement/Spline/MoveSpline.h +++ b/src/server/game/Movement/Spline/MoveSpline.h @@ -49,6 +49,7 @@ namespace Movement Result_NextSegment = 0x08 }; friend class PacketBuilder; + protected: MySpline spline; @@ -69,30 +70,30 @@ namespace Movement int32 point_Idx_offset; void init_spline(const MoveSplineInitArgs& args); - protected: - const MySpline::ControlArray& getPath() const { return spline.getPoints(); } + protected: + MySpline::ControlArray const& getPath() const { return spline.getPoints(); } void computeParabolicElevation(float& el) const; void computeFallElevation(float& el) const; UpdateResult _updateState(int32& ms_time_diff); - int32 next_timestamp() const { return spline.length(point_Idx+1); } - int32 segment_time_elapsed() const { return next_timestamp()-time_passed; } + int32 next_timestamp() const { return spline.length(point_Idx + 1); } + int32 segment_time_elapsed() const { return next_timestamp() - time_passed; } int32 timeElapsed() const { return Duration() - time_passed; } int32 timePassed() const { return time_passed; } public: int32 Duration() const { return spline.length(); } - const MySpline& _Spline() const { return spline; } + MySpline const& _Spline() const { return spline; } int32 _currentSplineIdx() const { return point_Idx; } void _Finalize(); - void _Interrupt() { splineflags.done = true;} + void _Interrupt() { splineflags.done = true; } public: void Initialize(const MoveSplineInitArgs&); bool Initialized() const { return !spline.empty(); } - explicit MoveSpline(); + MoveSpline(); template<class UpdateHandler> void updateState(int32 difftime, UpdateHandler& handler) @@ -116,8 +117,8 @@ namespace Movement bool Finalized() const { return splineflags.done; } bool isCyclic() const { return splineflags.cyclic; } bool isFalling() const { return splineflags.falling; } - const Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3(); } - const Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx+1) : Vector3(); } + Vector3 FinalDestination() const { return Initialized() ? spline.getPoint(spline.last()) : Vector3(); } + Vector3 CurrentDestination() const { return Initialized() ? spline.getPoint(point_Idx + 1) : Vector3(); } int32 currentPathIdx() const; bool onTransport; diff --git a/src/server/game/Movement/Spline/MoveSplineFlag.h b/src/server/game/Movement/Spline/MoveSplineFlag.h index ec7eaf7e763..2cac9034c84 100644 --- a/src/server/game/Movement/Spline/MoveSplineFlag.h +++ b/src/server/game/Movement/Spline/MoveSplineFlag.h @@ -101,8 +101,8 @@ namespace Movement void EnableAnimation(uint8 anim) { raw() = (raw() & ~(Mask_Animations | Falling | Parabolic)) | Animation | anim; } void EnableParabolic() { raw() = (raw() & ~(Mask_Animations | Falling | Animation)) | Parabolic; } - void EnableFalling() { raw() = (raw() & ~(Mask_Animations | Parabolic | Animation)) | Falling; } - void EnableFlying() { raw() = (raw() & ~Catmullrom) | Flying; } + void EnableFalling() { raw() = (raw() & ~(Mask_Animations | Parabolic | Flying | Animation)) | Falling; } + void EnableFlying() { raw() = (raw() & ~(Falling | Catmullrom)) | Flying; } void EnableCatmullRom() { raw() = (raw() & ~Flying) | Catmullrom; } void EnableFacingPoint() { raw() = (raw() & ~Mask_Final_Facing) | Final_Point; } void EnableFacingAngle() { raw() = (raw() & ~Mask_Final_Facing) | Final_Angle; } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.cpp b/src/server/game/Movement/Spline/MoveSplineInit.cpp index 2f4224c8b91..4209b9dd202 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.cpp +++ b/src/server/game/Movement/Spline/MoveSplineInit.cpp @@ -100,6 +100,8 @@ namespace Movement uint32 moveFlagsForSpeed = moveFlags; if (args.flags.walkmode) moveFlagsForSpeed |= MOVEMENTFLAG_WALKING; + else + moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING; args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed)); } diff --git a/src/server/game/Movement/Spline/MoveSplineInit.h b/src/server/game/Movement/Spline/MoveSplineInit.h index 441bad66142..7b0527bb3a0 100644 --- a/src/server/game/Movement/Spline/MoveSplineInit.h +++ b/src/server/game/Movement/Spline/MoveSplineInit.h @@ -145,7 +145,7 @@ namespace Movement inline void MoveSplineInit::SetWalk(bool enable) { args.flags.walkmode = enable; } inline void MoveSplineInit::SetSmooth() { args.flags.EnableCatmullRom(); } inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; } - inline void MoveSplineInit::SetFall() { args.flags.EnableFalling();} + inline void MoveSplineInit::SetFall() { args.flags.EnableFalling(); } inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; } inline void MoveSplineInit::SetOrientationInversed() { args.flags.orientationInversed = true;} inline void MoveSplineInit::SetTransportEnter() { args.flags.EnableTransportEnter(); } diff --git a/src/server/game/Movement/Spline/MoveSplineInitArgs.h b/src/server/game/Movement/Spline/MoveSplineInitArgs.h index 4a086094c3f..474541cbf15 100644 --- a/src/server/game/Movement/Spline/MoveSplineInitArgs.h +++ b/src/server/game/Movement/Spline/MoveSplineInitArgs.h @@ -30,9 +30,9 @@ namespace Movement union FacingInfo { - struct{ + struct { float x, y, z; - }f; + } f; uint64 target; float angle; @@ -43,8 +43,8 @@ namespace Movement struct MoveSplineInitArgs { - MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), - velocity(0.f), parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f), + MoveSplineInitArgs(size_t path_capacity = 16) : path_Idx_offset(0), velocity(0.f), + parabolic_amplitude(0.f), time_perc(0.f), splineId(0), initialOrientation(0.f), HasVelocity(false), TransformForTransport(true) { path.reserve(path_capacity); @@ -64,6 +64,7 @@ namespace Movement /** Returns true to show that the arguments were configured correctly and MoveSpline initialization will succeed. */ bool Validate(Unit* unit) const; + private: bool _checkPathBounds() const; }; diff --git a/src/server/game/Movement/Spline/MovementTypedefs.h b/src/server/game/Movement/Spline/MovementTypedefs.h index 51679260ebb..ffc19f10454 100644 --- a/src/server/game/Movement/Spline/MovementTypedefs.h +++ b/src/server/game/Movement/Spline/MovementTypedefs.h @@ -44,6 +44,9 @@ namespace Movement return ms / 1000.f; } + float computeFallTime(float path_length, bool isSafeFall); + float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity = 0.0f); + #ifndef static_assert #define CONCAT(x, y) CONCAT1 (x, y) #define CONCAT1(x, y) x##y @@ -75,7 +78,6 @@ namespace Movement typedef counter<uint32, 0xFFFFFFFF> UInt32Counter; extern double gravity; - extern float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity); extern UInt32Counter splineIdGen; } diff --git a/src/server/game/Movement/Spline/MovementUtil.cpp b/src/server/game/Movement/Spline/MovementUtil.cpp index ae85b63e113..f68a776d485 100644 --- a/src/server/game/Movement/Spline/MovementUtil.cpp +++ b/src/server/game/Movement/Spline/MovementUtil.cpp @@ -43,7 +43,7 @@ namespace Movement if (isSafeFall) { if (path_length >= terminal_safeFall_length) - time = (path_length - terminal_safeFall_length) / terminalSafefallVelocity + terminalSafefallVelocity / gravity; + time = (path_length - terminal_safeFall_length) / terminalSafefallVelocity + terminal_safeFall_fallTime; else time = sqrtf(2.0f * path_length / gravity); } @@ -58,7 +58,7 @@ namespace Movement return time; } - float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity) + float computeFallElevation(float t_passed, bool isSafeFall, float start_velocity /*= 0.0f*/) { float termVel; float result; @@ -85,22 +85,6 @@ namespace Movement return result; } - float computeFallElevation(float t_passed) - { - float result; - - if (t_passed > terminal_fallTime) - { - //result = terminalVelocity * (t_passed - terminal_time) + gravity*terminal_time*terminal_time*0.5f; - // simplified view: - result = terminalVelocity * (t_passed - terminal_fallTime) + terminal_length; - } - else - result = t_passed * t_passed * gravity * 0.5f; - - return result; - } - #define STR(x) #x char const* g_MovementFlag_names[] = diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 39b7fbe4ea4..f8bc67c7aac 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -2559,23 +2559,17 @@ void AuraEffect::HandleAuraAllowFlight(AuraApplication const* aurApp, uint8 mode } //! Not entirely sure if this should be sent for creatures as well, but I don't think so. - target->SetCanFly(apply); if (!apply) { - target->RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING_FLY); - target->GetMotionMaster()->MoveFall(); target->m_movementInfo.SetFallTime(0); + target->RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING_FLY); + target->AddUnitMovementFlag(MOVEMENTFLAG_FALLING); } - Player* player = target->ToPlayer(); - if (!player) - player = target->m_movedPlayer; - - if (player) - player->SendMovementCanFlyChange(); + target->SetCanFly(apply); - //! We still need to initiate a server-side MoveFall here, - //! which requires MSG_MOVE_FALL_LAND on landing. + if (target->GetTypeId() == TYPEID_UNIT) + target->GetMotionMaster()->MoveFall(); } void AuraEffect::HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -2592,12 +2586,7 @@ void AuraEffect::HandleAuraWaterWalk(AuraApplication const* aurApp, uint8 mode, return; } - if (apply) - target->AddUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); - else - target->RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); - - target->SendMovementWaterWalking(); + target->SetWaterWalking(apply); } void AuraEffect::HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode, bool apply) const @@ -2614,12 +2603,7 @@ void AuraEffect::HandleAuraFeatherFall(AuraApplication const* aurApp, uint8 mode return; } - if (apply) - target->AddUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); - else - target->RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); - - target->SendMovementFeatherFall(); + target->SetFeatherFall(apply); // start fall from current height if (!apply && target->GetTypeId() == TYPEID_PLAYER) @@ -2641,7 +2625,6 @@ void AuraEffect::HandleAuraHover(AuraApplication const* aurApp, uint8 mode, bool } target->SetHover(apply); //! Sets movementflags - target->SendMovementHover(); } void AuraEffect::HandleWaterBreathing(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const @@ -2963,6 +2946,8 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, return; Unit* target = aurApp->GetTarget(); + if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) + target->UpdateSpeed(MOVE_FLIGHT, true); //! Update ability to fly if (GetAuraType() == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) @@ -2970,22 +2955,17 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, // do not remove unit flag if there are more than this auraEffect of that kind on unit on unit if (mode & AURA_EFFECT_HANDLE_SEND_FOR_CLIENT_MASK && (apply || (!target->HasAuraType(SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED) && !target->HasAuraType(SPELL_AURA_FLY)))) { - target->SetCanFly(apply); if (!apply) { target->m_movementInfo.SetFallTime(0); target->RemoveUnitMovementFlag(MOVEMENTFLAG_MASK_MOVING_FLY); + target->AddUnitMovementFlag(MOVEMENTFLAG_FALLING); } - Player* player = target->ToPlayer(); - if (!player) - player = target->m_movedPlayer; - - if (player) - player->SendMovementCanFlyChange(); + target->SetCanFly(apply); - //! We still need to initiate a server-side MoveFall here, - //! which requires MSG_MOVE_FALL_LAND on landing. + if (target->GetTypeId() == TYPEID_UNIT) + target->GetMotionMaster()->MoveFall(); } //! Someone should clean up these hacks and remove it from this function. It doesn't even belong here. @@ -3000,9 +2980,6 @@ void AuraEffect::HandleAuraModIncreaseFlightSpeed(AuraApplication const* aurApp, target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, 16314); } } - - if (mode & AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK) - target->UpdateSpeed(MOVE_FLIGHT, true); } void AuraEffect::HandleAuraModIncreaseSwimSpeed(AuraApplication const* aurApp, uint8 mode, bool /*apply*/) const |