mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Scripts/Commands: new command '.debug instancespawn'
(cherry picked from commit 6ce078d8e8)
This commit is contained in:
@@ -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),
|
||||
|
||||
8
sql/updates/auth/master/2018_01_24_00_auth.sql
Normal file
8
sql/updates/auth/master/2018_01_24_00_auth.sql
Normal file
@@ -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);
|
||||
@@ -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.');
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user