diff options
| author | Giacomo Pozzoni <giacomopoz@gmail.com> | 2018-12-14 22:01:16 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-11-16 20:36:58 +0100 |
| commit | d5c41d23e67e3813adf09ee84afa636b2192c891 (patch) | |
| tree | 865a196a5dacfdf75aead0bf48afdd9c808515c6 /src/server/game/Entities/Object | |
| parent | aea3022e8974d2520bdd2427b1c83aa5cfbb1254 (diff) | |
Core/Misc: Log more information in asserts (#22783)
* Core/Misc: Log more information in asserts
Add a new function GetDebugInfos() to types that could trigger an ASSERT() to easily include more useful information in crashlogs.
This is an initial commit that requires many more commits to implement the new GetDebugInfos() function in all required types.
If the type doesn't have the function, the global default one is picked which doesn't log anything.
* Core/Misc: Fix dynamic build
Add missing attribute for dynamic build
* Core/Misc: Fix gcc/clang build
* Core/Misc: Rename GetDebugInfos() to GetDebugInfo()
* Core/Misc: Fix FormatAssertionMessage() adding an extra '\0'
* Core/Misc: Add GetDebugInfo support to Unit
* Core/Misc: Add GetDebugInfo support to Creature
* Core/Misc: Add more info to GetDebugInfo for Creature
* Core/Misc: Add GetDebugInfo support to GameObject
* Core/Misc: Add GetDebugInfo support to Player
* Core/Misc: Add more GetDebugInfo info
* Core/Misc: Add GetDebugInfo support to Item
* Core/Misc: Add GetDebugInfo support to Bag
* Core/Misc: Add GetDebugInfo support to Transport
* Core/Misc: Add GetDebugInfo support to TempSummon, Minion, Guardian, Pet
* Core/Misc: Add GetDebugInfo support to Map, InstanceMap
* Core/Misc: Add GetDebugInfo support to Spell
* Core/Misc: Fix build warning
* Core/Misc: Add GetDebugInfo support to Aura
* Core/Misc: Add GetDebugInfo support to UnitAI
(cherry picked from commit 9a924fb9d557434c5a2e4020c80db6e6bfe466ad)
Diffstat (limited to 'src/server/game/Entities/Object')
| -rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 17 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Object.h | 4 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Position.cpp | 7 | ||||
| -rw-r--r-- | src/server/game/Entities/Object/Position.h | 2 |
4 files changed, 30 insertions, 0 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index c255ebbfaf4..e05beed9feb 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -52,6 +52,7 @@ #include "World.h" #include "WorldSession.h" #include <G3D/Vector3.h> +#include <sstream> constexpr float VisibilityDistances[AsUnderlyingType(VisibilityDistanceType::Max)] = { @@ -747,6 +748,13 @@ void Object::BuildFieldsUpdate(Player* player, UpdateDataMapType& data_map) cons BuildValuesUpdateBlockForPlayer(&iter->second, iter->first); } +std::string Object::GetDebugInfo() const +{ + std::stringstream sstr; + sstr << GetGUID().ToString() + " Entry " << GetEntry(); + return sstr.str(); +} + void MovementInfo::OutDebug() { TC_LOG_DEBUG("misc", "MOVEMENT INFO"); @@ -3272,6 +3280,15 @@ float WorldObject::GetMapHeight(float x, float y, float z, bool vmap/* = true*/, return GetMap()->GetHeight(GetPhaseShift(), x, y, z, vmap, distanceToSearch); } +std::string WorldObject::GetDebugInfo() const +{ + std::stringstream sstr; + sstr << WorldLocation::GetDebugInfo() << "\n" + << Object::GetDebugInfo() << "\n" + << "Name: " << GetName(); + return sstr.str(); +} + template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>&, uint32, float) const; template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::deque<GameObject*>&, uint32, float) const; template TC_GAME_API void WorldObject::GetGameObjectListWithEntryInGrid(std::vector<GameObject*>&, uint32, float) const; diff --git a/src/server/game/Entities/Object/Object.h b/src/server/game/Entities/Object/Object.h index b194f96f8c0..8af47209787 100644 --- a/src/server/game/Entities/Object/Object.h +++ b/src/server/game/Entities/Object/Object.h @@ -229,6 +229,8 @@ class TC_GAME_API Object AddToObjectUpdateIfNeeded(); } + virtual std::string GetDebugInfo() const; + protected: Object(); @@ -666,6 +668,8 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation float GetMapWaterOrGroundLevel(float x, float y, float z, float* ground = nullptr) const; float GetMapHeight(float x, float y, float z, bool vmap = true, float distanceToSearch = 50.0f) const; // DEFAULT_HEIGHT_SEARCH in map.h + std::string GetDebugInfo() const override; + // Event handler EventProcessor m_Events; diff --git a/src/server/game/Entities/Object/Position.cpp b/src/server/game/Entities/Object/Position.cpp index b969a5492a9..7a5b8f47f00 100644 --- a/src/server/game/Entities/Object/Position.cpp +++ b/src/server/game/Entities/Object/Position.cpp @@ -199,3 +199,10 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Position::Packed buf.appendPackXYZ(streamer.Pos->GetPositionX(), streamer.Pos->GetPositionY(), streamer.Pos->GetPositionZ()); return buf; } + +std::string WorldLocation::GetDebugInfo() const +{ + std::stringstream sstr; + sstr << "MapID: " << m_mapId << " " << Position::ToString(); + return sstr.str(); +} diff --git a/src/server/game/Entities/Object/Position.h b/src/server/game/Entities/Object/Position.h index 0954169e756..ad5dc5a390a 100644 --- a/src/server/game/Entities/Object/Position.h +++ b/src/server/game/Entities/Object/Position.h @@ -186,6 +186,8 @@ public: uint32 GetMapId() const { return m_mapId; } uint32 m_mapId; + + std::string GetDebugInfo() const; }; TC_GAME_API ByteBuffer& operator<<(ByteBuffer& buf, Position::ConstStreamer<Position::XY> const& streamer); |
