diff options
| author | Treeston <treeston.mmoc@gmail.com> | 2018-02-05 01:33:24 +0100 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2021-06-19 23:33:24 +0200 |
| commit | 809c38994a47b972754fcd5379e8730bdab31e33 (patch) | |
| tree | f10c07093cd14b03f102ae02b368d48e596d346b /src/server/scripts/Commands | |
| parent | d34292534c197887cd33c15ff98ca8c96dc4fb99 (diff) | |
Core/Threat: Custom ThreatListIterator that transparently iterates over the backing map (instead of using heap iterators) when working with the unsorted threat list. This greatly reduces the range of actions that can cause iterator invalidation.
Also some minor adjustments to .debug threat, which no longer hides certain invalid states from view.
(cherry picked from commit 4cb13af4faff0c1f9dbda2ab6a86882b4e4201a6)
Diffstat (limited to 'src/server/scripts/Commands')
| -rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 79 |
1 files changed, 44 insertions, 35 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index e1ca92ce670..67490c05f7d 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -555,8 +555,8 @@ public: if (!target) return false; - handler->PSendSysMessage("Loot recipient for creature %s (%s, DB GUID %s) is %s", - target->GetName().c_str(), target->GetGUID().ToString().c_str(), std::to_string(target->GetSpawnId()).c_str(), + handler->PSendSysMessage("Loot recipient for creature %s (%s, SpawnID " UI64FMTD ") is %s", + target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetSpawnId(), target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient"); return true; } @@ -874,50 +874,59 @@ public: for (auto const& pair : threatenedByMe) { Unit* unit = pair.second->GetOwner(); - handler->PSendSysMessage(" %u. %s (%s, SpawnID %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0, pair.second->GetThreat()); + handler->PSendSysMessage(" %u. %s (%s, SpawnID " UI64FMTD ") - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0, pair.second->GetThreat()); } handler->SendSysMessage("End of threatened-by-me list."); } - if (!mgr.CanHaveThreatList()) - handler->PSendSysMessage("%s (%s) cannot have a threat list.", target->GetName().c_str(), target->GetGUID().ToString().c_str()); - else if (mgr.IsEngaged()) + if (mgr.CanHaveThreatList()) { - count = 0; - handler->PSendSysMessage("Threat list of %s (%s, SpawnID %u)", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); - for (ThreatReference const* ref : mgr.GetSortedThreatList()) + if (!mgr.IsThreatListEmpty(true)) { - Unit* unit = ref->GetVictim(); - char const* onlineStr; - switch (ref->GetOnlineState()) - { - case ThreatReference::ONLINE_STATE_SUPPRESSED: - onlineStr = " [SUPPRESSED]"; - break; - case ThreatReference::ONLINE_STATE_OFFLINE: - onlineStr = " [OFFLINE]"; - break; - default: - onlineStr = ""; - } - char const* tauntStr; - switch (ref->GetTauntState()) + if (mgr.IsEngaged()) + handler->PSendSysMessage("Threat list of %s (%s, SpawnID " UI64FMTD "):", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); + else + handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") is not engaged, but still has a threat list? Well, here it is:", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); + + count = 0; + for (ThreatReference const* ref : mgr.GetSortedThreatList()) { - case ThreatReference::TAUNT_STATE_TAUNT: - tauntStr = " [TAUNT]"; - break; - case ThreatReference::TAUNT_STATE_DETAUNT: - tauntStr = " [DETAUNT]"; - break; - default: - tauntStr = ""; + Unit* unit = ref->GetVictim(); + char const* onlineStr; + switch (ref->GetOnlineState()) + { + case ThreatReference::ONLINE_STATE_SUPPRESSED: + onlineStr = " [SUPPRESSED]"; + break; + case ThreatReference::ONLINE_STATE_OFFLINE: + onlineStr = " [OFFLINE]"; + break; + default: + onlineStr = ""; + } + char const* tauntStr; + switch (ref->GetTauntState()) + { + case ThreatReference::TAUNT_STATE_TAUNT: + tauntStr = " [TAUNT]"; + break; + case ThreatReference::TAUNT_STATE_DETAUNT: + tauntStr = " [DETAUNT]"; + break; + default: + tauntStr = ""; + } + handler->PSendSysMessage(" %u. %s (%s) - threat %f%s%s", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->GetThreat(), tauntStr, onlineStr); } - handler->PSendSysMessage(" %u. %s (%s) - threat %f%s%s", ++count, unit->GetName().c_str(), unit->GetGUID().ToString().c_str(), ref->GetThreat(), tauntStr, onlineStr); + handler->SendSysMessage("End of threat list."); } - handler->SendSysMessage("End of threat list."); + else if (!mgr.IsEngaged()) + handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") is not currently engaged.", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); + else + handler->PSendSysMessage("%s (%s, SpawnID " UI64FMTD ") seems to be engaged, but does not have a threat list??", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); } else - handler->PSendSysMessage("%s (%s, SpawnID %u) is not currently engaged.", target->GetName().c_str(), target->GetGUID().ToString().c_str(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0); + handler->PSendSysMessage("%s (%s) cannot have a threat list.", target->GetName().c_str(), target->GetGUID().ToString().c_str()); return true; } |
