[Commands] Cleanup #zunderworld Command. (#1809)

* [Commands] Cleanup #zunderworld Command.
- Cleanup message and logic.
- Add parameter to allow data to be saved to database.

* Update zunderworld.cpp
This commit is contained in:
Kinglykrab 2021-11-22 21:16:42 -05:00 committed by GitHub
parent cece66adc6
commit 26c7287997
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 7 deletions

View File

@ -405,7 +405,7 @@ int command_init(void)
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("zstats", "- Show info about zone header", AccountStatus::QuestTroupe, command_zstats) ||
command_add("zunderworld", "[zcoord] - Sets the underworld using zcoord", AccountStatus::QuestTroupe, command_zunderworld) ||
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)
) {
command_deinit();

View File

@ -2,11 +2,38 @@
void command_zunderworld(Client *c, const Seperator *sep)
{
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #zunderworld <zcoord>");
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #zunderworld [Z] [Permanent (0 = False, 1 = True)]");
return;
}
else {
zone->newzone_data.underworld = atof(sep->arg[1]);
}
}
auto z = std::stof(sep->arg[1]);
auto permanent = sep->arg[2] ? atobool(sep->arg[2]) : false;
if (permanent) {
auto query = fmt::format(
"UPDATE zone SET underworld = {:.2f} WHERE zoneidnumber = {} AND version = {}",
z,
zone->GetZoneID(),
zone->GetInstanceVersion()
);
database.QueryDatabase(query);
}
zone->newzone_data.underworld = z;
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(
"Underworld Z Changed | Zone: {} ({}) Z: {:.2f} Permanent: {}",
zone->GetLongName(),
zone->GetZoneID(),
z,
permanent ? "Yes" : "No"
).c_str()
);
}