mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-20 21:41:29 +00:00
[Commands] Cleanup #petname Command (#3829)
# Notes - Cleanup messages and logic.
This commit is contained in:
parent
411fe3d95d
commit
05f09b56e6
@ -2,21 +2,44 @@
|
|||||||
|
|
||||||
void command_petname(Client *c, const Seperator *sep)
|
void command_petname(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
Mob *target;
|
Mob *t = nullptr;
|
||||||
target = c->GetTarget();
|
if (c->GetTarget()) {
|
||||||
|
t = c->GetTarget();
|
||||||
if (!target || !target->IsPet()) {
|
|
||||||
c->Message(Chat::White, "Usage: #petname newname (requires a pet target)");
|
|
||||||
}
|
|
||||||
else if (target->GetOwnerID() == c->GetID() && strlen(sep->arg[1]) > 0) {
|
|
||||||
char *oldname = strdup(target->GetName());
|
|
||||||
target->TempName(sep->arg[1]);
|
|
||||||
c->Message(Chat::White, "Renamed %s to %s", oldname, sep->arg[1]);
|
|
||||||
free(oldname);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
target->TempName();
|
|
||||||
c->Message(Chat::White, "Restored the original name");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!t) {
|
||||||
|
c->Message(Chat::White, "You must target your pet to use this command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t->IsPet()) {
|
||||||
|
c->Message(Chat::White, "You must target your pet to use this command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (t->GetOwnerID() != c->GetID()) {
|
||||||
|
c->Message(Chat::White, "You must target your pet to use this command.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sep->arg[1]) {
|
||||||
|
const std::string& old_name = t->GetCleanName();
|
||||||
|
const std::string& new_name = sep->arg[1];
|
||||||
|
|
||||||
|
t->TempName(new_name.c_str());
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Renamed your pet from {} to {}.",
|
||||||
|
old_name,
|
||||||
|
new_name
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
t->TempName();
|
||||||
|
c->Message(Chat::White, "Restored the original name.");
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user