mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
* [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>
101 lines
1.9 KiB
C++
Executable File
101 lines
1.9 KiB
C++
Executable File
#include "../client.h"
|
|
|
|
void command_findaa(Client *c, const Seperator *sep)
|
|
{
|
|
auto arguments = sep->argnum;
|
|
if (!arguments) {
|
|
c->Message(Chat::White, "Command Syntax: #findaa [Search Criteria]");
|
|
return;
|
|
}
|
|
|
|
if (sep->IsNumber(1)) {
|
|
int aa_id = Strings::ToInt(sep->arg[1]);
|
|
auto aa_name = zone->GetAAName(aa_id);
|
|
if (!aa_name.empty()) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"AA {}: {}",
|
|
aa_id,
|
|
aa_name
|
|
).c_str()
|
|
);
|
|
} else {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"AA ID {} was not found.",
|
|
aa_id
|
|
).c_str()
|
|
);
|
|
}
|
|
} else {
|
|
const auto search_criteria = Strings::ToLower(sep->argplus[1]);
|
|
if (!search_criteria.empty()) {
|
|
std::map<int, std::string> ordered_aas;
|
|
|
|
for (const auto& a : zone->aa_abilities) {
|
|
ordered_aas[a.second.get()->first->id] = a.second.get()->name;
|
|
}
|
|
|
|
int found_count = 0;
|
|
for (const auto& a : ordered_aas) {
|
|
auto aa_name = zone->GetAAName(a.first);
|
|
if (!aa_name.empty()) {
|
|
auto aa_name_lower = Strings::ToLower(aa_name);
|
|
if (aa_name_lower.find(search_criteria) == std::string::npos) {
|
|
continue;
|
|
}
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"AA {}: {}",
|
|
a.first,
|
|
aa_name
|
|
).c_str()
|
|
);
|
|
found_count++;
|
|
|
|
if (found_count == 50) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!found_count) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"No AAs were found matching '{}'.",
|
|
search_criteria
|
|
).c_str()
|
|
);
|
|
return;
|
|
}
|
|
|
|
if (found_count == 50) {
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"50 AAs were found matching '{}', max reached.",
|
|
search_criteria
|
|
).c_str()
|
|
);
|
|
} else {
|
|
auto skill_message = found_count == 1 ? "An AA was" : fmt::format("{} AAs were", found_count);
|
|
|
|
c->Message(
|
|
Chat::White,
|
|
fmt::format(
|
|
"{} found matching '{}'.",
|
|
skill_message,
|
|
search_criteria
|
|
).c_str()
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|