aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2014-12-29 01:00:16 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2014-12-29 01:00:16 +0100
commit9ecc578cb187cc1ae0fd454883dab0cd058d3807 (patch)
tree6322b594c6ff6958de870dc5b4f0effee1f6e5c7 /src/server/game/Entities/Object
parent21360bb50c6a1390fbeb51c9c27bb0823ad0f252 (diff)
Core/Scripts: multiple changes
- fixed non pch build - fixed some warnings - fixed some coverity issues - some random things here and there
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp65
-rw-r--r--src/server/game/Entities/Object/Object.h34
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.cpp2
3 files changed, 35 insertions, 66 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index 0aa9098adf1..eabb2f3f202 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -44,8 +44,8 @@
#include "UpdateFieldFlags.h"
#include "TemporarySummon.h"
#include "Totem.h"
+#include "MovementPackets.h"
#include "OutdoorPvPMgr.h"
-#include "MovementPacketBuilder.h"
#include "DynamicTree.h"
#include "Unit.h"
#include "Group.h"
@@ -432,24 +432,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
data->WriteBit(0); // RemoteTimeValid
if (!unit->m_movementInfo.transport.guid.IsEmpty())
- {
- *data << unit->m_movementInfo.transport.guid; // Transport Guid
- *data << float(unit->GetTransOffsetX());
- *data << float(unit->GetTransOffsetY());
- *data << float(unit->GetTransOffsetZ());
- *data << float(unit->GetTransOffsetO());
- *data << int8(unit->m_movementInfo.transport.seat); // VehicleSeatIndex
- *data << uint32(unit->m_movementInfo.transport.time); // MoveTime
-
- data->WriteBit(unit->m_movementInfo.transport.prevTime != 0);
- data->WriteBit(unit->m_movementInfo.transport.vehicleId != 0);
-
- if (unit->m_movementInfo.transport.prevTime)
- *data << uint32(unit->m_movementInfo.transport.prevTime); // PrevMoveTime
-
- if (unit->m_movementInfo.transport.vehicleId)
- *data << uint32(unit->m_movementInfo.transport.vehicleId); // VehicleRecID
- }
+ *data << unit->m_movementInfo.transport;
if (HasFall)
{
@@ -488,28 +471,13 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
// HasMovementSpline - marks that spline data is present in packet
if (data->WriteBit(HasSpline))
- Movement::PacketBuilder::WriteCreate(*unit->movespline, *data);
+ WorldPackets::Movement::CommonMovement::WriteCreateObjectSplineDataBlock(*unit->movespline, *data);
}
if (HasMovementTransport)
{
WorldObject const* self = static_cast<WorldObject const*>(this);
- *data << self->m_movementInfo.transport.guid; // Transport Guid
- *data << float(self->GetTransOffsetX());
- *data << float(self->GetTransOffsetY());
- *data << float(self->GetTransOffsetZ());
- *data << float(self->GetTransOffsetO());
- *data << int8(self->m_movementInfo.transport.seat); // VehicleSeatIndex
- *data << uint32(self->m_movementInfo.transport.time); // MoveTime
-
- data->WriteBit(self->m_movementInfo.transport.prevTime != 0);
- data->WriteBit(self->m_movementInfo.transport.vehicleId != 0);
-
- if (self->m_movementInfo.transport.prevTime)
- *data << uint32(self->m_movementInfo.transport.prevTime); // PrevMoveTime
-
- if (self->m_movementInfo.transport.vehicleId)
- *data << uint32(self->m_movementInfo.transport.vehicleId); // VehicleRecID
+ *data << self->m_movementInfo.transport;
}
if (Stationary)
@@ -1506,7 +1474,7 @@ bool Position::operator==(Position const &a)
return (G3D::fuzzyEq(a.m_positionX, m_positionX) &&
G3D::fuzzyEq(a.m_positionY, m_positionY) &&
G3D::fuzzyEq(a.m_positionZ, m_positionZ) &&
- G3D::fuzzyEq(a.m_orientation, m_orientation));
+ G3D::fuzzyEq(a._orientation, _orientation));
}
bool Position::HasInLine(WorldObject const* target, float width) const
@@ -1521,7 +1489,7 @@ bool Position::HasInLine(WorldObject const* target, float width) const
std::string Position::ToString() const
{
std::stringstream sstr;
- sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << m_orientation;
+ sstr << "X: " << m_positionX << " Y: " << m_positionY << " Z: " << m_positionZ << " O: " << _orientation;
return sstr.str();
}
@@ -1529,14 +1497,14 @@ ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
{
float x, y, z, o;
buf >> x >> y >> z >> o;
- streamer.m_pos->Relocate(x, y, z, o);
+ streamer.Pos->Relocate(x, y, z, o);
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZStreamer const& streamer)
{
- float x, y, z;
- streamer.m_pos->GetPosition(x, y, z);
- buf << x << y << z;
+ buf << streamer.Pos->GetPositionX();
+ buf << streamer.Pos->GetPositionY();
+ buf << streamer.Pos->GetPositionZ();
return buf;
}
@@ -1544,15 +1512,16 @@ ByteBuffer& operator>>(ByteBuffer& buf, Position::PositionXYZStreamer const& str
{
float x, y, z;
buf >> x >> y >> z;
- streamer.m_pos->Relocate(x, y, z);
+ streamer.Pos->Relocate(x, y, z);
return buf;
}
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& streamer)
{
- float x, y, z, o;
- streamer.m_pos->GetPosition(x, y, z, o);
- buf << x << y << z << o;
+ buf << streamer.Pos->GetPositionX();
+ buf << streamer.Pos->GetPositionY();
+ buf << streamer.Pos->GetPositionZ();
+ buf << streamer.Pos->GetOrientation();
return buf;
}
@@ -1989,7 +1958,7 @@ bool Position::HasInArc(float arc, const Position* obj, float border) const
arc = NormalizeOrientation(arc);
float angle = GetAngle(obj);
- angle -= m_orientation;
+ angle -= _orientation;
// move angle to range -pi ... +pi
angle = NormalizeOrientation(angle);
@@ -2136,7 +2105,7 @@ void WorldObject::UpdateAllowedPositionZ(float x, float y, float &z) const
bool Position::IsPositionValid() const
{
- return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
+ return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, _orientation);
}
float WorldObject::GetGridActivationRange() const
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index d2dd0108d20..18e5e29028c 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -261,30 +261,30 @@ class Object
struct Position
{
Position(float x = 0, float y = 0, float z = 0, float o = 0)
- : m_positionX(x), m_positionY(y), m_positionZ(z), m_orientation(NormalizeOrientation(o)) { }
+ : m_positionX(x), m_positionY(y), m_positionZ(z), _orientation(NormalizeOrientation(o)) { }
- Position(const Position &loc) { Relocate(loc); }
+ Position(Position const& loc) { Relocate(loc); }
struct PositionXYZStreamer
{
- explicit PositionXYZStreamer(Position& pos) : m_pos(&pos) { }
- Position* m_pos;
+ explicit PositionXYZStreamer(Position& pos) : Pos(&pos) { }
+ Position* Pos;
};
struct PositionXYZOStreamer
{
- explicit PositionXYZOStreamer(Position& pos) : m_pos(&pos) { }
- Position* m_pos;
+ explicit PositionXYZOStreamer(Position& pos) : Pos(&pos) { }
+ Position* Pos;
};
float m_positionX;
float m_positionY;
float m_positionZ;
-// Better to limit access to m_orientation field, but this will be hard to achieve with many scripts using array initialization for this structure
-//private:
- float m_orientation;
-//public:
+// Better to limit access to _orientation field, to guarantee the value is normalized
+private:
+ float _orientation;
+public:
bool operator==(Position const &a);
inline bool operator!=(Position const &a)
@@ -299,24 +299,24 @@ struct Position
void Relocate(float x, float y, float z, float orientation)
{ m_positionX = x; m_positionY = y; m_positionZ = z; SetOrientation(orientation); }
void Relocate(Position const &pos)
- { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos.m_orientation); }
+ { m_positionX = pos.m_positionX; m_positionY = pos.m_positionY; m_positionZ = pos.m_positionZ; SetOrientation(pos._orientation); }
void Relocate(Position const* pos)
- { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->m_orientation); }
+ { m_positionX = pos->m_positionX; m_positionY = pos->m_positionY; m_positionZ = pos->m_positionZ; SetOrientation(pos->_orientation); }
void RelocateOffset(Position const &offset);
void SetOrientation(float orientation)
- { m_orientation = NormalizeOrientation(orientation); }
+ { _orientation = NormalizeOrientation(orientation); }
float GetPositionX() const { return m_positionX; }
float GetPositionY() const { return m_positionY; }
float GetPositionZ() const { return m_positionZ; }
- float GetOrientation() const { return m_orientation; }
+ float GetOrientation() const { return _orientation; }
void GetPosition(float &x, float &y) const
{ x = m_positionX; y = m_positionY; }
void GetPosition(float &x, float &y, float &z) const
{ x = m_positionX; y = m_positionY; z = m_positionZ; }
void GetPosition(float &x, float &y, float &z, float &o) const
- { x = m_positionX; y = m_positionY; z = m_positionZ; o = m_orientation; }
+ { x = m_positionX; y = m_positionY; z = m_positionZ; o = _orientation; }
Position GetPosition() const
{
@@ -357,8 +357,8 @@ struct Position
float GetAngle(Position const* pos) const;
float GetAngle(float x, float y) const;
float GetRelativeAngle(Position const* pos) const
- { return GetAngle(pos) - m_orientation; }
- float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - m_orientation; }
+ { return GetAngle(pos) - _orientation; }
+ float GetRelativeAngle(float x, float y) const { return GetAngle(x, y) - _orientation; }
void GetSinCos(float x, float y, float &vsin, float &vcos) const;
bool IsInDist2d(float x, float y, float dist) const
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp
index 327b83ba6d4..8fc88003faf 100644
--- a/src/server/game/Entities/Object/ObjectGuid.cpp
+++ b/src/server/game/Entities/Object/ObjectGuid.cpp
@@ -72,7 +72,7 @@ char const* TypeNames[] =
char const* ObjectGuid::GetTypeName(HighGuid high)
{
- if (high > HighGuid::Count)
+ if (high >= HighGuid::Count)
return "<unknown>";
return TypeNames[uint32(high)];