feat(Core/Debug): GetDebugInfo implementation (#12705)

Cherry-pick: https://github.com/TrinityCore/TrinityCore/commit/9a924fb9d557434c5a2e4020c80db6e6bfe466ad

Co-authored-by: jackpoz <giacomopoz@gmail.com>

Co-authored-by: jackpoz <giacomopoz@gmail.com>
This commit is contained in:
Maelthyr
2022-08-15 14:43:41 +02:00
committed by GitHub
parent 0fa783793e
commit d0d1671745
30 changed files with 218 additions and 20 deletions
+8
View File
@@ -106,6 +106,14 @@ float UnitAI::DoGetSpellMaxRange(uint32 spellId, bool positive)
return spellInfo ? spellInfo->GetMaxRange(positive) : 0;
}
std::string UnitAI::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Me: " << (me ? me->GetDebugInfo() : "NULL");
return sstr.str();
}
SpellCastResult UnitAI::DoAddAuraToAllHostilePlayers(uint32 spellid)
{
if (me->IsInCombat())
+2
View File
@@ -345,6 +345,8 @@ public:
virtual void sQuestComplete(Player* /*player*/, Quest const* /*quest*/) {}
virtual void sQuestReward(Player* /*player*/, Quest const* /*quest*/, uint32 /*opt*/) {}
virtual void sOnGameEvent(bool /*start*/, uint16 /*eventId*/) {}
virtual std::string GetDebugInfo() const;
};
class PlayerAI : public UnitAI
@@ -3664,3 +3664,12 @@ uint32 Creature::GetPlayerDamageReq() const
{
return _playerDamageReq;
}
std::string Creature::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Unit::GetDebugInfo() << "\n"
<< "AIName: " << GetAIName() << " ScriptName: " << GetScriptName()
<< " WaypointPath: " << GetWaypointPath() << " SpawnId: " << GetSpawnId();
return sstr.str();
}
@@ -384,6 +384,8 @@ public:
void ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds duration);
std::string GetDebugInfo() const override;
protected:
bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
bool InitEntry(uint32 entry, const CreatureData* data = nullptr);
@@ -320,6 +320,15 @@ void TempSummon::RemoveFromWorld()
Creature::RemoveFromWorld();
}
std::string TempSummon::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Creature::GetDebugInfo() << "\n"
<< std::boolalpha
<< "TempSummonType : " << std::to_string(GetSummonType()) << " Summoner: " << GetSummonerGUID().ToString();
return sstr.str();
}
Minion::Minion(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : TempSummon(properties, owner, isWorldObject)
, m_owner(owner)
{
@@ -378,6 +387,15 @@ void Minion::setDeathState(DeathState s, bool despawn)
}
}
std::string Minion::GetDebugInfo() const
{
std::stringstream sstr;
sstr << TempSummon::GetDebugInfo() << "\n"
<< std::boolalpha
<< "Owner: " << (GetOwner() ? GetOwner()->GetGUID().ToString() : "");
return sstr.str();
}
Guardian::Guardian(SummonPropertiesEntry const* properties, ObjectGuid owner, bool isWorldObject) : Minion(properties, owner, isWorldObject)
{
m_unitTypeMask |= UNIT_MASK_GUARDIAN;
@@ -416,6 +434,13 @@ void Guardian::InitSummon()
}
}
std::string Guardian::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Minion::GetDebugInfo();
return sstr.str();
}
Puppet::Puppet(SummonPropertiesEntry const* properties, ObjectGuid owner) : Minion(properties, owner, false), m_owner(owner) //maybe true?
{
ASSERT(owner.IsPlayer());
@@ -52,12 +52,14 @@ public:
[[nodiscard]] Unit* GetSummonerUnit() const;
[[nodiscard]] Creature* GetSummonerCreatureBase() const;
[[nodiscard]] GameObject* GetSummonerGameObject() const;
ObjectGuid GetSummonerGUID() { return m_summonerGUID; }
TempSummonType const& GetSummonType() { return m_type; }
ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }
TempSummonType GetSummonType() const { return m_type; }
uint32 GetTimer() { return m_timer; }
void SetTimer(uint32 t) { m_timer = t; }
const SummonPropertiesEntry* const m_Properties;
std::string GetDebugInfo() const override;
private:
TempSummonType m_type;
uint32 m_timer;
@@ -77,6 +79,8 @@ public:
[[nodiscard]] bool IsPetGhoul() const {return GetEntry() == 26125 /*normal ghoul*/ || GetEntry() == 30230 /*Raise Ally ghoul*/;} // Ghoul may be guardian or pet
[[nodiscard]] bool IsGuardianPet() const;
void setDeathState(DeathState s, bool despawn = false) override; // override virtual Unit::setDeathState
std::string GetDebugInfo() const override;
protected:
const ObjectGuid m_owner;
float m_followAngle;
@@ -97,6 +101,8 @@ public:
void UpdateMaxPower(Powers power) override;
void UpdateAttackPowerAndDamage(bool ranged = false) override;
void UpdateDamagePhysical(WeaponAttackType attType) override;
std::string GetDebugInfo() const override;
};
class Puppet : public Minion
@@ -3090,3 +3090,11 @@ bool GameObject::IsInSkillupList(ObjectGuid playerGuid) const
return false;
}
std::string GameObject::GetDebugInfo() const
{
std::stringstream sstr;
sstr << WorldObject::GetDebugInfo() << "\n"
<< "SpawnId: " << GetSpawnId() << " GoState: " << std::to_string(GetGoState()) << " ScriptId: " << GetScriptId() << " AIName: " << GetAIName();
return sstr.str();
}
@@ -1060,6 +1060,8 @@ public:
void UpdateSaveToDb(bool enable);
void SavingStateOnDB();
std::string GetDebugInfo() const override;
protected:
bool AIM_Initialize();
GameObjectModel* CreateModel();
@@ -239,3 +239,10 @@ Item* Bag::GetItemByPos(uint8 slot) const
return nullptr;
}
std::string Bag::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Item::GetDebugInfo();
return sstr.str();
}
@@ -35,7 +35,6 @@ public:
bool Create(ObjectGuid::LowType guidlow, uint32 itemid, Player const* owner) override;
void Clear();
void StoreItem(uint8 slot, Item* pItem, bool update);
void RemoveItem(uint8 slot, bool update);
@@ -58,6 +57,8 @@ public:
void BuildCreateUpdateBlockForPlayer(UpdateData* data, Player* target) const override;
std::string GetDebugInfo() const override;
protected:
// Bag Storage space
Item* m_bagslot[MAX_BAG_SIZE];
+11 -1
View File
@@ -1097,7 +1097,7 @@ Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clo
if (count > pProto->GetMaxStackSize())
count = pProto->GetMaxStackSize();
ASSERT(count != 0 && "pProto->Stackable == 0 but checked at loading already");
ASSERT_NODEBUGINFO(count != 0 && "pProto->Stackable == 0 but checked at loading already");
Item* pItem = NewItemOrBag(pProto);
if (pItem->Create(sObjectMgr->GetGenerator<HighGuid::Item>().Generate(), item, player))
@@ -1287,3 +1287,13 @@ bool Item::CheckSoulboundTradeExpire()
return false;
}
std::string Item::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Object::GetDebugInfo() << "\n"
<< std::boolalpha
<< "Owner: " << GetOwnerGUID().ToString() << " Count: " << GetCount()
<< " BagSlot: " << std::to_string(GetBagSlot()) << " Slot: " << std::to_string(GetSlot()) << " Equipped: " << IsEquipped();
return sstr.str();
}
+2
View File
@@ -353,6 +353,8 @@ public:
void RemoveFromObjectUpdate() override;
[[nodiscard]] uint32 GetScriptId() const { return GetTemplate()->ScriptId; }
std::string GetDebugInfo() const override;
private:
std::string m_text;
uint8 m_slot;
@@ -1010,6 +1010,13 @@ bool Object::PrintIndexError(uint32 index, bool set) const
return false;
}
std::string Object::GetDebugInfo() const
{
std::stringstream sstr;
sstr << GetGUID().ToString() + " Entry " << GetEntry();
return sstr.str();
}
void MovementInfo::OutDebug()
{
LOG_INFO("movement", "MOVEMENT INFO");
@@ -2419,6 +2426,15 @@ Player* WorldObject::SelectNearestPlayer(float distance) const
return target;
}
std::string WorldObject::GetDebugInfo() const
{
std::stringstream sstr;
sstr << WorldLocation::GetDebugInfo() << "\n"
<< Object::GetDebugInfo() << "\n"
<< "Name: " << GetName();
return sstr.str();
}
void WorldObject::GetGameObjectListWithEntryInGrid(std::list<GameObject*>& gameobjectList, uint32 entry, float maxSearchRange) const
{
Acore::AllGameObjectsWithEntryInRange check(this, entry, maxSearchRange);
+4
View File
@@ -208,6 +208,8 @@ public:
DynamicObject* ToDynObject() { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject*>(this); else return nullptr; }
[[nodiscard]] DynamicObject const* ToDynObject() const { if (GetTypeId() == TYPEID_DYNAMICOBJECT) return reinterpret_cast<DynamicObject const*>(this); else return nullptr; }
virtual std::string GetDebugInfo() const;
DataMap CustomData;
protected:
@@ -613,6 +615,8 @@ public:
[[nodiscard]] bool HasAllowedLooter(ObjectGuid guid) const;
[[nodiscard]] GuidUnorderedSet const& GetAllowedLooters() const;
std::string GetDebugInfo() const override;
ElunaEventProcessor* elunaEvents;
protected:
@@ -208,3 +208,10 @@ ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYZOStreamer const& st
buf << x << y << z << o;
return buf;
}
std::string WorldLocation::GetDebugInfo() const
{
std::stringstream sstr;
sstr << "MapID: " << m_mapId << " " << Position::ToString();
return sstr.str();
}
@@ -317,6 +317,8 @@ public:
}
uint32 m_mapId;
std::string GetDebugInfo() const;
};
ByteBuffer& operator<<(ByteBuffer& buf, Position::PositionXYStreamer const& streamer);
+10
View File
@@ -2439,3 +2439,13 @@ std::string Pet::GenerateActionBarData() const
return oss.str();
}
std::string Pet::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Guardian::GetDebugInfo() << "\n"
<< std::boolalpha
<< "PetType: " << std::to_string(getPetType()) << " "
<< "PetNumber: " << m_charmInfo->GetPetNumber();
return sstr.str();
}
+2
View File
@@ -143,6 +143,8 @@ public:
void SetLoading(bool load) { m_loading = load; }
[[nodiscard]] bool HasTempSpell() const { return m_tempspell != 0; }
std::string GetDebugInfo() const override;
protected:
Player* m_owner;
int32 m_happinessTimer;
@@ -15972,3 +15972,10 @@ uint32 Player::GetSpellCooldownDelay(uint32 spell_id) const
SpellCooldowns::const_iterator itr = m_spellCooldowns.find(spell_id);
return uint32(itr != m_spellCooldowns.end() && itr->second.end > getMSTime() ? itr->second.end - getMSTime() : 0);
}
std::string Player::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Unit::GetDebugInfo();
return sstr.str();
}
+2
View File
@@ -2558,6 +2558,8 @@ public:
[[nodiscard]] PlayerSetting GetPlayerSetting(std::string source, uint8 index);
void UpdatePlayerSetting(std::string source, uint8 index, uint32 value);
std::string GetDebugInfo() const override;
protected:
// Gamemaster whisper whitelist
WhisperListContainer WhisperList;
@@ -1004,3 +1004,10 @@ void StaticTransport::RemovePassenger(WorldObject* passenger, bool withAll)
}
}
}
std::string MotionTransport::GetDebugInfo() const
{
std::stringstream sstr;
sstr << GameObject::GetDebugInfo();
return sstr.str();
}
@@ -78,6 +78,7 @@ public:
uint32 GetPeriod() const { return GetUInt32Value(GAMEOBJECT_LEVEL); }
void SetPeriod(uint32 period) { SetUInt32Value(GAMEOBJECT_LEVEL, period); }
std::string GetDebugInfo() const override;
private:
void MoveToNextWaypoint();
float CalculateSegmentPos(float perc);
+12 -1
View File
@@ -1117,7 +1117,7 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
{
Player* he = duel_wasMounted ? victim->GetCharmer()->ToPlayer() : victim->ToPlayer();
ASSERT(he && he->duel);
ASSERT_NODEBUGINFO(he && he->duel);
if (duel_wasMounted) // In this case victim==mount
victim->SetHealth(1);
@@ -20809,3 +20809,14 @@ bool Unit::IsInDisallowedMountForm() const
return false;
}
std::string Unit::GetDebugInfo() const
{
std::stringstream sstr;
sstr << WorldObject::GetDebugInfo() << "\n"
<< std::boolalpha
<< "AliveState: " << IsAlive()
<< " UnitMovementFlags: " << GetUnitMovementFlags() << " ExtraUnitMovementFlags: " << GetExtraUnitMovementFlags()
<< " Class: " << std::to_string(getClass());
return sstr.str();
}
+2
View File
@@ -2426,6 +2426,8 @@ public:
[[nodiscard]] bool CanRestoreMana(SpellInfo const* spellInfo) const;
std::string GetDebugInfo() const override;
protected:
explicit Unit (bool isWorldObject);
+18
View File
@@ -4021,3 +4021,21 @@ void Map::DeleteCorpseData()
stmt->SetData(1, GetInstanceId());
CharacterDatabase.Execute(stmt);
}
std::string Map::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Id: " << GetId() << " InstanceId: " << GetInstanceId() << " Difficulty: " << std::to_string(GetDifficulty())
<< " HasPlayers: " << HavePlayers();
return sstr.str();
}
std::string InstanceMap::GetDebugInfo() const
{
std::stringstream sstr;
sstr << Map::GetDebugInfo() << "\n"
<< std::boolalpha
<< "ScriptId: " << GetScriptId() << " ScriptName: " << GetScriptName();
return sstr.str();
}
+5
View File
@@ -649,6 +649,8 @@ public:
return m_activeNonPlayers.size();
}
virtual std::string GetDebugInfo() const;
private:
void LoadMapAndVMap(int gx, int gy);
void LoadVMap(int gx, int gy);
@@ -830,6 +832,9 @@ public:
[[nodiscard]] uint32 GetMaxResetDelay() const;
void InitVisibilityDistance() override;
std::string GetDebugInfo() const override;
private:
bool m_resetAfterUnload;
bool m_unloadWhenEmpty;
+24 -15
View File
@@ -297,8 +297,8 @@ void AuraApplication::ClientUpdate(bool remove)
uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleEffectMask, WorldObject* owner)
{
ASSERT(spellProto);
ASSERT(owner);
ASSERT_NODEBUGINFO(spellProto);
ASSERT_NODEBUGINFO(owner);
uint8 effMask = 0;
switch (owner->GetTypeId())
{
@@ -325,10 +325,10 @@ uint8 Aura::BuildEffectMaskForOwner(SpellInfo const* spellProto, uint8 avalibleE
Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, bool* refresh /*= nullptr*/, bool periodicReset /*= false*/)
{
ASSERT(spellproto);
ASSERT(owner);
ASSERT(caster || casterGUID);
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
ASSERT_NODEBUGINFO(spellproto);
ASSERT_NODEBUGINFO(owner);
ASSERT_NODEBUGINFO(caster || casterGUID);
ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
if (refresh)
*refresh = false;
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
@@ -351,10 +351,10 @@ Aura* Aura::TryRefreshStackOrCreate(SpellInfo const* spellproto, uint8 tryEffMas
Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject* owner, Unit* caster, int32* baseAmount /*= nullptr*/, Item* castItem /*= nullptr*/, ObjectGuid casterGUID /*= ObjectGuid::Empty*/, ObjectGuid itemGUID /*= ObjectGuid::Empty*/)
{
ASSERT(spellproto);
ASSERT(owner);
ASSERT(caster || casterGUID);
ASSERT(tryEffMask <= MAX_EFFECT_MASK);
ASSERT_NODEBUGINFO(spellproto);
ASSERT_NODEBUGINFO(owner);
ASSERT_NODEBUGINFO(caster || casterGUID);
ASSERT_NODEBUGINFO(tryEffMask <= MAX_EFFECT_MASK);
uint8 effMask = Aura::BuildEffectMaskForOwner(spellproto, tryEffMask, owner);
if (!effMask)
return nullptr;
@@ -363,11 +363,11 @@ Aura* Aura::TryCreate(SpellInfo const* spellproto, uint8 tryEffMask, WorldObject
Aura* Aura::Create(SpellInfo const* spellproto, uint8 effMask, WorldObject* owner, Unit* caster, int32* baseAmount, Item* castItem, ObjectGuid casterGUID, ObjectGuid itemGUID /*= ObjectGuid::Empty*/)
{
ASSERT(effMask);
ASSERT(spellproto);
ASSERT(owner);
ASSERT(caster || casterGUID);
ASSERT(effMask <= MAX_EFFECT_MASK);
ASSERT_NODEBUGINFO(effMask);
ASSERT_NODEBUGINFO(spellproto);
ASSERT_NODEBUGINFO(owner);
ASSERT_NODEBUGINFO(caster || casterGUID);
ASSERT_NODEBUGINFO(effMask <= MAX_EFFECT_MASK);
// try to get caster of aura
if (casterGUID)
{
@@ -2707,6 +2707,15 @@ void Aura::SetTriggeredByAuraSpellInfo(SpellInfo const* triggeredByAuraSpellInfo
m_triggeredByAuraSpellInfo = triggeredByAuraSpellInfo;
}
std::string Aura::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Id: " << GetId() << " Caster: " << GetCasterGUID().ToString()
<< "\nOwner: " << (GetOwner() ? GetOwner()->GetDebugInfo() : "NULL");
return sstr.str();
}
SpellInfo const* Aura::GetTriggeredByAuraSpellInfo() const
{
return m_triggeredByAuraSpellInfo;
@@ -236,6 +236,8 @@ public:
std::list<AuraScript*> m_loadedScripts;
virtual std::string GetDebugInfo() const;
void SetTriggeredByAuraSpellInfo(SpellInfo const* triggeredByAuraSpellInfo);
SpellInfo const* GetTriggeredByAuraSpellInfo() const;
+9
View File
@@ -8866,6 +8866,15 @@ void TriggeredByAuraSpellData::Init(AuraEffect const* aurEff)
tickNumber = aurEff->GetTickNumber();
}
std::string Spell::GetDebugInfo() const
{
std::stringstream sstr;
sstr << std::boolalpha
<< "Id: " << GetSpellInfo()->Id << " OriginalCaster: " << m_originalCasterGUID.ToString()
<< " State: " << getState();
return sstr.str();
}
namespace Acore
{
+2
View File
@@ -606,6 +606,8 @@ public:
Spell** m_selfContainer; // pointer to our spell container (if applicable)
std::string GetDebugInfo() const;
//Spell data
SpellSchoolMask m_spellSchoolMask; // Spell school (can be overwrite for some spells (wand shoot for example)
WeaponAttackType m_attackType; // For weapon based attack