Alex King 2a6cf8c8e7
[Strings] Add more number formatters (#2873)
* [Strings] Add more number formatters

# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* [Strings] Add more number formatters

- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* Rebase cleanup

* Changes/benchmarks/tests

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
2023-03-04 17:01:19 -06:00

51 lines
1.1 KiB
C++
Executable File

#include "../client.h"
void command_setanim(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
return;
}
Mob* target = c;
if (c->GetTarget()) {
target = c->GetTarget();
}
int animation_id = Strings::ToInt(sep->arg[1]);
if (
animation_id < 0 ||
animation_id > eaLooting
) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
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";
}
c->Message(
Chat::White,
fmt::format(
"Set animation to {} ({}) for {}.",
animation_name,
animation_id,
c->GetTargetDescription(target)
).c_str()
);
}