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

53 lines
1.3 KiB
C++
Executable File

#include "../client.h"
void command_wpadd(Client *c, const Seperator *sep)
{
int type1 = 0, type2 = 0, pause = 0; // Defaults for a new grid
Mob *target = c->GetTarget();
if (target && target->IsNPC()) {
Spawn2 *s2info = target->CastToNPC()->respawn2;
if (s2info == nullptr) {
c->Message(
Chat::White,
"#wpadd Failed, you must target a valid spawn."
);
return;
}
if (sep->arg[1][0]) {
if (Strings::ToInt(sep->arg[1]) >= 0) {
pause = Strings::ToInt(sep->arg[1]);
}
else {
c->Message(Chat::White, "Usage: #wpadd [pause] [-h]");
return;
}
}
auto position = c->GetPosition();
if (strcmp("-h", sep->arg[2]) != 0) {
position.w = -1;
}
auto zone_id = zone->GetZoneID();
uint32 tmp_grid = content_db.AddWPForSpawn(c, s2info->GetID(), position, pause, type1, type2, zone_id);
if (tmp_grid) {
target->CastToNPC()->SetGrid(tmp_grid);
}
auto grid_id = target->CastToNPC()->GetGrid();
target->CastToNPC()->AssignWaypoints(grid_id);
c->Message(
Chat::White,
fmt::format(
"Waypoint added to grid {} in zone ID {}. Use #wpinfo to see waypoints for this NPC (may need to #repop first).",
grid_id,
zone_id
).c_str()
);
}
else {
c->Message(Chat::White, "You must target an NPC to use this.");
}
}