From 7c12c5d5ef2d513d757a028929079a00d94e3662 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 21 Nov 2021 09:56:10 -0500 Subject: [PATCH] [Commands] Cleanup #permaclass Command. (#1777) - Cleanup message and logic. --- zone/command.cpp | 2 +- zone/gm_commands/permaclass.cpp | 48 ++++++++++++++++++++------------- 2 files changed, 31 insertions(+), 19 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 1ed2629e2..66956d85b 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -274,7 +274,7 @@ int command_init(void) command_add("path", "- view and edit pathing", AccountStatus::GMMgmt, command_path) || command_add("peekinv", "[equip/gen/cursor/poss/limbo/curlim/trib/bank/shbank/allbank/trade/world/all] - Print out contents of your player target's inventory", AccountStatus::GMAdmin, command_peekinv) || command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", AccountStatus::Player, command_peqzone) || - command_add("permaclass", "[classnum] - Change your or your player target's class (target is disconnected)", AccountStatus::QuestTroupe, command_permaclass) || + command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) || command_add("permagender", "[gendernum] - Change your or your player target's gender (zone to take effect)", AccountStatus::QuestTroupe, command_permagender) || command_add("permarace", "[racenum] - Change your or your player target's race (zone to take effect)", AccountStatus::QuestTroupe, command_permarace) || command_add("petitioninfo", "[petition number] - Get info about a petition", AccountStatus::ApprenticeGuide, command_petitioninfo) || diff --git a/zone/gm_commands/permaclass.cpp b/zone/gm_commands/permaclass.cpp index 72c69b80f..3aa72c97a 100755 --- a/zone/gm_commands/permaclass.cpp +++ b/zone/gm_commands/permaclass.cpp @@ -2,27 +2,39 @@ void command_permaclass(Client *c, const Seperator *sep) { - Client *t = c; + int arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #permaclass [Class ID]"); + return; + } + Client *target = c; if (c->GetTarget() && c->GetTarget()->IsClient()) { - t = c->GetTarget()->CastToClient(); + target = c->GetTarget()->CastToClient(); } - if (sep->arg[1][0] == 0) { - c->Message(Chat::White, "Usage: #permaclass "); - } - else if (!t->IsClient()) { - c->Message(Chat::White, "Target is not a client."); - } - else { - c->Message(Chat::White, "Setting %s's class...Sending to char select.", t->GetName()); - LogInfo("Class change request from [{}] for [{}], requested class:[{}]", - c->GetName(), - t->GetName(), - atoi(sep->arg[1])); - t->SetBaseClass(atoi(sep->arg[1])); - t->Save(); - t->Kick("Class was changed."); + auto class_id = std::stoi(sep->arg[1]); + + LogInfo("Class changed by {} for {} to {} ({})", + c->GetCleanName(), + target->GetCleanName(), + GetClassIDName(class_id), + class_id + ); + + target->SetBaseClass(class_id); + target->Save(); + target->Kick("Class was changed."); + + if (c != target) { + c->Message( + Chat::White, + fmt::format( + "Class changed for {} to {} ({}).", + target->GetCleanName(), + GetClassIDName(class_id), + class_id + ).c_str() + ); } } -