mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Commands] Cleanup #zsky Command. (#1808)
- Cleanup message and logic. - Add parameter to allow data to be saved to database.
This commit is contained in:
parent
0da4610249
commit
9240497cbc
@ -403,7 +403,7 @@ int command_init(void)
|
||||
command_add("zopp", "Troubleshooting command - Sends a fake item packet to you. No server reference is created.", AccountStatus::GMImpossible, command_zopp) ||
|
||||
command_add("zsafecoords", "[x] [y] [z] - Set safe coords", AccountStatus::QuestTroupe, command_zsafecoords) ||
|
||||
command_add("zsave", " - Saves zheader to the database", AccountStatus::QuestTroupe, command_zsave) ||
|
||||
command_add("zsky", "[skytype] - Change zone sky type", AccountStatus::QuestTroupe, command_zsky) ||
|
||||
command_add("zsky", "[Sky Type] [Permanent (0 = False, 1 = True)] - Change zone sky type", AccountStatus::QuestTroupe, command_zsky) ||
|
||||
command_add("zstats", "- Show info about zone header", AccountStatus::QuestTroupe, command_zstats) ||
|
||||
command_add("zunderworld", "[Z] [Permanent (0 = False, 1 = True)] - Change zone underworld Z", AccountStatus::QuestTroupe, command_zunderworld) ||
|
||||
command_add("zuwcoords", "[z coord] - Set underworld coord", AccountStatus::QuestTroupe, command_zuwcoords)
|
||||
|
||||
@ -2,19 +2,43 @@
|
||||
|
||||
void command_zsky(Client *c, const Seperator *sep)
|
||||
{
|
||||
// modifys and resends zhdr packet
|
||||
if (sep->arg[1][0] == 0) {
|
||||
c->Message(Chat::White, "Usage: #zsky <sky type>");
|
||||
int arguments = sep->argnum;
|
||||
if (!arguments || !sep->IsNumber(1)) {
|
||||
c->Message(Chat::White, "Usage: #zsky [Sky Type] [Permanent (0 = False, 1 = True)]");
|
||||
return;
|
||||
}
|
||||
else if (atoi(sep->arg[1]) < 0 || atoi(sep->arg[1]) > 255) {
|
||||
c->Message(Chat::White, "ERROR: Sky type can not be less than 0 or greater than 255!");
|
||||
|
||||
auto sky_type = std::stoul(sep->arg[1]);
|
||||
auto permanent = sep->arg[2] ? atobool(sep->arg[2]) : false;
|
||||
if (sky_type < 0 || sky_type > 255) {
|
||||
c->Message(Chat::White, "Sky Type cannot be less than 0 or greater than 255!");
|
||||
return;
|
||||
}
|
||||
else {
|
||||
zone->newzone_data.sky = atoi(sep->arg[1]);
|
||||
|
||||
if (permanent) {
|
||||
auto query = fmt::format(
|
||||
"UPDATE zone SET sky = {} WHERE zoneidnumber = {} AND version = {}",
|
||||
sky_type,
|
||||
zone->GetZoneID(),
|
||||
zone->GetInstanceVersion()
|
||||
);
|
||||
database.QueryDatabase(query);
|
||||
}
|
||||
|
||||
zone->newzone_data.sky = static_cast<uint8>(sky_type);
|
||||
auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct));
|
||||
memcpy(outapp->pBuffer, &zone->newzone_data, outapp->size);
|
||||
entity_list.QueueClients(c, outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"Sky Changed | Zone: {} ({}) Sky Type: {} Permanent: {}",
|
||||
zone->GetLongName(),
|
||||
zone->GetZoneID(),
|
||||
sky_type,
|
||||
permanent ? "Yes" : "No"
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user