diff --git a/zone/client.cpp b/zone/client.cpp index 8bb8606be..dd2527dc2 100644 --- a/zone/client.cpp +++ b/zone/client.cpp @@ -7483,21 +7483,53 @@ void Client::RemoveAutoXTargets() void Client::ShowXTargets(Client *c) { - if(!c) + if (!c) { return; + } + + auto xtarget_count = 0; + + for (int i = 0; i < GetMaxXTargets(); ++i) { + c->Message( + Chat::White, + fmt::format( + "xtarget slot [{}] type [{}] ID [{}] name [{}]", + i, + XTargets[i].Type, + XTargets[i].ID, + strlen(XTargets[i].Name) ? XTargets[i].Name : "No Name" + ).c_str() + ); + + xtarget_count++; + } - for(int i = 0; i < GetMaxXTargets(); ++i) - c->Message(Chat::White, "Xtarget Slot: %i, Type: %2i, ID: %4i, Name: %s", i, XTargets[i].Type, XTargets[i].ID, XTargets[i].Name); auto &list = GetXTargetAutoMgr()->get_list(); // yeah, I kept having to do something for debugging to tell if managers were the same object or not :P // so lets use the address as an "ID" - c->Message(Chat::White, "XTargetAutoMgr ID %p size %d", GetXTargetAutoMgr(), list.size()); + c->Message( + Chat::White, + fmt::format( + "XTargetAutoMgr ID [{}] size [{}]", + fmt::ptr(GetXTargetAutoMgr()), + list.size() + ).c_str() + ); + int count = 0; for (auto &e : list) { - c->Message(Chat::White, "spawn id %d count %d", e.spawn_id, e.count); + c->Message( + Chat::White, + fmt::format( + "Spawn ID: {} Count: {}", + e.spawn_id, + e.count + ).c_str() + ); + count++; - if (count == 20) { // lets not spam too many ... - c->Message(Chat::White, " ... "); + + if (count == 20) { break; } } diff --git a/zone/command.cpp b/zone/command.cpp index b6fc71ba7..cc4b88ca3 100644 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -354,7 +354,7 @@ int command_init(void) command_add("wpadd", "[pause] [-h] - Add your current location as a waypoint to your NPC target's AI path. (-h to use current heading)", AccountStatus::GMAreas, command_wpadd) || command_add("wpinfo", "Show waypoint info about your NPC target", AccountStatus::GMAreas, command_wpinfo) || command_add("worldwide", "Performs world-wide GM functions such as cast (can be extended for other commands). Use caution", AccountStatus::GMImpossible, command_worldwide) || - command_add("xtargets", "Show your targets Extended Targets and optionally set how many xtargets they can have.", AccountStatus::GMImpossible, command_xtargets) || + command_add("xtargets", "[New Max XTargets] - Show your or your target's XTargets and optionally set max XTargets.", AccountStatus::GMImpossible, command_xtargets) || command_add("zclip", "[Minimum Clip] [Maximum Clip] [Fog Minimum Clip] [Fog Maximum Clip] [Permanent (0 = False, 1 = True)] - Change zone clipping", AccountStatus::QuestTroupe, command_zclip) || command_add("zcolor", "[Red] [Green] [Blue] [Permanent (0 = False, 1 = True)] - Change sky color", AccountStatus::QuestTroupe, command_zcolor) || command_add("zheader", "[Zone ID|Zone Short Name] [Version] - Load a zone header from the database", AccountStatus::QuestTroupe, command_zheader) || diff --git a/zone/gm_commands/xtargets.cpp b/zone/gm_commands/xtargets.cpp index bd300e819..c352b26b3 100755 --- a/zone/gm_commands/xtargets.cpp +++ b/zone/gm_commands/xtargets.cpp @@ -1,28 +1,40 @@ #include "../client.h" +#include "../../common/data_verification.h" void command_xtargets(Client *c, const Seperator *sep) { - Client *t; - + auto t = c; if (c->GetTarget() && c->GetTarget()->IsClient()) { t = c->GetTarget()->CastToClient(); } - else { - t = c; - } - if (sep->arg[1][0]) { - uint8 NewMax = atoi(sep->arg[1]); - - if ((NewMax < 5) || (NewMax > XTARGET_HARDCAP)) { - c->Message(Chat::Red, "Number of XTargets must be between 5 and %i", XTARGET_HARDCAP); - return; - } - t->SetMaxXTargets(NewMax); - c->Message(Chat::White, "Max number of XTargets set to %i", NewMax); - } - else { + auto arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { t->ShowXTargets(c); + return; } -} + const auto new_max = static_cast(std::stoul(sep->arg[1])); + + if (!EQ::ValueWithin(new_max, 5, XTARGET_HARDCAP)) { + c->Message( + Chat::White, + fmt::format( + "Number of XTargets must be between 5 and {}.", + XTARGET_HARDCAP + ).c_str() + ); + return; + } + + t->SetMaxXTargets(new_max); + + c->Message( + Chat::White, + fmt::format( + "Max number of XTargets set to {} for {}.", + new_max, + c->GetTargetDescription(t, TargetDescriptionType::LCSelf) + ).c_str() + ); +}