aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Commands
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-02-05 01:33:24 +0100
committerTreeston <treeston.mmoc@gmail.com>2018-02-05 01:33:41 +0100
commit4cb13af4faff0c1f9dbda2ab6a86882b4e4201a6 (patch)
treedd91c18a44fb15df3027eff5663411cf0295340b /src/server/scripts/Commands
parent2d2c43f4b91fef6fcd4d8c069a9bb41d66c97efe (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.
Diffstat (limited to 'src/server/scripts/Commands')
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp77
1 files changed, 43 insertions, 34 deletions
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 0a2db46d6a0..56bfd14de66 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -551,7 +551,7 @@ public:
if (!target)
return false;
- handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, DB GUID %u) is %s",
+ handler->PSendSysMessage("Loot recipient for creature %s (GUID %u, SpawnID %u) is %s",
target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetSpawnId(),
target->hasLootRecipient() ? (target->GetLootRecipient() ? target->GetLootRecipient()->GetName().c_str() : "offline") : "no loot recipient");
return true;
@@ -870,50 +870,59 @@ public:
for (auto const& pair : threatenedByMe)
{
Unit* unit = pair.second->GetOwner();
- handler->PSendSysMessage(" %u. %s (current guid %u, DB guid %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().GetCounter(), unit->GetTypeId() == TYPEID_UNIT ? unit->ToCreature()->GetSpawnId() : 0, pair.second->GetThreat());
+ handler->PSendSysMessage(" %u. %s (GUID %u, SpawnID %u) - threat %f", ++count, unit->GetName().c_str(), unit->GetGUID().GetCounter(), 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 (guid %u) cannot have a threat list.", target->GetName().c_str(), target->GetGUID().GetCounter());
- else if (mgr.IsEngaged())
+ if (mgr.CanHaveThreatList())
{
- count = 0;
- handler->PSendSysMessage("Threat list of %s (guid %u, spawnID %u)", target->GetName().c_str(), target->GetGUID().GetCounter(), 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 (GUID %u, SpawnID %u):", target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
+ else
+ handler->PSendSysMessage("%s (GUID %u, SpawnID %u) is not engaged, but still has a threat list? Well, here it is:", target->GetName().c_str(), target->GetGUID().GetCounter(), 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 (GUID %u) - threat %f%s%s", ++count, unit->GetName().c_str(), unit->GetGUID().GetCounter(), ref->GetThreat(), tauntStr, onlineStr);
}
- handler->PSendSysMessage(" %u. %s (guid %u) - threat %f%s%s", ++count, unit->GetName().c_str(), unit->GetGUID().GetCounter(), ref->GetThreat(), tauntStr, onlineStr);
+ handler->SendSysMessage("End of threat list.");
}
- handler->SendSysMessage("End of threat list.");
+ else if (!mgr.IsEngaged())
+ handler->PSendSysMessage("%s (GUID %u, SpawnID %u) is not currently engaged.", target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
+ else
+ handler->PSendSysMessage("%s (GUID %u, SpawnID %u) seems to be engaged, but does not have a threat list??", target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
}
else
- handler->PSendSysMessage("%s (guid %u, spawnID %u) is not currently engaged.", target->GetName().c_str(), target->GetGUID().GetCounter(), target->GetTypeId() == TYPEID_UNIT ? target->ToCreature()->GetSpawnId() : 0);
+ handler->PSendSysMessage("%s (GUID %u) cannot have a threat list.", target->GetName().c_str(), target->GetGUID().GetCounter());
return true;
}