[Commands] Cleanup #reloadworld and #repop Command. (#2127)

* [Commands] Cleanup #reloadworld Command.
- Cleanup messages and logic.

* [Commands] Cleanup #reloadworld and #repop Command.
- Cleanup messages and logic.
- Add #reloadworld 2 option to forcefully repop all mobs globally as well as reset quest timers and reload quests.
- Remove delay argument from #repop as it isn't used for anything.

* Typos.
This commit is contained in:
Kinglykrab
2022-05-06 20:06:51 -04:00
committed by GitHub
parent 9fbab76d40
commit 3091a84540
15 changed files with 121 additions and 71 deletions
+26 -8
View File
@@ -5,17 +5,35 @@ extern WorldServer worldserver;
void command_reloadworld(Client *c, const Seperator *sep)
{
int world_repop = atoi(sep->arg[1]);
if (world_repop == 0) {
c->Message(Chat::White, "Reloading quest cache worldwide.");
}
else {
c->Message(Chat::White, "Reloading quest cache and repopping zones worldwide.");
uint8 global_repop = ReloadWorld::NoRepop;
if (sep->IsNumber(1)) {
global_repop = static_cast<uint8>(std::stoul(sep->arg[1]));
if (global_repop > ReloadWorld::ForceRepop) {
global_repop = ReloadWorld::ForceRepop;
}
}
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
c->Message(
Chat::White,
fmt::format(
"Attempting to reload quests {}worldwide.",
(
global_repop ?
(
global_repop == ReloadWorld::Repop ?
"and repop NPCs " :
"and forcefully repop NPCs "
) :
""
)
).c_str()
);
auto pack = new ServerPacket(ServerOP_ReloadWorld, sizeof(ReloadWorld_Struct));
ReloadWorld_Struct *RW = (ReloadWorld_Struct *) pack->pBuffer;
RW->Option = world_repop;
RW->global_repop = global_repop;
worldserver.SendPacket(pack);
safe_delete(pack);
}
+12 -29
View File
@@ -2,39 +2,22 @@
void command_repop(Client *c, const Seperator *sep)
{
int timearg = 1;
int delay = 0;
if (sep->arg[1] && strcasecmp(sep->arg[1], "force") == 0) {
timearg++;
LinkedListIterator<Spawn2 *> iterator(zone->spawn2_list);
iterator.Reset();
while (iterator.MoreElements()) {
std::string query = StringFormat(
"DELETE FROM respawn_times WHERE id = %lu AND instance_id = %lu",
(unsigned long) iterator.GetData()->GetID(),
(unsigned long) zone->GetInstanceID()
);
auto results = database.QueryDatabase(query);
iterator.Advance();
}
c->Message(Chat::White, "Zone depop: Force resetting spawn timers.");
}
if (!sep->IsNumber(timearg)) {
c->Message(Chat::White, "Zone depopped - repopping now.");
zone->Repop();
/* Force a spawn2 timer trigger so we don't delay actually spawning the NPC's */
zone->spawn2_timer.Trigger();
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Zone depopped, repopping now.");
return;
}
c->Message(Chat::White, "Zone depoped. Repop in %i seconds", atoi(sep->arg[timearg]));
zone->Repop(atoi(sep->arg[timearg]) * 1000);
bool is_force = !strcasecmp(sep->arg[1], "force");
if (is_force) {
zone->ClearSpawnTimers();
c->Message(Chat::White, "Zone depopped, forcefully repopping now.");
} else {
c->Message(Chat::White, "Zone depopped, repopping now.");
}
zone->Repop();
zone->spawn2_timer.Trigger();
}