Skip to content

Commit

Permalink
[Cleanup] Cleanup Strings::ToInt uses. (#3142)
Browse files Browse the repository at this point in the history
* [Cleanup] Cleanup Strings::ToInt uses.

* fix for conversion

* remove != 0

* cleanup
  • Loading branch information
Aeadoin authored Mar 26, 2023
1 parent 9d1ace6 commit eb51550
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion common/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) {

auto row = results.begin();

uint32 accountId = Strings::ToInt(row[0]);
uint32 accountId = Strings::ToUnsignedInt(row[0]);

if (oCharID)
*oCharID = Strings::ToUnsignedInt(row[1]);
Expand Down
6 changes: 3 additions & 3 deletions common/database_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){
ExtendedProfile_Struct* e_pp;
uint32 pplen = 0;
uint32 i;
int character_id = 0;
uint32 character_id = 0;
int account_id = 0;
int number_of_characters = 0;
int printppdebug = 0; /* Prints Player Profile */
Expand Down Expand Up @@ -929,12 +929,12 @@ bool Database::CheckDatabaseConvertPPDeblob(){

for (auto row = results.begin(); row != results.end(); ++row) {
char_iter_count++;
squery = StringFormat("SELECT `id`, `profile`, `name`, `level`, `account_id`, `firstlogon`, `lfg`, `lfp`, `mailkey`, `xtargets`, `inspectmessage`, `extprofile` FROM `character_` WHERE `id` = %i", Strings::ToInt(row[0]));
squery = StringFormat("SELECT `id`, `profile`, `name`, `level`, `account_id`, `firstlogon`, `lfg`, `lfp`, `mailkey`, `xtargets`, `inspectmessage`, `extprofile` FROM `character_` WHERE `id` = %i", Strings::ToUnsignedInt(row[0]));
auto results2 = QueryDatabase(squery);
auto row2 = results2.begin();
pp = (Convert::PlayerProfile_Struct*)row2[1];
e_pp = (ExtendedProfile_Struct*)row2[11];
character_id = Strings::ToInt(row[0]);
character_id = Strings::ToUnsignedInt(row[0]);
account_id = Strings::ToInt(row2[4]);
/* Convert some data from the character_ table that is still relevant */
firstlogon = Strings::ToUnsignedInt(row2[5]);
Expand Down
2 changes: 1 addition & 1 deletion common/events/player_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,7 @@ namespace PlayerEvent {
};

struct AAPurchasedEvent {
int32 aa_id;
uint32 aa_id;
int32 aa_cost;
int32 aa_previous_id;
int32 aa_next_id;
Expand Down
8 changes: 4 additions & 4 deletions common/shareddb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -964,10 +964,10 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_

// Flags
item.ArtifactFlag = Strings::ToBool(row[ItemField::artifactflag]);
item.Attuneable = !disable_attuneable && Strings::ToInt(row[ItemField::attuneable]) != 0;
item.BenefitFlag = Strings::ToBool(row[ItemField::benefitflag]) != 0;
item.FVNoDrop = Strings::ToInt(row[ItemField::fvnodrop]) != 0;
item.Magic = Strings::ToBool(row[ItemField::magic]) != 0;
item.Attuneable = !disable_attuneable && Strings::ToBool(row[ItemField::attuneable]);
item.BenefitFlag = Strings::ToBool(row[ItemField::benefitflag]);
item.FVNoDrop = Strings::ToBool(row[ItemField::fvnodrop]);
item.Magic = Strings::ToBool(row[ItemField::magic]);
item.NoDrop = disable_no_drop ? static_cast<uint8>(255) : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::nodrop]));
item.NoPet = !disable_no_pet && Strings::ToBool(row[ItemField::nopet]);
item.NoRent = disable_no_rent ? static_cast<uint8>(255) : static_cast<uint8>(Strings::ToUnsignedInt(row[ItemField::norent]));
Expand Down
10 changes: 5 additions & 5 deletions loginserver/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Database::Database(
user.c_str(),
pass.c_str(),
name.c_str(),
Strings::ToInt(port),
Strings::ToUnsignedInt(port),
&errnum,
errbuf
)
Expand Down Expand Up @@ -93,7 +93,7 @@ bool Database::GetLoginDataFromAccountInfo(

auto row = results.begin();

id = Strings::ToInt(row[0]);
id = Strings::ToUnsignedInt(row[0]);
password = row[1];

LogDebug(
Expand Down Expand Up @@ -145,7 +145,7 @@ bool Database::GetLoginTokenDataFromToken(
}

if (strcmp(row[2], "login_server_id") == 0) {
db_account_id = Strings::ToInt(row[3]);
db_account_id = Strings::ToUnsignedInt(row[3]);
found_login_id = true;
continue;
}
Expand Down Expand Up @@ -373,7 +373,7 @@ Database::DbWorldRegistration Database::GetWorldRegistration(
r.server_list_type = Strings::ToInt(row[3]);
r.is_server_trusted = Strings::ToInt(row[2]) > 0;
r.server_list_description = row[4];
r.server_admin_id = Strings::ToInt(row[5]);
r.server_admin_id = Strings::ToUnsignedInt(row[5]);

if (r.server_admin_id <= 0) {
return r;
Expand Down Expand Up @@ -513,7 +513,7 @@ bool Database::CreateWorldRegistration(

auto row = results.begin();

id = Strings::ToInt(row[0]);
id = Strings::ToUnsignedInt(row[0]);
auto insert_query = fmt::format(
"INSERT INTO login_world_servers SET id = {0}, long_name = '{1}', short_name = '{2}', last_ip_address = '{3}', \n"
"login_server_list_type_id = 3, login_server_admin_id = {4}, is_server_trusted = 0, tag_description = ''",
Expand Down
20 changes: 10 additions & 10 deletions zone/aa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1448,9 +1448,9 @@ bool ZoneDatabase::LoadAlternateAdvancement(Client *c) {

int i = 0;
for(auto row = results.begin(); row != results.end(); ++row) {
uint32 aa = Strings::ToInt(row[0]);
uint32 value = Strings::ToInt(row[1]);
uint32 charges = Strings::ToInt(row[2]);
uint32 aa = Strings::ToUnsignedInt(row[0]);
uint32 value = Strings::ToUnsignedInt(row[1]);
uint32 charges = Strings::ToUnsignedInt(row[2]);

auto rank = zone->GetAlternateAdvancementRank(aa);
if(!rank) {
Expand Down Expand Up @@ -1775,7 +1775,7 @@ 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 = Strings::ToInt(row[0]);
ability->id = Strings::ToUnsignedInt(row[0]);
ability->name = row[1];
ability->category = Strings::ToInt(row[2]);
//EQ client has classes left shifted by one bit for some odd reason
Expand All @@ -1786,8 +1786,8 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_map<int, std
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->grant_only = Strings::ToBool(row[10]);
ability->reset_on_death = Strings::ToBool(row[11]);
ability->first_rank_id = Strings::ToInt(row[12]);
ability->first = nullptr;

Expand All @@ -1814,7 +1814,7 @@ 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 = Strings::ToInt(row[0]);
rank->id = Strings::ToUnsignedInt(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]);
Expand Down Expand Up @@ -1846,8 +1846,8 @@ 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 = Strings::ToInt(row[0]);
effect.slot = Strings::ToInt(row[1]);
uint32 rank_id = Strings::ToUnsignedInt(row[0]);
effect.slot = Strings::ToUnsignedInt(row[1]);
effect.effect_id = Strings::ToInt(row[2]);
effect.base_value = Strings::ToInt(row[3]);
effect.limit_value = Strings::ToInt(row[4]);
Expand All @@ -1871,7 +1871,7 @@ 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 = Strings::ToInt(row[0]);
uint32 rank_id = Strings::ToUnsignedInt(row[0]);
int aa_id = Strings::ToInt(row[1]);
int points = Strings::ToInt(row[2]);

Expand Down
2 changes: 1 addition & 1 deletion zone/aa_ability.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class Ability
Rank *GetRankByPointsSpent(int current_level);
int GetMaxLevel(Mob *who);

int id;
uint32 id;
std::string name;
int category;
int classes;
Expand Down
2 changes: 1 addition & 1 deletion zone/aa_rank.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Rank
Rank() { }
~Rank() { }

int id;
uint32 id;
int upper_hotkey_sid;
int lower_hotkey_sid;
int title_sid;
Expand Down
2 changes: 1 addition & 1 deletion zone/aa_rank_effects.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ namespace AA

struct RankEffect
{
int slot;
uint32 slot;
int effect_id;
int base_value;
int limit_value;
Expand Down
4 changes: 2 additions & 2 deletions zone/bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3462,7 +3462,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {

if(item) {
if(strlen(item->IDFile) > 2)
ns->spawn.equipment.Primary.Material = Strings::ToInt(&item->IDFile[2]);
ns->spawn.equipment.Primary.Material = Strings::ToUnsignedInt(&item->IDFile[2]);


ns->spawn.equipment_tint.Primary.Color = GetEquipmentColor(EQ::textures::weaponPrimary);
Expand All @@ -3475,7 +3475,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) {

if(item) {
if(strlen(item->IDFile) > 2)
ns->spawn.equipment.Secondary.Material = Strings::ToInt(&item->IDFile[2]);
ns->spawn.equipment.Secondary.Material = Strings::ToUnsignedInt(&item->IDFile[2]);

ns->spawn.equipment_tint.Secondary.Color = GetEquipmentColor(EQ::textures::weaponSecondary);
}
Expand Down
2 changes: 1 addition & 1 deletion zone/zoning.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ bool Client::CanEnterZone(const std::string& zone_short_name, int16 instance_ver
return false;
}

if (!z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToInt(z->flag_needed) == 1) {
if (!z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToBool(z->flag_needed)) {
if (Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(z->zoneidnumber)) {
LogInfo(
"Character [{}] does not have the flag to be in this zone [{}]!",
Expand Down

0 comments on commit eb51550

Please sign in to comment.