[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:
Alex King
2023-03-04 18:01:19 -05:00
committed by GitHub
parent be567af70d
commit 2a6cf8c8e7
261 changed files with 3178 additions and 3012 deletions
+35 -35
View File
@@ -1448,9 +1448,9 @@ bool ZoneDatabase::LoadAlternateAdvancement(Client *c) {
int i = 0;
for(auto row = results.begin(); row != results.end(); ++row) {
uint32 aa = atoi(row[0]);
uint32 value = atoi(row[1]);
uint32 charges = atoi(row[2]);
uint32 aa = Strings::ToInt(row[0]);
uint32 value = Strings::ToInt(row[1]);
uint32 charges = Strings::ToInt(row[2]);
auto rank = zone->GetAlternateAdvancementRank(aa);
if(!rank) {
@@ -1775,20 +1775,20 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) {
auto ability = new AA::Ability;
ability->id = atoi(row[0]);
ability->id = Strings::ToInt(row[0]);
ability->name = row[1];
ability->category = atoi(row[2]);
ability->category = Strings::ToInt(row[2]);
//EQ client has classes left shifted by one bit for some odd reason
ability->classes = atoi(row[3]) << 1;
ability->races = atoi(row[4]);
ability->deities = atoi(row[5]);
ability->drakkin_heritage = atoi(row[6]);
ability->status = atoi(row[7]);
ability->type = atoi(row[8]);
ability->charges = atoi(row[9]);
ability->grant_only = atoi(row[10]) != 0 ? true : false;
ability->reset_on_death = atoi(row[11]) != 0 ? true : false;
ability->first_rank_id = atoi(row[12]);
ability->classes = Strings::ToInt(row[3]) << 1;
ability->races = Strings::ToInt(row[4]);
ability->deities = Strings::ToInt(row[5]);
ability->drakkin_heritage = Strings::ToInt(row[6]);
ability->status = Strings::ToInt(row[7]);
ability->type = Strings::ToInt(row[8]);
ability->charges = Strings::ToInt(row[9]);
ability->grant_only = Strings::ToInt(row[10]) != 0 ? true : false;
ability->reset_on_death = Strings::ToInt(row[11]) != 0 ? true : false;
ability->first_rank_id = Strings::ToInt(row[12]);
ability->first = nullptr;
abilities[ability->id] = std::unique_ptr<AA::Ability>(ability);
@@ -1814,18 +1814,18 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) {
auto rank = new AA::Rank;
rank->id = atoi(row[0]);
rank->upper_hotkey_sid = atoi(row[1]);
rank->lower_hotkey_sid = atoi(row[2]);
rank->title_sid = atoi(row[3]);
rank->desc_sid = atoi(row[4]);
rank->cost = atoi(row[5]);
rank->level_req = atoi(row[6]);
rank->spell = atoi(row[7]);
rank->spell_type = atoi(row[8]);
rank->recast_time = atoi(row[9]);
rank->next_id = atoi(row[10]);
rank->expansion = atoi(row[11]);
rank->id = Strings::ToInt(row[0]);
rank->upper_hotkey_sid = Strings::ToInt(row[1]);
rank->lower_hotkey_sid = Strings::ToInt(row[2]);
rank->title_sid = Strings::ToInt(row[3]);
rank->desc_sid = Strings::ToInt(row[4]);
rank->cost = Strings::ToInt(row[5]);
rank->level_req = Strings::ToInt(row[6]);
rank->spell = Strings::ToInt(row[7]);
rank->spell_type = Strings::ToInt(row[8]);
rank->recast_time = Strings::ToInt(row[9]);
rank->next_id = Strings::ToInt(row[10]);
rank->expansion = Strings::ToInt(row[11]);
rank->base_ability = nullptr;
rank->total_cost = 0;
rank->prev_id = -1;
@@ -1846,11 +1846,11 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) {
AA::RankEffect effect;
int rank_id = atoi(row[0]);
effect.slot = atoi(row[1]);
effect.effect_id = atoi(row[2]);
effect.base_value = atoi(row[3]);
effect.limit_value = atoi(row[4]);
int rank_id = Strings::ToInt(row[0]);
effect.slot = Strings::ToInt(row[1]);
effect.effect_id = Strings::ToInt(row[2]);
effect.base_value = Strings::ToInt(row[3]);
effect.limit_value = Strings::ToInt(row[4]);
if(effect.slot < 1)
continue;
@@ -1871,9 +1871,9 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
results = QueryDatabase(query);
if(results.Success()) {
for(auto row = results.begin(); row != results.end(); ++row) {
int rank_id = atoi(row[0]);
int aa_id = atoi(row[1]);
int points = atoi(row[2]);
int rank_id = Strings::ToInt(row[0]);
int aa_id = Strings::ToInt(row[1]);
int points = Strings::ToInt(row[2]);
if(aa_id <= 0 || points <= 0) {
continue;