[Commands] Cleanup #xtargets Command. (#2545)

* [Commands] Cleanup #xtargets Command.

- Cleanup messages and logic.

* Update client.cpp

* Update client.cpp
This commit is contained in:
Kinglykrab 2022-11-16 19:11:35 -05:00 committed by GitHub
parent bd95daa1f3
commit ce4d96dc91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 69 additions and 25 deletions

View File

@ -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;
}
}

View File

@ -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) ||

View File

@ -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<uint8>(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()
);
}