aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2018-01-09 18:09:24 +0100
committerTreeston <treeston.mmoc@gmail.com>2018-01-09 18:09:24 +0100
commitf45c211987794ff7e4192e0d3d4ca6bf67335fb5 (patch)
treeb9bc15e45e349ca157f7d5401bbb2dab2b3a8d85
parent274dede3dc89fa72ec1687d5ff454feba9849e47 (diff)
Scripts/Commands: New command: .debug threatinfo
-rw-r--r--sql/base/auth_database.sql4
-rw-r--r--sql/updates/auth/3.3.5/2018_01_09_00_auth.sql8
-rw-r--r--sql/updates/world/3.3.5/2018_01_09_00_world.sql6
-rw-r--r--src/server/game/Accounts/RBAC.h1
-rw-r--r--src/server/game/Combat/ThreatManager.h4
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp75
6 files changed, 96 insertions, 2 deletions
diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql
index 7273a4c0147..69e11cb61a7 100644
--- a/sql/base/auth_database.sql
+++ b/sql/base/auth_database.sql
@@ -817,6 +817,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
(196,843),
(196,866),
(196,867),
+(196,870),
(197,232),
(197,236),
(197,237),
@@ -1707,7 +1708,8 @@ INSERT INTO `rbac_permissions` VALUES
(864,'Command: group set mainassist'),
(865,'Command: npc showloot'),
(866,'Command: list spawnpoints'),
-(867,'Command: reload quest_greeting_locale');
+(867,'Command: reload quest_greeting_locale'),
+(870,'Command: debug threatinfo');
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
UNLOCK TABLES;
diff --git a/sql/updates/auth/3.3.5/2018_01_09_00_auth.sql b/sql/updates/auth/3.3.5/2018_01_09_00_auth.sql
new file mode 100644
index 00000000000..aac66eaaa2b
--- /dev/null
+++ b/sql/updates/auth/3.3.5/2018_01_09_00_auth.sql
@@ -0,0 +1,8 @@
+--
+DELETE FROM `rbac_permissions` WHERE `id`=870;
+INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
+(870, 'Command: debug threatinfo');
+
+DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=870;
+INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
+(196,870);
diff --git a/sql/updates/world/3.3.5/2018_01_09_00_world.sql b/sql/updates/world/3.3.5/2018_01_09_00_world.sql
new file mode 100644
index 00000000000..3e524284dea
--- /dev/null
+++ b/sql/updates/world/3.3.5/2018_01_09_00_world.sql
@@ -0,0 +1,6 @@
+--
+DELETE FROM `command` WHERE `name`="debug threatinfo";
+INSERT INTO `command` (`name`,`permission`,`help`) VALUES
+('debug threatinfo', 870, 'Syntax: .debug threatinfo
+
+Displays various debug information about the target\'s threat state, modifiers, redirects and similar.');
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index f745adba50c..f399ac69a21 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -775,6 +775,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_RELOAD_QUEST_GREETING_LOCALE = 867,
RBAC_PERM_COMMAND_MODIFY_POWER = 868, // reserved
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869, // reserved
+ RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
//
// IF YOU ADD NEW PERMISSIONS, ADD THEM IN MASTER BRANCH AS WELL!
//
diff --git a/src/server/game/Combat/ThreatManager.h b/src/server/game/Combat/ThreatManager.h
index 8ea28a65c11..fa6b596d88b 100644
--- a/src/server/game/Combat/ThreatManager.h
+++ b/src/server/game/Combat/ThreatManager.h
@@ -22,6 +22,7 @@
#include "IteratorPair.h"
#include "ObjectGuid.h"
#include "SharedDefines.h"
+#include <array>
#include <boost/heap/fibonacci_heap.hpp>
#include <unordered_map>
#include <vector>
@@ -204,7 +205,7 @@ class TC_GAME_API ThreatManager
void PutThreatenedByMeRef(ObjectGuid const& guid, ThreatReference* ref);
void PurgeThreatenedByMeRef(ObjectGuid const& guid);
std::unordered_map<ObjectGuid, ThreatReference*> _threatenedByMe; // these refs are entries for myself on other units' threat lists
- float _singleSchoolModifiers[MAX_SPELL_SCHOOL]; // most spells are single school - we pre-calculate these and store them
+ std::array<float, MAX_SPELL_SCHOOL> _singleSchoolModifiers; // most spells are single school - we pre-calculate these and store them
mutable std::unordered_map<std::underlying_type<SpellSchoolMask>::type, float> _multiSchoolModifiers; // these are calculated on demand
// redirect system (is kind of dumb, but that's because none of the redirection spells actually have any aura effect associated with them, so spellscript needs to deal with it)
@@ -218,6 +219,7 @@ class TC_GAME_API ThreatManager
friend class ThreatReference;
friend struct CompareThreatLessThan;
+ friend class debug_commandscript;
};
// Please check Game/Combat/ThreatManager.h for documentation on how this class works!
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 8ec08191185..82f9c824575 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -36,6 +36,7 @@ EndScriptData */
#include "MapManager.h"
#include "ObjectMgr.h"
#include "RBAC.h"
+#include "SpellMgr.h"
#include "Transport.h"
#include <fstream>
#include <limits>
@@ -72,6 +73,7 @@ public:
{
{ "setbit", rbac::RBAC_PERM_COMMAND_DEBUG_SETBIT, false, &HandleDebugSet32BitCommand, "" },
{ "threat", rbac::RBAC_PERM_COMMAND_DEBUG_THREAT, false, &HandleDebugThreatListCommand, "" },
+ { "threatinfo", rbac::RBAC_PERM_COMMAND_DEBUG_THREATINFO, false, &HandleDebugThreatInfoCommand, "" },
{ "combat", rbac::RBAC_PERM_COMMAND_DEBUG_COMBAT, false, &HandleDebugCombatListCommand, "" },
{ "anim", rbac::RBAC_PERM_COMMAND_DEBUG_ANIM, false, &HandleDebugAnimCommand, "" },
{ "arena", rbac::RBAC_PERM_COMMAND_DEBUG_ARENA, true, &HandleDebugArenaCommand, "" },
@@ -910,6 +912,79 @@ public:
return true;
}
+ static bool HandleDebugThreatInfoCommand(ChatHandler* handler, char const* /*args*/)
+ {
+ Unit* target = handler->getSelectedUnit();
+ if (!target)
+ {
+ handler->SendSysMessage(LANG_SELECT_CHAR_OR_CREATURE);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ handler->PSendSysMessage("Threat info for %s (%s):", target->GetName(), target->GetGUID().ToString().c_str());
+
+ ThreatManager const& mgr = target->GetThreatManager();
+
+ // _singleSchoolModifiers
+ {
+ auto& mods = mgr._singleSchoolModifiers;
+ handler->SendSysMessage(" - Single-school threat modifiers:");
+ handler->PSendSysMessage(" |-- Physical: %.2f%%", mods[SPELL_SCHOOL_NORMAL]*100.0f);
+ handler->PSendSysMessage(" |-- Holy : %.2f%%", mods[SPELL_SCHOOL_HOLY]*100.0f);
+ handler->PSendSysMessage(" |-- Fire : %.2f%%", mods[SPELL_SCHOOL_FIRE]*100.0f);
+ handler->PSendSysMessage(" |-- Nature : %.2f%%", mods[SPELL_SCHOOL_NATURE]*100.0f);
+ handler->PSendSysMessage(" |-- Frost : %.2f%%", mods[SPELL_SCHOOL_FROST]*100.0f);
+ handler->PSendSysMessage(" |-- Shadow : %.2f%%", mods[SPELL_SCHOOL_SHADOW]*100.0f);
+ handler->PSendSysMessage(" |-- Arcane : %.2f%%", mods[SPELL_SCHOOL_ARCANE]*100.0f);
+ }
+
+ // _multiSchoolModifiers
+ {
+ auto& mods = mgr._multiSchoolModifiers;
+ handler->PSendSysMessage("- Multi-school threat modifiers (%zu entries):", mods.size());
+ for (auto const& pair : mods)
+ handler->PSendSysMessage(" |-- Mask 0x%x: %.2f%%", uint32(pair.first), pair.second);
+ }
+
+ // _redirectInfo
+ {
+ auto const& redirectInfo = mgr._redirectInfo;
+ if (redirectInfo.empty())
+ handler->SendSysMessage(" - No redirects being applied");
+ else
+ {
+ handler->PSendSysMessage(" - %02zu redirects being applied:", redirectInfo.size());
+ for (auto const& pair : redirectInfo)
+ {
+ Unit* unit = ObjectAccessor::GetUnit(*target, pair.first);
+ handler->PSendSysMessage(" |-- %02u%% to %s", pair.second, unit ? unit->GetName().c_str() : pair.first.ToString().c_str());
+ }
+ }
+ }
+
+ // _redirectRegistry
+ {
+ auto const& redirectRegistry = mgr._redirectRegistry;
+ if (redirectRegistry.empty())
+ handler->SendSysMessage(" - No redirects are registered");
+ else
+ {
+ handler->PSendSysMessage(" - %02zu spells may have redirects registered", redirectRegistry.size());
+ for (auto const& outerPair : redirectRegistry) // (spellId, (guid, pct))
+ {
+ SpellInfo const* const spell = sSpellMgr->GetSpellInfo(outerPair.first);
+ handler->PSendSysMessage(" |-- #%06u %s (%zu entries):", outerPair.first, spell ? spell->SpellName[0] : "<unknown>", outerPair.second.size());
+ for (auto const& innerPair : outerPair.second) // (guid, pct)
+ {
+ Unit* unit = ObjectAccessor::GetUnit(*target, innerPair.first);
+ handler->PSendSysMessage(" |-- %02u%% to %s", innerPair.second, unit ? unit->GetName().c_str() : innerPair.first.ToString().c_str());
+ }
+ }
+ }
+ }
+ }
+
static bool HandleDebugCombatListCommand(ChatHandler* handler, char const* /*args*/)
{
Unit* target = handler->getSelectedUnit();