mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-03 21:56:36 +00:00
[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>
This commit is contained in:
+13
-13
@@ -64,7 +64,7 @@ void command_ai(Client *c, const Seperator *sep)
|
||||
}
|
||||
} else if (is_faction) {
|
||||
if (sep->IsNumber(2)) {
|
||||
auto faction_id = std::stoi(sep->arg[2]);
|
||||
auto faction_id = Strings::ToInt(sep->arg[2]);
|
||||
auto faction_name = content_db.GetFactionName(faction_id);
|
||||
target->SetNPCFactionID(faction_id);
|
||||
c->Message(
|
||||
@@ -113,21 +113,21 @@ void command_ai(Client *c, const Seperator *sep)
|
||||
sep->IsNumber(5) &&
|
||||
sep->IsNumber(6)
|
||||
) {
|
||||
auto distance = std::stof(sep->arg[2]);
|
||||
auto min_x = std::stof(sep->arg[3]);
|
||||
auto max_x = std::stof(sep->arg[4]);
|
||||
auto min_y = std::stof(sep->arg[5]);
|
||||
auto max_y = std::stof(sep->arg[6]);
|
||||
auto distance = Strings::ToFloat(sep->arg[2]);
|
||||
auto min_x = Strings::ToFloat(sep->arg[3]);
|
||||
auto max_x = Strings::ToFloat(sep->arg[4]);
|
||||
auto min_y = Strings::ToFloat(sep->arg[5]);
|
||||
auto max_y = Strings::ToFloat(sep->arg[6]);
|
||||
|
||||
uint32 delay = 2500;
|
||||
uint32 minimum_delay = 2500;
|
||||
|
||||
if (sep->IsNumber(7)) {
|
||||
delay = std::stoul(sep->arg[7]);
|
||||
delay = Strings::ToUnsignedInt(sep->arg[7]);
|
||||
}
|
||||
|
||||
if (sep->IsNumber(8)) {
|
||||
minimum_delay = std::stoul(sep->arg[8]);
|
||||
minimum_delay = Strings::ToUnsignedInt(sep->arg[8]);
|
||||
}
|
||||
|
||||
target->CastToNPC()->AI_SetRoambox(
|
||||
@@ -176,18 +176,18 @@ void command_ai(Client *c, const Seperator *sep)
|
||||
sep->IsNumber(2) &&
|
||||
sep->IsNumber(3)
|
||||
) {
|
||||
auto max_distance = std::stof(sep->arg[2]);
|
||||
auto roam_distance_variance = std::stof(sep->arg[3]);
|
||||
auto max_distance = Strings::ToFloat(sep->arg[2]);
|
||||
auto roam_distance_variance = Strings::ToFloat(sep->arg[3]);
|
||||
|
||||
uint32 delay = 2500;
|
||||
uint32 minimum_delay = 2500;
|
||||
|
||||
if (sep->IsNumber(4)) {
|
||||
delay = std::stoul(sep->arg[4]);
|
||||
delay = Strings::ToUnsignedInt(sep->arg[4]);
|
||||
}
|
||||
|
||||
if (sep->IsNumber(5)) {
|
||||
minimum_delay = std::stoul(sep->arg[5]);
|
||||
minimum_delay = Strings::ToUnsignedInt(sep->arg[5]);
|
||||
}
|
||||
|
||||
target->CastToNPC()->AI_SetRoambox(
|
||||
@@ -233,7 +233,7 @@ void command_ai(Client *c, const Seperator *sep)
|
||||
}
|
||||
} else if (is_spells) {
|
||||
if (sep->IsNumber(2)) {
|
||||
auto spell_list_id = std::stoul(sep->arg[2]);
|
||||
auto spell_list_id = Strings::ToUnsignedInt(sep->arg[2]);
|
||||
if (spell_list_id >= 0) {
|
||||
target->CastToNPC()->AI_AddNPCSpells(spell_list_id);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user