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"
#include "../worldserver.h"
extern WorldServer worldserver;
void command_emote(Client *c, const Seperator *sep)
{
auto arguments = sep->argnum;
if (arguments < 3 || !sep->IsNumber(2)) {
c->Message(Chat::White, "Usage: #emote [Name] [Type] [Message]");
c->Message(Chat::White, "Usage: #emote world [Type] [Message]");
c->Message(Chat::White, "Usage: #emote zone [Type] [Message]");
return;
}
if (!worldserver.Connected()) {
c->Message(Chat::White, "Error: World server disconnected!");
return;
}
bool is_world = !strcasecmp(sep->arg[1], "world");
bool is_zone = !strcasecmp(sep->arg[1], "zone");
const std::string emote_message = sep->argplus[3];
const auto emote_type = Strings::ToUnsignedInt(sep->arg[2]);
if (is_zone) {
if (!Strings::Contains(emote_message, "^")) {
entity_list.Message(0, emote_type, emote_message.c_str());
return;
}
for (const auto& m : Strings::Split(emote_message, "^")) {
entity_list.Message(0, emote_type, m.c_str());
}
} else {
if (!Strings::Contains(emote_message, "^")) {
worldserver.SendEmoteMessage(
is_world ? 0 : sep->arg[1],
0,
emote_type,
emote_message.c_str()
);
return;
}
for (const auto& m : Strings::Split(emote_message, "^")) {
worldserver.SendEmoteMessage(
is_world ? 0 : sep->arg[1],
0,
emote_type,
m.c_str()
);
}
}
}