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

58 lines
1.4 KiB
C++
Executable File

#include "../client.h"
void command_texture(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #texture [Texture] [Helmet Texture]");
return;
}
auto texture = static_cast<uint16>(std::min(Strings::ToUnsignedInt(sep->arg[1]), (uint32) 65535));
auto helmet_texture = static_cast<uint8>(
sep->IsNumber(2) ?
std::min(Strings::ToUnsignedInt(sep->arg[2]), (uint32) 255) :
0
);
Mob* target = c;
if (c->GetTarget() && c->Admin() >= commandTextureOthers) {
target = c->GetTarget();
}
if (Mob::IsPlayerRace(target->GetModel())) { // Player Races Wear Armor, so Wearchange is sent instead
for (
int texture_slot = EQ::textures::textureBegin;
texture_slot <= EQ::textures::LastTintableTexture;
texture_slot++
) {
target->SendTextureWC(texture_slot, texture);
}
} else { // Non-Player Races only need Illusion Packets to be sent for texture
target->SendIllusionPacket(
target->GetModel(),
target->GetGender(),
texture,
helmet_texture
);
}
c->Message(
Chat::White,
fmt::format(
"Texture Changed for {} | Texture: {}{}",
c->GetTargetDescription(target, TargetDescriptionType::UCSelf),
texture,
(
Mob::IsPlayerRace(target->GetModel()) ?
"" :
fmt::format(
" Helmet Texture: {}",
helmet_texture
)
)
).c_str()
);
}