mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-24 17:48:20 +00:00
[Commands] Cleanup #zonebootup and #zoneshutdown Commands (#3729)
# Notes - Cleanup messages and logic.
This commit is contained in:
@@ -5,26 +5,37 @@ extern WorldServer worldserver;
|
||||
|
||||
void command_zoneshutdown(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (!worldserver.Connected()) {
|
||||
c->Message(Chat::White, "Error: World server disconnected");
|
||||
const int arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown [Zone ID|Zone Short Name]");
|
||||
return;
|
||||
}
|
||||
else if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown zoneshortname");
|
||||
}
|
||||
else {
|
||||
auto pack = new ServerPacket(
|
||||
ServerOP_ZoneShutdown,
|
||||
sizeof(ServerZoneStateChange_struct));
|
||||
ServerZoneStateChange_struct *s = (ServerZoneStateChange_struct *) pack->pBuffer;
|
||||
strcpy(s->adminname, c->GetName());
|
||||
if (sep->arg[1][0] >= '0' && sep->arg[1][0] <= '9') {
|
||||
s->ZoneServerID = Strings::ToInt(sep->arg[1]);
|
||||
}
|
||||
else {
|
||||
s->zoneid = ZoneID(sep->arg[1]);
|
||||
}
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
}
|
||||
|
||||
if (!worldserver.Connected()) {
|
||||
c->Message(Chat::White, "World server disconnected.");
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32 zone_id = sep->IsNumber(1) ? Strings::ToUnsignedInt(sep->arg[1]) : ZoneID(sep->arg[1]);
|
||||
|
||||
if (!zone_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Zone '{}' does not exist.",
|
||||
sep->arg[1]
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_ZoneShutdown, sizeof(ServerZoneStateChange_Struct));
|
||||
auto *s = (ServerZoneStateChange_Struct *) pack->pBuffer;
|
||||
|
||||
s->zone_id = zone_id;
|
||||
|
||||
strn0cpy(s->admin_name, c->GetName(), sizeof(s->admin_name));
|
||||
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user