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

77 lines
1.8 KiB
C++
Executable File

#include "../client.h"
#include "../mob_movement_manager.h"
void command_movement(Client *c, const Seperator *sep)
{
auto &mgr = MobMovementManager::Get();
if (sep->arg[1][0] == 0) {
c->Message(Chat::White, "Usage: #movement stats/clearstats/walkto/runto/rotateto/stop/packet");
return;
}
if (strcasecmp(sep->arg[1], "stats") == 0) {
mgr.DumpStats(c);
}
else if (strcasecmp(sep->arg[1], "clearstats") == 0) {
mgr.ClearStats();
}
else if (strcasecmp(sep->arg[1], "walkto") == 0) {
auto target = c->GetTarget();
if (target == nullptr) {
c->Message(Chat::White, "No target found.");
return;
}
target->WalkTo(c->GetX(), c->GetY(), c->GetZ());
}
else if (strcasecmp(sep->arg[1], "runto") == 0) {
auto target = c->GetTarget();
if (target == nullptr) {
c->Message(Chat::White, "No target found.");
return;
}
target->RunTo(c->GetX(), c->GetY(), c->GetZ());
}
else if (strcasecmp(sep->arg[1], "rotateto") == 0) {
auto target = c->GetTarget();
if (target == nullptr) {
c->Message(Chat::White, "No target found.");
return;
}
target->RotateToWalking(target->CalculateHeadingToTarget(c->GetX(), c->GetY()));
}
else if (strcasecmp(sep->arg[1], "stop") == 0) {
auto target = c->GetTarget();
if (target == nullptr) {
c->Message(Chat::White, "No target found.");
return;
}
target->StopNavigation();
}
else if (strcasecmp(sep->arg[1], "packet") == 0) {
auto target = c->GetTarget();
if (target == nullptr) {
c->Message(Chat::White, "No target found.");
return;
}
mgr.SendCommandToClients(
target,
Strings::ToFloat(sep->arg[2]),
Strings::ToFloat(sep->arg[3]),
Strings::ToFloat(sep->arg[4]),
Strings::ToFloat(sep->arg[5]),
Strings::ToInt(sep->arg[6]),
ClientRangeAny
);
}
else {
c->Message(Chat::White, "Usage: #movement stats/clearstats/walkto/runto/rotateto/stop/packet");
}
}