aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-11-10 18:35:45 +0100
committerShauren <shauren.trinity@gmail.com>2024-11-10 18:35:45 +0100
commitd6ae7030dac388bbdf79954bd235c98209b53630 (patch)
tree998dd6f26431f3377c04ad4f848d2b521d64e58d /src/server/game/Entities/Object
parentb98d83ca5341c48bf3f4dcc3327165d0b5bc07a0 (diff)
Core/Position: Position constructor improvements
* Prevent constructing with only X coord * Remove unneccessary NormalizeOrientation calls when constructed with default orientation (0)
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/MovementInfo.h35
-rw-r--r--src/server/game/Entities/Object/Position.h28
2 files changed, 36 insertions, 27 deletions
diff --git a/src/server/game/Entities/Object/MovementInfo.h b/src/server/game/Entities/Object/MovementInfo.h
index 2f753ee5257..65a044ecbe4 100644
--- a/src/server/game/Entities/Object/MovementInfo.h
+++ b/src/server/game/Entities/Object/MovementInfo.h
@@ -28,11 +28,11 @@ struct MovementInfo
{
// common
ObjectGuid guid;
- uint32 flags;
- uint32 flags2;
- uint32 flags3;
+ uint32 flags = 0;
+ uint32 flags2 = 0;
+ uint32 flags3 = 0;
Position pos;
- uint32 time;
+ uint32 time = 0;
// transport
struct TransportInfo
@@ -49,14 +49,14 @@ struct MovementInfo
ObjectGuid guid;
Position pos;
- int8 seat;
- uint32 time;
- uint32 prevTime;
- uint32 vehicleId;
+ int8 seat = -1;
+ uint32 time = 0;
+ uint32 prevTime = 0;
+ uint32 vehicleId = 0;
} transport;
// swimming/flying
- float pitch;
+ float pitch = 0.0f;
struct Inertia
{
@@ -78,13 +78,16 @@ struct MovementInfo
zspeed = sinAngle = cosAngle = xyspeed = 0.0f;
}
- uint32 fallTime;
+ uint32 fallTime = 0;
- float zspeed, sinAngle, cosAngle, xyspeed;
+ float zspeed = 0.0f;
+ float sinAngle = 0.0f;
+ float cosAngle = 0.0f;
+ float xyspeed = 0.0f;
} jump;
- float stepUpStartElevation;
+ float stepUpStartElevation = 0.0f;
// advflying
struct AdvFlying
@@ -97,14 +100,6 @@ struct MovementInfo
Optional<ObjectGuid> standingOnGameObjectGUID;
- MovementInfo() :
- flags(0), flags2(0), flags3(0), time(0), pitch(0.0f), stepUpStartElevation(0.0f)
- {
- pos.Relocate(0.0f, 0.0f, 0.0f, 0.0f);
- transport.Reset();
- jump.Reset();
- }
-
uint32 GetMovementFlags() const { return flags; }
void SetMovementFlags(uint32 flag) { flags = flag; }
void AddMovementFlag(uint32 flag) { flags |= flag; }
diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h
index ed4709dadf3..f2f1ddcde43 100644
--- a/src/server/game/Entities/Object/Position.h
+++ b/src/server/game/Entities/Object/Position.h
@@ -27,7 +27,16 @@ class ByteBuffer;
struct TC_GAME_API Position
{
- constexpr Position(float x = 0, float y = 0, float z = 0, float o = 0)
+ constexpr Position()
+ : m_positionX(0.0f), m_positionY(0.0f), m_positionZ(0.0f), m_orientation(0.0f) { }
+
+ constexpr Position(float x, float y)
+ : m_positionX(x), m_positionY(y), m_positionZ(0.0f), m_orientation(0.0f) { }
+
+ constexpr Position(float x, float y, float z)
+ : m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(0.0f) { }
+
+ constexpr Position(float x, float y, float z, float o)
: m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientationConstexprWrapper(o)) { }
// streamer tags
@@ -181,16 +190,18 @@ private:
class TC_GAME_API WorldLocation : public Position
{
public:
- constexpr explicit WorldLocation(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f)
- : Position(x, y, z, o), m_mapId(mapId) { }
+ constexpr WorldLocation() : m_mapId(MAPID_INVALID) { }
+
+ constexpr WorldLocation(uint32 mapId, float x, float y) : Position(x, y), m_mapId(mapId) { }
+ constexpr WorldLocation(uint32 mapId, float x, float y, float z) : Position(x, y, z), m_mapId(mapId) { }
+ constexpr WorldLocation(uint32 mapId, float x, float y, float z, float o) : Position(x, y, z, o), m_mapId(mapId) { }
- constexpr WorldLocation(uint32 mapId, Position const& position)
- : Position(position), m_mapId(mapId) { }
+ constexpr WorldLocation(uint32 mapId, Position const& position) : Position(position), m_mapId(mapId) { }
constexpr void WorldRelocate(WorldLocation const& loc) { m_mapId = loc.GetMapId(); Relocate(loc); }
constexpr void WorldRelocate(WorldLocation const* loc) { m_mapId = loc->GetMapId(); Relocate(loc); }
constexpr void WorldRelocate(uint32 mapId, Position const& pos) { m_mapId = mapId; Relocate(pos); }
- constexpr void WorldRelocate(uint32 mapId = MAPID_INVALID, float x = 0.f, float y = 0.f, float z = 0.f, float o = 0.f)
+ constexpr void WorldRelocate(uint32 mapId, float x, float y, float z, float o)
{
m_mapId = mapId;
Relocate(x, y, z, o);
@@ -219,7 +230,10 @@ TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Posi
template<class Tag>
struct TaggedPosition
{
- constexpr TaggedPosition(float x = 0.0f, float y = 0.0f, float z = 0.0f, float o = 0.0f) : Pos(x, y, z, o) { }
+ constexpr TaggedPosition() { }
+ constexpr TaggedPosition(float x, float y) : Pos(x, y) { }
+ constexpr TaggedPosition(float x, float y, float z) : Pos(x, y, z) { }
+ constexpr TaggedPosition(float x, float y, float z, float o) : Pos(x, y, z, o) { }
constexpr TaggedPosition(Position const& pos) : Pos(pos) { }
constexpr TaggedPosition& operator=(Position const& pos)