[Commands] Cleanup #reloadtraps Command. (#2126)

* [Commands] Cleanup #reloadtraps Command.
- Cleanup messages and logic.
- Allow the option to reload/repop traps globally for this command.

* Typos.
This commit is contained in:
Kinglykrab 2022-05-06 22:39:21 -04:00 committed by GitHub
parent 7549fbbeea
commit 0b3065d7a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 93 additions and 4 deletions

View File

@ -231,6 +231,7 @@
#define ServerOP_ReloadLevelEXPMods 0x4015
#define ServerOP_ReloadMerchants 0x4016
#define ServerOP_ReloadAAData 0x4017
#define ServerOP_ReloadTraps 0x4018
#define ServerOP_ReloadStaticZoneData 0x4020
#define ServerOP_CZDialogueWindow 0x4500

View File

@ -293,7 +293,7 @@ int command_init(void)
command_add("reloadqst", " - Clear quest cache (any argument causes it to also stop all timers)", AccountStatus::GMLeadAdmin, command_reloadqst) ||
command_add("reloadrulesworld", "Executes a reload of all rules in world specifically.", AccountStatus::QuestTroupe, command_reloadworldrules) ||
command_add("reloadstatic", "- Reload Static Zone Data globally", AccountStatus::GMLeadAdmin, command_reloadstatic) ||
command_add("reloadtraps", "- Repops all traps in the current zone.", AccountStatus::QuestTroupe, command_reloadtraps) ||
command_add("reloadtraps", "[0|1] - Reloads and repops traps, globally if specified (1 = global)", AccountStatus::QuestTroupe, command_reloadtraps) ||
command_add("reloadtitles", "- Reload player titles from the database", AccountStatus::GMLeadAdmin, command_reloadtitles) ||
command_add("reloadworld", "[0|1|2] - Reload quests global and repop NPCs if specified (0 = No Repop, 1 = Repop, 2 = Force Repop)", AccountStatus::Max, command_reloadworld) ||
command_add("reloadzps", "- Reload zone points from database", AccountStatus::GMLeadAdmin, command_reloadzps) ||

View File

@ -2,7 +2,64 @@
void command_reloadtraps(Client *c, const Seperator *sep)
{
entity_list.UpdateAllTraps(true, true);
c->Message(Chat::Default, "Traps reloaded for %s.", zone->GetShortName());
int arguments = sep->argnum;
if (!arguments) {
entity_list.UpdateAllTraps(true, true);
c->Message(
Chat::Yellow,
fmt::format(
"Traps reloaded for {}{}.",
fmt::format(
"{} ({})",
zone->GetLongName(),
zone->GetZoneID()
),
(
zone->GetInstanceID() ?
fmt::format(
" (Instance ID {})",
zone->GetInstanceID()
) :
""
)
).c_str()
);
return;
}
bool global = false;
if (sep->IsNumber(1)) {
global = std::stoi(sep->arg[1]) ? true : false;
}
if (!global) {
entity_list.UpdateAllTraps(true, true);
c->Message(
Chat::Yellow,
fmt::format(
"Traps reloaded for {}{}.",
fmt::format(
"{} ({})",
zone->GetLongName(),
zone->GetZoneID()
),
(
zone->GetInstanceID() ?
fmt::format(
" (Instance ID {})",
zone->GetInstanceID()
) :
""
)
).c_str()
);
return;
}
c->Message(Chat::White, "Attempting to reload traps globally.");
auto pack = new ServerPacket(ServerOP_ReloadTraps, 0);
worldserver.SendPacket(pack);
safe_delete(pack);
}

View File

@ -2073,7 +2073,38 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
parse->LoadPerlEventExportSettings(parse->perl_event_export_settings);
break;
}
case ServerOP_ReloadLevelEXPMods: {
case ServerOP_ReloadTraps:
{
if (zone) {
worldserver.SendEmoteMessage(
0,
0,
AccountStatus::GMAdmin,
Chat::Yellow,
fmt::format(
"Traps reloaded for {}{}.",
fmt::format(
"{} ({})",
zone->GetLongName(),
zone->GetZoneID()
),
(
zone->GetInstanceID() ?
fmt::format(
" (Instance ID {})",
zone->GetInstanceID()
) :
""
)
).c_str()
);
entity_list.UpdateAllTraps(true, true);
}
break;
}
case ServerOP_ReloadLevelEXPMods:
{
if (zone) {
worldserver.SendEmoteMessage(
0,