aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Object
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2017-05-18 23:52:58 +0200
committerShauren <shauren.trinity@gmail.com>2017-05-18 23:53:25 +0200
commitc5d3dd90bea3889ef5fcd33c9ef0d59d7c544f8a (patch)
treeaa7fde6f924fc39da54908bd6eeeb0be422e5fc3 /src/server/game/Entities/Object
parent74456703146194de72424ec98c4ea76402077be6 (diff)
Core/Game: Include cleanup
* Mostly aimed at removing Log/DatabaseEnv includes from other headers * Fix most packet headers including other packet headers - moved common structures such as ItemInstance to their own files * Moved SAI function definitions to source files (massive or requiring many different dependencies)
Diffstat (limited to 'src/server/game/Entities/Object')
-rw-r--r--src/server/game/Entities/Object/Object.cpp7
-rw-r--r--src/server/game/Entities/Object/Object.h4
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.cpp20
-rw-r--r--src/server/game/Entities/Object/ObjectGuid.h43
-rw-r--r--src/server/game/Entities/Object/Position.cpp35
-rw-r--r--src/server/game/Entities/Object/Position.h37
-rw-r--r--src/server/game/Entities/Object/Updates/UpdateData.cpp4
-rw-r--r--src/server/game/Entities/Object/Updates/UpdateData.h1
8 files changed, 64 insertions, 87 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp
index c59ae332c9e..a97451b1c05 100644
--- a/src/server/game/Entities/Object/Object.cpp
+++ b/src/server/game/Entities/Object/Object.cpp
@@ -127,7 +127,6 @@ void Object::_Create(ObjectGuid const& guid)
SetGuidValue(OBJECT_FIELD_GUID, guid);
SetUInt16Value(OBJECT_FIELD_TYPE, 0, m_objectType);
- m_PackGUID.Set(guid);
}
std::string Object::_ConcatFields(uint16 startIndex, uint16 size) const
@@ -239,7 +238,7 @@ void Object::BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(0x400);
buf << uint8(updateType);
- buf << GetPackGUID();
+ buf << GetGUID();
buf << uint8(m_objectTypeId);
BuildMovementUpdate(&buf, flags);
@@ -267,7 +266,7 @@ void Object::BuildValuesUpdateBlockForPlayer(UpdateData* data, Player* target) c
ByteBuffer buf(500);
buf << uint8(UPDATETYPE_VALUES);
- buf << GetPackGUID();
+ buf << GetGUID();
BuildValuesUpdate(UPDATETYPE_VALUES, &buf, target);
BuildDynamicValuesUpdate(UPDATETYPE_VALUES, &buf, target);
@@ -385,7 +384,7 @@ void Object::BuildMovementUpdate(ByteBuffer* data, uint32 flags) const
bool HasFall = HasFallDirection || unit->m_movementInfo.jump.fallTime != 0;
bool HasSpline = unit->IsSplineEnabled();
- *data << GetPackGUID(); // MoverGUID
+ *data << GetGUID(); // MoverGUID
*data << uint32(unit->m_movementInfo.time); // MoveTime
*data << float(unit->GetPositionX());
diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h
index bc332f74ce9..3030364ed2f 100644
--- a/src/server/game/Entities/Object/Object.h
+++ b/src/server/game/Entities/Object/Object.h
@@ -25,6 +25,7 @@
#include "ObjectGuid.h"
#include "Position.h"
#include "SharedDefines.h"
+
#include "UpdateFields.h"
#include <list>
#include <set>
@@ -170,7 +171,6 @@ class TC_GAME_API Object
virtual void RemoveFromWorld();
ObjectGuid const& GetGUID() const { return GetGuidValue(OBJECT_FIELD_GUID); }
- PackedGuid const& GetPackGUID() const { return m_PackGUID; }
uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
void SetEntry(uint32 entry) { SetUInt32Value(OBJECT_FIELD_ENTRY, entry); }
@@ -373,8 +373,6 @@ class TC_GAME_API Object
private:
bool m_inWorld;
- PackedGuid m_PackGUID;
-
// for output helpfull error messages from asserts
bool PrintIndexError(uint32 index, bool set) const;
Object(Object const& right) = delete;
diff --git a/src/server/game/Entities/Object/ObjectGuid.cpp b/src/server/game/Entities/Object/ObjectGuid.cpp
index a353a8a2afd..a3a1b235c3b 100644
--- a/src/server/game/Entities/Object/ObjectGuid.cpp
+++ b/src/server/game/Entities/Object/ObjectGuid.cpp
@@ -17,9 +17,11 @@
*/
#include "ObjectGuid.h"
+#include "ByteBuffer.h"
#include "Errors.h"
#include "Hash.h"
#include "Log.h"
+#include "Realm.h"
#include "World.h"
#include <sstream>
#include <iomanip>
@@ -148,10 +150,16 @@ void ObjectGuid::SetRawValue(std::vector<uint8> const& guid)
memcpy(this, guid.data(), sizeof(*this));
}
-void PackedGuid::Set(ObjectGuid const& guid)
+uint8& ObjectGuid::operator[](uint32 index)
{
- _packedGuid.clear();
- _packedGuid << guid;
+ ASSERT(index < sizeof(uint64) * 2);
+ return ((uint8*)&_low)[index];
+}
+
+uint8 const& ObjectGuid::operator[](uint32 index) const
+{
+ ASSERT(index < sizeof(uint64) * 2);
+ return ((uint8 const*)&_low)[index];
}
ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid)
@@ -184,12 +192,6 @@ ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid)
return buf;
}
-ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid)
-{
- buf.append(guid._packedGuid);
- return buf;
-}
-
std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid)
{
std::ostringstream tmp;
diff --git a/src/server/game/Entities/Object/ObjectGuid.h b/src/server/game/Entities/Object/ObjectGuid.h
index bcb029b2deb..131f911f77d 100644
--- a/src/server/game/Entities/Object/ObjectGuid.h
+++ b/src/server/game/Entities/Object/ObjectGuid.h
@@ -19,14 +19,14 @@
#ifndef ObjectGuid_h__
#define ObjectGuid_h__
-#include "ByteBuffer.h"
+#include "Define.h"
#include <deque>
#include <functional>
#include <list>
#include <set>
#include <type_traits>
-#include <unordered_set>
#include <vector>
+#include <unordered_set>
enum TypeID
{
@@ -199,8 +199,7 @@ struct ObjectGuidTraits<HighGuid::Transport>
static bool const MapSpecific = true;
};
-class ObjectGuid;
-class PackedGuid;
+class ByteBuffer;
#pragma pack(push, 1)
@@ -248,19 +247,8 @@ class TC_GAME_API ObjectGuid
LowType GetMaxCounter() const { return GetMaxCounter(GetHigh()); }
- // deprecated
- uint8& operator[](uint32 index)
- {
- //ASSERT(index < sizeof(uint64) * 2);
- return ((uint8*)&_low)[index];
- }
-
- // deprecated
- uint8 const& operator[](uint32 index) const
- {
- //ASSERT(index < sizeof(uint64) * 2);
- return ((uint8 const*)&_low)[index];
- }
+ uint8& operator[](uint32 index);
+ uint8 const& operator[](uint32 index) const;
bool IsEmpty() const { return _low == 0 && _high == 0; }
bool IsCreature() const { return GetHigh() == HighGuid::Creature; }
@@ -360,25 +348,6 @@ typedef std::deque<ObjectGuid> GuidDeque;
typedef std::vector<ObjectGuid> GuidVector;
typedef std::unordered_set<ObjectGuid> GuidUnorderedSet;
-// maximum buffer size for packed guid is 18 bytes
-#define PACKED_GUID_MIN_BUFFER_SIZE 18
-
-class TC_GAME_API PackedGuid
-{
- friend TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
-
- public:
- explicit PackedGuid() : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { _packedGuid << uint16(0); }
- explicit PackedGuid(ObjectGuid const& guid) : _packedGuid(PACKED_GUID_MIN_BUFFER_SIZE) { Set(guid); }
-
- void Set(ObjectGuid const& guid);
-
- size_t size() const { return _packedGuid.size(); }
-
- private:
- ByteBuffer _packedGuid;
-};
-
class TC_GAME_API ObjectGuidGeneratorBase
{
public:
@@ -410,8 +379,6 @@ public:
TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, ObjectGuid const& guid);
TC_GAME_API ByteBuffer& operator>>(ByteBuffer& buf, ObjectGuid& guid);
-TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, PackedGuid const& guid);
-
TC_GAME_API std::ostream& operator<<(std::ostream& stream, ObjectGuid const& guid);
namespace std
diff --git a/src/server/game/Entities/Object/Position.cpp b/src/server/game/Entities/Object/Position.cpp
index 63120fff443..74ead0a6f8e 100644
--- a/src/server/game/Entities/Object/Position.cpp
+++ b/src/server/game/Entities/Object/Position.cpp
@@ -21,6 +21,7 @@
#include "Random.h"
#include <G3D/g3dmath.h>
+#include <sstream>
bool Position::operator==(Position const &a)
{
@@ -43,6 +44,26 @@ bool Position::IsPositionValid() const
return Trinity::IsValidMapCoord(m_positionX, m_positionY, m_positionZ, m_orientation);
}
+float Position::GetExactDist2d(const float x, const float y) const
+{
+ return std::sqrt(GetExactDist2dSq(x, y));
+}
+
+float Position::GetExactDist2d(Position const* pos) const
+{
+ return std::sqrt(GetExactDist2dSq(pos));
+}
+
+float Position::GetExactDist(float x, float y, float z) const
+{
+ return std::sqrt(GetExactDistSq(x, y, z));
+}
+
+float Position::GetExactDist(Position const* pos) const
+{
+ return std::sqrt(GetExactDistSq(pos));
+}
+
void Position::GetPositionOffsetTo(const Position & endPos, Position & retOffset) const
{
float dx = endPos.GetPositionX() - GetPositionX();
@@ -165,6 +186,20 @@ std::string Position::ToString() const
return sstr.str();
}
+float Position::NormalizeOrientation(float o)
+{
+ // fmod only supports positive numbers. Thus we have
+ // to emulate negative numbers
+ if (o < 0)
+ {
+ float mod = o *-1;
+ mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
+ mod = -mod + 2.0f * static_cast<float>(M_PI);
+ return mod;
+ }
+ return std::fmod(o, 2.0f * static_cast<float>(M_PI));
+}
+
ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Position::XY> const& streamer)
{
buf << streamer.Pos->GetPositionX();
diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h
index 381f970a014..f045eb93824 100644
--- a/src/server/game/Entities/Object/Position.h
+++ b/src/server/game/Entities/Object/Position.h
@@ -18,7 +18,8 @@
#ifndef Trinity_game_Position_h__
#define Trinity_game_Position_h__
-#include "Common.h"
+#include "Define.h"
+#include <string>
#include <cmath>
class ByteBuffer;
@@ -136,10 +137,7 @@ public:
float dx = m_positionX - x; float dy = m_positionY - y; return dx*dx + dy*dy;
}
- float GetExactDist2d(const float x, const float y) const
- {
- return std::sqrt(GetExactDist2dSq(x, y));
- }
+ float GetExactDist2d(const float x, const float y) const;
float GetExactDist2dSq(Position const& pos) const
{
@@ -156,20 +154,14 @@ public:
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; return dx*dx + dy*dy;
}
- float GetExactDist2d(Position const* pos) const
- {
- return std::sqrt(GetExactDist2dSq(pos));
- }
+ float GetExactDist2d(Position const* pos) const;
float GetExactDistSq(float x, float y, float z) const
{
float dz = m_positionZ - z; return GetExactDist2dSq(x, y) + dz*dz;
}
- float GetExactDist(float x, float y, float z) const
- {
- return std::sqrt(GetExactDistSq(x, y, z));
- }
+ float GetExactDist(float x, float y, float z) const;
float GetExactDistSq(Position const& pos) const
{
@@ -186,10 +178,7 @@ public:
float dx = m_positionX - pos->m_positionX; float dy = m_positionY - pos->m_positionY; float dz = m_positionZ - pos->m_positionZ; return dx*dx + dy*dy + dz*dz;
}
- float GetExactDist(Position const* pos) const
- {
- return std::sqrt(GetExactDistSq(pos));
- }
+ float GetExactDist(Position const* pos) const;
void GetPositionOffsetTo(Position const & endPos, Position & retOffset) const;
Position GetPositionWithOffset(Position const& offset) const;
@@ -234,19 +223,7 @@ public:
std::string ToString() const;
// modulos a radian orientation to the range of 0..2PI
- static float NormalizeOrientation(float o)
- {
- // fmod only supports positive numbers. Thus we have
- // to emulate negative numbers
- if (o < 0)
- {
- float mod = o *-1;
- mod = std::fmod(mod, 2.0f * static_cast<float>(M_PI));
- mod = -mod + 2.0f * static_cast<float>(M_PI);
- return mod;
- }
- return std::fmod(o, 2.0f * static_cast<float>(M_PI));
- }
+ static float NormalizeOrientation(float o);
};
#define MAPID_INVALID 0xFFFFFFFF
diff --git a/src/server/game/Entities/Object/Updates/UpdateData.cpp b/src/server/game/Entities/Object/Updates/UpdateData.cpp
index 7a59f1cf236..1358d7a8568 100644
--- a/src/server/game/Entities/Object/Updates/UpdateData.cpp
+++ b/src/server/game/Entities/Object/Updates/UpdateData.cpp
@@ -16,11 +16,9 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "Common.h"
-#include "ByteBuffer.h"
+#include "UpdateData.h"
#include "Errors.h"
#include "WorldPacket.h"
-#include "UpdateData.h"
#include "Opcodes.h"
UpdateData::UpdateData(uint32 map) : m_map(map), m_blockCount(0) { }
diff --git a/src/server/game/Entities/Object/Updates/UpdateData.h b/src/server/game/Entities/Object/Updates/UpdateData.h
index 7e7d86590d9..ca3bdcd4cce 100644
--- a/src/server/game/Entities/Object/Updates/UpdateData.h
+++ b/src/server/game/Entities/Object/Updates/UpdateData.h
@@ -19,6 +19,7 @@
#ifndef __UPDATEDATA_H
#define __UPDATEDATA_H
+#include "Define.h"
#include "ByteBuffer.h"
#include "ObjectGuid.h"
#include <set>