aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sql/base/auth_database.sql3
-rw-r--r--sql/updates/auth/master/2018_01_24_00_auth.sql8
-rw-r--r--sql/updates/world/master/2021_06_16_12_world_2018_01_24_06_world.sql6
-rw-r--r--src/server/game/Accounts/RBAC.h2
-rw-r--r--src/server/game/Instances/InstanceScript.h2
-rw-r--r--src/server/scripts/Commands/cs_debug.cpp111
6 files changed, 131 insertions, 1 deletions
diff --git a/sql/base/auth_database.sql b/sql/base/auth_database.sql
index 7da5fa1a7b4..79040edc640 100644
--- a/sql/base/auth_database.sql
+++ b/sql/base/auth_database.sql
@@ -1196,6 +1196,7 @@ INSERT INTO `rbac_linked_permissions` VALUES
(196,872),
(196,881),
(196,870),
+(196,871),
(197,232),
(197,236),
(197,237),
@@ -2125,6 +2126,7 @@ INSERT INTO `rbac_permissions` VALUES
(868,'Command: modify power'),
(869,'Command: debug send playerchoice'),
(870,'Command: debug threatinfo'),
+(871,'Command: debug instancespawn'),
(872,'Command: server debug'),
(881,'Command: reload vehicle_template');
/*!40000 ALTER TABLE `rbac_permissions` ENABLE KEYS */;
@@ -2339,6 +2341,7 @@ INSERT INTO `updates` VALUES
('2017_12_31_00_auth.sql','1721ACBD35EB95FAE33B9E95F8C4E4B1FB70A5E4','ARCHIVED','2017-12-31 20:15:23',0),
('2018_01_02_00_auth.sql','CD9B826B9D95697DC412DEF780E814FA3991D6CD','ARCHIVED','2018-01-02 20:40:37',0),
('2018_01_09_00_auth.sql','A5D4EC8FCFAB4F2DCE70EDCAD1ACBFB484FD68D5','RELEASED','2018-01-09 00:00:00',0),
+('2018_01_24_00_auth.sql','167B17D8A253D62A8112F8A7EB21C6E99CAEF1E4','RELEASED','2018-01-24 00:00:00',0)
('2018_02_18_00_auth.sql','8489DD3EFFE14A7486B593435F0BA2BC69B6EABF','ARCHIVED','2018-02-18 16:35:55',0),
('2018_02_19_00_auth.sql','07CE658C5EF88693D3C047EF8E724F94ADA74C15','ARCHIVED','2018-02-19 22:33:32',0),
('2018_02_28_00_auth.sql','E92EF4ABF7FA0C66649E1633DD0459F44C09EB83','ARCHIVED','2018-02-28 23:07:59',0),
diff --git a/sql/updates/auth/master/2018_01_24_00_auth.sql b/sql/updates/auth/master/2018_01_24_00_auth.sql
new file mode 100644
index 00000000000..119db7ae391
--- /dev/null
+++ b/sql/updates/auth/master/2018_01_24_00_auth.sql
@@ -0,0 +1,8 @@
+--
+DELETE FROM `rbac_permissions` WHERE `id`=871;
+INSERT INTO `rbac_permissions` (`id`,`name`) VALUES
+(871, 'Command: debug instancespawn');
+
+DELETE FROM `rbac_linked_permissions` WHERE `linkedId`=871;
+INSERT INTO `rbac_linked_permissions` (`id`,`linkedId`) VALUES
+(196,871);
diff --git a/sql/updates/world/master/2021_06_16_12_world_2018_01_24_06_world.sql b/sql/updates/world/master/2021_06_16_12_world_2018_01_24_06_world.sql
new file mode 100644
index 00000000000..f8599a2952c
--- /dev/null
+++ b/sql/updates/world/master/2021_06_16_12_world_2018_01_24_06_world.sql
@@ -0,0 +1,6 @@
+--
+DELETE FROM `command` WHERE `name`="debug instancespawn";
+INSERT INTO `command`(`name`,`permission`,`help`) VALUES
+('debug instancespawn',871,'Syntax: .debug instancespawn [<groupID>/explain]
+
+Displays information about the spawn groups being managed by the current instance script. If groupID is specified, additionally explains why that spawn group is in the listed state. If "explain" is specified, explains all spawn groups.');
diff --git a/src/server/game/Accounts/RBAC.h b/src/server/game/Accounts/RBAC.h
index c90a86b7f3a..aef00f3d236 100644
--- a/src/server/game/Accounts/RBAC.h
+++ b/src/server/game/Accounts/RBAC.h
@@ -776,7 +776,7 @@ enum RBACPermissions
RBAC_PERM_COMMAND_MODIFY_POWER = 868,
RBAC_PERM_COMMAND_DEBUG_SEND_PLAYER_CHOICE = 869,
RBAC_PERM_COMMAND_DEBUG_THREATINFO = 870,
- RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871, // reserved
+ RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN = 871,
RBAC_PERM_COMMAND_SERVER_DEBUG = 872,
RBAC_PERM_COMMAND_RELOAD_CREATURE_MOVEMENT_OVERRIDE = 873,
// 874 previously used, do not reuse
diff --git a/src/server/game/Instances/InstanceScript.h b/src/server/game/Instances/InstanceScript.h
index 3350c2775c3..cba5fa03936 100644
--- a/src/server/game/Instances/InstanceScript.h
+++ b/src/server/game/Instances/InstanceScript.h
@@ -349,6 +349,8 @@ class TC_GAME_API InstanceScript : public ZoneScript
// Strong reference to the associated script module
std::shared_ptr<ModuleReference> module_reference;
#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
+
+ friend class debug_commandscript;
};
#endif // TRINITY_INSTANCE_DATA_H
diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp
index 2d53688e2e5..9bb19db3910 100644
--- a/src/server/scripts/Commands/cs_debug.cpp
+++ b/src/server/scripts/Commands/cs_debug.cpp
@@ -33,6 +33,7 @@ EndScriptData */
#include "Conversation.h"
#include "GossipDef.h"
#include "GridNotifiersImpl.h"
+#include "InstanceScript.h"
#include "Language.h"
#include "Log.h"
#include "M2Stores.h"
@@ -107,6 +108,7 @@ public:
{ "boundary", rbac::RBAC_PERM_COMMAND_DEBUG_BOUNDARY, false, &HandleDebugBoundaryCommand, "" },
{ "raidreset", rbac::RBAC_PERM_COMMAND_INSTANCE_UNBIND, false, &HandleDebugRaidResetCommand, "" },
{ "neargraveyard", rbac::RBAC_PERM_COMMAND_NEARGRAVEYARD, false, &HandleDebugNearGraveyard, "" },
+ { "instancespawn", rbac::RBAC_PERM_COMMAND_DEBUG_INSTANCESPAWN, false, &HandleDebugInstanceSpawns, "" },
{ "conversation" , rbac::RBAC_PERM_COMMAND_DEBUG_CONVERSATION, false, &HandleDebugConversationCommand, "" },
{ "worldstate" , rbac::RBAC_PERM_COMMAND_DEBUG, false, &HandleDebugWorldStateCommand, "" },
{ "wsexpression" , rbac::RBAC_PERM_COMMAND_DEBUG, false, &HandleDebugWSExpressionCommand, "" },
@@ -1484,6 +1486,115 @@ public:
return true;
}
+ static bool HandleDebugInstanceSpawns(ChatHandler* handler, char const* args)
+ {
+ Player const* const player = handler->GetSession()->GetPlayer();
+ if (!player)
+ return false;
+
+ bool explain = false;
+ uint32 groupID = 0;
+ if (!stricmp(args, "explain"))
+ explain = true;
+ else
+ groupID = atoi(args);
+
+ if (groupID && !sObjectMgr->GetSpawnGroupData(groupID))
+ {
+ handler->PSendSysMessage("There is no spawn group with ID %u.", groupID);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ Map const* const map = player->GetMap();
+ char const* const mapName = map->GetMapName();
+ InstanceScript const* const instance = player->GetInstanceScript();
+ if (!instance)
+ {
+ handler->PSendSysMessage("%s has no instance script.", mapName);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ if (!instance->_instanceSpawnGroups || instance->_instanceSpawnGroups->empty())
+ {
+ handler->PSendSysMessage("%s's instance script does not manage any spawn groups.", mapName);
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+ auto const& spawnGroups = *instance->_instanceSpawnGroups;
+ std::unordered_map<uint32, std::set<std::tuple<bool, uint8, uint8>>> store;
+ for (InstanceSpawnGroupInfo const& info : spawnGroups)
+ {
+ if (groupID && info.SpawnGroupId != groupID)
+ continue;
+
+ bool isSpawn;
+ if (info.Flags & InstanceSpawnGroupInfo::FLAG_BLOCK_SPAWN)
+ isSpawn = false;
+ else if (info.Flags & InstanceSpawnGroupInfo::FLAG_ACTIVATE_SPAWN)
+ isSpawn = true;
+ else
+ continue;
+
+ store[info.SpawnGroupId].emplace(isSpawn, info.BossStateId, info.BossStates);
+ }
+
+ if (groupID && store.find(groupID) == store.end())
+ {
+ handler->PSendSysMessage("%s's instance script does not manage group '%s'.", mapName, sObjectMgr->GetSpawnGroupData(groupID)->name.c_str());
+ handler->SetSentErrorMessage(true);
+ return false;
+ }
+
+ if (!groupID)
+ handler->PSendSysMessage("Spawn groups managed by %s (%u):", mapName, map->GetId());
+
+ for (auto const& pair : store)
+ {
+ SpawnGroupTemplateData const* groupData = sObjectMgr->GetSpawnGroupData(pair.first);
+ assert(groupData); // checked by objectmgr on load
+ if (explain)
+ {
+ handler->PSendSysMessage(" |-- '%s' (%u)", groupData->name, pair.first);
+ bool isBlocked = false, isSpawned = false;
+ for (auto const& tuple : pair.second)
+ {
+ bool const isSpawn = std::get<0>(tuple);
+ uint8 const bossStateId = std::get<1>(tuple);
+ EncounterState const actualState = instance->GetBossState(bossStateId);
+ if (std::get<2>(tuple) & (1 << actualState))
+ {
+ if (isSpawn)
+ {
+ isSpawned = true;
+ if (isBlocked)
+ handler->PSendSysMessage(" | |-- '%s' would be allowed to spawn by boss state %u being %s, but this is overruled", groupData->name, bossStateId, InstanceScript::GetBossStateName(actualState));
+ else
+ handler->PSendSysMessage(" | |-- '%s' is allowed to spawn because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
+ }
+ else
+ {
+ isBlocked = true;
+ handler->PSendSysMessage(" | |-- '%s' is blocked from spawning because boss state %u is %s.", groupData->name, bossStateId, InstanceScript::GetBossStateName(bossStateId));
+ }
+ }
+ else
+ handler->PSendSysMessage(" | |-- '%s' could've been %s if boss state %u matched mask %u; but it is %s -> %u, which does not match.",
+ groupData->name, isSpawn ? "allowed to spawn" : "blocked from spawning", bossStateId, std::get<2>(tuple), InstanceScript::GetBossStateName(actualState), (1 << actualState));
+ }
+ if (isBlocked)
+ handler->PSendSysMessage(" | |=> '%s' is not active due to a blocking rule being matched", groupData->name);
+ else if (isSpawned)
+ handler->PSendSysMessage(" | |=> '%s' is active due to a spawn rule being matched", groupData->name);
+ else
+ handler->PSendSysMessage(" | |=> '%s' is not active due to none of its rules being matched", groupData->name);
+ }
+ else
+ handler->PSendSysMessage(" - '%s' (%u) is %sactive", groupData->name, pair.first, map->IsSpawnGroupActive(pair.first) ? "" : "not ");
+ }
+ return true;
+ }
+
static bool HandleDebugConversationCommand(ChatHandler* handler, char const* args)
{
if (!*args)