From 1a1c3abc24b8f8ff4c8c4230e8021f9a905b377f Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Wed, 8 Dec 2021 18:18:06 -0500 Subject: [PATCH] [Commands] Cleanup #setstartzone Command. (#1853) - Add a message when setting start zone. - Cleanup logic. --- zone/command.cpp | 2 +- zone/gm_commands/setstartzone.cpp | 67 +++++++++++++++++++++---------- 2 files changed, 47 insertions(+), 22 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 1149f09e5..a17361d18 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -337,7 +337,7 @@ int command_init(void) command_add("setpvppoints", "[Amount] - Set your or your player target's PVP points", AccountStatus::GMAdmin, command_setpvppoints) || command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", AccountStatus::Guide, command_setskill) || command_add("setskillall", "[value] - Set all of your target's skills to value", AccountStatus::Guide, command_setskillall) || - command_add("setstartzone", "[zoneid] - Set target's starting zone. Set to zero to allow the player to use /setstartcity", AccountStatus::QuestTroupe, command_setstartzone) || + command_add("setstartzone", "[Zone ID|Zone Short Name] - Sets your or your target's starting zone (Use '0' or 'Reset' to allow the player use of /setstartcity)", AccountStatus::QuestTroupe, command_setstartzone) || command_add("setstat", "- Sets the stats to a specific value.", AccountStatus::Max, command_setstat) || command_add("setxp", "[value] - Set your or your player target's experience", AccountStatus::GMAdmin, command_setxp) || command_add("showbonusstats", "[item|spell|all] Shows bonus stats for target from items or spells. Shows both by default.", AccountStatus::Guide, command_showbonusstats) || diff --git a/zone/gm_commands/setstartzone.cpp b/zone/gm_commands/setstartzone.cpp index bff04d296..cf946041d 100755 --- a/zone/gm_commands/setstartzone.cpp +++ b/zone/gm_commands/setstartzone.cpp @@ -2,34 +2,59 @@ void command_setstartzone(Client *c, const Seperator *sep) { - uint32 startzone = 0; - Client *target = nullptr; - if (c->GetTarget() && c->GetTarget()->IsClient() && sep->arg[1][0] != 0) { - target = c->GetTarget()->CastToClient(); - } - else { - c->Message(Chat::White, "Usage: (needs PC target) #setstartzone zonename"); + int arguments = sep->argnum; + if (!arguments) { + c->Message(Chat::White, "Usage: #setstartzone [Zone ID|Zone Short Name]"); c->Message( Chat::White, - "Optional Usage: Use '#setstartzone reset' or '#setstartzone 0' to clear a starting zone. Player can select a starting zone using /setstartcity" + "Optional Usage: Use '#setstartzone Reset' or '#setstartzone 0' to clear a starting zone. Player can select a starting zone using /setstartcity" ); return; } - if (sep->IsNumber(1)) { - startzone = atoi(sep->arg[1]); - } - else if (strcasecmp(sep->arg[1], "reset") == 0) { - startzone = 0; - } - else { - startzone = ZoneID(sep->arg[1]); - if (startzone == 0) { - c->Message(Chat::White, "Unable to locate zone '%s'", sep->arg[1]); - return; - } + auto target = c; + if (c->GetTarget() && c->GetTarget()->IsClient()) { + target = c->GetTarget()->CastToClient(); } - target->SetStartZone(startzone); + auto zone_id = ( + sep->IsNumber(1) ? + std::stoul(sep->arg[1]) : + ZoneID(sep->arg[1]) + ); + + target->SetStartZone(zone_id); + + bool is_reset = ( + !strcasecmp(sep->arg[1], "reset") || + zone_id == 0 + ); + + c->Message( + Chat::White, + fmt::format( + "Start Zone {} for {} |{}", + is_reset ? "Reset" : "Changed", + ( + c == target ? + "Yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ), + ( + zone_id ? + fmt::format( + " {} ({}) ID: {}", + ZoneLongName(zone_id), + ZoneName(zone_id), + zone_id + ) : + "" + ) + ).c_str() + ); }