diff options
| author | Shauren <shauren.trinity@gmail.com> | 2016-10-21 18:24:47 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2016-10-21 18:24:47 +0200 |
| commit | 537ff17ca07bcb4aafc5857e4232bdf2d50b7b67 (patch) | |
| tree | b5885432a3eac3363d440fa2d9af3a47a59d4de9 /src/server/game/Entities/Unit | |
| parent | a3b953952ae987b4fb8cc6d4b7a4395981e99bc2 (diff) | |
Core/PacketIO: Fixed unneccessary packet spam when units become visible for players
Before this change, one player starting to see any unit (CreateObject) would trigger sending root, feather fall, water walk, hover, can turn while falling and double jump status changes to ALL nearby players
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 138 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 12 |
2 files changed, 66 insertions, 84 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 750643ec126..ca44e62923d 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15372,25 +15372,22 @@ bool Unit::SetWalk(bool enable) return true; } -bool Unit::SetDisableGravity(bool disable, bool packetOnly /*= false*/) +bool Unit::SetDisableGravity(bool disable) { - if (!packetOnly) - { - if (disable == IsLevitating()) - return false; + if (disable == IsLevitating()) + return false; - if (disable) - { - AddUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); - RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_SPLINE_ELEVATION); - SetFall(false); - } - else - { - RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); - if (!HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)) - SetFall(true); - } + if (disable) + { + AddUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); + RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING | MOVEMENTFLAG_SPLINE_ELEVATION); + SetFall(false); + } + else + { + RemoveUnitMovementFlag(MOVEMENTFLAG_DISABLE_GRAVITY); + if (!HasUnitMovementFlag(MOVEMENTFLAG_CAN_FLY)) + SetFall(true); } static OpcodeServer const gravityOpcodeTable[2][2] = @@ -15503,18 +15500,15 @@ bool Unit::SetCanFly(bool enable) return true; } -bool Unit::SetWaterWalking(bool enable, bool packetOnly /*= false */) +bool Unit::SetWaterWalking(bool enable) { - if (!packetOnly) - { - if (enable == HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING)) - return false; + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_WATERWALKING)) + return false; - if (enable) - AddUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); - else - RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); - } + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_WATERWALKING); static OpcodeServer const waterWalkingOpcodeTable[2][2] = { @@ -15543,18 +15537,15 @@ bool Unit::SetWaterWalking(bool enable, bool packetOnly /*= false */) return true; } -bool Unit::SetFeatherFall(bool enable, bool packetOnly /*= false */) +bool Unit::SetFeatherFall(bool enable) { - if (!packetOnly) - { - if (enable == HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW)) - return false; + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW)) + return false; - if (enable) - AddUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); - else - RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); - } + if (enable) + AddUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); + else + RemoveUnitMovementFlag(MOVEMENTFLAG_FALLING_SLOW); static OpcodeServer const featherFallOpcodeTable[2][2] = { @@ -15583,31 +15574,28 @@ bool Unit::SetFeatherFall(bool enable, bool packetOnly /*= false */) return true; } -bool Unit::SetHover(bool enable, bool packetOnly /*= false*/) +bool Unit::SetHover(bool enable) { - if (!packetOnly) - { - if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) - return false; + if (enable == HasUnitMovementFlag(MOVEMENTFLAG_HOVER)) + return false; - float hoverHeight = GetFloatValue(UNIT_FIELD_HOVERHEIGHT); + float hoverHeight = GetFloatValue(UNIT_FIELD_HOVERHEIGHT); - if (enable) - { - //! No need to check height on ascent - AddUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (hoverHeight) - UpdateHeight(GetPositionZ() + hoverHeight); - } - else + if (enable) + { + //! No need to check height on ascent + AddUnitMovementFlag(MOVEMENTFLAG_HOVER); + if (hoverHeight) + UpdateHeight(GetPositionZ() + hoverHeight); + } + else + { + RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER); + if (hoverHeight) { - RemoveUnitMovementFlag(MOVEMENTFLAG_HOVER); - if (hoverHeight) - { - float newZ = GetPositionZ() - hoverHeight; - UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); - UpdateHeight(newZ); - } + float newZ = GetPositionZ() - hoverHeight; + UpdateAllowedPositionZ(GetPositionX(), GetPositionY(), newZ); + UpdateHeight(newZ); } } @@ -15709,18 +15697,15 @@ bool Unit::SetCanTransitionBetweenSwimAndFly(bool enable) return true; } -bool Unit::SetCanTurnWhileFalling(bool enable, bool packetOnly /*= false*/) +bool Unit::SetCanTurnWhileFalling(bool enable) { - if (!packetOnly) - { - if (enable == HasExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING)) - return false; + if (enable == HasExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING)) + return false; - if (enable) - AddExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING); - else - RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING); - } + if (enable) + AddExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING); + else + RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_CAN_TURN_WHILE_FALLING); static OpcodeServer const canTurnWhileFallingOpcodeTable[2] = { @@ -15743,18 +15728,15 @@ bool Unit::SetCanTurnWhileFalling(bool enable, bool packetOnly /*= false*/) return true; } -bool Unit::SetDoubleJump(bool enable, bool packetOnly /*= false*/) +bool Unit::SetDoubleJump(bool enable) { - if (!packetOnly) - { - if (enable == HasExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP)) - return false; + if (enable == HasExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP)) + return false; - if (enable) - AddExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP); - else - RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP); - } + if (enable) + AddExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP); + else + RemoveExtraUnitMovementFlag(MOVEMENTFLAG2_DOUBLE_JUMP); static OpcodeServer const doubleJumpOpcodeTable[2] = { diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 58cab981dfc..a521a782a0d 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1690,17 +1690,17 @@ class TC_GAME_API Unit : public WorldObject bool IsWalking() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_WALKING); } bool IsHovering() const { return m_movementInfo.HasMovementFlag(MOVEMENTFLAG_HOVER); } bool SetWalk(bool enable); - bool SetDisableGravity(bool disable, bool packetOnly = false); + bool SetDisableGravity(bool disable); bool SetFall(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); + bool SetWaterWalking(bool enable); + bool SetFeatherFall(bool enable); + bool SetHover(bool enable); bool SetCollision(bool disable); bool SetCanTransitionBetweenSwimAndFly(bool enable); - bool SetCanTurnWhileFalling(bool enable, bool packetOnly = false); - bool SetDoubleJump(bool enable, bool packetOnly = false); + bool SetCanTurnWhileFalling(bool enable); + bool SetDoubleJump(bool enable); void SendSetVehicleRecId(uint32 vehicleId); void SetInFront(WorldObject const* target); |
