[Commands] Cleanup #setanim (#3350)

# Notes
- Make use of constants instead of hard-coded strings.
This commit is contained in:
Alex King 2023-05-25 19:04:09 -04:00 committed by GitHub
parent 9993022418
commit 67fdc75df3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,9 +2,24 @@
void command_setanim(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
const auto arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
c->Message(Chat::White, "Usage: #setanim [Animation ID]");
uint32 animation_number = 1;
for (const auto& a : EQ::constants::GetSpawnAnimationMap()) {
c->Message(
Chat::White,
fmt::format(
"Animation {} | ID: {} Name: {}",
animation_number,
a.first,
a.second
).c_str()
);
animation_number++;
}
return;
}
@ -13,29 +28,36 @@ void command_setanim(Client *c, const Seperator *sep)
target = c->GetTarget();
}
int animation_id = Strings::ToInt(sep->arg[1]);
const auto animation_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
if (
animation_id < 0 ||
animation_id > eaLooting
!EQ::ValueWithin(
animation_id,
static_cast<uint8>(eaStanding),
static_cast<uint8>(eaLooting)
)
) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
c->Message(Chat::White, "Usage: #setanim [Animation ID]");
uint32 animation_number = 1;
for (const auto& a : EQ::constants::GetSpawnAnimationMap()) {
c->Message(
Chat::White,
fmt::format(
"Animation {} | ID: {} Name: {}",
animation_number,
a.first,
a.second
).c_str()
);
animation_number++;
}
return;
}
target->SetAppearance(static_cast<EmuAppearance>(animation_id), false);
std::string animation_name;
if (animation_id == eaStanding) {
animation_name = "Standing";
} else if (animation_id == eaSitting) {
animation_name = "Sitting";
} else if (animation_id == eaCrouching) {
animation_name = "Crouching";
} else if (animation_id == eaDead) {
animation_name = "Dead";
} else if (animation_id == eaLooting) {
animation_name = "Looting";
}
const auto animation_name = EQ::constants::GetSpawnAnimationName(animation_id);
c->Message(
Chat::White,