mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 17:26:30 +00:00
[Commands] Add Instance Support to #zoneshutdown (#4807)
* [Commands] Add Instance Support to #zoneshutdown * Update zoneserver.cpp * Update zoneshutdown.cpp
This commit is contained in:
@@ -6,8 +6,18 @@ extern WorldServer worldserver;
|
||||
void command_zoneshutdown(Client *c, const Seperator *sep)
|
||||
{
|
||||
const int arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown [Zone ID|Zone Short Name]");
|
||||
if (arguments < 2) {
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown instance [Instance ID]");
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown zone [Zone ID|Zone Short Name]");
|
||||
return;
|
||||
}
|
||||
|
||||
bool is_instance = !strcasecmp(sep->arg[1], "instance");
|
||||
bool is_zone = !strcasecmp(sep->arg[1], "zone");
|
||||
|
||||
if (!is_instance && !is_zone) {
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown instance [Instance ID]");
|
||||
c->Message(Chat::White, "Usage: #zoneshutdown zone [Zone ID|Zone Short Name]");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -16,23 +26,55 @@ void command_zoneshutdown(Client *c, const Seperator *sep)
|
||||
return;
|
||||
}
|
||||
|
||||
const uint32 zone_id = sep->IsNumber(1) ? Strings::ToUnsignedInt(sep->arg[1]) : ZoneID(sep->arg[1]);
|
||||
uint32 zone_id = 0;
|
||||
uint16 instance_id = 0;
|
||||
std::string message = "";
|
||||
|
||||
if (!zone_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Zone '{}' does not exist.",
|
||||
sep->arg[1]
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
if (is_instance) {
|
||||
instance_id = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : 0;
|
||||
|
||||
if (!database.CheckInstanceExists(instance_id)) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Instance ID '{}' does not exist.",
|
||||
instance_id
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
message = fmt::format("Instance ID {}", instance_id);
|
||||
} else if (is_zone) {
|
||||
zone_id = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]);
|
||||
|
||||
if (!zone_id) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Zone '{}' does not exist.",
|
||||
sep->arg[1]
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
message = fmt::format("{} (ID {})", ZoneLongName(zone_id), zone_id);
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Attempting to shut down {}.",
|
||||
message
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_ZoneShutdown, sizeof(ServerZoneStateChange_Struct));
|
||||
auto *s = (ServerZoneStateChange_Struct *) pack->pBuffer;
|
||||
|
||||
s->zone_id = zone_id;
|
||||
s->zone_id = zone_id;
|
||||
s->instance_id = instance_id;
|
||||
|
||||
strn0cpy(s->admin_name, c->GetName(), sizeof(s->admin_name));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user