diff --git a/client_files/export/main.cpp b/client_files/export/main.cpp index 67d19326f4..08e2037224 100644 --- a/client_files/export/main.cpp +++ b/client_files/export/main.cpp @@ -183,7 +183,7 @@ bool SkillUsable(SharedDatabase *db, int skill_id, int class_id) } auto row = results.begin(); - if (row[0] && atoi(row[0]) > 0) { + if (row[0] && Strings::ToInt(row[0]) > 0) { return true; } @@ -207,7 +207,7 @@ int GetSkill(SharedDatabase *db, int skill_id, int class_id, int level) } auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } void ExportSkillCaps(SharedDatabase *db) diff --git a/client_files/import/main.cpp b/client_files/import/main.cpp index 6e23821ab5..c1859be0e0 100644 --- a/client_files/import/main.cpp +++ b/client_files/import/main.cpp @@ -241,10 +241,10 @@ void ImportSkillCaps(SharedDatabase *db) { } int class_id, skill_id, level, cap; - class_id = atoi(split[0].c_str()); - skill_id = atoi(split[1].c_str()); - level = atoi(split[2].c_str()); - cap = atoi(split[3].c_str()); + class_id = Strings::ToInt(split[0].c_str()); + skill_id = Strings::ToInt(split[1].c_str()); + level = Strings::ToInt(split[2].c_str()); + cap = Strings::ToInt(split[3].c_str()); std::string sql = StringFormat("INSERT INTO skill_caps(class, skillID, level, cap) VALUES(%d, %d, %d, %d)", class_id, skill_id, level, cap); @@ -280,16 +280,16 @@ void ImportBaseData(SharedDatabase *db) { int level, class_id; double hp, mana, end, unk1, unk2, hp_fac, mana_fac, end_fac; - level = atoi(split[0].c_str()); - class_id = atoi(split[1].c_str()); - hp = atof(split[2].c_str()); - mana = atof(split[3].c_str()); - end = atof(split[4].c_str()); - unk1 = atof(split[5].c_str()); - unk2 = atof(split[6].c_str()); - hp_fac = atof(split[7].c_str()); - mana_fac = atof(split[8].c_str()); - end_fac = atof(split[9].c_str()); + level = Strings::ToInt(split[0].c_str()); + class_id = Strings::ToInt(split[1].c_str()); + hp = Strings::ToFloat(split[2].c_str()); + mana = Strings::ToFloat(split[3].c_str()); + end = Strings::ToFloat(split[4].c_str()); + unk1 = Strings::ToFloat(split[5].c_str()); + unk2 = Strings::ToFloat(split[6].c_str()); + hp_fac = Strings::ToFloat(split[7].c_str()); + mana_fac = Strings::ToFloat(split[8].c_str()); + end_fac = Strings::ToFloat(split[9].c_str()); sql = StringFormat("INSERT INTO base_data(level, class, hp, mana, end, unk1, unk2, hp_fac, " "mana_fac, end_fac) VALUES(%d, %d, %f, %f, %f, %f, %f, %f, %f, %f)", @@ -339,8 +339,8 @@ void ImportDBStrings(SharedDatabase *db) { int id, type; std::string value; - id = atoi(split[0].c_str()); - type = atoi(split[1].c_str()); + id = Strings::ToInt(split[0].c_str()); + type = Strings::ToInt(split[1].c_str()); if(split.size() >= 3) { value = ::Strings::Escape(split[2]); diff --git a/common/cron/croncpp.h b/common/cron/croncpp.h index 5a22a7f723..3034dc9523 100644 --- a/common/cron/croncpp.h +++ b/common/cron/croncpp.h @@ -313,7 +313,7 @@ namespace cron { try { - return static_cast(std::stoul(text.data())); + return static_cast(Strings::ToUnsignedInt(text.data())); } catch (std::exception const & ex) { diff --git a/common/database.cpp b/common/database.cpp index ff2f8aa89e..8b0cbb5764 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -121,10 +121,10 @@ uint32 Database::CheckLogin(const char* name, const char* password, const char * auto row = results.begin(); - auto id = std::stoul(row[0]); + auto id = Strings::ToUnsignedInt(row[0]); if (oStatus) { - *oStatus = std::stoi(row[1]); + *oStatus = Strings::ToInt(row[1]); } return id; @@ -202,11 +202,11 @@ int16 Database::CheckStatus(uint32 account_id) } auto row = results.begin(); - int16 status = std::stoi(row[0]); + int16 status = Strings::ToInt(row[0]); int32 date_diff = 0; if (row[1]) { - date_diff = std::stoi(row[1]); + date_diff = Strings::ToInt(row[1]); } if (date_diff > 0) { @@ -345,7 +345,7 @@ bool Database::ReserveName(uint32 account_id, char* name) { std::string query = StringFormat("SELECT `account_id`, `name` FROM `character_data` WHERE `name` = '%s'", name); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - if (row[0] && atoi(row[0]) > 0){ + if (row[0] && Strings::ToInt(row[0]) > 0){ LogInfo("Account: [{}] tried to request name: [{}], but it is already taken", account_id, name); return false; } @@ -396,7 +396,7 @@ bool Database::DeleteCharacter(char *character_name) std::string query = StringFormat("SELECT `id` from `character_data` WHERE `name` = '%s'", character_name); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - character_id = atoi(row[0]); + character_id = Strings::ToInt(row[0]); } if (character_id <= 0) { @@ -820,7 +820,7 @@ uint32 Database::GetCharacterID(const char *name) { auto row = results.begin(); if (results.RowCount() == 1) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -845,10 +845,10 @@ uint32 Database::GetAccountIDByChar(const char* charname, uint32* oCharID) { auto row = results.begin(); - uint32 accountId = atoi(row[0]); + uint32 accountId = Strings::ToInt(row[0]); if (oCharID) - *oCharID = atoi(row[1]); + *oCharID = Strings::ToInt(row[1]); return accountId; } @@ -865,7 +865,7 @@ uint32 Database::GetAccountIDByChar(uint32 char_id) { return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint32 Database::GetAccountIDByName(std::string account_name, std::string loginserver, int16* status, uint32* lsid) { @@ -885,14 +885,14 @@ uint32 Database::GetAccountIDByName(std::string account_name, std::string logins } auto row = results.begin(); - auto account_id = std::stoul(row[0]); + auto account_id = Strings::ToUnsignedInt(row[0]); if (status) { - *status = static_cast(std::stoi(row[1])); + *status = static_cast(Strings::ToInt(row[1])); } if (lsid) { - *lsid = row[2] ? std::stoul(row[2]) : 0; + *lsid = row[2] ? Strings::ToUnsignedInt(row[2]) : 0; } return account_id; @@ -913,7 +913,7 @@ void Database::GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID strcpy(name, row[0]); if (row[1] && oLSAccountID) { - *oLSAccountID = atoi(row[1]); + *oLSAccountID = Strings::ToInt(row[1]); } } @@ -1001,7 +1001,7 @@ bool Database::LoadVariables() { std::string key, value; for (auto row = results.begin(); row != results.end(); ++row) { - varcache.last_update = atoi(row[2]); // ahh should we be comparing if this is newer? + varcache.last_update = Strings::ToInt(row[2]); // ahh should we be comparing if this is newer? key = row[0]; value = row[1]; std::transform(std::begin(key), std::end(key), std::begin(key), ::tolower); // keys are lower case, DB doesn't have to be @@ -1085,15 +1085,15 @@ bool Database::GetZoneGraveyard(const uint32 graveyard_id, uint32* graveyard_zon auto row = results.begin(); if(graveyard_zoneid != nullptr) - *graveyard_zoneid = atoi(row[0]); + *graveyard_zoneid = Strings::ToInt(row[0]); if(graveyard_x != nullptr) - *graveyard_x = atof(row[1]); + *graveyard_x = Strings::ToFloat(row[1]); if(graveyard_y != nullptr) - *graveyard_y = atof(row[2]); + *graveyard_y = Strings::ToFloat(row[2]); if(graveyard_z != nullptr) - *graveyard_z = atof(row[3]); + *graveyard_z = Strings::ToFloat(row[3]); if(graveyard_heading != nullptr) - *graveyard_heading = atof(row[4]); + *graveyard_heading = Strings::ToFloat(row[4]); return true; } @@ -1201,13 +1201,13 @@ uint32 Database::GetAccountIDFromLSID( } for (auto row = results.begin(); row != results.end(); ++row) { - account_id = std::stoi(row[0]); + account_id = Strings::ToInt(row[0]); if (in_account_name) { strcpy(in_account_name, row[1]); } if (in_status) { - *in_status = std::stoi(row[2]); + *in_status = Strings::ToInt(row[2]); } } @@ -1231,7 +1231,7 @@ void Database::GetAccountFromID(uint32 id, char* oAccountName, int16* oStatus) { if (oAccountName) strcpy(oAccountName, row[0]); if (oStatus) - *oStatus = atoi(row[1]); + *oStatus = Strings::ToInt(row[1]); } void Database::ClearMerchantTemp(){ @@ -1277,7 +1277,7 @@ uint8 Database::GetServerType() { return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool Database::MoveCharacterToZone(uint32 character_id, uint32 zone_id) @@ -1329,7 +1329,7 @@ uint8 Database::GetRaceSkill(uint8 skillid, uint8 in_race) return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 in_level) @@ -1345,12 +1345,12 @@ uint8 Database::GetSkillCap(uint8 skillid, uint8 in_race, uint8 in_class, uint16 if (results.Success() && results.RowsAffected() != 0) { auto row = results.begin(); - skill_level = atoi(row[0]); - skill_formula = atoi(row[1]); - skill_cap = atoi(row[2]); - if (atoi(row[3]) > skill_cap) - skill_cap2 = (atoi(row[3])-skill_cap)/10; //Split the post-50 skill cap into difference between pre-50 cap and post-50 cap / 10 to determine amount of points per level. - skill_cap3 = atoi(row[4]); + skill_level = Strings::ToInt(row[0]); + skill_formula = Strings::ToInt(row[1]); + skill_cap = Strings::ToInt(row[2]); + if (Strings::ToInt(row[3]) > skill_cap) + skill_cap2 = (Strings::ToInt(row[3])-skill_cap)/10; //Split the post-50 skill cap into difference between pre-50 cap and post-50 cap / 10 to determine amount of points per level. + skill_cap3 = Strings::ToInt(row[4]); } int race_skill = GetRaceSkill(skillid,in_race); @@ -1395,10 +1395,10 @@ uint32 Database::GetCharacterInfo(std::string character_name, uint32 *account_id } auto row = results.begin(); - auto character_id = std::stoul(row[0]); - *account_id = std::stoul(row[1]); - *zone_id = std::stoul(row[2]); - *instance_id = std::stoul(row[3]); + auto character_id = Strings::ToUnsignedInt(row[0]); + *account_id = Strings::ToUnsignedInt(row[1]); + *zone_id = Strings::ToUnsignedInt(row[2]); + *instance_id = Strings::ToUnsignedInt(row[3]); return character_id; } @@ -1521,7 +1521,7 @@ uint32 Database::GetGroupID(const char* name){ auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } std::string Database::GetGroupLeaderForLogin(std::string character_name) { @@ -1535,7 +1535,7 @@ std::string Database::GetGroupLeaderForLogin(std::string character_name) { if (results.Success() && results.RowCount()) { auto row = results.begin(); - group_id = std::stoul(row[0]); + group_id = Strings::ToUnsignedInt(row[0]); } if (!group_id) { @@ -1624,7 +1624,7 @@ char *Database::GetGroupLeadershipInfo(uint32 gid, char* leaderbuf, char* mainta strcpy(mentoree, row[5]); if (mentor_percent) - *mentor_percent = atoi(row[6]); + *mentor_percent = Strings::ToInt(row[6]); if(GLAA && results.LengthOfColumn(7) == sizeof(GroupLeadershipAA_Struct)) memcpy(GLAA, row[7], sizeof(GroupLeadershipAA_Struct)); @@ -1671,7 +1671,7 @@ uint8 Database::GetAgreementFlag(uint32 acctid) { auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } void Database::SetAgreementFlag(uint32 acctid) { @@ -1757,7 +1757,7 @@ uint32 Database::GetRaidID(const char* name) } if (row[0]) // would it ever be possible to have a null here? - return atoi(row[0]); + return Strings::ToInt(row[0]); return 0; } @@ -1840,7 +1840,7 @@ void Database::GetGroupLeadershipInfo(uint32 gid, uint32 rid, char *maintank, strcpy(mentoree, row[4]); if (mentor_percent) - *mentor_percent = atoi(row[5]); + *mentor_percent = Strings::ToInt(row[5]); if (GLAA && results.LengthOfColumn(6) == sizeof(GroupLeadershipAA_Struct)) memcpy(GLAA, row[6], sizeof(GroupLeadershipAA_Struct)); @@ -2013,16 +2013,16 @@ bool Database::GetAdventureStats(uint32 char_id, AdventureStats_Struct *as) auto row = results.begin(); - as->success.guk = atoi(row[0]); - as->success.mir = atoi(row[1]); - as->success.mmc = atoi(row[2]); - as->success.ruj = atoi(row[3]); - as->success.tak = atoi(row[4]); - as->failure.guk = atoi(row[5]); - as->failure.mir = atoi(row[6]); - as->failure.mmc = atoi(row[7]); - as->failure.ruj = atoi(row[8]); - as->failure.tak = atoi(row[9]); + as->success.guk = Strings::ToInt(row[0]); + as->success.mir = Strings::ToInt(row[1]); + as->success.mmc = Strings::ToInt(row[2]); + as->success.ruj = Strings::ToInt(row[3]); + as->success.tak = Strings::ToInt(row[4]); + as->failure.guk = Strings::ToInt(row[5]); + as->failure.mir = Strings::ToInt(row[6]); + as->failure.mmc = Strings::ToInt(row[7]); + as->failure.ruj = Strings::ToInt(row[8]); + as->failure.tak = Strings::ToInt(row[9]); as->failure.total = as->failure.guk + as->failure.mir + as->failure.mmc + as->failure.ruj + as->failure.tak; as->success.total = as->success.guk + as->success.mir + as->success.mmc + as->success.ruj + as->success.tak; @@ -2041,7 +2041,7 @@ uint32 Database::GetGuildIDByCharID(uint32 character_id) return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint32 Database::GetGroupIDByCharID(uint32 character_id) @@ -2063,7 +2063,7 @@ uint32 Database::GetGroupIDByCharID(uint32 character_id) return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint32 Database::GetRaidIDByCharID(uint32 character_id) { @@ -2077,7 +2077,7 @@ uint32 Database::GetRaidIDByCharID(uint32 character_id) { ); auto results = QueryDatabase(query); for (auto row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -2091,7 +2091,7 @@ int Database::CountInvSnapshots() { auto row = results.begin(); - int64 count = atoll(row[0]); + int64 count = Strings::ToBigInt(row[0]); if (count > 2147483647) return -2; if (count < 0) @@ -2127,12 +2127,12 @@ struct TimeOfDay_Struct Database::LoadTime(time_t &realtime) else{ auto row = results.begin(); - eqTime.minute = atoi(row[0]); - eqTime.hour = atoi(row[1]); - eqTime.day = atoi(row[2]); - eqTime.month = atoi(row[3]); - eqTime.year = atoi(row[4]); - realtime = atoi(row[5]); + eqTime.minute = Strings::ToInt(row[0]); + eqTime.hour = Strings::ToInt(row[1]); + eqTime.day = Strings::ToInt(row[2]); + eqTime.month = Strings::ToInt(row[3]); + eqTime.year = Strings::ToInt(row[4]); + realtime = Strings::ToInt(row[5]); } return eqTime; @@ -2159,7 +2159,7 @@ int Database::GetIPExemption(std::string account_ip) { } auto row = results.begin(); - return std::stoi(row[0]); + return Strings::ToInt(row[0]); } void Database::SetIPExemption(std::string account_ip, int exemption_amount) { @@ -2173,7 +2173,7 @@ void Database::SetIPExemption(std::string account_ip, int exemption_amount) { auto results = QueryDatabase(query); if (results.Success() && results.RowCount()) { auto row = results.begin(); - exemption_id = std::stoul(row[0]); + exemption_id = Strings::ToUnsignedInt(row[0]); } query = fmt::format( @@ -2199,7 +2199,7 @@ int Database::GetInstanceID(uint32 char_id, uint32 zone_id) { if (results.Success() && results.RowCount() > 0) { auto row = results.begin(); - return atoi(row[0]);; + return Strings::ToInt(row[0]);; } return 0; diff --git a/common/database.h b/common/database.h index 2f08037204..10120c109e 100644 --- a/common/database.h +++ b/common/database.h @@ -34,8 +34,6 @@ #include #include -//atoi is not uint32 or uint32 safe!!!! -#define atoul(str) strtoul(str, nullptr, 10) class MySQLRequestResult; class Client; diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index 8e212eeec2..15ba384ebf 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -538,7 +538,7 @@ bool Database::CheckDatabaseConvertPPDeblob(){ rquery = StringFormat("SELECT COUNT(`id`) FROM `character_`"); results = QueryDatabase(rquery); for (auto row = results.begin(); row != results.end(); ++row) { - number_of_characters = atoi(row[0]); + number_of_characters = Strings::ToInt(row[0]); printf("Number of Characters in Database: %i \n", number_of_characters); } @@ -945,19 +945,19 @@ 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", atoi(row[0])); + 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])); auto results2 = QueryDatabase(squery); auto row2 = results2.begin(); pp = (Convert::PlayerProfile_Struct*)row2[1]; e_pp = (ExtendedProfile_Struct*)row2[11]; - character_id = atoi(row[0]); - account_id = atoi(row2[4]); + character_id = Strings::ToInt(row[0]); + account_id = Strings::ToInt(row2[4]); /* Convert some data from the character_ table that is still relevant */ - firstlogon = atoi(row2[5]); - lfg = atoi(row2[6]); - lfp = atoi(row2[7]); + firstlogon = Strings::ToInt(row2[5]); + lfg = Strings::ToInt(row2[6]); + lfp = Strings::ToInt(row2[7]); mailkey = row2[8]; - xtargets = atoi(row2[9]); + xtargets = Strings::ToInt(row2[9]); inspectmessage = row2[10]; /* Verify PP Integrity */ @@ -1607,7 +1607,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ rquery = StringFormat("SELECT DISTINCT charid FROM character_corpses"); results = QueryDatabase(rquery); for (auto row = results.begin(); row != results.end(); ++row) { - std::string squery = StringFormat("SELECT id, charname, data, time_of_death, is_rezzed FROM character_corpses WHERE `charid` = %i", atoi(row[0])); + std::string squery = StringFormat("SELECT id, charname, data, time_of_death, is_rezzed FROM character_corpses WHERE `charid` = %i", Strings::ToInt(row[0])); auto results2 = QueryDatabase(squery); for (auto row2 = results2.begin(); row2 != results2.end(); ++row2) { in_datasize = results2.LengthOfColumn(2); @@ -1639,7 +1639,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ c_type = "NULL"; continue; } - std::cout << "Converting Corpse: [OK] [" << c_type << "]: " << "ID: " << atoi(row2[0]) << std::endl; + std::cout << "Converting Corpse: [OK] [" << c_type << "]: " << "ID: " << Strings::ToInt(row2[0]) << std::endl; if (is_sof){ scquery = StringFormat("UPDATE `character_corpses` SET \n" @@ -1710,7 +1710,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ dbpc->item_tint[6].color, dbpc->item_tint[7].color, dbpc->item_tint[8].color, - atoi(row2[0]) + Strings::ToInt(row2[0]) ); if (scquery != ""){ auto sc_results = QueryDatabase(scquery); } @@ -1722,7 +1722,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ scquery = StringFormat("REPLACE INTO `character_corpse_items` \n" " (corpse_id, equip_slot, item_id, charges, aug_1, aug_2, aug_3, aug_4, aug_5, aug_6, attuned) \n" " VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u) \n", - atoi(row2[0]), + Strings::ToInt(row2[0]), dbpc->items[i].equipSlot, dbpc->items[i].item_id, dbpc->items[i].charges, @@ -1738,7 +1738,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ } else{ scquery = scquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u) \n", - atoi(row2[0]), + Strings::ToInt(row2[0]), dbpc->items[i].equipSlot, dbpc->items[i].item_id, dbpc->items[i].charges, @@ -1818,7 +1818,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ dbpc_c->item_tint[6].color, dbpc_c->item_tint[7].color, dbpc_c->item_tint[8].color, - atoi(row2[0]) + Strings::ToInt(row2[0]) ); if (scquery != ""){ auto sc_results = QueryDatabase(scquery); } @@ -1831,7 +1831,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ scquery = StringFormat("REPLACE INTO `character_corpse_items` \n" " (corpse_id, equip_slot, item_id, charges, aug_1, aug_2, aug_3, aug_4, aug_5, aug_6, attuned) \n" " VALUES (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u) \n", - atoi(row2[0]), + Strings::ToInt(row2[0]), dbpc_c->items[i].equipSlot, dbpc_c->items[i].item_id, dbpc_c->items[i].charges, @@ -1847,7 +1847,7 @@ bool Database::CheckDatabaseConvertCorpseDeblob(){ } else{ scquery = scquery + StringFormat(", (%u, %u, %u, %u, %u, %u, %u, %u, %u, %u, %u) \n", - atoi(row2[0]), + Strings::ToInt(row2[0]), dbpc_c->items[i].equipSlot, dbpc_c->items[i].item_id, dbpc_c->items[i].charges, diff --git a/common/database_instances.cpp b/common/database_instances.cpp index f9e4f7c911..36e6a78937 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -167,8 +167,8 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id) auto row = results.begin(); - if (atoi(row[0]) <= max) { - instance_id = atoi(row[0]); + if (Strings::ToInt(row[0]) <= max) { + instance_id = Strings::ToInt(row[0]); return true; } @@ -194,7 +194,7 @@ bool Database::GetUnusedInstanceID(uint16 &instance_id) max_reserved_instance_id++; for (auto row : results) { - if (max_reserved_instance_id < std::stoul(row[0])) { + if (max_reserved_instance_id < Strings::ToUnsignedInt(row[0])) { instance_id = max_reserved_instance_id; return true; } @@ -301,7 +301,7 @@ uint16 Database::GetInstanceID(uint32 zone_id, uint32 character_id, int16 versio auto row = results.begin(); - return static_cast(std::stoul(row[0])); + return static_cast(Strings::ToUnsignedInt(row[0])); } std::vector Database::GetInstanceIDs(uint32 zone_id, uint32 character_id) @@ -328,7 +328,7 @@ std::vector Database::GetInstanceIDs(uint32 zone_id, uint32 character_id } for (auto row : results) { - l.push_back(static_cast(std::stoul(row[0]))); + l.push_back(static_cast(Strings::ToUnsignedInt(row[0]))); } return l; diff --git a/common/discord/discord.cpp b/common/discord/discord.cpp index 2ba584503e..e063110352 100644 --- a/common/discord/discord.cpp +++ b/common/discord/discord.cpp @@ -57,7 +57,7 @@ void Discord::SendWebhookMessage(const std::string &message, const std::string & LogDiscord("JSON serialization failure [{}] via [{}]", ex.what(), res->body); } - retry_timer = std::stoi(response["retry_after"].asString()) + 500; + retry_timer = Strings::ToInt(response["retry_after"].asString()) + 500; } LogDiscord("Rate limited... retrying message in [{}ms]", retry_timer); @@ -125,7 +125,7 @@ void Discord::SendPlayerEventMessage( LogDiscord("JSON serialization failure [{}] via [{}]", ex.what(), res->body); } - retry_timer = std::stoi(response["retry_after"].asString()) + 500; + retry_timer = Strings::ToInt(response["retry_after"].asString()) + 500; } LogDiscord("Rate limited... retrying message in [{}ms]", retry_timer); diff --git a/common/eqemu_config.cpp b/common/eqemu_config.cpp index 85161ba8ac..b258be2e3d 100644 --- a/common/eqemu_config.cpp +++ b/common/eqemu_config.cpp @@ -19,6 +19,7 @@ #include "../common/global_define.h" #include "eqemu_config.h" #include "misc_functions.h" +#include "strings.h" #include #include @@ -33,13 +34,13 @@ void EQEmuConfig::parse_config() LongName = _root["server"]["world"].get("longname", "").asString(); WorldAddress = _root["server"]["world"].get("address", "").asString(); LocalAddress = _root["server"]["world"].get("localaddress", "").asString(); - MaxClients = atoi(_root["server"]["world"].get("maxclients", "-1").asString().c_str()); + MaxClients = Strings::ToInt(_root["server"]["world"].get("maxclients", "-1").asString().c_str()); SharedKey = _root["server"]["world"].get("key", "").asString(); LoginCount = 0; if (_root["server"]["world"]["loginserver"].isObject()) { LoginHost = _root["server"]["world"]["loginserver"].get("host", "login.eqemulator.net").asString(); - LoginPort = atoi(_root["server"]["world"]["loginserver"].get("port", "5998").asString().c_str()); + LoginPort = Strings::ToInt(_root["server"]["world"]["loginserver"].get("port", "5998").asString().c_str()); LoginLegacy = false; if (_root["server"]["world"]["loginserver"].get("legacy", "0").asString() == "1") { LoginLegacy = true; } LoginAccount = _root["server"]["world"]["loginserver"].get("account", "").asString(); @@ -62,7 +63,7 @@ void EQEmuConfig::parse_config() auto loginconfig = new LoginConfig; loginconfig->LoginHost = _root["server"]["world"][str].get("host", "login.eqemulator.net").asString(); - loginconfig->LoginPort = atoi(_root["server"]["world"][str].get("port", "5998").asString().c_str()); + loginconfig->LoginPort = Strings::ToInt(_root["server"]["world"][str].get("port", "5998").asString().c_str()); loginconfig->LoginAccount = _root["server"]["world"][str].get("account", "").asString(); loginconfig->LoginPassword = _root["server"]["world"][str].get("password", "").asString(); @@ -85,15 +86,15 @@ void EQEmuConfig::parse_config() Locked = false; if (_root["server"]["world"].get("locked", "false").asString() == "true") { Locked = true; } WorldIP = _root["server"]["world"]["tcp"].get("host", "127.0.0.1").asString(); - WorldTCPPort = atoi(_root["server"]["world"]["tcp"].get("port", "9000").asString().c_str()); + WorldTCPPort = Strings::ToInt(_root["server"]["world"]["tcp"].get("port", "9000").asString().c_str()); TelnetIP = _root["server"]["world"]["telnet"].get("ip", "127.0.0.1").asString(); - TelnetTCPPort = atoi(_root["server"]["world"]["telnet"].get("port", "9001").asString().c_str()); + TelnetTCPPort = Strings::ToInt(_root["server"]["world"]["telnet"].get("port", "9001").asString().c_str()); TelnetEnabled = false; if (_root["server"]["world"]["telnet"].get("enabled", "false").asString() == "true") { TelnetEnabled = true; } WorldHTTPMimeFile = _root["server"]["world"]["http"].get("mimefile", "mime.types").asString(); - WorldHTTPPort = atoi(_root["server"]["world"]["http"].get("port", "9080").asString().c_str()); + WorldHTTPPort = Strings::ToInt(_root["server"]["world"]["http"].get("port", "9080").asString().c_str()); WorldHTTPEnabled = false; if (_root["server"]["world"]["http"].get("enabled", "false").asString() == "true") { @@ -108,9 +109,9 @@ void EQEmuConfig::parse_config() * UCS */ ChatHost = _root["server"]["chatserver"].get("host", "eqchat.eqemulator.net").asString(); - ChatPort = atoi(_root["server"]["chatserver"].get("port", "7778").asString().c_str()); + ChatPort = Strings::ToInt(_root["server"]["chatserver"].get("port", "7778").asString().c_str()); MailHost = _root["server"]["mailserver"].get("host", "eqmail.eqemulator.net").asString(); - MailPort = atoi(_root["server"]["mailserver"].get("port", "7778").asString().c_str()); + MailPort = Strings::ToInt(_root["server"]["mailserver"].get("port", "7778").asString().c_str()); /** * Database @@ -118,7 +119,7 @@ void EQEmuConfig::parse_config() DatabaseUsername = _root["server"]["database"].get("username", "eq").asString(); DatabasePassword = _root["server"]["database"].get("password", "eq").asString(); DatabaseHost = _root["server"]["database"].get("host", "localhost").asString(); - DatabasePort = atoi(_root["server"]["database"].get("port", "3306").asString().c_str()); + DatabasePort = Strings::ToInt(_root["server"]["database"].get("port", "3306").asString().c_str()); DatabaseDB = _root["server"]["database"].get("db", "eq").asString(); /** @@ -127,14 +128,14 @@ void EQEmuConfig::parse_config() ContentDbUsername = _root["server"]["content_database"].get("username", "").asString(); ContentDbPassword = _root["server"]["content_database"].get("password", "").asString(); ContentDbHost = _root["server"]["content_database"].get("host", "").asString(); - ContentDbPort = atoi(_root["server"]["content_database"].get("port", 0).asString().c_str()); + ContentDbPort = Strings::ToInt(_root["server"]["content_database"].get("port", 0).asString().c_str()); ContentDbName = _root["server"]["content_database"].get("db", "").asString(); /** * QS */ QSDatabaseHost = _root["server"]["qsdatabase"].get("host", "localhost").asString(); - QSDatabasePort = atoi(_root["server"]["qsdatabase"].get("port", "3306").asString().c_str()); + QSDatabasePort = Strings::ToInt(_root["server"]["qsdatabase"].get("port", "3306").asString().c_str()); QSDatabaseUsername = _root["server"]["qsdatabase"].get("username", "eq").asString(); QSDatabasePassword = _root["server"]["qsdatabase"].get("password", "eq").asString(); QSDatabaseDB = _root["server"]["qsdatabase"].get("db", "eq").asString(); @@ -142,9 +143,9 @@ void EQEmuConfig::parse_config() /** * Zones */ - DefaultStatus = atoi(_root["server"]["zones"].get("defaultstatus", 0).asString().c_str()); - ZonePortLow = atoi(_root["server"]["zones"]["ports"].get("low", "7000").asString().c_str()); - ZonePortHigh = atoi(_root["server"]["zones"]["ports"].get("high", "7999").asString().c_str()); + DefaultStatus = Strings::ToInt(_root["server"]["zones"].get("defaultstatus", 0).asString().c_str()); + ZonePortLow = Strings::ToInt(_root["server"]["zones"]["ports"].get("low", "7000").asString().c_str()); + ZonePortHigh = Strings::ToInt(_root["server"]["zones"]["ports"].get("high", "7999").asString().c_str()); /** * Files @@ -174,10 +175,10 @@ void EQEmuConfig::parse_config() /** * Launcher */ - RestartWait = atoi(_root["server"]["launcher"]["timers"].get("restart", "10000").asString().c_str()); - TerminateWait = atoi(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str()); - InitialBootWait = atoi(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str()); - ZoneBootInterval = atoi(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str()); + RestartWait = Strings::ToInt(_root["server"]["launcher"]["timers"].get("restart", "10000").asString().c_str()); + TerminateWait = Strings::ToInt(_root["server"]["launcher"]["timers"].get("reterminate", "10000").asString().c_str()); + InitialBootWait = Strings::ToInt(_root["server"]["launcher"]["timers"].get("initial", "20000").asString().c_str()); + ZoneBootInterval = Strings::ToInt(_root["server"]["launcher"]["timers"].get("interval", "2000").asString().c_str()); #ifdef WIN32 ZoneExe = _root["server"]["launcher"].get("exe", "zone.exe").asString(); #else diff --git a/common/guild_base.cpp b/common/guild_base.cpp index 07322f9e18..911f286513 100644 --- a/common/guild_base.cpp +++ b/common/guild_base.cpp @@ -61,7 +61,7 @@ bool BaseGuildManager::LoadGuilds() { } for (auto row=results.begin();row!=results.end();++row) - _CreateGuild(atoi(row[0]), row[1], atoi(row[2]), atoi(row[3]), row[4], row[5], row[6], row[7]); + _CreateGuild(Strings::ToInt(row[0]), row[1], Strings::ToInt(row[2]), Strings::ToInt(row[3]), row[4], row[5], row[6], row[7]); LogInfo("Loaded [{}] Guilds", Strings::Commify(std::to_string(results.RowCount()))); @@ -75,8 +75,8 @@ bool BaseGuildManager::LoadGuilds() { for (auto row=results.begin();row!=results.end();++row) { - uint32 guild_id = atoi(row[0]); - uint8 rankn = atoi(row[1]); + uint32 guild_id = Strings::ToInt(row[0]); + uint8 rankn = Strings::ToInt(row[1]); if(rankn > GUILD_MAX_RANK) { LogGuilds("Found invalid (too high) rank [{}] for guild [{}], skipping", rankn, guild_id); @@ -131,7 +131,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { auto row = results.begin(); - info = _CreateGuild(guild_id, row[0], atoi(row[1]), atoi(row[2]), row[3], row[4], row[5], row[6]); + info = _CreateGuild(guild_id, row[0], Strings::ToInt(row[1]), Strings::ToInt(row[2]), row[3], row[4], row[5], row[6]); query = StringFormat("SELECT guild_id, `rank`, title, can_hear, can_speak, can_invite, can_remove, can_promote, can_demote, can_motd, can_warpeace " "FROM guild_ranks WHERE guild_id=%lu", (unsigned long)guild_id); @@ -144,7 +144,7 @@ bool BaseGuildManager::RefreshGuild(uint32 guild_id) { for (auto row=results.begin();row!=results.end();++row) { - uint8 rankn = atoi(row[1]); + uint8 rankn = Strings::ToInt(row[1]); if(rankn > GUILD_MAX_RANK) { LogGuilds("Found invalid (too high) rank [{}] for guild [{}], skipping", rankn, guild_id); @@ -787,7 +787,7 @@ bool BaseGuildManager::GetBankerFlag(uint32 CharID) auto row = results.begin(); - bool IsBanker = atoi(row[0]); + bool IsBanker = Strings::ToInt(row[0]); return IsBanker; } @@ -817,7 +817,7 @@ bool BaseGuildManager::GetAltFlag(uint32 CharID) auto row = results.begin(); - bool IsAlt = atoi(row[0]); + bool IsAlt = Strings::ToInt(row[0]); return IsAlt; } @@ -873,19 +873,19 @@ bool BaseGuildManager::QueryWithLogging(std::string query, const char *errmsg) { " FROM `character_data` AS c LEFT JOIN `guild_members` AS g ON c.`id` = g.`char_id` " static void ProcessGuildMember(MySQLRequestRow row, CharGuildInfo &into) { //fields from `characer_` - into.char_id = atoi(row[0]); + into.char_id = Strings::ToInt(row[0]); into.char_name = row[1]; - into.class_ = atoi(row[2]); - into.level = atoi(row[3]); - into.time_last_on = atoul(row[4]); - into.zone_id = atoi(row[5]); + into.class_ = Strings::ToInt(row[2]); + into.level = Strings::ToInt(row[3]); + into.time_last_on = Strings::ToUnsignedInt(row[4]); + into.zone_id = Strings::ToInt(row[5]); //fields from `guild_members`, leave at defaults if missing - into.guild_id = row[6] ? atoi(row[6]) : GUILD_NONE; - into.rank = row[7] ? atoi(row[7]) : (GUILD_MAX_RANK+1); + into.guild_id = row[6] ? Strings::ToInt(row[6]) : GUILD_NONE; + into.rank = row[7] ? Strings::ToInt(row[7]) : (GUILD_MAX_RANK+1); into.tribute_enable = row[8] ? (row[8][0] == '0'?false:true) : false; - into.total_tribute = row[9] ? atoi(row[9]) : 0; - into.last_tribute = row[10]? atoul(row[10]) : 0; //timestamp + into.total_tribute = row[9] ? Strings::ToInt(row[9]) : 0; + into.last_tribute = row[10]? Strings::ToUnsignedInt(row[10]) : 0; //timestamp into.banker = row[11]? (row[11][0] == '0'?false:true) : false; into.public_note = row[12]? row[12] : ""; into.alt = row[13]? (row[13][0] == '0'?false:true) : false; @@ -1258,7 +1258,7 @@ uint32 BaseGuildManager::GetGuildIDByCharacterID(uint32 character_id) } auto row = results.begin(); - auto guild_id = std::stoul(row[0]); + auto guild_id = Strings::ToUnsignedInt(row[0]); return guild_id; } diff --git a/common/http/httplib.h b/common/http/httplib.h index e0cae6b722..e212eb09e8 100644 --- a/common/http/httplib.h +++ b/common/http/httplib.h @@ -272,6 +272,8 @@ inline const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1) { #include #endif +#include "../strings.h" + /* * Declaration */ @@ -3812,12 +3814,12 @@ inline bool brotli_decompressor::decompress(const char *data, if (std::regex_match(b, e, cm, re_another_range)) { ssize_t first = -1; if (!cm.str(1).empty()) { - first = static_cast(std::stoll(cm.str(1))); + first = static_cast(Strings::ToBigInt(cm.str(1))); } ssize_t last = -1; if (!cm.str(2).empty()) { - last = static_cast(std::stoll(cm.str(2))); + last = static_cast(Strings::ToBigInt(cm.str(2))); } if (first != -1 && last != -1 && first > last) { diff --git a/common/item_instance.cpp b/common/item_instance.cpp index 6dda479785..319e37ad29 100644 --- a/common/item_instance.cpp +++ b/common/item_instance.cpp @@ -610,7 +610,7 @@ bool EQ::ItemInstance::UpdateOrnamentationInfo() { SetOrnamentHeroModel(ornamentItem->HerosForgeModel); if (strlen(ornamentItem->IDFile) > 2) { - SetOrnamentationIDFile(atoi(&ornamentItem->IDFile[2])); + SetOrnamentationIDFile(Strings::ToInt(&ornamentItem->IDFile[2])); } else { diff --git a/common/misc.cpp b/common/misc.cpp index b9dc31d286..61f21a589a 100644 --- a/common/misc.cpp +++ b/common/misc.cpp @@ -18,6 +18,7 @@ #include "misc.h" #include "types.h" #include +#include "strings.h" std::map DBFieldNames; @@ -150,7 +151,7 @@ static char *temp=nullptr; return false; } ptr++; - uint32 id = atoi(field[id_pos].c_str()); + uint32 id = Strings::ToInt(field[id_pos].c_str()); items[id]=field; for(i=0;i<10;i++) { diff --git a/common/misc_functions.cpp b/common/misc_functions.cpp index a85ca9c2bb..5c1584193a 100644 --- a/common/misc_functions.cpp +++ b/common/misc_functions.cpp @@ -21,6 +21,7 @@ #include "misc_functions.h" #include #include +#include "strings.h" #ifndef WIN32 #include @@ -130,7 +131,7 @@ bool ParseAddress(const char* iAddress, uint32* oIP, uint16* oPort, char* errbuf if (*oIP == 0) return false; if (oPort) - *oPort = atoi(sep.arg[1]); + *oPort = Strings::ToInt(sep.arg[1]); return true; } return false; diff --git a/common/patches/sof.cpp b/common/patches/sof.cpp index a1ae185053..693b6b46b6 100644 --- a/common/patches/sof.cpp +++ b/common/patches/sof.cpp @@ -2095,13 +2095,13 @@ namespace SoF } else { - val = atoi(&emu->lastName[2]); + val = Strings::ToInt(&emu->lastName[2]); } } else { sep[0] = nullptr; - ofs = atoi(&emu->lastName[2]); + ofs = Strings::ToInt(&emu->lastName[2]); sep[0] = '='; if ((sep[1] < '0') || (sep[1] > '9')) { @@ -2109,7 +2109,7 @@ namespace SoF } else { - val = atoi(&sep[1]); + val = Strings::ToInt(&sep[1]); } } diff --git a/common/ptimer.cpp b/common/ptimer.cpp index e5e5f438e3..437f82f864 100644 --- a/common/ptimer.cpp +++ b/common/ptimer.cpp @@ -288,7 +288,7 @@ bool PTimerList::Load(Database *db) { PersistentTimer *cur; for (auto row = results.begin(); row != results.end(); ++row) { - type = atoi(row[0]); + type = Strings::ToInt(row[0]); start_time = strtoul(row[1], nullptr, 10); timer_time = strtoul(row[2], nullptr, 10); enabled = (row[3][0] == '1'); diff --git a/common/rulesys.cpp b/common/rulesys.cpp index 60970a52f4..639df7e487 100644 --- a/common/rulesys.cpp +++ b/common/rulesys.cpp @@ -141,11 +141,11 @@ bool RuleManager::SetRule(const std::string &rule_name, const std::string &rule_ switch (type) { case IntRule: - m_RuleIntValues[index] = atoi(rule_value.c_str()); + m_RuleIntValues[index] = Strings::ToInt(rule_value.c_str()); LogRules("Set rule [{}] to value [{}]", rule_name, m_RuleIntValues[index]); break; case RealRule: - m_RuleRealValues[index] = atof(rule_value.c_str()); + m_RuleRealValues[index] = Strings::ToFloat(rule_value.c_str()); LogRules("Set rule [{}] to value [{:.2f}]", rule_name, m_RuleRealValues[index]); break; case BoolRule: diff --git a/common/shareddb.cpp b/common/shareddb.cpp index 64e9be3fe8..efd962c503 100644 --- a/common/shareddb.cpp +++ b/common/shareddb.cpp @@ -126,7 +126,7 @@ uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) { const std::string query = StringFormat("SELECT `time_played` FROM `character_data` WHERE `account_id` = %u", AccountID); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - EntitledTime += atoi(row[0]); + EntitledTime += Strings::ToInt(row[0]); } return EntitledTime; } @@ -228,8 +228,8 @@ bool SharedDatabase::VerifyInventory(uint32 account_id, int16 slot_id, const EQ: auto& row = results.begin(); - const uint32 id = atoi(row[0]); - const uint16 charges = atoi(row[1]); + const uint32 id = Strings::ToInt(row[0]); + const uint16 charges = Strings::ToInt(row[1]); uint16 expect_charges; @@ -436,7 +436,7 @@ int32 SharedDatabase::GetSharedPlatinum(uint32 account_id) auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool SharedDatabase::SetSharedPlatinum(uint32 account_id, int32 amount_to_add) { @@ -473,9 +473,9 @@ bool SharedDatabase::SetStartingItems(PlayerProfile_Struct* pp, EQ::InventoryPro for (auto& row = results.begin(); row != results.end(); ++row) { - const int32 itemid = atoi(row[0]); - const int32 charges = atoi(row[1]); - int32 slot = atoi(row[2]); + const int32 itemid = Strings::ToInt(row[0]); + const int32 charges = Strings::ToInt(row[1]); + int32 slot = Strings::ToInt(row[2]); myitem = GetItem(itemid); if(!myitem) @@ -518,17 +518,17 @@ bool SharedDatabase::GetSharedBank(uint32 id, EQ::InventoryProfile *inv, bool is } for (auto& row = results.begin(); row != results.end(); ++row) { - int16 slot_id = static_cast(atoi(row[0])); - uint32 item_id = static_cast(atoi(row[1])); - const int16 charges = static_cast(atoi(row[2])); + int16 slot_id = static_cast(Strings::ToInt(row[0])); + uint32 item_id = static_cast(Strings::ToInt(row[1])); + const int16 charges = static_cast(Strings::ToInt(row[2])); uint32 aug[EQ::invaug::SOCKET_COUNT]; - aug[0] = static_cast(atoi(row[3])); - aug[1] = static_cast(atoi(row[4])); - aug[2] = static_cast(atoi(row[5])); - aug[3] = static_cast(atoi(row[6])); - aug[4] = static_cast(atoi(row[7])); - aug[5] = static_cast(atoi(row[8])); + aug[0] = static_cast(Strings::ToInt(row[3])); + aug[1] = static_cast(Strings::ToInt(row[4])); + aug[2] = static_cast(Strings::ToInt(row[5])); + aug[3] = static_cast(Strings::ToInt(row[6])); + aug[4] = static_cast(Strings::ToInt(row[7])); + aug[5] = static_cast(Strings::ToInt(row[8])); const EQ::ItemData *item = GetItem(item_id); @@ -616,7 +616,7 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQ::InventoryProfile *inv) const auto bank_size = inv->GetLookup()->InventoryTypeSize.Bank; for (auto& row = results.begin(); row != results.end(); ++row) { - int16 slot_id = atoi(row[0]); + int16 slot_id = Strings::ToInt(row[0]); if (slot_id <= EQ::invslot::POSSESSIONS_END && slot_id >= EQ::invslot::POSSESSIONS_BEGIN) { // Titanium thru UF check if (((static_cast(1) << slot_id) & pmask) == 0) { @@ -645,24 +645,24 @@ bool SharedDatabase::GetInventory(uint32 char_id, EQ::InventoryProfile *inv) } } - uint32 item_id = atoi(row[1]); - const uint16 charges = atoi(row[2]); - const uint32 color = atoul(row[3]); + uint32 item_id = Strings::ToInt(row[1]); + const uint16 charges = Strings::ToInt(row[2]); + const uint32 color = Strings::ToUnsignedInt(row[3]); uint32 aug[EQ::invaug::SOCKET_COUNT]; - aug[0] = std::stoul(row[4]); - aug[1] = std::stoul(row[5]); - aug[2] = std::stoul(row[6]); - aug[3] = std::stoul(row[7]); - aug[4] = std::stoul(row[8]); - aug[5] = std::stoul(row[9]); + aug[0] = Strings::ToUnsignedInt(row[4]); + aug[1] = Strings::ToUnsignedInt(row[5]); + aug[2] = Strings::ToUnsignedInt(row[6]); + aug[3] = Strings::ToUnsignedInt(row[7]); + aug[4] = Strings::ToUnsignedInt(row[8]); + aug[5] = Strings::ToUnsignedInt(row[9]); - const bool instnodrop = (row[10] && static_cast(atoi(row[10]))) ? true : false; + const bool instnodrop = (row[10] && static_cast(Strings::ToInt(row[10]))) ? true : false; - const uint32 ornament_icon = std::stoul(row[12]); - const uint32 ornament_idfile = std::stoul(row[13]); - uint32 ornament_hero_model = std::stoul(row[14]); + const uint32 ornament_icon = Strings::ToUnsignedInt(row[12]); + const uint32 ornament_idfile = Strings::ToUnsignedInt(row[13]); + uint32 ornament_hero_model = Strings::ToUnsignedInt(row[14]); const EQ::ItemData *item = GetItem(item_id); @@ -794,23 +794,23 @@ bool SharedDatabase::GetInventory(uint32 account_id, char *name, EQ::InventoryPr } for (auto& row = results.begin(); row != results.end(); ++row) { - int16 slot_id = atoi(row[0]); - uint32 item_id = atoi(row[1]); - const int8 charges = atoi(row[2]); - const uint32 color = atoul(row[3]); + int16 slot_id = Strings::ToInt(row[0]); + uint32 item_id = Strings::ToInt(row[1]); + const int8 charges = Strings::ToInt(row[2]); + const uint32 color = Strings::ToUnsignedInt(row[3]); uint32 aug[EQ::invaug::SOCKET_COUNT]; - aug[0] = static_cast(atoi(row[4])); - aug[1] = static_cast(atoi(row[5])); - aug[2] = static_cast(atoi(row[6])); - aug[3] = static_cast(atoi(row[7])); - aug[4] = static_cast(atoi(row[8])); - aug[5] = static_cast(atoi(row[9])); - - const bool instnodrop = (row[10] && static_cast(atoi(row[10]))) ? true : false; - const uint32 ornament_icon = std::stoul(row[12]); - const uint32 ornament_idfile = std::stoul(row[13]); - uint32 ornament_hero_model = std::stoul(row[14]); + aug[0] = static_cast(Strings::ToInt(row[4])); + aug[1] = static_cast(Strings::ToInt(row[5])); + aug[2] = static_cast(Strings::ToInt(row[6])); + aug[3] = static_cast(Strings::ToInt(row[7])); + aug[4] = static_cast(Strings::ToInt(row[8])); + aug[5] = static_cast(Strings::ToInt(row[9])); + + const bool instnodrop = (row[10] && static_cast(Strings::ToInt(row[10]))) ? true : false; + const uint32 ornament_icon = Strings::ToUnsignedInt(row[12]); + const uint32 ornament_idfile = Strings::ToUnsignedInt(row[13]); + uint32 ornament_hero_model = Strings::ToUnsignedInt(row[14]); const EQ::ItemData *item = GetItem(item_id); if (!item) @@ -892,7 +892,7 @@ std::map SharedDatabase::GetItemRecastTimestamps(uint32 char_id) return timers; for (auto& row = results.begin(); row != results.end(); ++row) - timers[atoul(row[0])] = atoul(row[1]); + timers[Strings::ToUnsignedInt(row[0])] = Strings::ToUnsignedInt(row[1]); return timers; // RVO or move assigned } @@ -905,7 +905,7 @@ uint32 SharedDatabase::GetItemRecastTimestamp(uint32 char_id, uint32 recast_type return 0; auto& row = results.begin(); - return static_cast(atoul(row[0])); + return static_cast(Strings::ToUnsignedInt(row[0])); } void SharedDatabase::ClearOldRecastTimestamps(uint32 char_id) @@ -933,10 +933,10 @@ void SharedDatabase::GetItemsCount(int32 &item_count, uint32 &max_id) auto& row = results.begin(); if (row[0]) - max_id = atoi(row[0]); + max_id = Strings::ToInt(row[0]); if (row[1]) - item_count = atoi(row[1]); + item_count = Strings::ToInt(row[1]); } bool SharedDatabase::LoadItems(const std::string &prefix) { @@ -1018,188 +1018,188 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_ memset(&item, 0, sizeof(EQ::ItemData)); // Unique Identifier - item.ID = std::stoul(row[ItemField::id]); + item.ID = Strings::ToUnsignedInt(row[ItemField::id]); // Name and Lore strn0cpy(item.Name, row[ItemField::name], sizeof(item.Name)); strn0cpy(item.Lore, row[ItemField::lore], sizeof(item.Lore)); // Flags - item.ArtifactFlag = std::stoi(row[ItemField::artifactflag]) ? true : false; - item.Attuneable = disable_attuneable ? false : std::stoi(row[ItemField::attuneable]) ? true : false; - item.BenefitFlag = std::stoi(row[ItemField::benefitflag]) ? true : false; - item.FVNoDrop = std::stoi(row[ItemField::fvnodrop]) ? true : false; - item.Magic = std::stoi(row[ItemField::magic]) ? true : false; - item.NoDrop = disable_no_drop ? static_cast(255) : static_cast(std::stoul(row[ItemField::nodrop])); - item.NoPet = disable_no_pet ? false : std::stoi(row[ItemField::nopet]) ? true : false; - item.NoRent = disable_no_rent ? static_cast(255) : static_cast(std::stoul(row[ItemField::norent])); - item.NoTransfer = disable_no_transfer ? false : std::stoi(row[ItemField::notransfer]) ? true : false; - item.PendingLoreFlag = std::stoi(row[ItemField::pendingloreflag]) ? true : false; - item.QuestItemFlag = std::stoi(row[ItemField::questitemflag]) ? true : false; - item.Stackable = std::stoi(row[ItemField::stackable]) ? true : false; - item.Tradeskills = std::stoi(row[ItemField::tradeskills]) ? true : false; - item.SummonedFlag = std::stoi(row[ItemField::summonedflag]) ? true : false; + item.ArtifactFlag = Strings::ToInt(row[ItemField::artifactflag]) ? true : false; + item.Attuneable = disable_attuneable ? false : Strings::ToInt(row[ItemField::attuneable]) ? true : false; + item.BenefitFlag = Strings::ToInt(row[ItemField::benefitflag]) ? true : false; + item.FVNoDrop = Strings::ToInt(row[ItemField::fvnodrop]) ? true : false; + item.Magic = Strings::ToInt(row[ItemField::magic]) ? true : false; + item.NoDrop = disable_no_drop ? static_cast(255) : static_cast(Strings::ToUnsignedInt(row[ItemField::nodrop])); + item.NoPet = disable_no_pet ? false : Strings::ToInt(row[ItemField::nopet]) ? true : false; + item.NoRent = disable_no_rent ? static_cast(255) : static_cast(Strings::ToUnsignedInt(row[ItemField::norent])); + item.NoTransfer = disable_no_transfer ? false : Strings::ToInt(row[ItemField::notransfer]) ? true : false; + item.PendingLoreFlag = Strings::ToInt(row[ItemField::pendingloreflag]) ? true : false; + item.QuestItemFlag = Strings::ToInt(row[ItemField::questitemflag]) ? true : false; + item.Stackable = Strings::ToInt(row[ItemField::stackable]) ? true : false; + item.Tradeskills = Strings::ToInt(row[ItemField::tradeskills]) ? true : false; + item.SummonedFlag = Strings::ToInt(row[ItemField::summonedflag]) ? true : false; // Lore - item.LoreGroup = disable_lore ? 0 : std::stoi(row[ItemField::loregroup]); + item.LoreGroup = disable_lore ? 0 : Strings::ToInt(row[ItemField::loregroup]); item.LoreFlag = disable_lore ? false : item.LoreGroup != 0; // Type - item.AugType = std::stoul(row[ItemField::augtype]); - item.ItemType = static_cast(std::stoul(row[ItemField::itemtype])); - item.SubType = std::stoi(row[ItemField::subtype]); + item.AugType = Strings::ToUnsignedInt(row[ItemField::augtype]); + item.ItemType = static_cast(Strings::ToUnsignedInt(row[ItemField::itemtype])); + item.SubType = Strings::ToInt(row[ItemField::subtype]); // Miscellaneous - item.ExpendableArrow = static_cast(std::stoul(row[ItemField::expendablearrow])); - item.Light = static_cast(std::stoi(row[ItemField::light])); - item.MaxCharges = static_cast(std::stoi(row[ItemField::maxcharges])); - item.Size = static_cast(std::stoul(row[ItemField::size])); - item.StackSize = static_cast(std::stoi(row[ItemField::stacksize])); - item.Weight = std::stoi(row[ItemField::weight]); + item.ExpendableArrow = static_cast(Strings::ToUnsignedInt(row[ItemField::expendablearrow])); + item.Light = static_cast(Strings::ToInt(row[ItemField::light])); + item.MaxCharges = static_cast(Strings::ToInt(row[ItemField::maxcharges])); + item.Size = static_cast(Strings::ToUnsignedInt(row[ItemField::size])); + item.StackSize = static_cast(Strings::ToInt(row[ItemField::stacksize])); + item.Weight = Strings::ToInt(row[ItemField::weight]); // Potion Belt - item.PotionBelt = disable_potion_belt ? false : std::stoi(row[ItemField::potionbelt]) ? true : false; - item.PotionBeltSlots = disable_potion_belt ? 0 : static_cast(std::stoul(row[ItemField::potionbeltslots])); + item.PotionBelt = disable_potion_belt ? false : Strings::ToInt(row[ItemField::potionbelt]) ? true : false; + item.PotionBeltSlots = disable_potion_belt ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::potionbeltslots])); // Merchant - item.Favor = std::stoul(row[ItemField::favor]); - item.GuildFavor = std::stoul(row[ItemField::guildfavor]); - item.Price = std::stoul(row[ItemField::price]); - item.SellRate = std::stof(row[ItemField::sellrate]); + item.Favor = Strings::ToUnsignedInt(row[ItemField::favor]); + item.GuildFavor = Strings::ToUnsignedInt(row[ItemField::guildfavor]); + item.Price = Strings::ToUnsignedInt(row[ItemField::price]); + item.SellRate = Strings::ToFloat(row[ItemField::sellrate]); // Display - item.Color = std::stoul(row[ItemField::color]); - item.EliteMaterial = std::stoul(row[ItemField::elitematerial]); - item.HerosForgeModel = std::stoul(row[ItemField::herosforgemodel]); - item.Icon = std::stoul(row[ItemField::icon]); + item.Color = Strings::ToUnsignedInt(row[ItemField::color]); + item.EliteMaterial = Strings::ToUnsignedInt(row[ItemField::elitematerial]); + item.HerosForgeModel = Strings::ToUnsignedInt(row[ItemField::herosforgemodel]); + item.Icon = Strings::ToUnsignedInt(row[ItemField::icon]); strn0cpy(item.IDFile, row[ItemField::idfile], sizeof(item.IDFile)); - item.Material = static_cast(std::stoul(row[ItemField::material])); + item.Material = static_cast(Strings::ToUnsignedInt(row[ItemField::material])); // Resists - item.CR = static_cast(EQ::Clamp(std::stoi(row[ItemField::cr]), -128, 127)); - item.DR = static_cast(EQ::Clamp(std::stoi(row[ItemField::dr]), -128, 127)); - item.FR = static_cast(EQ::Clamp(std::stoi(row[ItemField::fr]), -128, 127)); - item.MR = static_cast(EQ::Clamp(std::stoi(row[ItemField::mr]), -128, 127)); - item.PR = static_cast(EQ::Clamp(std::stoi(row[ItemField::pr]), -128, 127)); - item.SVCorruption = static_cast(EQ::Clamp(std::stoi(row[ItemField::svcorruption]), -128, 127)); + item.CR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::cr]), -128, 127)); + item.DR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::dr]), -128, 127)); + item.FR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::fr]), -128, 127)); + item.MR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::mr]), -128, 127)); + item.PR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::pr]), -128, 127)); + item.SVCorruption = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::svcorruption]), -128, 127)); // Heroic Resists - item.HeroicCR = std::stoi(row[ItemField::heroic_cr]); - item.HeroicDR = std::stoi(row[ItemField::heroic_dr]); - item.HeroicFR = std::stoi(row[ItemField::heroic_fr]); - item.HeroicMR = std::stoi(row[ItemField::heroic_mr]); - item.HeroicPR = std::stoi(row[ItemField::heroic_pr]); - item.HeroicSVCorrup = std::stoi(row[ItemField::heroic_svcorrup]); + item.HeroicCR = Strings::ToInt(row[ItemField::heroic_cr]); + item.HeroicDR = Strings::ToInt(row[ItemField::heroic_dr]); + item.HeroicFR = Strings::ToInt(row[ItemField::heroic_fr]); + item.HeroicMR = Strings::ToInt(row[ItemField::heroic_mr]); + item.HeroicPR = Strings::ToInt(row[ItemField::heroic_pr]); + item.HeroicSVCorrup = Strings::ToInt(row[ItemField::heroic_svcorrup]); // Stats - item.AAgi = static_cast(EQ::Clamp(std::stoi(row[ItemField::aagi]), -128, 127)); - item.ACha = static_cast(EQ::Clamp(std::stoi(row[ItemField::acha]), -128, 127)); - item.ADex = static_cast(EQ::Clamp(std::stoi(row[ItemField::adex]), -128, 127)); - item.AInt = static_cast(EQ::Clamp(std::stoi(row[ItemField::aint]), -128, 127)); - item.ASta = static_cast(EQ::Clamp(std::stoi(row[ItemField::asta]), -128, 127)); - item.AStr = static_cast(EQ::Clamp(std::stoi(row[ItemField::astr]), -128, 127)); - item.AWis = static_cast(EQ::Clamp(std::stoi(row[ItemField::awis]), -128, 127)); + item.AAgi = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::aagi]), -128, 127)); + item.ACha = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::acha]), -128, 127)); + item.ADex = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::adex]), -128, 127)); + item.AInt = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::aint]), -128, 127)); + item.ASta = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::asta]), -128, 127)); + item.AStr = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::astr]), -128, 127)); + item.AWis = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::awis]), -128, 127)); // Heroic Stats - item.HeroicAgi = std::stoi(row[ItemField::heroic_agi]); - item.HeroicCha = std::stoi(row[ItemField::heroic_cha]); - item.HeroicDex = std::stoi(row[ItemField::heroic_dex]); - item.HeroicInt = std::stoi(row[ItemField::heroic_int]); - item.HeroicSta = std::stoi(row[ItemField::heroic_sta]); - item.HeroicStr = std::stoi(row[ItemField::heroic_str]); - item.HeroicWis = std::stoi(row[ItemField::heroic_wis]); + item.HeroicAgi = Strings::ToInt(row[ItemField::heroic_agi]); + item.HeroicCha = Strings::ToInt(row[ItemField::heroic_cha]); + item.HeroicDex = Strings::ToInt(row[ItemField::heroic_dex]); + item.HeroicInt = Strings::ToInt(row[ItemField::heroic_int]); + item.HeroicSta = Strings::ToInt(row[ItemField::heroic_sta]); + item.HeroicStr = Strings::ToInt(row[ItemField::heroic_str]); + item.HeroicWis = Strings::ToInt(row[ItemField::heroic_wis]); // Health, Mana, and Endurance - item.HP = std::stoi(row[ItemField::hp]); - item.Regen = std::stoi(row[ItemField::regen]); - item.Mana = std::stoi(row[ItemField::mana]); - item.ManaRegen = std::stoi(row[ItemField::manaregen]); - item.Endur = std::stoi(row[ItemField::endur]); - item.EnduranceRegen = std::stoi(row[ItemField::enduranceregen]); + item.HP = Strings::ToInt(row[ItemField::hp]); + item.Regen = Strings::ToInt(row[ItemField::regen]); + item.Mana = Strings::ToInt(row[ItemField::mana]); + item.ManaRegen = Strings::ToInt(row[ItemField::manaregen]); + item.Endur = Strings::ToInt(row[ItemField::endur]); + item.EnduranceRegen = Strings::ToInt(row[ItemField::enduranceregen]); // Bane Damage - item.BaneDmgAmt = std::stoi(row[ItemField::banedmgamt]); - item.BaneDmgBody = std::stoul(row[ItemField::banedmgbody]); - item.BaneDmgRace = std::stoul(row[ItemField::banedmgrace]); - item.BaneDmgRaceAmt = std::stoul(row[ItemField::banedmgraceamt]); + item.BaneDmgAmt = Strings::ToInt(row[ItemField::banedmgamt]); + item.BaneDmgBody = Strings::ToUnsignedInt(row[ItemField::banedmgbody]); + item.BaneDmgRace = Strings::ToUnsignedInt(row[ItemField::banedmgrace]); + item.BaneDmgRaceAmt = Strings::ToUnsignedInt(row[ItemField::banedmgraceamt]); // Elemental Damage - item.ElemDmgType = static_cast(std::stoul(row[ItemField::elemdmgtype])); - item.ElemDmgAmt = static_cast(std::stoul(row[ItemField::elemdmgamt])); + item.ElemDmgType = static_cast(Strings::ToUnsignedInt(row[ItemField::elemdmgtype])); + item.ElemDmgAmt = static_cast(Strings::ToUnsignedInt(row[ItemField::elemdmgamt])); // Combat - item.BackstabDmg = std::stoul(row[ItemField::backstabdmg]); - item.Damage = std::stoul(row[ItemField::damage]); - item.Delay = static_cast(std::stoul(row[ItemField::delay])); - item.Range = static_cast(std::stoul(row[ItemField::range])); + item.BackstabDmg = Strings::ToUnsignedInt(row[ItemField::backstabdmg]); + item.Damage = Strings::ToUnsignedInt(row[ItemField::damage]); + item.Delay = static_cast(Strings::ToUnsignedInt(row[ItemField::delay])); + item.Range = static_cast(Strings::ToUnsignedInt(row[ItemField::range])); // Combat Stats - item.AC = std::stoi(row[ItemField::ac]); - item.Accuracy = static_cast(EQ::Clamp(std::stoi(row[ItemField::accuracy]), -128, 127)); - item.Attack = std::stoi(row[ItemField::attack]); - item.Avoidance = static_cast(EQ::Clamp(std::stoi(row[ItemField::avoidance]), -128, 127)); - item.Clairvoyance = std::stoul(row[ItemField::clairvoyance]); - item.CombatEffects = Strings::IsNumber(row[ItemField::combateffects]) ? static_cast(EQ::Clamp(std::stoi(row[ItemField::combateffects]), -128, 127)) : 0; - item.DamageShield = std::stoi(row[ItemField::damageshield]); - item.DotShielding = std::stoi(row[ItemField::dotshielding]); - item.DSMitigation = std::stoul(row[ItemField::dsmitigation]); - item.Haste = std::stoi(row[ItemField::haste]); - item.HealAmt = std::stoi(row[ItemField::healamt]); - item.Purity = std::stoul(row[ItemField::purity]); - item.Shielding = static_cast(EQ::Clamp(std::stoi(row[ItemField::shielding]), -128, 127)); - item.SpellDmg = std::stoi(row[ItemField::spelldmg]); - item.SpellShield = static_cast(EQ::Clamp(std::stoi(row[ItemField::spellshield]), -128, 127)); - item.StrikeThrough = static_cast(EQ::Clamp(std::stoi(row[ItemField::strikethrough]), -128, 127)); - item.StunResist = static_cast(EQ::Clamp(std::stoi(row[ItemField::stunresist]), -128, 127)); + item.AC = Strings::ToInt(row[ItemField::ac]); + item.Accuracy = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::accuracy]), -128, 127)); + item.Attack = Strings::ToInt(row[ItemField::attack]); + item.Avoidance = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::avoidance]), -128, 127)); + item.Clairvoyance = Strings::ToUnsignedInt(row[ItemField::clairvoyance]); + item.CombatEffects = Strings::IsNumber(row[ItemField::combateffects]) ? static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::combateffects]), -128, 127)) : 0; + item.DamageShield = Strings::ToInt(row[ItemField::damageshield]); + item.DotShielding = Strings::ToInt(row[ItemField::dotshielding]); + item.DSMitigation = Strings::ToUnsignedInt(row[ItemField::dsmitigation]); + item.Haste = Strings::ToInt(row[ItemField::haste]); + item.HealAmt = Strings::ToInt(row[ItemField::healamt]); + item.Purity = Strings::ToUnsignedInt(row[ItemField::purity]); + item.Shielding = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::shielding]), -128, 127)); + item.SpellDmg = Strings::ToInt(row[ItemField::spelldmg]); + item.SpellShield = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::spellshield]), -128, 127)); + item.StrikeThrough = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::strikethrough]), -128, 127)); + item.StunResist = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::stunresist]), -128, 127)); // Restrictions - item.AugRestrict = std::stoul(row[ItemField::augrestrict]); - item.Classes = std::stoul(row[ItemField::classes]); - item.Deity = std::stoul(row[ItemField::deity]); - item.ItemClass = static_cast(std::stoul(row[ItemField::itemclass])); - item.Races = std::stoul(row[ItemField::races]); - item.RecLevel = static_cast(std::stoul(row[ItemField::reclevel])); - item.RecSkill = static_cast(std::stoul(row[ItemField::recskill])); - item.ReqLevel = static_cast(std::stoul(row[ItemField::reqlevel])); - item.Slots = std::stoul(row[ItemField::slots]); + item.AugRestrict = Strings::ToUnsignedInt(row[ItemField::augrestrict]); + item.Classes = Strings::ToUnsignedInt(row[ItemField::classes]); + item.Deity = Strings::ToUnsignedInt(row[ItemField::deity]); + item.ItemClass = static_cast(Strings::ToUnsignedInt(row[ItemField::itemclass])); + item.Races = Strings::ToUnsignedInt(row[ItemField::races]); + item.RecLevel = static_cast(Strings::ToUnsignedInt(row[ItemField::reclevel])); + item.RecSkill = static_cast(Strings::ToUnsignedInt(row[ItemField::recskill])); + item.ReqLevel = static_cast(Strings::ToUnsignedInt(row[ItemField::reqlevel])); + item.Slots = Strings::ToUnsignedInt(row[ItemField::slots]); // Skill Modifier - item.SkillModValue = std::stoi(row[ItemField::skillmodvalue]); - item.SkillModMax = std::stoi(row[ItemField::skillmodmax]); - item.SkillModType = std::stoul(row[ItemField::skillmodtype]); + item.SkillModValue = Strings::ToInt(row[ItemField::skillmodvalue]); + item.SkillModMax = Strings::ToInt(row[ItemField::skillmodmax]); + item.SkillModType = Strings::ToUnsignedInt(row[ItemField::skillmodtype]); // Extra Damage Skill - item.ExtraDmgSkill = std::stoul(row[ItemField::extradmgskill]); - item.ExtraDmgAmt = std::stoul(row[ItemField::extradmgamt]); + item.ExtraDmgSkill = Strings::ToUnsignedInt(row[ItemField::extradmgskill]); + item.ExtraDmgAmt = Strings::ToUnsignedInt(row[ItemField::extradmgamt]); // Bard - item.BardType = std::stoul(row[ItemField::bardtype]); - item.BardValue = std::stoi(row[ItemField::bardvalue]); + item.BardType = Strings::ToUnsignedInt(row[ItemField::bardtype]); + item.BardValue = Strings::ToInt(row[ItemField::bardvalue]); // Faction - item.FactionAmt1 = std::stoi(row[ItemField::factionamt1]); - item.FactionMod1 = std::stoi(row[ItemField::factionmod1]); - item.FactionAmt2 = std::stoi(row[ItemField::factionamt2]); - item.FactionMod2 = std::stoi(row[ItemField::factionmod2]); - item.FactionAmt3 = std::stoi(row[ItemField::factionamt3]); - item.FactionMod3 = std::stoi(row[ItemField::factionmod3]); - item.FactionAmt4 = std::stoi(row[ItemField::factionamt4]); - item.FactionMod4 = std::stoi(row[ItemField::factionmod4]); + item.FactionAmt1 = Strings::ToInt(row[ItemField::factionamt1]); + item.FactionMod1 = Strings::ToInt(row[ItemField::factionmod1]); + item.FactionAmt2 = Strings::ToInt(row[ItemField::factionamt2]); + item.FactionMod2 = Strings::ToInt(row[ItemField::factionmod2]); + item.FactionAmt3 = Strings::ToInt(row[ItemField::factionamt3]); + item.FactionMod3 = Strings::ToInt(row[ItemField::factionmod3]); + item.FactionAmt4 = Strings::ToInt(row[ItemField::factionamt4]); + item.FactionMod4 = Strings::ToInt(row[ItemField::factionmod4]); // Augment - item.AugDistiller = std::stoul(row[ItemField::augdistiller]); - item.AugSlotType[0] = static_cast(std::stoul(row[ItemField::augslot1type])); - item.AugSlotVisible[0] = static_cast(std::stoul(row[ItemField::augslot1visible])); - item.AugSlotType[1] = static_cast(std::stoul(row[ItemField::augslot2type])); - item.AugSlotVisible[1] = static_cast(std::stoul(row[ItemField::augslot2visible])); - item.AugSlotType[2] = static_cast(std::stoul(row[ItemField::augslot3type])); - item.AugSlotVisible[2] = static_cast(std::stoul(row[ItemField::augslot3visible])); - item.AugSlotType[3] = static_cast(std::stoul(row[ItemField::augslot4type])); - item.AugSlotVisible[3] = static_cast(std::stoul(row[ItemField::augslot4visible])); - item.AugSlotType[4] = static_cast(std::stoul(row[ItemField::augslot5type])); - item.AugSlotVisible[4] = static_cast(std::stoul(row[ItemField::augslot5visible])); - item.AugSlotType[5] = static_cast(std::stoul(row[ItemField::augslot6type])); - item.AugSlotVisible[5] = static_cast(std::stoul(row[ItemField::augslot6visible])); + item.AugDistiller = Strings::ToUnsignedInt(row[ItemField::augdistiller]); + item.AugSlotType[0] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot1type])); + item.AugSlotVisible[0] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot1visible])); + item.AugSlotType[1] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot2type])); + item.AugSlotVisible[1] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot2visible])); + item.AugSlotType[2] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot3type])); + item.AugSlotVisible[2] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot3visible])); + item.AugSlotType[3] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot4type])); + item.AugSlotVisible[3] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot4visible])); + item.AugSlotType[4] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot5type])); + item.AugSlotVisible[4] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot5visible])); + item.AugSlotType[5] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot6type])); + item.AugSlotVisible[5] = static_cast(Strings::ToUnsignedInt(row[ItemField::augslot6visible])); // Augment Unknowns for (uint8 i = EQ::invaug::SOCKET_BEGIN; i <= EQ::invaug::SOCKET_END; i++) { @@ -1207,79 +1207,79 @@ void SharedDatabase::LoadItems(void *data, uint32 size, int32 items, uint32 max_ } // LDoN - item.LDoNTheme = std::stoul(row[ItemField::ldontheme]); - item.LDoNPrice = std::stoul(row[ItemField::ldonprice]); - item.LDoNSellBackRate = std::stoul(row[ItemField::ldonsellbackrate]); - item.LDoNSold = std::stoul(row[ItemField::ldonsold]); - item.PointType = std::stoul(row[ItemField::pointtype]); + item.LDoNTheme = Strings::ToUnsignedInt(row[ItemField::ldontheme]); + item.LDoNPrice = Strings::ToUnsignedInt(row[ItemField::ldonprice]); + item.LDoNSellBackRate = Strings::ToUnsignedInt(row[ItemField::ldonsellbackrate]); + item.LDoNSold = Strings::ToUnsignedInt(row[ItemField::ldonsold]); + item.PointType = Strings::ToUnsignedInt(row[ItemField::pointtype]); // Bag - item.BagSize = static_cast(std::stoul(row[ItemField::bagsize])); - item.BagSlots = static_cast(EQ::Clamp(std::stoi(row[ItemField::bagslots]), 0, 10)); // Will need to be changed from std::min to just use database value when bag slots are increased - item.BagType = static_cast(std::stoul(row[ItemField::bagtype])); - item.BagWR = static_cast(EQ::Clamp(std::stoi(row[ItemField::bagwr]), 0, 100)); + item.BagSize = static_cast(Strings::ToUnsignedInt(row[ItemField::bagsize])); + item.BagSlots = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::bagslots]), 0, 10)); // Will need to be changed from std::min to just use database value when bag slots are increased + item.BagType = static_cast(Strings::ToUnsignedInt(row[ItemField::bagtype])); + item.BagWR = static_cast(EQ::Clamp(Strings::ToInt(row[ItemField::bagwr]), 0, 100)); // Bard Effect - item.Bard.Effect = disable_bard_focus_effects ? 0 : std::stoi(row[ItemField::bardeffect]); - item.Bard.Type = disable_bard_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::bardtype])); - item.Bard.Level = disable_bard_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::bardlevel])); - item.Bard.Level2 = disable_bard_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::bardlevel2])); + item.Bard.Effect = disable_bard_focus_effects ? 0 : Strings::ToInt(row[ItemField::bardeffect]); + item.Bard.Type = disable_bard_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::bardtype])); + item.Bard.Level = disable_bard_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::bardlevel])); + item.Bard.Level2 = disable_bard_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::bardlevel2])); // Book - item.Book = static_cast(std::stoul(row[ItemField::book])); - item.BookType = std::stoul(row[ItemField::booktype]); + item.Book = static_cast(Strings::ToUnsignedInt(row[ItemField::book])); + item.BookType = Strings::ToUnsignedInt(row[ItemField::booktype]); // Click Effect - item.CastTime = std::stoul(row[ItemField::casttime]); - item.CastTime_ = std::stoi(row[ItemField::casttime_]); - item.Click.Effect = std::stoi(row[ItemField::clickeffect]); - item.Click.Type = static_cast(std::stoul(row[ItemField::clicktype])); - item.Click.Level = static_cast(std::stoul(row[ItemField::clicklevel])); - item.Click.Level2 = static_cast(std::stoul(row[ItemField::clicklevel2])); + item.CastTime = Strings::ToUnsignedInt(row[ItemField::casttime]); + item.CastTime_ = Strings::ToInt(row[ItemField::casttime_]); + item.Click.Effect = Strings::ToInt(row[ItemField::clickeffect]); + item.Click.Type = static_cast(Strings::ToUnsignedInt(row[ItemField::clicktype])); + item.Click.Level = static_cast(Strings::ToUnsignedInt(row[ItemField::clicklevel])); + item.Click.Level2 = static_cast(Strings::ToUnsignedInt(row[ItemField::clicklevel2])); strn0cpy(item.ClickName, row[ItemField::clickname], sizeof(item.ClickName)); - item.RecastDelay = std::stoul(row[ItemField::recastdelay]); - item.RecastType = std::stoi(row[ItemField::recasttype]); + item.RecastDelay = Strings::ToUnsignedInt(row[ItemField::recastdelay]); + item.RecastType = Strings::ToInt(row[ItemField::recasttype]); // Focus Effect - item.Focus.Effect = disable_spell_focus_effects ? 0 : std::stoi(row[ItemField::focuseffect]); - item.Focus.Type = disable_spell_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::focustype])); - item.Focus.Level = disable_spell_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::focuslevel])); - item.Focus.Level2 = disable_spell_focus_effects ? 0 : static_cast(std::stoul(row[ItemField::focuslevel2])); + item.Focus.Effect = disable_spell_focus_effects ? 0 : Strings::ToInt(row[ItemField::focuseffect]); + item.Focus.Type = disable_spell_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::focustype])); + item.Focus.Level = disable_spell_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::focuslevel])); + item.Focus.Level2 = disable_spell_focus_effects ? 0 : static_cast(Strings::ToUnsignedInt(row[ItemField::focuslevel2])); strn0cpy(item.FocusName, disable_spell_focus_effects ? "" : row[ItemField::focusname], sizeof(item.FocusName)); // Proc Effect - item.Proc.Effect = std::stoi(row[ItemField::proceffect]); - item.Proc.Type = static_cast(std::stoul(row[ItemField::proctype])); - item.Proc.Level = static_cast(std::stoul(row[ItemField::proclevel])); - item.Proc.Level2 = static_cast(std::stoul(row[ItemField::proclevel2])); + item.Proc.Effect = Strings::ToInt(row[ItemField::proceffect]); + item.Proc.Type = static_cast(Strings::ToUnsignedInt(row[ItemField::proctype])); + item.Proc.Level = static_cast(Strings::ToUnsignedInt(row[ItemField::proclevel])); + item.Proc.Level2 = static_cast(Strings::ToUnsignedInt(row[ItemField::proclevel2])); strn0cpy(item.ProcName, row[ItemField::procname], sizeof(item.ProcName)); - item.ProcRate = std::stoi(row[ItemField::procrate]); + item.ProcRate = Strings::ToInt(row[ItemField::procrate]); // Scroll Effect - item.Scroll.Effect = std::stoi(row[ItemField::scrolleffect]); - item.Scroll.Type = static_cast(std::stoul(row[ItemField::scrolltype])); - item.Scroll.Level = static_cast(std::stoul(row[ItemField::scrolllevel])); - item.Scroll.Level2 = static_cast(std::stoul(row[ItemField::scrolllevel2])); + item.Scroll.Effect = Strings::ToInt(row[ItemField::scrolleffect]); + item.Scroll.Type = static_cast(Strings::ToUnsignedInt(row[ItemField::scrolltype])); + item.Scroll.Level = static_cast(Strings::ToUnsignedInt(row[ItemField::scrolllevel])); + item.Scroll.Level2 = static_cast(Strings::ToUnsignedInt(row[ItemField::scrolllevel2])); strn0cpy(item.ScrollName, row[ItemField::scrollname], sizeof(item.ScrollName)); // Worn Effect - item.Worn.Effect = std::stoi(row[ItemField::worneffect]); - item.Worn.Type = static_cast(std::stoul(row[ItemField::worntype])); - item.Worn.Level = static_cast(std::stoul(row[ItemField::wornlevel])); - item.Worn.Level2 = static_cast(std::stoul(row[ItemField::wornlevel2])); + item.Worn.Effect = Strings::ToInt(row[ItemField::worneffect]); + item.Worn.Type = static_cast(Strings::ToUnsignedInt(row[ItemField::worntype])); + item.Worn.Level = static_cast(Strings::ToUnsignedInt(row[ItemField::wornlevel])); + item.Worn.Level2 = static_cast(Strings::ToUnsignedInt(row[ItemField::wornlevel2])); strn0cpy(item.WornName, row[ItemField::wornname], sizeof(item.WornName)); // Evolving Item - item.EvolvingID = std::stoul(row[ItemField::evoid]); - item.EvolvingItem = static_cast(std::stoul(row[ItemField::evoitem])); - item.EvolvingLevel = static_cast(std::stoul(row[ItemField::evolvinglevel])); - item.EvolvingMax = static_cast(std::stoul(row[ItemField::evomax])); + item.EvolvingID = Strings::ToUnsignedInt(row[ItemField::evoid]); + item.EvolvingItem = static_cast(Strings::ToUnsignedInt(row[ItemField::evoitem])); + item.EvolvingLevel = static_cast(Strings::ToUnsignedInt(row[ItemField::evolvinglevel])); + item.EvolvingMax = static_cast(Strings::ToUnsignedInt(row[ItemField::evomax])); // Scripting - item.CharmFileID = Strings::IsNumber(row[ItemField::charmfileid]) ? std::stoul(row[ItemField::charmfileid]) : 0; + item.CharmFileID = Strings::IsNumber(row[ItemField::charmfileid]) ? Strings::ToUnsignedInt(row[ItemField::charmfileid]) : 0; strn0cpy(item.CharmFile, row[ItemField::charmfile], sizeof(item.CharmFile)); strn0cpy(item.Filename, row[ItemField::filename], sizeof(item.Filename)); - item.ScriptFileID = std::stoul(row[ItemField::scriptfileid]); + item.ScriptFileID = Strings::ToUnsignedInt(row[ItemField::scriptfileid]); // Custom Vegas item.GearScore = static_cast(std::stoi(row[ItemField::GearScore])); @@ -1356,7 +1356,7 @@ std::string SharedDatabase::GetBook(const char *txtfile, int16 *language) auto& row = results.begin(); txtout.assign(row[0],strlen(row[0])); - *language = static_cast(atoi(row[1])); + *language = static_cast(Strings::ToInt(row[1])); return txtout; } @@ -1376,8 +1376,8 @@ void SharedDatabase::GetFactionListInfo(uint32 &list_count, uint32 &max_lists) { auto& row = results.begin(); - list_count = static_cast(atoul(row[0])); - max_lists = static_cast(atoul(row[1] ? row[1] : "0")); + list_count = static_cast(Strings::ToUnsignedInt(row[0])); + max_lists = static_cast(Strings::ToUnsignedInt(row[1] ? row[1] : "0")); } const NPCFactionList* SharedDatabase::GetNPCFactionEntry(uint32 id) const @@ -1410,7 +1410,7 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co uint32 current_entry = 0; for(auto& row = results.begin(); row != results.end(); ++row) { - const uint32 id = static_cast(atoul(row[0])); + const uint32 id = static_cast(Strings::ToUnsignedInt(row[0])); if(id != current_id) { if(current_id != 0) { hash.insert(current_id, faction); @@ -1420,8 +1420,8 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co current_entry = 0; current_id = id; faction.id = id; - faction.primaryfaction = static_cast(atoul(row[1])); - faction.assistprimaryfaction = (atoi(row[2]) == 0); + faction.primaryfaction = static_cast(Strings::ToUnsignedInt(row[1])); + faction.assistprimaryfaction = (Strings::ToInt(row[2]) == 0); } if(!row[3]) @@ -1430,10 +1430,10 @@ void SharedDatabase::LoadNPCFactionLists(void *data, uint32 size, uint32 list_co if(current_entry >= MAX_NPC_FACTIONS) continue; - faction.factionid[current_entry] = static_cast(atoul(row[3])); - faction.factionvalue[current_entry] = static_cast(atoi(row[4])); - faction.factionnpcvalue[current_entry] = static_cast(atoi(row[5])); - faction.factiontemp[current_entry] = static_cast(atoi(row[6])); + faction.factionid[current_entry] = static_cast(Strings::ToUnsignedInt(row[3])); + faction.factionvalue[current_entry] = static_cast(Strings::ToInt(row[4])); + faction.factionnpcvalue[current_entry] = static_cast(Strings::ToInt(row[5])); + faction.factiontemp[current_entry] = static_cast(Strings::ToInt(row[6])); ++current_entry; } @@ -1671,7 +1671,7 @@ bool SharedDatabase::GetCommandSettings(std::map= skill_count || class_ >= class_count || level >= level_count) continue; @@ -1871,9 +1871,9 @@ void SharedDatabase::LoadDamageShieldTypes(SPDat_Spell_Struct* sp, int32 iMaxSpe } for(auto& row = results.begin(); row != results.end(); ++row) { - const int spellID = atoi(row[0]); + const int spellID = Strings::ToInt(row[0]); if((spellID > 0) && (spellID <= iMaxSpellID)) - sp[spellID].damage_shield_type = atoi(row[1]); + sp[spellID].damage_shield_type = Strings::ToInt(row[1]); } } @@ -1891,7 +1891,7 @@ int SharedDatabase::GetMaxSpellID() { auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool SharedDatabase::LoadSpells(const std::string &prefix, int32 *records, const SPDat_Spell_Struct **sp) { @@ -1937,7 +1937,7 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { int counter = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - const int tempid = atoi(row[0]); + const int tempid = Strings::ToInt(row[0]); if(tempid >= max_spells) { LogSpells("Non fatal error: spell.id >= max_spells, ignoring"); continue; @@ -1954,141 +1954,141 @@ void SharedDatabase::LoadSpells(void *data, int max_spells) { strn0cpy(sp[tempid].cast_on_other, row[7], sizeof(sp[tempid].cast_on_other)); strn0cpy(sp[tempid].spell_fades, row[8], sizeof(sp[tempid].spell_fades)); - sp[tempid].range=static_cast(atof(row[9])); - sp[tempid].aoe_range=static_cast(atof(row[10])); - sp[tempid].push_back=static_cast(atof(row[11])); - sp[tempid].push_up=static_cast(atof(row[12])); - sp[tempid].cast_time=atoi(row[13]); - sp[tempid].recovery_time=atoi(row[14]); - sp[tempid].recast_time=atoi(row[15]); - sp[tempid].buff_duration_formula=atoi(row[16]); - sp[tempid].buff_duration=atoi(row[17]); - sp[tempid].aoe_duration=atoi(row[18]); - sp[tempid].mana=atoi(row[19]); + sp[tempid].range=static_cast(Strings::ToFloat(row[9])); + sp[tempid].aoe_range=static_cast(Strings::ToFloat(row[10])); + sp[tempid].push_back=static_cast(Strings::ToFloat(row[11])); + sp[tempid].push_up=static_cast(Strings::ToFloat(row[12])); + sp[tempid].cast_time=Strings::ToInt(row[13]); + sp[tempid].recovery_time=Strings::ToInt(row[14]); + sp[tempid].recast_time=Strings::ToInt(row[15]); + sp[tempid].buff_duration_formula=Strings::ToInt(row[16]); + sp[tempid].buff_duration=Strings::ToInt(row[17]); + sp[tempid].aoe_duration=Strings::ToInt(row[18]); + sp[tempid].mana=Strings::ToInt(row[19]); int y=0; for(y=0; y< EFFECT_COUNT;y++) - sp[tempid].base_value[y]=atoi(row[20+y]); // effect_base_value + sp[tempid].base_value[y]=Strings::ToInt(row[20+y]); // effect_base_value for(y=0; y < EFFECT_COUNT; y++) - sp[tempid].limit_value[y]=atoi(row[32+y]); // effect_limit_value + sp[tempid].limit_value[y]=Strings::ToInt(row[32+y]); // effect_limit_value for(y=0; y< EFFECT_COUNT;y++) - sp[tempid].max_value[y]=atoi(row[44+y]); + sp[tempid].max_value[y]=Strings::ToInt(row[44+y]); for(y=0; y< 4;y++) - sp[tempid].component[y]=atoi(row[58+y]); + sp[tempid].component[y]=Strings::ToInt(row[58+y]); for(y=0; y< 4;y++) - sp[tempid].component_count[y]=atoi(row[62+y]); + sp[tempid].component_count[y]=Strings::ToInt(row[62+y]); for(y=0; y< 4;y++) - sp[tempid].no_expend_reagent[y]=atoi(row[66+y]); + sp[tempid].no_expend_reagent[y]=Strings::ToInt(row[66+y]); for(y=0; y< EFFECT_COUNT;y++) - sp[tempid].formula[y]=atoi(row[70+y]); + sp[tempid].formula[y]=Strings::ToInt(row[70+y]); - sp[tempid].good_effect=atoi(row[83]); - sp[tempid].activated=atoi(row[84]); - sp[tempid].resist_type=atoi(row[85]); + sp[tempid].good_effect=Strings::ToInt(row[83]); + sp[tempid].activated=Strings::ToInt(row[84]); + sp[tempid].resist_type=Strings::ToInt(row[85]); for(y=0; y< EFFECT_COUNT;y++) - sp[tempid].effect_id[y]=atoi(row[86+y]); + sp[tempid].effect_id[y]=Strings::ToInt(row[86+y]); - sp[tempid].target_type = static_cast(atoi(row[98])); - sp[tempid].base_difficulty=atoi(row[99]); + sp[tempid].target_type = static_cast(Strings::ToInt(row[98])); + sp[tempid].base_difficulty=Strings::ToInt(row[99]); - int tmp_skill = atoi(row[100]); + int tmp_skill = Strings::ToInt(row[100]); if (tmp_skill < 0 || tmp_skill > EQ::skills::HIGHEST_SKILL) sp[tempid].skill = EQ::skills::SkillBegging; /* not much better we can do. */ // can probably be changed to client-based 'SkillNone' once activated else sp[tempid].skill = static_cast(tmp_skill); - sp[tempid].zone_type=atoi(row[101]); - sp[tempid].environment_type=atoi(row[102]); - sp[tempid].time_of_day=atoi(row[103]); + sp[tempid].zone_type=Strings::ToInt(row[101]); + sp[tempid].environment_type=Strings::ToInt(row[102]); + sp[tempid].time_of_day=Strings::ToInt(row[103]); for(y=0; y < PLAYER_CLASS_COUNT;y++) - sp[tempid].classes[y]=atoi(row[104+y]); + sp[tempid].classes[y]=Strings::ToInt(row[104+y]); - sp[tempid].casting_animation=atoi(row[120]); - sp[tempid].spell_affect_index=atoi(row[123]); - sp[tempid].disallow_sit=atoi(row[124]); - sp[tempid].deity_agnostic=atoi(row[125]); + sp[tempid].casting_animation=Strings::ToInt(row[120]); + sp[tempid].spell_affect_index=Strings::ToInt(row[123]); + sp[tempid].disallow_sit=Strings::ToInt(row[124]); + sp[tempid].deity_agnostic=Strings::ToInt(row[125]); for (y = 0; y < 16; y++) - sp[tempid].deities[y]=atoi(row[126+y]); - - sp[tempid].new_icon=atoi(row[144]); - sp[tempid].uninterruptable=atoi(row[146]) != 0; - sp[tempid].resist_difficulty=atoi(row[147]); - sp[tempid].unstackable_dot = atoi(row[148]) != 0; - sp[tempid].recourse_link = atoi(row[150]); - sp[tempid].no_partial_resist = atoi(row[151]) != 0; - - sp[tempid].short_buff_box = atoi(row[154]); - sp[tempid].description_id = atoi(row[155]); - sp[tempid].type_description_id = atoi(row[156]); - sp[tempid].effect_description_id = atoi(row[157]); - - sp[tempid].npc_no_los = atoi(row[159]) != 0; - sp[tempid].feedbackable = atoi(row[160]) != 0; - sp[tempid].reflectable = atoi(row[161]) != 0; - sp[tempid].bonus_hate=atoi(row[162]); - - sp[tempid].ldon_trap = atoi(row[165]) != 0; - sp[tempid].endurance_cost=atoi(row[166]); - sp[tempid].timer_id=atoi(row[167]); - sp[tempid].is_discipline = atoi(row[168]) != 0; - sp[tempid].hate_added=atoi(row[173]); - sp[tempid].endurance_upkeep=atoi(row[174]); - sp[tempid].hit_number_type = atoi(row[175]); - sp[tempid].hit_number = atoi(row[176]); - sp[tempid].pvp_resist_base=atoi(row[177]); - sp[tempid].pvp_resist_per_level=atoi(row[178]); - sp[tempid].pvp_resist_cap=atoi(row[179]); - sp[tempid].spell_category=atoi(row[180]); - sp[tempid].pvp_duration = atoi(row[181]); - sp[tempid].pvp_duration_cap = atoi(row[182]); - sp[tempid].pcnpc_only_flag=atoi(row[183]); - sp[tempid].cast_not_standing = atoi(row[184]) != 0; - sp[tempid].can_mgb=atoi(row[185]); - sp[tempid].dispel_flag = atoi(row[186]); - sp[tempid].min_resist = atoi(row[189]); - sp[tempid].max_resist = atoi(row[190]); - sp[tempid].viral_targets = atoi(row[191]); - sp[tempid].viral_timer = atoi(row[192]); - sp[tempid].nimbus_effect = atoi(row[193]); - sp[tempid].directional_start = static_cast(atoi(row[194])); - sp[tempid].directional_end = static_cast(atoi(row[195])); - sp[tempid].sneak = atoi(row[196]) != 0; - sp[tempid].not_focusable = atoi(row[197]) != 0; - sp[tempid].no_detrimental_spell_aggro = atoi(row[198]) != 0; - sp[tempid].suspendable = atoi(row[200]) != 0; - sp[tempid].viral_range = atoi(row[201]); - sp[tempid].song_cap = atoi(row[202]); - sp[tempid].no_block = atoi(row[205]); - sp[tempid].spell_group=atoi(row[207]); - sp[tempid].rank = atoi(row[208]); - sp[tempid].no_resist=atoi(row[209]); - sp[tempid].cast_restriction = atoi(row[211]); - sp[tempid].allow_rest = atoi(row[212]) != 0; - sp[tempid].can_cast_in_combat = atoi(row[213]) != 0; - sp[tempid].can_cast_out_of_combat = atoi(row[214]) != 0; - sp[tempid].override_crit_chance = atoi(row[217]); - sp[tempid].aoe_max_targets = atoi(row[218]); - sp[tempid].no_heal_damage_item_mod = atoi(row[219]); - sp[tempid].caster_requirement_id = atoi(row[220]); - sp[tempid].spell_class = atoi(row[221]); - sp[tempid].spell_subclass = atoi(row[222]); - sp[tempid].persist_death = atoi(row[224]) != 0; - sp[tempid].min_distance = static_cast(atof(row[227])); - sp[tempid].min_distance_mod = static_cast(atof(row[228])); - sp[tempid].max_distance = static_cast(atof(row[229])); - sp[tempid].max_distance_mod = static_cast(atof(row[230])); - sp[tempid].min_range = static_cast(atoi(row[231])); - sp[tempid].no_remove = atoi(row[232]) != 0; + sp[tempid].deities[y]=Strings::ToInt(row[126+y]); + + sp[tempid].new_icon=Strings::ToInt(row[144]); + sp[tempid].uninterruptable=Strings::ToInt(row[146]) != 0; + sp[tempid].resist_difficulty=Strings::ToInt(row[147]); + sp[tempid].unstackable_dot = Strings::ToInt(row[148]) != 0; + sp[tempid].recourse_link = Strings::ToInt(row[150]); + sp[tempid].no_partial_resist = Strings::ToInt(row[151]) != 0; + + sp[tempid].short_buff_box = Strings::ToInt(row[154]); + sp[tempid].description_id = Strings::ToInt(row[155]); + sp[tempid].type_description_id = Strings::ToInt(row[156]); + sp[tempid].effect_description_id = Strings::ToInt(row[157]); + + sp[tempid].npc_no_los = Strings::ToInt(row[159]) != 0; + sp[tempid].feedbackable = Strings::ToInt(row[160]) != 0; + sp[tempid].reflectable = Strings::ToInt(row[161]) != 0; + sp[tempid].bonus_hate=Strings::ToInt(row[162]); + + sp[tempid].ldon_trap = Strings::ToInt(row[165]) != 0; + sp[tempid].endurance_cost=Strings::ToInt(row[166]); + sp[tempid].timer_id=Strings::ToInt(row[167]); + sp[tempid].is_discipline = Strings::ToInt(row[168]) != 0; + sp[tempid].hate_added=Strings::ToInt(row[173]); + sp[tempid].endurance_upkeep=Strings::ToInt(row[174]); + sp[tempid].hit_number_type = Strings::ToInt(row[175]); + sp[tempid].hit_number = Strings::ToInt(row[176]); + sp[tempid].pvp_resist_base=Strings::ToInt(row[177]); + sp[tempid].pvp_resist_per_level=Strings::ToInt(row[178]); + sp[tempid].pvp_resist_cap=Strings::ToInt(row[179]); + sp[tempid].spell_category=Strings::ToInt(row[180]); + sp[tempid].pvp_duration = Strings::ToInt(row[181]); + sp[tempid].pvp_duration_cap = Strings::ToInt(row[182]); + sp[tempid].pcnpc_only_flag=Strings::ToInt(row[183]); + sp[tempid].cast_not_standing = Strings::ToInt(row[184]) != 0; + sp[tempid].can_mgb=Strings::ToInt(row[185]); + sp[tempid].dispel_flag = Strings::ToInt(row[186]); + sp[tempid].min_resist = Strings::ToInt(row[189]); + sp[tempid].max_resist = Strings::ToInt(row[190]); + sp[tempid].viral_targets = Strings::ToInt(row[191]); + sp[tempid].viral_timer = Strings::ToInt(row[192]); + sp[tempid].nimbus_effect = Strings::ToInt(row[193]); + sp[tempid].directional_start = static_cast(Strings::ToInt(row[194])); + sp[tempid].directional_end = static_cast(Strings::ToInt(row[195])); + sp[tempid].sneak = Strings::ToInt(row[196]) != 0; + sp[tempid].not_focusable = Strings::ToInt(row[197]) != 0; + sp[tempid].no_detrimental_spell_aggro = Strings::ToInt(row[198]) != 0; + sp[tempid].suspendable = Strings::ToInt(row[200]) != 0; + sp[tempid].viral_range = Strings::ToInt(row[201]); + sp[tempid].song_cap = Strings::ToInt(row[202]); + sp[tempid].no_block = Strings::ToInt(row[205]); + sp[tempid].spell_group=Strings::ToInt(row[207]); + sp[tempid].rank = Strings::ToInt(row[208]); + sp[tempid].no_resist=Strings::ToInt(row[209]); + sp[tempid].cast_restriction = Strings::ToInt(row[211]); + sp[tempid].allow_rest = Strings::ToInt(row[212]) != 0; + sp[tempid].can_cast_in_combat = Strings::ToInt(row[213]) != 0; + sp[tempid].can_cast_out_of_combat = Strings::ToInt(row[214]) != 0; + sp[tempid].override_crit_chance = Strings::ToInt(row[217]); + sp[tempid].aoe_max_targets = Strings::ToInt(row[218]); + sp[tempid].no_heal_damage_item_mod = Strings::ToInt(row[219]); + sp[tempid].caster_requirement_id = Strings::ToInt(row[220]); + sp[tempid].spell_class = Strings::ToInt(row[221]); + sp[tempid].spell_subclass = Strings::ToInt(row[222]); + sp[tempid].persist_death = Strings::ToInt(row[224]) != 0; + sp[tempid].min_distance = static_cast(Strings::ToFloat(row[227])); + sp[tempid].min_distance_mod = static_cast(Strings::ToFloat(row[228])); + sp[tempid].max_distance = static_cast(Strings::ToFloat(row[229])); + sp[tempid].max_distance_mod = static_cast(Strings::ToFloat(row[230])); + sp[tempid].min_range = static_cast(Strings::ToInt(row[231])); + sp[tempid].no_remove = Strings::ToInt(row[232]) != 0; sp[tempid].damage_shield_type = 0; } @@ -2107,7 +2107,7 @@ int SharedDatabase::GetMaxBaseDataLevel() { auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool SharedDatabase::LoadBaseData(const std::string &prefix) { @@ -2141,8 +2141,8 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) { } for (auto& row = results.begin(); row != results.end(); ++row) { - const int lvl = atoi(row[0]); - const int cl = atoi(row[1]); + const int lvl = Strings::ToInt(row[0]); + const int cl = Strings::ToInt(row[1]); if(lvl <= 0) { LogError("Non fatal error: base_data.level <= 0, ignoring."); @@ -2165,14 +2165,14 @@ void SharedDatabase::LoadBaseData(void *data, int max_level) { } BaseDataStruct *bd = reinterpret_cast(base_ptr + (((16 * (lvl - 1)) + (cl - 1)) * sizeof(BaseDataStruct))); - bd->base_hp = atof(row[2]); - bd->base_mana = atof(row[3]); - bd->base_end = atof(row[4]); - bd->hp_regen = atof(row[5]); - bd->end_regen = atof(row[6]); - bd->hp_factor = atof(row[7]); - bd->mana_factor = atof(row[8]); - bd->endurance_factor = atof(row[9]); + bd->base_hp = Strings::ToFloat(row[2]); + bd->base_mana = Strings::ToFloat(row[3]); + bd->base_end = Strings::ToFloat(row[4]); + bd->hp_regen = Strings::ToFloat(row[5]); + bd->end_regen = Strings::ToFloat(row[6]); + bd->hp_factor = Strings::ToFloat(row[7]); + bd->mana_factor = Strings::ToFloat(row[8]); + bd->endurance_factor = Strings::ToFloat(row[9]); } } @@ -2225,9 +2225,9 @@ void SharedDatabase::GetLootTableInfo(uint32 &loot_table_count, uint32 &max_loot auto& row = results.begin(); - loot_table_count = static_cast(atoul(row[0])); - max_loot_table = static_cast(atoul(row[1] ? row[1] : "0")); - loot_table_entries = static_cast(atoul(row[2])); + loot_table_count = static_cast(Strings::ToUnsignedInt(row[0])); + max_loot_table = static_cast(Strings::ToUnsignedInt(row[1] ? row[1] : "0")); + loot_table_entries = static_cast(Strings::ToUnsignedInt(row[2])); } void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_drop, uint32 &loot_drop_entries) { @@ -2250,9 +2250,9 @@ void SharedDatabase::GetLootDropInfo(uint32 &loot_drop_count, uint32 &max_loot_d auto& row =results.begin(); - loot_drop_count = static_cast(atoul(row[0])); - max_loot_drop = static_cast(atoul(row[1] ? row[1] : "0")); - loot_drop_entries = static_cast(atoul(row[2])); + loot_drop_count = static_cast(Strings::ToUnsignedInt(row[0])); + max_loot_drop = static_cast(Strings::ToUnsignedInt(row[1] ? row[1] : "0")); + loot_drop_entries = static_cast(Strings::ToUnsignedInt(row[2])); } void SharedDatabase::LoadLootTables(void *data, uint32 size) { @@ -2296,7 +2296,7 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) { uint32 current_entry = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - const uint32 id = static_cast(atoul(row[0])); + const uint32 id = static_cast(Strings::ToUnsignedInt(row[0])); if (id != current_id) { if (current_id != 0) { hash.insert( @@ -2308,12 +2308,12 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) { memset(loot_table, 0, sizeof(LootTable_Struct) + (sizeof(LootTableEntries_Struct) * 128)); current_entry = 0; current_id = id; - lt->mincash = static_cast(atoul(row[1])); - lt->maxcash = static_cast(atoul(row[2])); - lt->avgcoin = static_cast(atoul(row[3])); + lt->mincash = static_cast(Strings::ToUnsignedInt(row[1])); + lt->maxcash = static_cast(Strings::ToUnsignedInt(row[2])); + lt->avgcoin = static_cast(Strings::ToUnsignedInt(row[3])); - lt->content_flags.min_expansion = static_cast(atoi(row[9])); - lt->content_flags.max_expansion = static_cast(atoi(row[10])); + lt->content_flags.min_expansion = static_cast(Strings::ToInt(row[9])); + lt->content_flags.max_expansion = static_cast(Strings::ToInt(row[10])); strn0cpy(lt->content_flags.content_flags, row[11], sizeof(lt->content_flags.content_flags)); strn0cpy(lt->content_flags.content_flags_disabled, row[12], sizeof(lt->content_flags.content_flags_disabled)); @@ -2327,11 +2327,11 @@ void SharedDatabase::LoadLootTables(void *data, uint32 size) { continue; } - lt->Entries[current_entry].lootdrop_id = static_cast(atoul(row[4])); - lt->Entries[current_entry].multiplier = static_cast(atoi(row[5])); - lt->Entries[current_entry].droplimit = static_cast(atoi(row[6])); - lt->Entries[current_entry].mindrop = static_cast(atoi(row[7])); - lt->Entries[current_entry].probability = static_cast(atof(row[8])); + lt->Entries[current_entry].lootdrop_id = static_cast(Strings::ToUnsignedInt(row[4])); + lt->Entries[current_entry].multiplier = static_cast(Strings::ToInt(row[5])); + lt->Entries[current_entry].droplimit = static_cast(Strings::ToInt(row[6])); + lt->Entries[current_entry].mindrop = static_cast(Strings::ToInt(row[7])); + lt->Entries[current_entry].probability = static_cast(Strings::ToFloat(row[8])); ++(lt->NumEntries); ++current_entry; @@ -2390,7 +2390,7 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) { uint32 current_entry = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - const auto id = static_cast(atoul(row[0])); + const auto id = static_cast(Strings::ToUnsignedInt(row[0])); if (id != current_id) { if (current_id != 0) { hash.insert( @@ -2403,8 +2403,8 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) { current_entry = 0; current_id = id; - p_loot_drop_struct->content_flags.min_expansion = static_cast(atoi(row[10])); - p_loot_drop_struct->content_flags.max_expansion = static_cast(atoi(row[11])); + p_loot_drop_struct->content_flags.min_expansion = static_cast(Strings::ToInt(row[10])); + p_loot_drop_struct->content_flags.max_expansion = static_cast(Strings::ToInt(row[11])); strn0cpy(p_loot_drop_struct->content_flags.content_flags, row[12], sizeof(p_loot_drop_struct->content_flags.content_flags)); strn0cpy(p_loot_drop_struct->content_flags.content_flags_disabled, row[13], sizeof(p_loot_drop_struct->content_flags.content_flags_disabled)); @@ -2414,15 +2414,15 @@ void SharedDatabase::LoadLootDrops(void *data, uint32 size) { continue; } - p_loot_drop_struct->Entries[current_entry].item_id = static_cast(atoul(row[1])); - p_loot_drop_struct->Entries[current_entry].item_charges = static_cast(atoi(row[2])); - p_loot_drop_struct->Entries[current_entry].equip_item = static_cast(atoi(row[3])); - p_loot_drop_struct->Entries[current_entry].chance = static_cast(atof(row[4])); - p_loot_drop_struct->Entries[current_entry].trivial_min_level = static_cast(atoi(row[5])); - p_loot_drop_struct->Entries[current_entry].trivial_max_level = static_cast(atoi(row[6])); - p_loot_drop_struct->Entries[current_entry].npc_min_level = static_cast(atoi(row[7])); - p_loot_drop_struct->Entries[current_entry].npc_max_level = static_cast(atoi(row[8])); - p_loot_drop_struct->Entries[current_entry].multiplier = static_cast(atoi(row[9])); + p_loot_drop_struct->Entries[current_entry].item_id = static_cast(Strings::ToUnsignedInt(row[1])); + p_loot_drop_struct->Entries[current_entry].item_charges = static_cast(Strings::ToInt(row[2])); + p_loot_drop_struct->Entries[current_entry].equip_item = static_cast(Strings::ToInt(row[3])); + p_loot_drop_struct->Entries[current_entry].chance = static_cast(Strings::ToFloat(row[4])); + p_loot_drop_struct->Entries[current_entry].trivial_min_level = static_cast(Strings::ToInt(row[5])); + p_loot_drop_struct->Entries[current_entry].trivial_max_level = static_cast(Strings::ToInt(row[6])); + p_loot_drop_struct->Entries[current_entry].npc_min_level = static_cast(Strings::ToInt(row[7])); + p_loot_drop_struct->Entries[current_entry].npc_max_level = static_cast(Strings::ToInt(row[8])); + p_loot_drop_struct->Entries[current_entry].multiplier = static_cast(Strings::ToInt(row[9])); ++(p_loot_drop_struct->NumEntries); ++current_entry; @@ -2518,7 +2518,7 @@ uint32 SharedDatabase::GetSpellsCount() auto& row = results.begin(); if (row[0]) { - return atoul(row[0]); + return Strings::ToUnsignedInt(row[0]); } return 0; @@ -2534,7 +2534,7 @@ uint32 SharedDatabase::GetItemsCount() auto& row = results.begin(); if (row[0]) { - return atoul(row[0]); + return Strings::ToUnsignedInt(row[0]); } return 0; diff --git a/common/strings.cpp b/common/strings.cpp index 74405fa868..d0e4ebd370 100644 --- a/common/strings.cpp +++ b/common/strings.cpp @@ -191,24 +191,23 @@ std::string Strings::Escape(const std::string &s) bool Strings::IsNumber(const std::string &s) { - try { - auto r = stoi(s); - return true; - } - catch (std::exception &) { - return false; + for (char const &c: s) { + if (c == s[0] && s[0] == '-') { + continue; + } + if (std::isdigit(c) == 0) { + return false; + } } + + return true; } bool Strings::IsFloat(const std::string &s) { - try { - auto r = stof(s); - return true; - } - catch (std::exception &) { - return false; - } + char* ptr; + strtof(s.c_str(), &ptr); + return (*ptr) == '\0'; } std::string Strings::Join(const std::vector &ar, const std::string &delim) @@ -728,7 +727,7 @@ uint32 Strings::TimeToSeconds(std::string time_string) time_unit.end() ); - auto unit = std::stoul(time_unit); + auto unit = Strings::ToUnsignedInt(time_unit); uint32 duration = 0; if (Strings::Contains(time_string, "s")) { @@ -755,7 +754,7 @@ bool Strings::ToBool(std::string bool_string) Strings::Contains(bool_string, "on") || Strings::Contains(bool_string, "enable") || Strings::Contains(bool_string, "enabled") || - (Strings::IsNumber(bool_string) && std::stoi(bool_string)) + (Strings::IsNumber(bool_string) && Strings::ToInt(bool_string)) ) { return true; } @@ -785,6 +784,26 @@ int Strings::ToInt(const std::string &s, int fallback) return Strings::IsNumber(s) ? std::stoi(s) : fallback; } +int64 Strings::ToBigInt(const std::string &s, int64 fallback) +{ + return Strings::IsNumber(s) ? std::stoll(s) : fallback; +} + +uint32 Strings::ToUnsignedInt(const std::string &s, uint32 fallback) +{ + return Strings::IsNumber(s) ? std::stoul(s) : fallback; +} + +uint64 Strings::ToUnsignedBigInt(const std::string &s, uint64 fallback) +{ + return Strings::IsNumber(s) ? std::stoull(s) : fallback; +} + +float Strings::ToFloat(const std::string &s, float fallback) +{ + return Strings::IsFloat(s) ? std::stof(s) : fallback; +} + std::string Strings::RemoveNumbers(std::string s) { int current = 0; diff --git a/common/strings.h b/common/strings.h index a25898f7e1..d454b90b9c 100644 --- a/common/strings.h +++ b/common/strings.h @@ -86,7 +86,11 @@ class Strings { public: static bool Contains(std::vector container, std::string element); static bool Contains(const std::string& subject, const std::string& search); - static int ToInt(const std::string &s, int fallback = 0); + static int ToInt(const std::string &s, int fallback = 0); + static int64 ToBigInt(const std::string &s, int64 fallback = 0); + static uint32 ToUnsignedInt(const std::string &s, uint32 fallback = 0); + static uint64 ToUnsignedBigInt(const std::string &s, uint64 fallback = 0); + static float ToFloat(const std::string &s, float fallback = 0.0f); static bool IsNumber(const std::string &s); static std::string RemoveNumbers(std::string s); static bool IsFloat(const std::string &s); diff --git a/common/strings_legacy.cpp b/common/strings_legacy.cpp index 480a4ebe59..e1d324d455 100644 --- a/common/strings_legacy.cpp +++ b/common/strings_legacy.cpp @@ -192,7 +192,7 @@ bool atobool(const char *iBool) if (!strcasecmp(iBool, "n")) { return false; } - if (atoi(iBool)) { + if (Strings::ToInt(iBool)) { return true; } return false; diff --git a/loginserver/account_management.cpp b/loginserver/account_management.cpp index 6be0119512..dba6e25d83 100644 --- a/loginserver/account_management.cpp +++ b/loginserver/account_management.cpp @@ -381,7 +381,7 @@ uint32 AccountManagement::CheckExternalLoginserverUserCredentials( auto s = Strings::Split(server.options.GetEQEmuLoginServerAddress(), ':'); if (s.size() == 2) { auto address = s[0]; - auto port = std::stoi(s[1]); + auto port = Strings::ToInt(s[1]); EQ::Net::DNSLookup( address, port, false, [&](const std::string &addr) { diff --git a/loginserver/database.cpp b/loginserver/database.cpp index b07b0a1c29..25ea28aa66 100644 --- a/loginserver/database.cpp +++ b/loginserver/database.cpp @@ -32,7 +32,7 @@ Database::Database( user.c_str(), pass.c_str(), name.c_str(), - std::stoi(port), + Strings::ToInt(port), &errnum, errbuf ) @@ -93,7 +93,7 @@ bool Database::GetLoginDataFromAccountInfo( auto row = results.begin(); - id = atoi(row[0]); + id = Strings::ToInt(row[0]); password = row[1]; LogDebug( @@ -145,7 +145,7 @@ bool Database::GetLoginTokenDataFromToken( } if (strcmp(row[2], "login_server_id") == 0) { - db_account_id = atoi(row[3]); + db_account_id = Strings::ToInt(row[3]); found_login_id = true; continue; } @@ -178,7 +178,7 @@ unsigned int Database::GetFreeID(const std::string &loginserver) auto row = results.begin(); - return std::stoi(row[0]); + return Strings::ToInt(row[0]); } /** @@ -368,12 +368,12 @@ Database::DbWorldRegistration Database::GetWorldRegistration( auto row = results.begin(); r.loaded = true; - r.server_id = std::stoi(row[0]); + r.server_id = Strings::ToInt(row[0]); r.server_description = row[1]; - r.server_list_type = std::stoi(row[3]); - r.is_server_trusted = std::stoi(row[2]) > 0; + 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 = std::stoi(row[5]); + r.server_admin_id = Strings::ToInt(row[5]); if (r.server_admin_id <= 0) { return r; @@ -513,7 +513,7 @@ bool Database::CreateWorldRegistration( auto row = results.begin(); - id = std::stoi(row[0]); + id = Strings::ToInt(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 = ''", @@ -647,7 +647,7 @@ Database::DbLoginServerAdmin Database::GetLoginServerAdmin(const std::string &ac if (results.RowCount() == 1) { auto row = results.begin(); r.loaded = true; - r.id = std::stoi(row[0]); + r.id = Strings::ToInt(row[0]); r.account_name = row[1]; r.account_password = row[2]; r.first_name = row[3]; @@ -683,7 +683,7 @@ Database::DbLoginServerAccount Database::GetLoginServerAccountByAccountName( if (results.RowCount() == 1) { auto row = results.begin(); r.loaded = true; - r.id = std::stoi(row[0]); + r.id = Strings::ToInt(row[0]); r.account_name = row[1]; r.account_password = row[2]; r.account_email = row[3]; diff --git a/loginserver/loginserver_webserver.cpp b/loginserver/loginserver_webserver.cpp index eb0acb5513..e7f3f5a3b8 100644 --- a/loginserver/loginserver_webserver.cpp +++ b/loginserver/loginserver_webserver.cpp @@ -480,8 +480,8 @@ namespace LoginserverWebserver { for (auto row = results.begin(); row != results.end(); ++row) { LoginserverWebserver::TokenManager::token_data token_data; token_data.token = row[0]; - token_data.can_write = std::stoi(row[1]) > 0; - token_data.can_read = std::stoi(row[2]) > 0; + token_data.can_write = Strings::ToInt(row[1]) > 0; + token_data.can_read = Strings::ToInt(row[2]) > 0; LogDebug( "Inserting api token to internal list [{0}] write {1} read {2}", diff --git a/queryserv/database.h b/queryserv/database.h index ed67b6db82..c0e664bc2b 100644 --- a/queryserv/database.h +++ b/queryserv/database.h @@ -33,8 +33,6 @@ #include #include -//atoi is not uint32 or uint32 safe!!!! -#define atoul(str) strtoul(str, nullptr, 10) class QSDatabase : public Database { public: diff --git a/queryserv/lfguild.cpp b/queryserv/lfguild.cpp index d97cc38556..e1ec302573 100644 --- a/queryserv/lfguild.cpp +++ b/queryserv/lfguild.cpp @@ -44,15 +44,15 @@ bool LFGuildManager::LoadDatabase() } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 type = atoul(row[0]); + uint32 type = Strings::ToUnsignedInt(row[0]); if(type == 0) { - PlayerLookingForGuild p(row[1], row[2], atoul(row[3]), atoul(row[5]), atoul(row[6]), atoul(row[7]), atoul(row[8])); + PlayerLookingForGuild p(row[1], row[2], Strings::ToUnsignedInt(row[3]), Strings::ToUnsignedInt(row[5]), Strings::ToUnsignedInt(row[6]), Strings::ToUnsignedInt(row[7]), Strings::ToUnsignedInt(row[8])); Players.push_back(p); continue; } - GuildLookingForPlayers g(row[1], row[2], atoul(row[3]), atoul(row[4]), atoul(row[5]), atoul(row[6]), atoul(row[7]), atoul(row[8])); + GuildLookingForPlayers g(row[1], row[2], Strings::ToUnsignedInt(row[3]), Strings::ToUnsignedInt(row[4]), Strings::ToUnsignedInt(row[5]), Strings::ToUnsignedInt(row[6]), Strings::ToUnsignedInt(row[7]), Strings::ToUnsignedInt(row[8])); Guilds.push_back(g); } diff --git a/tests/main.cpp b/tests/main.cpp index 2f32c2840f..50ddf890ba 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -46,8 +46,7 @@ int main() auto ConfigLoadResult = EQEmuConfig::LoadConfig(); Config = EQEmuConfig::get(); try { - std::ofstream outfile("test_output.txt"); - std::unique_ptr output(new Test::TextOutput(Test::TextOutput::Verbose, outfile)); + std::unique_ptr output(new Test::TextOutput(Test::TextOutput::Verbose)); Test::Suite tests; tests.add(new MemoryMappedFileTest()); tests.add(new IPCMutexTest()); @@ -60,7 +59,9 @@ int main() tests.add(new SkillsUtilsTest()); tests.add(new TaskStateTest()); tests.run(*output, true); - } catch (...) { + } + catch (std::exception &ex) { + LogError("Test Failure [{}]", ex.what()); return -1; } return 0; diff --git a/tests/string_util_test.h b/tests/string_util_test.h index 5d8a3a9561..3a8b59c358 100644 --- a/tests/string_util_test.h +++ b/tests/string_util_test.h @@ -31,6 +31,8 @@ class StringUtilTest : public Test::Suite { TEST_ADD(StringUtilTest::SearchDeliminatedStringTest); TEST_ADD(StringUtilTest::SplitStringTest); TEST_ADD(StringUtilTest::FromCharsTest); + TEST_ADD(StringUtilTest::TestIsFloat); + TEST_ADD(StringUtilTest::TestIsNumber); } ~StringUtilTest() { @@ -116,6 +118,26 @@ class StringUtilTest : public Test::Suite { TEST_ASSERT(float_value == 3.14f); } + + void TestIsFloat() { + TEST_ASSERT_EQUALS(Strings::IsFloat("0.23424523"), true); + TEST_ASSERT_EQUALS(Strings::IsFloat("12312312313.23424523"), true); + TEST_ASSERT_EQUALS(Strings::IsFloat("12312312313"), true); + TEST_ASSERT_EQUALS(Strings::IsFloat(".234234"), true); + TEST_ASSERT_EQUALS(Strings::IsFloat(".234234f"), false); + TEST_ASSERT_EQUALS(Strings::IsFloat("Johnson"), false); + } + + void TestIsNumber() { + TEST_ASSERT_EQUALS(Strings::IsNumber("0.23424523"), false); + TEST_ASSERT_EQUALS(Strings::IsNumber("12312312313.23424523"), false); + TEST_ASSERT_EQUALS(Strings::IsNumber("12312312313"), true); + TEST_ASSERT_EQUALS(Strings::IsNumber("12312312313f"), false); // character at end + TEST_ASSERT_EQUALS(Strings::IsNumber("18446744073709551616"), true); // 64 + TEST_ASSERT_EQUALS(Strings::IsNumber("-18"), true); + TEST_ASSERT_EQUALS(Strings::IsNumber("-f18"), false); + TEST_ASSERT_EQUALS(Strings::IsNumber("-18446744073709551616"), true); // 64 + } }; #endif diff --git a/ucs/chatchannel.cpp b/ucs/chatchannel.cpp index 123c4aa993..4da5aebc8b 100644 --- a/ucs/chatchannel.cpp +++ b/ucs/chatchannel.cpp @@ -657,7 +657,7 @@ ChatChannel *ChatChannelList::RemoveClientFromChannel(const std::string& in_chan std::string channel_name = in_channel_name; if (in_channel_name.length() > 0 && isdigit(channel_name[0])) { - channel_name = c->ChannelSlotName(atoi(in_channel_name.c_str())); + channel_name = c->ChannelSlotName(Strings::ToInt(in_channel_name.c_str())); } auto *required_channel = FindChannel(channel_name); diff --git a/ucs/clientlist.cpp b/ucs/clientlist.cpp index 070c962ccf..cb57367257 100644 --- a/ucs/clientlist.cpp +++ b/ucs/clientlist.cpp @@ -379,14 +379,14 @@ static void ProcessSetMessageStatus(std::string SetMessageCommand) { if (NumEnd == std::string::npos) { - MessageNumber = atoi(SetMessageCommand.substr(NumStart).c_str()); + MessageNumber = Strings::ToInt(SetMessageCommand.substr(NumStart).c_str()); database.SetMessageStatus(MessageNumber, Status); break; } - MessageNumber = atoi(SetMessageCommand.substr(NumStart, NumEnd - NumStart).c_str()); + MessageNumber = Strings::ToInt(SetMessageCommand.substr(NumStart, NumEnd - NumStart).c_str()); database.SetMessageStatus(MessageNumber, Status); @@ -876,7 +876,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string command_string, boo break; case CommandGetBody: - database.SendBody(c, atoi(parameters.c_str())); + database.SendBody(c, Strings::ToInt(parameters.c_str())); break; case CommandMailTo: @@ -891,7 +891,7 @@ void Clientlist::ProcessOPMailCommand(Client *c, std::string command_string, boo case CommandSelectMailBox: { std::string::size_type NumStart = parameters.find_first_of("0123456789"); - c->ChangeMailBox(atoi(parameters.substr(NumStart).c_str())); + c->ChangeMailBox(Strings::ToInt(parameters.substr(NumStart).c_str())); break; } case CommandSetMailForwarding: @@ -1253,7 +1253,7 @@ void Client::ProcessChannelList(std::string Input) { std::string ChannelName = Input; if (isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); @@ -1414,7 +1414,7 @@ void Client::SendChannelMessageByNumber(std::string Message) { if (MessageStart == std::string::npos) return; - int ChannelNumber = atoi(Message.substr(0, MessageStart).c_str()); + int ChannelNumber = Strings::ToInt(Message.substr(0, MessageStart).c_str()); if ((ChannelNumber < 1) || (ChannelNumber > MAX_JOINED_CHANNELS)) { @@ -1657,7 +1657,7 @@ void Client::SetChannelPassword(std::string ChannelPassword) { std::string ChannelName = ChannelPassword.substr(ChannelStart); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); std::string Message; @@ -1722,7 +1722,7 @@ void Client::SetChannelOwner(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); LogInfo("Set owner of channel [[{}]] to [[{}]]", ChannelName.c_str(), NewOwner.c_str()); @@ -1768,7 +1768,7 @@ void Client::OPList(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); @@ -1811,7 +1811,7 @@ void Client::ChannelInvite(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); LogInfo("[[{}]] invites [[{}]] to channel [[{}]]", GetName().c_str(), Invitee.c_str(), ChannelName.c_str()); @@ -1881,7 +1881,7 @@ void Client::ChannelModerate(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); ChatChannel *RequiredChannel = ChannelList->FindChannel(ChannelName); @@ -1939,7 +1939,7 @@ void Client::ChannelGrantModerator(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); LogInfo("[[{}]] gives [[{}]] moderator rights to channel [[{}]]", GetName().c_str(), Moderator.c_str(), ChannelName.c_str()); @@ -2020,7 +2020,7 @@ void Client::ChannelGrantVoice(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); LogInfo("[[{}]] gives [[{}]] voice to channel [[{}]]", GetName().c_str(), Voicee.c_str(), ChannelName.c_str()); @@ -2108,7 +2108,7 @@ void Client::ChannelKick(std::string CommandString) { std::string ChannelName = CapitaliseName(CommandString.substr(ChannelStart)); if ((ChannelName.length() > 0) && isdigit(ChannelName[0])) - ChannelName = ChannelSlotName(atoi(ChannelName.c_str())); + ChannelName = ChannelSlotName(Strings::ToInt(ChannelName.c_str())); LogInfo("[[{}]] kicks [[{}]] from channel [[{}]]", GetName().c_str(), Kickee.c_str(), ChannelName.c_str()); diff --git a/ucs/database.cpp b/ucs/database.cpp index ee69cf1c37..b33efe2055 100644 --- a/ucs/database.cpp +++ b/ucs/database.cpp @@ -84,10 +84,10 @@ void UCSDatabase::GetAccountStatus(Client *client) auto row = results.begin(); - client->SetAccountStatus(atoi(row[0])); - client->SetHideMe(atoi(row[1]) != 0); - client->SetKarma(atoi(row[2])); - client->SetRevoked((atoi(row[3]) == 1 ? true : false)); + client->SetAccountStatus(Strings::ToInt(row[0])); + client->SetHideMe(Strings::ToInt(row[1]) != 0); + client->SetKarma(Strings::ToInt(row[2])); + client->SetRevoked((Strings::ToInt(row[3]) == 1 ? true : false)); LogDebug( "Set account status to [{}], hideme to [{}] and karma to [{}] for [{}]", @@ -119,9 +119,9 @@ int UCSDatabase::FindAccount(const char *characterName, Client *client) } auto row = results.begin(); - client->AddCharacter(atoi(row[0]), characterName, atoi(row[2])); + client->AddCharacter(Strings::ToInt(row[0]), characterName, Strings::ToInt(row[2])); - int accountID = atoi(row[1]); + int accountID = Strings::ToInt(row[1]); LogInfo("Account ID for [{}] is [{}]", characterName, accountID); @@ -137,7 +137,7 @@ int UCSDatabase::FindAccount(const char *characterName, Client *client) } for (auto row = results.begin(); row != results.end(); ++row) - client->AddCharacter(atoi(row[0]), row[1], atoi(row[2])); + client->AddCharacter(Strings::ToInt(row[0]), row[1], Strings::ToInt(row[2])); return accountID; } @@ -197,7 +197,7 @@ int UCSDatabase::FindCharacter(const char *characterName) auto row = results.begin(); - int characterID = atoi(row[0]); + int characterID = Strings::ToInt(row[0]); return characterID; } @@ -224,7 +224,7 @@ bool UCSDatabase::GetVariable(const char *varname, char *varvalue, uint16 varval bool UCSDatabase::LoadChatChannels() -{ +{ if (!RuleB(Chat, ChannelsIgnoreNameFilter)) { LoadFilteredNamesFromDB(); } @@ -244,7 +244,7 @@ bool UCSDatabase::LoadChatChannels() auto channel_min_status = row[3]; if (!ChannelList->FindChannel(channel_name)) { - ChannelList->CreateChannel(channel_name, channel_owner, channel_password, true, atoi(channel_min_status), false); + ChannelList->CreateChannel(channel_name, channel_owner, channel_password, true, Strings::ToInt(channel_min_status), false); } } return true; @@ -743,7 +743,7 @@ void UCSDatabase::GetFriendsAndIgnore(const int& charID, std::vector #include -//atoi is not uint32 or uint32 safe!!!! -#define atoul(str) strtoul(str, nullptr, 10) class UCSDatabase : public Database { public: diff --git a/utils/TaskMaster/activities.cpp b/utils/TaskMaster/activities.cpp index 4cbb2a1b5e..2f2dc04510 100644 --- a/utils/TaskMaster/activities.cpp +++ b/utils/TaskMaster/activities.cpp @@ -507,11 +507,11 @@ void MainFrame::SaveActivity(wxCommandEvent& event) ourAct.optional = mActivityOptional->GetValue(); getStr = mActID->GetValue(); - ourAct.activityId = atoi(getStr.mb_str()); + ourAct.activityId = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mActStep->GetValue(); - ourAct.step = atoi(getStr.mb_str()); + ourAct.step = Strings::ToInt(getStr.mb_str()); getStr.Clear(); int type = mActType->GetSelection(); @@ -530,17 +530,17 @@ void MainFrame::SaveActivity(wxCommandEvent& event) } getStr = mActDeliver->GetValue(); - ourAct.deliverToNpc = atoi(getStr.mb_str()); + ourAct.deliverToNpc = Strings::ToInt(getStr.mb_str()); getStr.Clear(); ourAct.goalmethod = mActMethod->GetSelection(); getStr = mActGoalID->GetValue(); - ourAct.goalid = atoi(getStr.mb_str()); + ourAct.goalid = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mActGoalCount->GetValue(); - ourAct.goalcount = atoi(getStr.mb_str()); + ourAct.goalcount = Strings::ToInt(getStr.mb_str()); getStr.Clear(); if(ourAct.activityId == openedActivity.activityid && ourAct.id == openedActivity.id){ @@ -645,4 +645,4 @@ void MainFrame::ContextMenuActivityList() PopupMenu(mMenu); delete mMenu; -} \ No newline at end of file +} diff --git a/utils/TaskMaster/base_utility.cpp b/utils/TaskMaster/base_utility.cpp index d507bdb893..dbbd444f7b 100644 --- a/utils/TaskMaster/base_utility.cpp +++ b/utils/TaskMaster/base_utility.cpp @@ -76,7 +76,7 @@ bool MainFrame::LoadItems(){ while ((row = mysql_fetch_row(res)) != NULL){ eqitem newIT; strcpy(newIT.name, row[0]); - newIT.id = atoi(row[1]); + newIT.id = Strings::ToInt(row[1]); itemList.push_back(newIT); itemsLoaded++; } @@ -127,7 +127,7 @@ bool MainFrame::LoadZones() eqtask_zones newZ; strcpy(newZ.name, row[0]); - newZ.id = atoi(row[1]); + newZ.id = Strings::ToInt(row[1]); taskZoneList.push_back(newZ); int * zoneId = new int; @@ -168,7 +168,7 @@ bool MainFrame::LoadTasks() res = mysql_use_result(mMysql); while ((row = mysql_fetch_row(res)) != NULL){ eqtask newT; - newT.id = atoi(row[0]); + newT.id = Strings::ToInt(row[0]); //This isn't all that safe //Working under the assumption that: @@ -185,15 +185,15 @@ bool MainFrame::LoadTasks() if(newT.id > highestIndex) highestIndex = newT.id; - newT.rewardid = atoi(row[4]); - newT.cashreward = atoi(row[5]); - newT.xpreward = atoi(row[6]); - newT.rewardmethod = atoi(row[7]); - newT.startzone = atoi(row[8]); - newT.duration = atoi(row[9]); - newT.level_min = atoi(row[10]); - newT.level_max = atoi(row[11]); - newT.repeatable = atoi(row[12]) ? true : false; + newT.rewardid = Strings::ToInt(row[4]); + newT.cashreward = Strings::ToInt(row[5]); + newT.xpreward = Strings::ToInt(row[6]); + newT.rewardmethod = Strings::ToInt(row[7]); + newT.startzone = Strings::ToInt(row[8]); + newT.duration = Strings::ToInt(row[9]); + newT.level_min = Strings::ToInt(row[10]); + newT.level_max = Strings::ToInt(row[11]); + newT.repeatable = Strings::ToInt(row[12]) ? true : false; taskList.push_back(newT); @@ -225,8 +225,8 @@ bool MainFrame::LoadGoals() res = mysql_use_result(mMysql); while ((row = mysql_fetch_row(res)) != NULL){ eqtask_goallist newGL; - newGL.id = atoi(row[0]); - newGL.value = atoi(row[1]); + newGL.id = Strings::ToInt(row[0]); + newGL.value = Strings::ToInt(row[1]); goalTaskList.push_back(newGL); goalsLoaded++; @@ -258,19 +258,19 @@ bool MainFrame::LoadActivities() { while ((row = mysql_fetch_row(res)) != NULL) { eqtask_activities newAL; - newAL.id = atoi(row[0]); - newAL.activityId = atoi(row[1]); - newAL.step = atoi(row[2]); - newAL.activityType = atoi(row[3]); + newAL.id = Strings::ToInt(row[0]); + newAL.activityId = Strings::ToInt(row[1]); + newAL.step = Strings::ToInt(row[2]); + newAL.activityType = Strings::ToInt(row[3]); strcpy(newAL.text1, row[4]); strcpy(newAL.text2, row[5]); strcpy(newAL.text3, row[6]); - newAL.goalid = atoi(row[7]); - newAL.goalmethod = atoi(row[8]); - newAL.goalcount = atoi(row[9]); - newAL.deliverToNpc = atoi(row[10]); - newAL.zoneid = atoi(row[11]); - newAL.optional = atoi(row[12]) ? true : false; + newAL.goalid = Strings::ToInt(row[7]); + newAL.goalmethod = Strings::ToInt(row[8]); + newAL.goalcount = Strings::ToInt(row[9]); + newAL.deliverToNpc = Strings::ToInt(row[10]); + newAL.zoneid = Strings::ToInt(row[11]); + newAL.optional = Strings::ToInt(row[12]) ? true : false; taskActivitiesList.push_back(newAL); activitiesLoaded++; @@ -301,8 +301,8 @@ bool MainFrame::LoadProximity() while ((row = mysql_fetch_row(res)) != NULL){ eqtask_proximity newPR; - newPR.zoneid = atoi(row[0]); - newPR.exploreid = atoi(row[1]); + newPR.zoneid = Strings::ToInt(row[0]); + newPR.exploreid = Strings::ToInt(row[1]); newPR.minx = atof(row[2]); newPR.maxx = atof(row[3]); newPR.miny = atof(row[4]); @@ -438,4 +438,4 @@ wxString MainFrame::MakeStringSQLSafe(const char * c) ret.Printf("%s", c); ret.Replace("\'", "\\\'"); return ret; -} \ No newline at end of file +} diff --git a/utils/TaskMaster/proximity.cpp b/utils/TaskMaster/proximity.cpp index 0ed3820d9d..cbe498d7a8 100644 --- a/utils/TaskMaster/proximity.cpp +++ b/utils/TaskMaster/proximity.cpp @@ -276,7 +276,7 @@ void MainFrame::SaveProximity(wxCommandEvent& event) inStr.Clear(); inStr = mProxId->GetValue(); - toSave.exploreid = atoi(inStr.mb_str()); + toSave.exploreid = Strings::ToInt(inStr.mb_str()); inStr.Clear(); inStr = mProxMinx->GetValue(); @@ -465,4 +465,4 @@ void MainFrame::ContextMenuProximity() PopupMenu(mMenu); delete mMenu; -} \ No newline at end of file +} diff --git a/utils/TaskMaster/tasks.cpp b/utils/TaskMaster/tasks.cpp index 48aa44080b..9cfedb7fe7 100644 --- a/utils/TaskMaster/tasks.cpp +++ b/utils/TaskMaster/tasks.cpp @@ -195,7 +195,7 @@ void MainFrame::OnRewardButton(wxCommandEvent& event) { wxString ridStr = mRewardID->GetValue(); int rtype = mRewardMethod->GetCurrentSelection(); - int rid = atoi(ridStr.mb_str()); + int rid = Strings::ToInt(ridStr.mb_str()); ShowRewardChange(rtype,rid); } @@ -224,15 +224,15 @@ void MainFrame::SaveTask(wxCommandEvent& event) getStr.Clear(); getStr = mTaskMinLvl->GetValue(); - ourTask.level_min = atoi(getStr.mb_str()); + ourTask.level_min = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mTaskMaxLvl->GetValue(); - ourTask.level_max = atoi(getStr.mb_str()); + ourTask.level_max = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mTaskDuration->GetValue(); - ourTask.duration = atoi(getStr.mb_str()); + ourTask.duration = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mRewardName->GetValue(); @@ -240,15 +240,15 @@ void MainFrame::SaveTask(wxCommandEvent& event) getStr.Clear(); getStr = mRewardID->GetValue(); - ourTask.rewardid = atoi(getStr.mb_str()); + ourTask.rewardid = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mRewardCash->GetValue(); - ourTask.cashreward = atoi(getStr.mb_str()); + ourTask.cashreward = Strings::ToInt(getStr.mb_str()); getStr.Clear(); getStr = mRewardXP->GetValue(); - ourTask.xpreward = atoi(getStr.mb_str()); + ourTask.xpreward = Strings::ToInt(getStr.mb_str()); getStr.Clear(); int * i = (int*)mStartZone->GetClientData(mStartZone->GetSelection()); @@ -325,4 +325,4 @@ void MainFrame::ContextMenuTaskList() PopupMenu(mMenu); delete mMenu; -} \ No newline at end of file +} diff --git a/utils/deprecated/apathing/load_db.cpp b/utils/deprecated/apathing/load_db.cpp index 44a5f7b807..dc712568ea 100644 --- a/utils/deprecated/apathing/load_db.cpp +++ b/utils/deprecated/apathing/load_db.cpp @@ -19,8 +19,8 @@ Fear Pathing generation utility. bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list &db_paths, list &end_points) { char query[512]; - - sprintf(query, + + sprintf(query, "SELECT x,y,z,gridid FROM grid_entries,zone " "WHERE zone.zoneidnumber=zoneid AND short_name='%s' " "ORDER BY gridid,number", zone); @@ -28,21 +28,21 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & printf("Unable to query: %s\n", mysql_error(m)); return(false); } - + MYSQL_RES *res = mysql_store_result(m); if(res == NULL) { printf("Unable to store res: %s\n", mysql_error(m)); return(false); } - + MYSQL_ROW row; - + PathNode *cur = NULL, *last = NULL, *first = NULL; PathGraph *g = NULL; int cur_g = -1,last_g = -1; - + // int lid = 0; - + while((row = mysql_fetch_row(res))) { last = cur; cur = new PathNode; @@ -50,7 +50,7 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & cur->x = atof(row[0]); cur->y = atof(row[1]); cur->z = atof(row[2]); - cur_g = atoi(row[3]); + cur_g = Strings::ToInt(row[3]); if(cur_g != last_g) { if(g != NULL) { //if we have a first and last node for this path @@ -70,15 +70,15 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & last_g = cur_g; last = NULL; } - + g->nodes.push_back(cur); - + #ifdef LINK_PATH_ENDPOINTS //this is a begining point if(last == NULL) end_points.push_back(cur); #endif - + if(last != NULL) { #ifdef SPLIT_INVALID_PATHS if(CheckLOS(map, last, cur)) { @@ -93,7 +93,7 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & #endif } } - + //handle the last active path if(g != NULL) { if(first != NULL && cur->Dist2(first) < ENDPOINT_CONNECT_MAX_DISTANCE*ENDPOINT_CONNECT_MAX_DISTANCE) { @@ -102,7 +102,7 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & } db_paths.push_back(g); } - + mysql_free_result(res); return(true); } @@ -110,25 +110,25 @@ bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list & bool load_spawns_from_db(MYSQL *m, const char *zone, list &db_spawns) { char query[512]; - - sprintf(query, + + sprintf(query, "SELECT x,y,z FROM spawn2 " "WHERE zone='%s'", zone); if(mysql_query(m, query) != 0) { printf("Unable to query: %s\n", mysql_error(m)); return(false); } - + MYSQL_RES *res = mysql_store_result(m); if(res == NULL) { printf("Unable to store res: %s\n", mysql_error(m)); return(false); } - + MYSQL_ROW row; - + PathNode *cur = NULL; - + while((row = mysql_fetch_row(res))) { cur = new PathNode; cur->x = atof(row[0]); @@ -136,34 +136,34 @@ bool load_spawns_from_db(MYSQL *m, const char *zone, list &db_spawns) cur->z = atof(row[2]); db_spawns.push_back(cur); } - + mysql_free_result(res); - + return(true); } bool load_doors_from_db(MYSQL *m, const char *zone, list &db_spawns) { char query[512]; - - sprintf(query, + + sprintf(query, "SELECT pos_x,pos_y,pos_z FROM doors " "WHERE zone='%s'", zone); if(mysql_query(m, query) != 0) { printf("Unable to query: %s\n", mysql_error(m)); return(false); } - + MYSQL_RES *res = mysql_store_result(m); if(res == NULL) { printf("Unable to store res: %s\n", mysql_error(m)); return(false); } - + MYSQL_ROW row; - + PathNode *cur = NULL; - + while((row = mysql_fetch_row(res))) { cur = new PathNode; cur->x = atof(row[0]); @@ -173,54 +173,54 @@ bool load_doors_from_db(MYSQL *m, const char *zone, list &db_spawns) //doors, not the edge of them which I assume these points are db_spawns.push_back(cur); } - + mysql_free_result(res); - + return(true); } bool load_hints_from_db(MYSQL *m, const char *zone, list &db_spawns) { char query[512]; - - sprintf(query, + + sprintf(query, "SELECT x,y,z,forced,disjoint FROM fear_hints " "WHERE zone='%s'", zone); if(mysql_query(m, query) != 0) { printf("Unable to query: %s\n", mysql_error(m)); return(false); } - + MYSQL_RES *res = mysql_store_result(m); if(res == NULL) { printf("Unable to store res: %s\n", mysql_error(m)); return(false); } - + MYSQL_ROW row; - + PathNode *cur = NULL; - + while((row = mysql_fetch_row(res))) { cur = new PathNode; cur->x = atof(row[0]); cur->y = atof(row[1]); cur->z = atof(row[2]); - cur->forced = atoi(row[3])?true:false; - cur->disjoint = atoi(row[4])?true:false; + cur->forced = Strings::ToInt(row[3])?true:false; + cur->disjoint = Strings::ToInt(row[4])?true:false; db_spawns.push_back(cur); } - + mysql_free_result(res); - + return(true); } bool load_settings_from_db(MYSQL *m, const char *zone) { char query[512]; - - sprintf(query, + + sprintf(query, "SELECT use_doors, min_fix_z, max_fear_distance, image_scale, split_invalid_paths," " link_path_endpoints, end_distance, split_long_min, split_long_step, same_dist, node_combine_dist," " grid_combine_dist, close_all_los, cross_count, cross_min_length, cross_max_z_diff, cross_combine_dist," @@ -231,46 +231,46 @@ bool load_settings_from_db(MYSQL *m, const char *zone) { // printf("Unable to query: %s\n", mysql_error(m)); return(false); } - + MYSQL_RES *res = mysql_store_result(m); if(res == NULL) { // printf("Unable to store res: %s\n", mysql_error(m)); return(false); } - + MYSQL_ROW row; - + int r = 0; if((row = mysql_fetch_row(res))) { - INCLUDE_DOORS = atoi(row[r++])?true:false; + INCLUDE_DOORS = Strings::ToInt(row[r++])?true:false; MIN_FIX_Z = atof(row[r++]); FEAR_MAXIMUM_DISTANCE = atof(row[r++]); - IMAGE_SCALE = atoi(row[r++]); - SPLIT_INVALID_PATHS = atoi(row[r++])?true:false; - LINK_PATH_ENDPOINTS = atoi(row[r++])?true:false; + IMAGE_SCALE = Strings::ToInt(row[r++]); + SPLIT_INVALID_PATHS = Strings::ToInt(row[r++])?true:false; + LINK_PATH_ENDPOINTS = Strings::ToInt(row[r++])?true:false; ENDPOINT_CONNECT_MAX_DISTANCE = atof(row[r++]); SPLIT_LINE_LENGTH = atof(row[r++]); SPLIT_LINE_INTERVAL = atof(row[r++]); CLOSE_ENOUGH = atof(row[r++]); CLOSE_ENOUGH_COMBINE = atof(row[r++]); MERGE_MIN_SECOND_DIST = atof(row[r++]); - COMBINE_CHECK_ALL_LOS = atoi(row[r++])?true:false; - CROSS_REDUCE_COUNT = atoi(row[r++]); + COMBINE_CHECK_ALL_LOS = Strings::ToInt(row[r++])?true:false; + CROSS_REDUCE_COUNT = Strings::ToInt(row[r++]); CROSS_MIN_LENGTH = atof(row[r++]); CROSS_MAX_Z_DIFF = atof(row[r++]); CLOSE_ENOUGH_CROSS = atof(row[r++]); - + SPAWN_MIN_SECOND_DIST = atof(row[r++]); MAX_LINK_SPAWN_DIST = atof(row[r++]); - int sc = atoi(row[r++]); + int sc = Strings::ToInt(row[r++]); SPAWN_LINK_TWICE = sc >= 2?true:false; SPAWN_LINK_THRICE = sc >= 3?true:false; mysql_free_result(res); return(true); } - + mysql_free_result(res); - + return(false); } diff --git a/utils/deprecated/azone2/azone.cpp b/utils/deprecated/azone2/azone.cpp index 81a143ba2f..c457d45400 100644 --- a/utils/deprecated/azone2/azone.cpp +++ b/utils/deprecated/azone2/azone.cpp @@ -1118,7 +1118,7 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li if((ch==EOF)||(ch=='\n')) { IniBuffer[StrIndex] = '\0'; if(State == ReadingModelNumbers) { - ModelNumber = atoi(IniBuffer); + ModelNumber = Strings::ToInt(IniBuffer); if((ModelNumber >= 0) && (ModelNumber < fileloader->model_data.model_count)) { fileloader->model_data.models[ModelNumber]->IncludeInMap = true; @@ -1146,7 +1146,7 @@ void QTBuilder::AddPlaceable(FileLoader *fileloader, char *ZoneFileName, bool Li } } else { - ModelNumber = atoi(IniBuffer); + ModelNumber = Strings::ToInt(IniBuffer); if((ModelNumber >= 0) && (ModelNumber < fileloader->model_data.model_count)) { fileloader->model_data.models[ModelNumber]->IncludeInMap = true; @@ -1323,7 +1323,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool Group = true; strcpy(IniBuffer, IniBuffer+1); } - ModelNumber = atoi(IniBuffer); + ModelNumber = Strings::ToInt(IniBuffer); if(!Group) { if((ModelNumber >= 0) && (ModelNumber < fileloader->model_data.model_count)) @@ -1369,7 +1369,7 @@ void QTBuilder::AddPlaceableV4(FileLoader *fileloader, char *ZoneFileName, bool Group = true; strcpy(IniBuffer, IniBuffer+1); } - ModelNumber = atoi(IniBuffer); + ModelNumber = Strings::ToInt(IniBuffer); if(!Group) { if((ModelNumber >= 0) && (ModelNumber < fileloader->model_data.model_count)) diff --git a/utils/deprecated/azone2/dat.cpp b/utils/deprecated/azone2/dat.cpp index 7fec482be3..6458147877 100644 --- a/utils/deprecated/azone2/dat.cpp +++ b/utils/deprecated/azone2/dat.cpp @@ -278,7 +278,7 @@ int DATLoader::Open(char *base_path, char *zone_name, Archive *archive) { if(Token == "*QUADSPERTILE") { Token = GetToken(ZonBuffer, ZonPosition); - QuadsPerTile = atoi(Token.c_str()); + QuadsPerTile = Strings::ToInt(Token.c_str()); #ifdef DEBUGDAT printf("Set QuadsPerTile to %i\n", QuadsPerTile); #endif diff --git a/utils/deprecated/azone2/wld.cpp b/utils/deprecated/azone2/wld.cpp index d4dbcf25b2..953a777c4b 100644 --- a/utils/deprecated/azone2/wld.cpp +++ b/utils/deprecated/azone2/wld.cpp @@ -97,7 +97,7 @@ FRAG_CONSTRUCTOR(Data15) { plac->scale[1] = hdr->scale[1]; plac->scale[2] = hdr->scale[1]; - plac->model = atoi((const char*)&wld->sHash[-(int)hdr->ref]); + plac->model = Strings::ToInt((const char*)&wld->sHash[-(int)hdr->ref]); pl = new Placeable *[wld->model_data.plac_count + 1]; memcpy(pl, wld->model_data.placeable, sizeof(Placeable *) * wld->model_data.plac_count); diff --git a/utils/deprecated/charmove/export_char.cpp b/utils/deprecated/charmove/export_char.cpp index 293c3d7b9f..68e796b55b 100644 --- a/utils/deprecated/charmove/export_char.cpp +++ b/utils/deprecated/charmove/export_char.cpp @@ -20,41 +20,41 @@ void usage() { } int main(int argc, char *argv[]) { - + const char *outfile; - + if(argc != 3) usage(); - int charid = atoi(argv[1]); + int charid = Strings::ToInt(argv[1]); if(charid == 0) usage(); outfile = argv[2]; - + char *query = new char[1024]; char host[200], user[200], passwd[200], database[200]; int32 port=0; bool compression = false; bool items[6] = {false, false, false, false, false, false}; - + if(!DBcore::ReadDBINI(host, user, passwd, database, port, compression, items)) { exit(1); } - + if (!items[0] || !items[1] || !items[2] || !items[3]) { printf ("Incomplete DB.INI file.\n"); exit (1); } - + MYSQL m; mysql_init(&m); - + if(!mysql_real_connect(&m, host, user, passwd, database, 0, NULL, 0)) { printf("Unable to connect 1: %s.\n", mysql_error(&m)); return(1); } - + CharHeader header; char *ppbuffer; char *eppbuffer; @@ -62,13 +62,13 @@ int main(int argc, char *argv[]) { InventoryEntry *inventory; InventoryEntry *sharedbank; QuestGlobalEntry *qglobals;*/ - + sprintf(query, "SELECT name,profile,extprofile,x,y,z,zonename,zoneid FROM character_ WHERE id=%d", charid); if(mysql_query(&m, query) != 0) { printf("Unable to query.\n"); return(1); } - + MYSQL_RES *res = mysql_use_result(&m); if(res == NULL) { printf("Unable to use character_ res.\n"); @@ -82,7 +82,7 @@ int main(int argc, char *argv[]) { } unsigned long* lengths; lengths = mysql_fetch_lengths(res); - + header.char_magic = CHAR_MAGIC; strcpy(header.name, row[0]); header.profile_length = lengths[1]; @@ -91,15 +91,15 @@ int main(int argc, char *argv[]) { header.y = atof(row[4]); header.z = atof(row[5]); strcpy(header.zone_name, row[6]); - header.zone_id = atoi(row[7]); + header.zone_id = Strings::ToInt(row[7]); //copy in blobs ppbuffer = new char[header.profile_length]; eppbuffer = new char[header.extprofile_length]; memcpy(ppbuffer, row[1], header.profile_length); memcpy(eppbuffer, row[2], header.extprofile_length); - + mysql_free_result(res); - + //query faction sprintf(query, "SELECT faction_id,current_value FROM faction_values WHERE char_id=%d", charid); if(mysql_query(&m, query) != 0) { @@ -114,12 +114,12 @@ int main(int argc, char *argv[]) { vector fr; while((row = mysql_fetch_row(res))) { FactionValueRecord r; - r.faction_id = atoi(row[0]); - r.current_value = atoi(row[1]); + r.faction_id = Strings::ToInt(row[0]); + r.current_value = Strings::ToInt(row[1]); fr.push_back(r); } mysql_free_result(res); - + //query inventory sprintf(query, "SELECT slotid,itemid,charges,color,augslot1,augslot2,augslot3,augslot4,augslot5,instnodrop FROM inventory WHERE charid=%d", charid); if(mysql_query(&m, query) != 0) { @@ -134,19 +134,19 @@ int main(int argc, char *argv[]) { vector inv; while((row = mysql_fetch_row(res))) { InventoryEntry r; - r.slotid = atoi(row[0]); - r.itemid = atoi(row[1]); - r.charges = atoi(row[2]); - r.colors = atoi(row[3]); - r.augs[0] = atoi(row[4]); - r.augs[1] = atoi(row[5]); - r.augs[2] = atoi(row[6]); - r.augs[3] = atoi(row[7]); - r.augs[4] = atoi(row[8]); + r.slotid = Strings::ToInt(row[0]); + r.itemid = Strings::ToInt(row[1]); + r.charges = Strings::ToInt(row[2]); + r.colors = Strings::ToInt(row[3]); + r.augs[0] = Strings::ToInt(row[4]); + r.augs[1] = Strings::ToInt(row[5]); + r.augs[2] = Strings::ToInt(row[6]); + r.augs[3] = Strings::ToInt(row[7]); + r.augs[4] = Strings::ToInt(row[8]); inv.push_back(r); } mysql_free_result(res); - + //query shared bank sprintf(query, "SELECT slotid,itemid,charges,augslot1,augslot2,augslot3,augslot4,augslot5 FROM sharedbank,character_ WHERE sharedbank.acctid = character_.account_id AND character_.id=%d", charid); if(mysql_query(&m, query) != 0) { @@ -161,18 +161,18 @@ int main(int argc, char *argv[]) { vector sb; while((row = mysql_fetch_row(res))) { InventoryEntry r; - r.slotid = atoi(row[0]); - r.itemid = atoi(row[1]); - r.charges = atoi(row[2]); - r.augs[0] = atoi(row[3]); - r.augs[1] = atoi(row[4]); - r.augs[2] = atoi(row[5]); - r.augs[3] = atoi(row[6]); - r.augs[4] = atoi(row[7]); + r.slotid = Strings::ToInt(row[0]); + r.itemid = Strings::ToInt(row[1]); + r.charges = Strings::ToInt(row[2]); + r.augs[0] = Strings::ToInt(row[3]); + r.augs[1] = Strings::ToInt(row[4]); + r.augs[2] = Strings::ToInt(row[5]); + r.augs[3] = Strings::ToInt(row[6]); + r.augs[4] = Strings::ToInt(row[7]); sb.push_back(r); } mysql_free_result(res); - + //query quest_globals sprintf(query, "SELECT npcid,zoneid,name,value,expdate FROM quest_globals WHERE charid=%d", charid); if(mysql_query(&m, query) != 0) { @@ -187,37 +187,37 @@ int main(int argc, char *argv[]) { vector qg; while((row = mysql_fetch_row(res))) { QuestGlobalEntry r; - r.npcid = atoi(row[0]); - r.zoneid = atoi(row[1]); + r.npcid = Strings::ToInt(row[0]); + r.zoneid = Strings::ToInt(row[1]); strcpy(r.name, row[2]); strcpy(r.value, row[3]); - r.expdate = atoi(row[4]); + r.expdate = Strings::ToInt(row[4]); qg.push_back(r); } mysql_free_result(res); - + mysql_close(&m); - - + + FILE *outf = fopen(outfile, "wb"); if(outf == NULL) { printf("Unable to open output file %s\n", outfile); return(1); } - + //fill in our counters header.faction_value_count = fr.size(); header.inventory_count = inv.size(); header.sharedbank_count = sb.size(); header.quest_globals_count = qg.size(); - + //write header fwrite(&header, 1, sizeof(header), outf); - + //write out pp and epp fwrite(ppbuffer, 1, header.profile_length, outf); fwrite(eppbuffer, 1, header.extprofile_length, outf); - + //write out our variable length segments vector::iterator curfr, endfr; curfr = fr.begin(); @@ -226,7 +226,7 @@ int main(int argc, char *argv[]) { FactionValueRecord &r = *curfr; fwrite(&r, 1, sizeof(FactionValueRecord), outf); } - + vector::iterator curi, endi; curi = inv.begin(); endi = inv.end(); @@ -234,14 +234,14 @@ int main(int argc, char *argv[]) { InventoryEntry &i = *curi; fwrite(&i, 1, sizeof(InventoryEntry), outf); } - + curi = sb.begin(); endi = sb.end(); for(; curi != endi; curi++) { InventoryEntry &i = *curi; fwrite(&i, 1, sizeof(InventoryEntry), outf); } - + vector::iterator curqg, endqg; curqg = qg.begin(); endqg = qg.end(); @@ -249,9 +249,9 @@ int main(int argc, char *argv[]) { QuestGlobalEntry &r = *curqg; fwrite(&r, 1, sizeof(QuestGlobalEntry), outf); } - + fclose(outf); - + return(0); } diff --git a/utils/deprecated/charmove/import_char.cpp b/utils/deprecated/charmove/import_char.cpp index 48bb009a5d..1a330df62e 100644 --- a/utils/deprecated/charmove/import_char.cpp +++ b/utils/deprecated/charmove/import_char.cpp @@ -15,42 +15,42 @@ void usage() { } int main(int argc, char *argv[]) { - + const char *infile; - + if(argc != 3) usage(); - int accountid = atoi(argv[1]); + int accountid = Strings::ToInt(argv[1]); if(accountid == 0) usage(); infile = argv[2]; - + char *query = new char[1024000]; char *cursor; char host[200], user[200], passwd[200], database[200]; int32 port=0; bool compression = false; bool items[6] = {false, false, false, false, false, false}; - + if(!DBcore::ReadDBINI(host, user, passwd, database, port, compression, items)) { exit(1); } - + if (!items[0] || !items[1] || !items[2] || !items[3]) { printf ("Incomplete DB.INI file.\n"); exit (1); } - + MYSQL m; mysql_init(&m); - + if(!mysql_real_connect(&m, host, user, passwd, database, 0, NULL, 0)) { printf("Unable to connect 1: %s.\n", mysql_error(&m)); return(1); } - + CharHeader header; char *ppbuffer; char *eppbuffer; @@ -58,25 +58,25 @@ int main(int argc, char *argv[]) { InventoryEntry *inventory; InventoryEntry *sharedbank; QuestGlobalEntry *qglobals; - + FILE *inf = fopen(infile, "rb"); if(inf == NULL) { printf("Unable to open infile %s\n", infile); return(1); } - + if(fread(&header, sizeof(header), 1, inf) != 1) { printf("Error reading header.\n"); return(1); } - + ppbuffer = new char[header.profile_length]; eppbuffer = new char[header.extprofile_length]; factions = new FactionValueRecord[header.faction_value_count]; inventory = new InventoryEntry[header.inventory_count]; sharedbank = new InventoryEntry[header.sharedbank_count]; qglobals = new QuestGlobalEntry[header.quest_globals_count]; - + //read all the shit in if(fread(ppbuffer, header.profile_length, 1, inf) != 1) { printf("Error reading pp.\n"); @@ -102,9 +102,9 @@ int main(int argc, char *argv[]) { printf("Error reading quest globals.\n"); return(1); } - + fclose(inf); - + cursor = query; cursor += sprintf(cursor, "INSERT INTO character_ " "(account_id,name,profile,extprofile,x,y,z,zonename,zoneid)" @@ -119,7 +119,7 @@ int main(int argc, char *argv[]) { } int charid = mysql_insert_id(&m); uint32 r; - + //faction for(r = 0; r < header.faction_value_count; r++) { sprintf(query, "INSERT INTO faction_values (char_id,faction_id,current_value)" @@ -129,13 +129,13 @@ int main(int argc, char *argv[]) { return(1); } } - + //inventory for(r = 0; r < header.inventory_count; r++) { sprintf(query, "INSERT INTO inventory (charid,slotid,itemid,charges,color,augslot1,augslot2,augslot3,augslot4,augslot5,instnodrop)" " VALUES(%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d)", charid, inventory[r].slotid, inventory[r].itemid, inventory[r].charges, inventory[r].colors, - inventory[r].augs[0], inventory[r].augs[1], inventory[r].augs[2], inventory[r].augs[3], + inventory[r].augs[0], inventory[r].augs[1], inventory[r].augs[2], inventory[r].augs[3], inventory[r].augs[4], inventory[r].instnodrop ); if(mysql_query(&m, query) != 0) { @@ -143,7 +143,7 @@ int main(int argc, char *argv[]) { return(1); } } - + //shared bank //this is far from perfect since this is per-account, works great with empty shard bank... for(r = 0; r < header.sharedbank_count; r++) { @@ -158,7 +158,7 @@ int main(int argc, char *argv[]) { // return(1); } } - + //quest globals for(r = 0; r < header.quest_globals_count; r++) { cursor = query; @@ -168,17 +168,17 @@ int main(int argc, char *argv[]) { cursor += sprintf(cursor, "','"); cursor += mysql_real_escape_string(&m, cursor, (const char *) qglobals[r].value, strlen(qglobals[r].value)); sprintf(cursor, "',%d)", qglobals[r].expdate); - + if(mysql_query(&m, query) != 0) { printf("Unable to insert quest global: %s\n", mysql_error(&m)); return(1); } } - + mysql_close(&m); - + printf("Successfully imported %s as character id %d\n", header.name, charid); - + return(0); } diff --git a/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp b/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp index aae2374893..0d8108a208 100644 --- a/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp +++ b/utils/deprecated/player_profile_set/player_profile_set/MiscFunctions.cpp @@ -226,7 +226,7 @@ bool atobool(char* iBool) { return true; if (!strcasecmp(iBool, "n")) return false; - if (atoi(iBool)) + if (Strings::ToInt(iBool)) return true; return false; } @@ -328,4 +328,4 @@ int FloatToEQH(float d) float EQHtoFloat(int d) { return(360.0f - float((d * 360) >> 11)); -} \ No newline at end of file +} diff --git a/utils/deprecated/player_profile_set/player_profile_set/database.cpp b/utils/deprecated/player_profile_set/player_profile_set/database.cpp index be85d51a28..a0aeadeb97 100644 --- a/utils/deprecated/player_profile_set/player_profile_set/database.cpp +++ b/utils/deprecated/player_profile_set/player_profile_set/database.cpp @@ -60,7 +60,7 @@ void EQEmuDatabase::GetPlayer(std::string name) while ((row = mysql_fetch_row(res)) != NULL) { player_entry pe; - pe.id = atoi(row[1]); + pe.id = Strings::ToInt(row[1]); pe.data = new char[sizeof(PlayerProfile_Struct)]; memcpy(pe.data, row[0], sizeof(PlayerProfile_Struct)); player_list.push_back(pe); @@ -97,7 +97,7 @@ void EQEmuDatabase::GetPlayers() while ((row = mysql_fetch_row(res)) != NULL) { player_entry pe; - pe.id = atoi(row[1]); + pe.id = Strings::ToInt(row[1]); pe.data = new char[sizeof(PlayerProfile_Struct)]; memcpy(pe.data, row[0], sizeof(PlayerProfile_Struct)); player_list.push_back(pe); diff --git a/utils/deprecated/ppconvert/ppconvert.cpp b/utils/deprecated/ppconvert/ppconvert.cpp index 716ddd7535..4054b4e05c 100644 --- a/utils/deprecated/ppconvert/ppconvert.cpp +++ b/utils/deprecated/ppconvert/ppconvert.cpp @@ -16,30 +16,30 @@ using namespace std; int convert_profile_once(char *src, char *dst, int len); int main() { - + char host[200], user[200], passwd[200], database[200]; int32 port=0; bool compression = false; bool items[6] = {false, false, false, false, false, false}; - + if(!DBcore::ReadDBINI(host, user, passwd, database, port, compression, items)) { exit(1); } - + if (!items[0] || !items[1] || !items[2] || !items[3]) { printf ("Incomplete DB.INI file.\n"); exit (1); } - + vector updates; - + MYSQL m; MYSQL out; mysql_init(&m); mysql_init(&out); - + if(!mysql_real_connect(&m, host, user, passwd, database, 0, NULL, 0)) { printf("Unable to connect 1: %s.\n", mysql_error(&m)); return(1); @@ -53,53 +53,53 @@ int main() { printf("Unable to query.\n"); return(1); } - + MYSQL_RES *res = mysql_use_result(&m); if(res == NULL) { printf("Unable to use res.\n"); return(1); } - + char *inbuffer = new char[sizeof(PlayerProfile_Struct)]; - + MYSQL_ROW row; unsigned long *lengths; - + int convert_count = 0; int correct_count = 0; int failed_count = 0; while((row = mysql_fetch_row(res))) { lengths = mysql_fetch_lengths(res); - unsigned long id = atoi(row[0]); - + unsigned long id = Strings::ToInt(row[0]); + int curlen = lengths[2]; - + if(curlen == sizeof(PlayerProfile_Struct)) { correct_count++; continue; //allready current. } - + fprintf(stderr, "Converting char %lu: %s...", id, row[1]); - + //make a copy of the version in the DB memcpy(inbuffer, row[2], curlen); - + char *outbuffer = new char[2*sizeof(PlayerProfile_Struct) + 512]; - + int steps; for(steps = 0; steps < MAX_CONVERT_STEPS && curlen != sizeof(PlayerProfile_Struct); steps++) { //clear outbuffer memset(outbuffer, 0, sizeof(PlayerProfile_Struct)); - + fprintf(stderr, " |"); fflush(stderr); - + //convert inbuffer one step closer to the current profile, into outbuffer curlen = convert_profile_once(inbuffer, outbuffer, curlen); if(curlen == 0) break; - + //copy outbuffer into inbuffer for the next convert step memcpy(inbuffer, outbuffer, curlen); } @@ -111,26 +111,26 @@ int main() { } fprintf(stderr, " *"); fflush(stderr); - + //the correct profile ends up in inbuffer, so we can escape it into outbuffer char *bptr = outbuffer; bptr += snprintf(bptr, 128, "UPDATE character_ SET profile='"); bptr += mysql_real_escape_string(&m, bptr, (const char *) inbuffer, sizeof(PlayerProfile_Struct)); snprintf(bptr, 128, "' WHERE id=%lu", id); - + // printf("Query: '%s'\n", outbuffer); /* if(mysql_query(&out, outbuffer) != 0) { failed_count++; printf(" Error updating char id %lu: %s\n", id, mysql_error(&m)); continue; } -*/ +*/ updates.push_back(outbuffer); fprintf(stderr, " done.\n"); // convert_count++; } // mysql_free_result(res); - + vector::iterator cur, end; cur = updates.begin(); @@ -145,12 +145,12 @@ updates.push_back(outbuffer); printf("."); fflush(stdout); delete[] *cur; - + convert_count++; } fprintf(stderr, "%d chars converted, %d errors, %d chars were up to date.\n", convert_count, failed_count, correct_count); - + mysql_close(&m); mysql_close(&out); return(0); @@ -217,11 +217,11 @@ int convert_profile_once(char *src, char *dst, int len) { s_ptr+=8; ptr+=12; memcpy(ptr,s_ptr,3700); - + pp->bind_x=((Before_Sep14th_PlayerProfile_Struct*)newpps)->bind_x; pp->bind_y=((Before_Sep14th_PlayerProfile_Struct*)newpps)->bind_y; pp->bind_z=((Before_Sep14th_PlayerProfile_Struct*)newpps)->bind_z; - + len = sizeof(Before_Sep14th_PlayerProfile_Struct); break; } @@ -249,7 +249,7 @@ int convert_profile_once(char *src, char *dst, int len) { pp->bind_x[0]=oldpp->bind_x; pp->bind_y[0]=oldpp->bind_y; pp->bind_z[0]=oldpp->bind_z; - + len = sizeof(Before_Dec15th_PlayerProfile_Struct); break; } @@ -257,10 +257,10 @@ int convert_profile_once(char *src, char *dst, int len) { #define StructDist(in, f1, f2) (uint32(&in->f2)-uint32(&in->f1)) Before_Dec15th_PlayerProfile_Struct* ops = (Before_Dec15th_PlayerProfile_Struct*)src; Before_June29th_PlayerProfile_Struct* pp = (Before_June29th_PlayerProfile_Struct*)dst; - + //start with the basics memcpy(dst, ops, sizeof(Before_June29th_PlayerProfile_Struct)); - + pp->anon = ops->anon; pp->guildrank = ops->guildrank; memcpy(pp->unknown0245, &ops->fatigue, StructDist(ops, fatigue, guildid2)); @@ -270,24 +270,24 @@ int convert_profile_once(char *src, char *dst, int len) { memcpy(pp->unknown6392, &ops->unknown5248, StructDist(ops, unknown5248, unknown11376)); //put the tribute block in the right place memcpy(&pp->tribute_time_remaining, &ops->tribute_time_remaining, StructDist(ops, tribute_time_remaining, unknown5764)); - + //copy over things that maybe moved, but I havent figure out how yet pp->aapoints = ops->aapoints; pp->aapoints_spent = ops->aapoints_spent; - + len = sizeof(Before_June29th_PlayerProfile_Struct); } case sizeof(Before_June29th_PlayerProfile_Struct): { Before_June29th_PlayerProfile_Struct* ops = (Before_June29th_PlayerProfile_Struct*)src; memcpy(dst, ops, sizeof(Before_June29th_PlayerProfile_Struct)); - + len = sizeof(Before_May12_PlayerProfile_Struct); } case sizeof(Before_May12_PlayerProfile_Struct): { Before_May12_PlayerProfile_Struct* ops = (Before_May12_PlayerProfile_Struct*)src; PlayerProfile_Struct* pp = (PlayerProfile_Struct*)dst; memcpy(dst, ops, sizeof(Before_May12_PlayerProfile_Struct)); - + memcpy(&pp->checksum, &ops->checksum, StructDist(ops, checksum, haircolor)); memcpy(&pp->haircolor, &ops->haircolor, StructDist(ops, haircolor, unknown0310[0])); memcpy(&pp->item_material[0], &ops->item_material[0], StructDist(ops, item_material[0], servername[0])); @@ -300,7 +300,7 @@ int convert_profile_once(char *src, char *dst, int len) { memcpy(&pp->tribute_time_remaining, &ops->tribute_time_remaining, StructDist(ops, tribute_time_remaining, unknown6860)); memcpy(&pp->leader_abilities, &ops->leader_abilities, StructDist(ops, leader_abilities, unknown6932[0])); memcpy(&pp->air_remaining, &ops->air_remaining, StructDist(ops, air_remaining, unknown18492)); - + /* * This is the last statement in this switch. */ diff --git a/utils/deprecated/ppskillfix/ppskillfix.cpp b/utils/deprecated/ppskillfix/ppskillfix.cpp index f2c7c1474a..cfdbdb8928 100644 --- a/utils/deprecated/ppskillfix/ppskillfix.cpp +++ b/utils/deprecated/ppskillfix/ppskillfix.cpp @@ -16,30 +16,30 @@ using namespace std; int convert_profile_once(char *src, char *dst, int len); int main() { - + char host[200], user[200], passwd[200], database[200]; int32 port=0; bool compression = false; bool items[6] = {false, false, false, false, false, false}; - + if(!DBcore::ReadDBINI(host, user, passwd, database, port, compression, items)) { exit(1); } - + if (!items[0] || !items[1] || !items[2] || !items[3]) { printf ("Incomplete DB.INI file.\n"); exit (1); } - + vector updates; - + MYSQL m; MYSQL out; mysql_init(&m); mysql_init(&out); - + if(!mysql_real_connect(&m, host, user, passwd, database, 0, NULL, 0)) { printf("Unable to connect 1: %s.\n", mysql_error(&m)); return(1); @@ -53,36 +53,36 @@ int main() { printf("Unable to query.\n"); return(1); } - + MYSQL_RES *res = mysql_use_result(&m); if(res == NULL) { printf("Unable to use res.\n"); return(1); } - + char *inbuffer = new char[sizeof(PlayerProfile_Struct)]; PlayerProfile_Struct *in_pp = (PlayerProfile_Struct *) inbuffer; - + MYSQL_ROW row; unsigned long *lengths; - + int convert_count = 0; int correct_count = 0; int failed_count = 0; while((row = mysql_fetch_row(res))) { lengths = mysql_fetch_lengths(res); - unsigned long id = atoi(row[0]); - + unsigned long id = Strings::ToInt(row[0]); + int curlen = lengths[2]; - + if(curlen != sizeof(PlayerProfile_Struct)) { fprintf(stderr, "Char '%s' has the wrong size. Expected %d, got %d\n", row[1], sizeof(PlayerProfile_Struct), curlen); failed_count++; continue; } - - + + //make a copy of the version in the DB memcpy(inbuffer, row[2], curlen); @@ -99,32 +99,32 @@ fprintf(stderr, "Char '%s' skill %d = %d\n", row[1], r, in_pp->skills[r]); correct_count++; continue; } - + fprintf(stderr, "Converting char %lu: %s...", id, row[1]); convert_count++; - + char *outbuffer = new char[2*sizeof(PlayerProfile_Struct) + 512]; - - + + //the correct profile ends up in inbuffer, so we can escape it into outbuffer char *bptr = outbuffer; bptr += snprintf(bptr, 128, "UPDATE character_ SET profile='"); bptr += mysql_real_escape_string(&m, bptr, (const char *) inbuffer, sizeof(PlayerProfile_Struct)); snprintf(bptr, 128, "' WHERE id=%lu", id); - + // printf("Query: '%s'\n", outbuffer); /* if(mysql_query(&out, outbuffer) != 0) { failed_count++; printf(" Error updating char id %lu: %s\n", id, mysql_error(&m)); continue; } -*/ +*/ updates.push_back(outbuffer); fprintf(stderr, " done.\n"); // convert_count++; } // mysql_free_result(res); - + vector::iterator cur, end; cur = updates.begin(); @@ -139,12 +139,12 @@ updates.push_back(outbuffer); printf("."); fflush(stdout);*/ delete[] *cur; - + convert_count++; } fprintf(stderr, "%d chars converted, %d errors, %d chars were up to date.\n", convert_count, failed_count, correct_count); - + mysql_close(&m); mysql_close(&out); return(0); diff --git a/utils/deprecated/spell_explorer.cpp b/utils/deprecated/spell_explorer.cpp index 83d116a468..ef4b2a7c89 100644 --- a/utils/deprecated/spell_explorer.cpp +++ b/utils/deprecated/spell_explorer.cpp @@ -4,43 +4,43 @@ #include "../zone/spdat.h" int main(int argc, char** argv) { - + int spid = 0; - + if(argc != 2) { printf("Invalid args: %s [spell id]\n", argv[0]); return(1); } - - spid = atoi(argv[1]); - - + + spid = Strings::ToInt(argv[1]); + + int tempid=0; int16 counter=0; char spell_line[2048]; - + FILE *sf = fopen("spells_us.txt", "r"); - + if(sf == NULL) { printf("Unable to open spells_us.txt file.\n"); return false; } - + SPDat_Spell_Struct sp; - + while(!feof(sf)) { fgets(spell_line, sizeof(spell_line), sf); Seperator sep(spell_line, '^', 205, 100, false, 0, 0, false); - + if(spell_line[0]=='\0') break; - - tempid = atoi(sep.arg[0]); + + tempid = Strings::ToInt(sep.arg[0]); if(tempid != spid) continue; - + printf("Found spell %d\n", spid); - + counter++; strcpy(sp.name, sep.arg[1]); strcpy(sp.player_1, sep.arg[2]); @@ -55,83 +55,83 @@ int main(int argc, char** argv) { sp.aoerange=atof(sep.arg[10]); sp.pushback=atof(sep.arg[11]); sp.pushup=atof(sep.arg[12]); - sp.cast_time=atoi(sep.arg[13]); - sp.recovery_time=atoi(sep.arg[14]); - sp.recast_time=atoi(sep.arg[15]); - sp.buffdurationformula=atoi(sep.arg[16]); - sp.buffduration=atoi(sep.arg[17]); - sp.AEDuration=atoi(sep.arg[18]); - sp.mana=atoi(sep.arg[19]); - + sp.cast_time=Strings::ToInt(sep.arg[13]); + sp.recovery_time=Strings::ToInt(sep.arg[14]); + sp.recast_time=Strings::ToInt(sep.arg[15]); + sp.buffdurationformula=Strings::ToInt(sep.arg[16]); + sp.buffduration=Strings::ToInt(sep.arg[17]); + sp.AEDuration=Strings::ToInt(sep.arg[18]); + sp.mana=Strings::ToInt(sep.arg[19]); + int y=0; for(y=0; y < EFFECT_COUNT;y++) - sp.base[y]=atoi(sep.arg[20+y]); + sp.base[y]=Strings::ToInt(sep.arg[20+y]); for(y=0;y<11;y++) - sp.base2[y]=atoi(sep.arg[33+y]); + sp.base2[y]=Strings::ToInt(sep.arg[33+y]); for(y=0; y < EFFECT_COUNT;y++) - sp.max[y]=atoi(sep.arg[44+y]); - - sp.icon=atoi(sep.arg[56]); - sp.memicon=atoi(sep.arg[57]); - + sp.max[y]=Strings::ToInt(sep.arg[44+y]); + + sp.icon=Strings::ToInt(sep.arg[56]); + sp.memicon=Strings::ToInt(sep.arg[57]); + for(y=0; y< 4;y++) - sp.components[y]=atoi(sep.arg[58+y]); - + sp.components[y]=Strings::ToInt(sep.arg[58+y]); + for(y=0; y< 4;y++) - sp.component_counts[y]=atoi(sep.arg[62+y]); - + sp.component_counts[y]=Strings::ToInt(sep.arg[62+y]); + for(y=0; y< 4;y++) - sp.NoexpendReagent[y]=atoi(sep.arg[66+y]); - + sp.NoexpendReagent[y]=Strings::ToInt(sep.arg[66+y]); + for(y=0; y< 12;y++) - sp.formula[y]=atoi(sep.arg[70+y]); - - sp.LightType=atoi(sep.arg[82]); - sp.goodEffect=atoi(sep.arg[83]); - sp.Activated=atoi(sep.arg[84]); - sp.resisttype=atoi(sep.arg[85]); - + sp.formula[y]=Strings::ToInt(sep.arg[70+y]); + + sp.LightType=Strings::ToInt(sep.arg[82]); + sp.goodEffect=Strings::ToInt(sep.arg[83]); + sp.Activated=Strings::ToInt(sep.arg[84]); + sp.resisttype=Strings::ToInt(sep.arg[85]); + for(y=0; y< 12;y++) - sp.effectid[y]=atoi(sep.arg[86+y]); - - sp.targettype=(SpellTargetType)atoi(sep.arg[98]); - sp.basediff=atoi(sep.arg[99]); - sp.skill=(SkillType)atoi(sep.arg[100]); - sp.zonetype=atoi(sep.arg[101]); - sp.EnvironmentType=atoi(sep.arg[102]); - sp.TimeOfDay=atoi(sep.arg[103]); - + sp.effectid[y]=Strings::ToInt(sep.arg[86+y]); + + sp.targettype=(SpellTargetType)Strings::ToInt(sep.arg[98]); + sp.basediff=Strings::ToInt(sep.arg[99]); + sp.skill=(SkillType)Strings::ToInt(sep.arg[100]); + sp.zonetype=Strings::ToInt(sep.arg[101]); + sp.EnvironmentType=Strings::ToInt(sep.arg[102]); + sp.TimeOfDay=Strings::ToInt(sep.arg[103]); + for(y=0; y< 16;y++) - sp.classes[y]=atoi(sep.arg[104+y]); - - sp.CastingAnim=atoi(sep.arg[120]); - sp.TargetAnim=atoi(sep.arg[121]); - sp.TravelType=atoi(sep.arg[122]); - sp.SpellAffectIndex=atoi(sep.arg[123]); - + sp.classes[y]=Strings::ToInt(sep.arg[104+y]); + + sp.CastingAnim=Strings::ToInt(sep.arg[120]); + sp.TargetAnim=Strings::ToInt(sep.arg[121]); + sp.TravelType=Strings::ToInt(sep.arg[122]); + sp.SpellAffectIndex=Strings::ToInt(sep.arg[123]); + for(y=0; y< 23;y++) { - sp.spacing124[y]=atoi(sep.arg[124+y]); + sp.spacing124[y]=Strings::ToInt(sep.arg[124+y]); } - - sp.ResistDiff=atoi(sep.arg[147]); - sp.dot_stacking_exempt=atoi(sep.arg[148]); - sp.deletable=atoi(sep.arg[149]); - - sp.RecourseLink = atoi(sep.arg[150]); - sp.descnum = atoi(sep.arg[155]); - sp.typedescnum = atoi(sep.arg[156]); - sp.effectdescnum = atoi(sep.arg[157]); + + sp.ResistDiff=Strings::ToInt(sep.arg[147]); + sp.dot_stacking_exempt=Strings::ToInt(sep.arg[148]); + sp.deletable=Strings::ToInt(sep.arg[149]); + + sp.RecourseLink = Strings::ToInt(sep.arg[150]); + sp.descnum = Strings::ToInt(sep.arg[155]); + sp.typedescnum = Strings::ToInt(sep.arg[156]); + sp.effectdescnum = Strings::ToInt(sep.arg[157]); // for(y=0; y< 17;y++) -// sp.Spacing4[y] = atoi(sep.arg[158+y]); - +// sp.Spacing4[y] = Strings::ToInt(sep.arg[158+y]); + break; } fclose(sf); - + const struct SPDat_Spell_Struct *s=&sp; - + printf("Spell info for spell #%d:\n", spid); printf(" name: %s\n", s->name); printf(" player_1: %s\n", s->player_1); @@ -181,7 +181,7 @@ int main(int argc, char** argv) { printf(" RecourseLink: %d\n", s->RecourseLink); printf(" Spacing124[23]: %d, %d, %d, %d, %d\n", s->spacing124[0], s->spacing124[1], s->spacing124[2], s->spacing124[3], s->spacing124[4]); - + return(0); } diff --git a/world/adventure.cpp b/world/adventure.cpp index 2e5a58fc10..bc72d8cf43 100644 --- a/world/adventure.cpp +++ b/world/adventure.cpp @@ -383,8 +383,8 @@ void Adventure::MoveCorpsesToGraveyard() if(!results.Success()) for(auto row = results.begin(); row != results.end(); ++row) { - dbid_list.push_back(atoi(row[0])); - charid_list.push_back(atoi(row[1])); + dbid_list.push_back(Strings::ToInt(row[0])); + charid_list.push_back(Strings::ToInt(row[1])); } for (auto &elem : dbid_list) { diff --git a/world/adventure_manager.cpp b/world/adventure_manager.cpp index 2f894134fa..3d8442e536 100644 --- a/world/adventure_manager.cpp +++ b/world/adventure_manager.cpp @@ -679,41 +679,41 @@ bool AdventureManager::LoadAdventureTemplates() for (auto row = results.begin(); row != results.end(); ++row) { auto adventure_template = new AdventureTemplate; - adventure_template->id = atoi(row[0]); + adventure_template->id = Strings::ToInt(row[0]); strcpy(adventure_template->zone, row[1]); - adventure_template->zone_version = atoi(row[2]); - adventure_template->is_hard = atoi(row[3]); - adventure_template->min_level = atoi(row[4]); - adventure_template->max_level = atoi(row[5]); - adventure_template->type = atoi(row[6]); - adventure_template->type_data = atoi(row[7]); - adventure_template->type_count = atoi(row[8]); - adventure_template->assa_x = atof(row[9]); - adventure_template->assa_y = atof(row[10]); - adventure_template->assa_z = atof(row[11]); - adventure_template->assa_h = atof(row[12]); + adventure_template->zone_version = Strings::ToInt(row[2]); + adventure_template->is_hard = Strings::ToInt(row[3]); + adventure_template->min_level = Strings::ToInt(row[4]); + adventure_template->max_level = Strings::ToInt(row[5]); + adventure_template->type = Strings::ToInt(row[6]); + adventure_template->type_data = Strings::ToInt(row[7]); + adventure_template->type_count = Strings::ToInt(row[8]); + adventure_template->assa_x = Strings::ToFloat(row[9]); + adventure_template->assa_y = Strings::ToFloat(row[10]); + adventure_template->assa_z = Strings::ToFloat(row[11]); + adventure_template->assa_h = Strings::ToFloat(row[12]); strn0cpy(adventure_template->text, row[13], sizeof(adventure_template->text)); - adventure_template->duration = atoi(row[14]); - adventure_template->zone_in_time = atoi(row[15]); - adventure_template->win_points = atoi(row[16]); - adventure_template->lose_points = atoi(row[17]); - adventure_template->theme = atoi(row[18]); - adventure_template->zone_in_zone_id = atoi(row[19]); - adventure_template->zone_in_x = atof(row[20]); - adventure_template->zone_in_y = atof(row[21]); - adventure_template->zone_in_object_id = atoi(row[22]); - adventure_template->dest_x = atof(row[23]); - adventure_template->dest_y = atof(row[24]); - adventure_template->dest_z = atof(row[25]); - adventure_template->dest_h = atof(row[26]); - adventure_template->graveyard_zone_id = atoi(row[27]); - adventure_template->graveyard_x = atof(row[28]); - adventure_template->graveyard_y = atof(row[29]); - adventure_template->graveyard_z = atof(row[30]); - adventure_template->graveyard_radius = atof(row[31]); + adventure_template->duration = Strings::ToInt(row[14]); + adventure_template->zone_in_time = Strings::ToInt(row[15]); + adventure_template->win_points = Strings::ToInt(row[16]); + adventure_template->lose_points = Strings::ToInt(row[17]); + adventure_template->theme = Strings::ToInt(row[18]); + adventure_template->zone_in_zone_id = Strings::ToInt(row[19]); + adventure_template->zone_in_x = Strings::ToFloat(row[20]); + adventure_template->zone_in_y = Strings::ToFloat(row[21]); + adventure_template->zone_in_object_id = Strings::ToInt(row[22]); + adventure_template->dest_x = Strings::ToFloat(row[23]); + adventure_template->dest_y = Strings::ToFloat(row[24]); + adventure_template->dest_z = Strings::ToFloat(row[25]); + adventure_template->dest_h = Strings::ToFloat(row[26]); + adventure_template->graveyard_zone_id = Strings::ToInt(row[27]); + adventure_template->graveyard_x = Strings::ToFloat(row[28]); + adventure_template->graveyard_y = Strings::ToFloat(row[29]); + adventure_template->graveyard_z = Strings::ToFloat(row[30]); + adventure_template->graveyard_radius = Strings::ToFloat(row[31]); adventure_templates[adventure_template->id] = adventure_template; } @@ -732,8 +732,8 @@ bool AdventureManager::LoadAdventureEntries() for (auto row = results.begin(); row != results.end(); ++row) { - int id = atoi(row[0]); - int template_id = atoi(row[1]); + int id = Strings::ToInt(row[0]); + int template_id = Strings::ToInt(row[1]); AdventureTemplate* tid = nullptr; auto t_iter = adventure_templates.find(template_id); @@ -1108,26 +1108,26 @@ void AdventureManager::LoadLeaderboardInfo() LeaderboardInfo lbi; lbi.name = row[0]; - lbi.wins = atoi(row[3]); - lbi.guk_wins = atoi(row[3]); - lbi.wins += atoi(row[4]); - lbi.mir_wins = atoi(row[4]); - lbi.wins += atoi(row[5]); - lbi.mmc_wins = atoi(row[5]); - lbi.wins += atoi(row[6]); - lbi.ruj_wins = atoi(row[6]); - lbi.wins += atoi(row[7]); - lbi.tak_wins = atoi(row[7]); - lbi.losses = atoi(row[8]); - lbi.guk_losses = atoi(row[8]); - lbi.losses += atoi(row[9]); - lbi.mir_losses = atoi(row[9]); - lbi.losses += atoi(row[10]); - lbi.mmc_losses = atoi(row[10]); - lbi.losses += atoi(row[11]); - lbi.ruj_losses = atoi(row[11]); - lbi.losses += atoi(row[12]); - lbi.tak_losses = atoi(row[12]); + lbi.wins = Strings::ToInt(row[3]); + lbi.guk_wins = Strings::ToInt(row[3]); + lbi.wins += Strings::ToInt(row[4]); + lbi.mir_wins = Strings::ToInt(row[4]); + lbi.wins += Strings::ToInt(row[5]); + lbi.mmc_wins = Strings::ToInt(row[5]); + lbi.wins += Strings::ToInt(row[6]); + lbi.ruj_wins = Strings::ToInt(row[6]); + lbi.wins += Strings::ToInt(row[7]); + lbi.tak_wins = Strings::ToInt(row[7]); + lbi.losses = Strings::ToInt(row[8]); + lbi.guk_losses = Strings::ToInt(row[8]); + lbi.losses += Strings::ToInt(row[9]); + lbi.mir_losses = Strings::ToInt(row[9]); + lbi.losses += Strings::ToInt(row[10]); + lbi.mmc_losses = Strings::ToInt(row[10]); + lbi.losses += Strings::ToInt(row[11]); + lbi.ruj_losses = Strings::ToInt(row[11]); + lbi.losses += Strings::ToInt(row[12]); + lbi.tak_losses = Strings::ToInt(row[12]); leaderboard_info_wins.push_back(lbi); leaderboard_info_percentage.push_back(lbi); diff --git a/world/cli/database_set_account_status.cpp b/world/cli/database_set_account_status.cpp index 52e777bf42..39dbeeb281 100644 --- a/world/cli/database_set_account_status.cpp +++ b/world/cli/database_set_account_status.cpp @@ -19,6 +19,6 @@ void WorldserverCLI::DatabaseSetAccountStatus(int argc, char **argv, argh::parse database.SetAccountStatus( cmd(2).str(), - std::stoi(cmd(3).str()) + Strings::ToInt(cmd(3).str()) ); } diff --git a/world/cli/test_string_benchmark.cpp b/world/cli/test_string_benchmark.cpp new file mode 100644 index 0000000000..32d5e9020c --- /dev/null +++ b/world/cli/test_string_benchmark.cpp @@ -0,0 +1,114 @@ +#include +#include +#include "../../common/events/player_events.h" +#include "../../common/timer.h" + +void WorldserverCLI::TestStringBenchmarkCommand(int argc, char **argv, argh::parser &cmd, std::string &description) +{ + description = "Test command"; + + if (cmd[{"-h", "--help"}]) { + return; + } + + enum Type { + StringsToInt = 0, + StringsToBigInt, + StringsToUnsignedInt, + StringsToUnsignedBigInt, + StringsToFloat, + StringsIsNumber, + StringsIsFloat, + StdStoi, + StdAtoi, + StdStoll, + StdAtoll, + StdStoul, + StdStoull, + StdStof, + }; + + struct Benchmark { + std::string name; + Type type; + }; + + std::vector benches = { + Benchmark{.name = "Strings::ToInt", .type = StringsToInt}, + Benchmark{.name = "std::stoi", .type = StdStoi}, + Benchmark{.name = "std::atoi", .type = StdAtoi}, + Benchmark{.name = "Strings::ToBigInt", .type = StringsToBigInt}, + Benchmark{.name = "std::stoll", .type = StdStoll}, + Benchmark{.name = "std::atoll", .type = StdAtoll}, + Benchmark{.name = "Strings::ToUnsignedInt", .type = StringsToUnsignedInt}, + Benchmark{.name = "std::stoul", .type = StdStoul}, + Benchmark{.name = "Strings::ToUnsignedBigInt", .type = StringsToUnsignedBigInt}, + Benchmark{.name = "std::stoull", .type = StdStoull}, + Benchmark{.name = "Strings::ToFloat", .type = StringsToFloat}, + Benchmark{.name = "std::stof", .type = StdStof}, + Benchmark{.name = "Strings::IsNumber", .type = StringsIsNumber}, + Benchmark{.name = "Strings::IsFloat", .type = StringsIsFloat}, + }; + + BenchTimer benchmark; + + for (auto &b: benches) { + int iterations = 10000000; + std::string number = "1111753784"; + std::string float_number = "1111753784.2345623456345"; + int64 convert = 0; + uint64_t uconvert = 0; + float fconvert = 0; + bool check = false; + + for (int i = 0; i < iterations; i++) { + switch (b.type) { + case StringsToInt: + convert = Strings::ToInt(number, 0); + break; + case StdStoi: + convert = std::stoi(number); + break; + case StdAtoi: + convert = std::atoi(number.c_str()); + break; + case StringsToBigInt: + convert = Strings::ToBigInt(number, 0); + break; + case StdStoll: + convert = std::stoll(number); + break; + case StdAtoll: + convert = std::atoll(number.c_str()); + break; + case StringsToUnsignedInt: + uconvert = Strings::ToUnsignedInt(number, 0); + break; + case StringsToUnsignedBigInt: + uconvert = Strings::ToUnsignedBigInt(number, 0); + break; + case StringsToFloat: + fconvert = Strings::ToFloat(number, 0); + break; + case StringsIsNumber: + check = Strings::IsNumber(number); + break; + case StringsIsFloat: + check = Strings::IsFloat(float_number); + break; + case StdStoul: + uconvert = std::stoul(number); + break; + case StdStoull: + uconvert = std::stoull(number); + break; + case StdStof: + fconvert = std::stof(number); + break; + } + } + + LogInfo("{:<30} | [{}] time [{}]", b.name, Strings::Commify(iterations), benchmark.elapsed()); + benchmark.reset(); + } +} diff --git a/world/client.cpp b/world/client.cpp index 4ca8afd250..fc41c0ec9b 100644 --- a/world/client.cpp +++ b/world/client.cpp @@ -453,7 +453,7 @@ bool Client::HandleSendLoginInfoPacket(const EQApplicationPacket *app) is_player_zoning = (login_info->zoning == 1); - uint32 id = std::stoi(name); + uint32 id = Strings::ToInt(name); if (id == 0) { LogWarning("Receiving Login Info Packet from Client | account_id is 0 - disconnecting"); return false; @@ -808,7 +808,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (!strcasecmp(row[1], char_name)) { if (RuleB(World, EnableReturnHomeButton)) { int now = time(nullptr); - if ((now - atoi(row[3])) >= RuleI(World, MinOfflineTimeToReturnHome)) { + if ((now - Strings::ToInt(row[3])) >= RuleI(World, MinOfflineTimeToReturnHome)) { home_enabled = true; break; } @@ -834,7 +834,7 @@ bool Client::HandleEnterWorldPacket(const EQApplicationPacket *app) { if (!strcasecmp(row[1], char_name)) { if ( RuleB(World, EnableTutorialButton) && - std::stoi(row[2]) <= RuleI(World, MaxLevelForTutorial) + Strings::ToInt(row[2]) <= RuleI(World, MaxLevelForTutorial) ) { tutorial_enabled = true; break; @@ -1258,7 +1258,7 @@ bool Client::ChecksumVerificationCRCEQGame(uint64 checksum) std::string checksumvar; uint64_t checksumint; if (database.GetVariable("crc_eqgame", checksumvar)) { - checksumint = atoll(checksumvar.c_str()); + checksumint = Strings::ToBigInt(checksumvar.c_str()); } else { LogChecksumVerification("variable not set in variables table."); @@ -1281,7 +1281,7 @@ bool Client::ChecksumVerificationCRCSkillCaps(uint64 checksum) std::string checksumvar; uint64_t checksumint; if (database.GetVariable("crc_skillcaps", checksumvar)) { - checksumint = atoll(checksumvar.c_str()); + checksumint = Strings::ToBigInt(checksumvar.c_str()); } else { LogChecksumVerification("[checksum_crc2_skillcaps] variable not set in variables table."); @@ -1304,7 +1304,7 @@ bool Client::ChecksumVerificationCRCBaseData(uint64 checksum) std::string checksumvar; uint64_t checksumint; if (database.GetVariable("crc_basedata", checksumvar)) { - checksumint = atoll(checksumvar.c_str()); + checksumint = Strings::ToBigInt(checksumvar.c_str()); } else { LogChecksumVerification("variable not set in variables table."); diff --git a/world/cliententry.cpp b/world/cliententry.cpp index 9609a2df7e..778723a8d5 100644 --- a/world/cliententry.cpp +++ b/world/cliententry.cpp @@ -365,7 +365,7 @@ bool ClientListEntry::CheckAuth(uint32 loginserver_account_id, const char *key_p } std::string lsworldadmin; if (database.GetVariable("honorlsworldadmin", lsworldadmin)) { - if (atoi(lsworldadmin.c_str()) == 1 && pworldadmin != 0 && (padmin < pworldadmin || padmin == AccountStatus::Player)) { + if (Strings::ToInt(lsworldadmin.c_str()) == 1 && pworldadmin != 0 && (padmin < pworldadmin || padmin == AccountStatus::Player)) { padmin = pworldadmin; } } diff --git a/world/console.cpp b/world/console.cpp index d0d71afdbd..a843dee67b 100644 --- a/world/console.cpp +++ b/world/console.cpp @@ -166,14 +166,14 @@ void ConsoleWho( } else if (Strings::IsNumber(arg)) { if (whom.lvllow == 0xFFFF) { - whom.lvllow = atoi(arg.c_str()); + whom.lvllow = Strings::ToInt(arg.c_str()); whom.lvlhigh = whom.lvllow; } - else if (atoi(arg.c_str()) > int(whom.lvllow)) { - whom.lvlhigh = atoi(arg.c_str()); + else if (Strings::ToInt(arg.c_str()) > int(whom.lvllow)) { + whom.lvlhigh = Strings::ToInt(arg.c_str()); } else { - whom.lvllow = atoi(arg.c_str()); + whom.lvllow = Strings::ToInt(arg.c_str()); } } else { @@ -200,11 +200,11 @@ void ConsoleUptime( return; } - if (Strings::IsNumber(args[0]) && atoi(args[0].c_str()) > 0) { + if (Strings::IsNumber(args[0]) && Strings::ToInt(args[0].c_str()) > 0) { auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct)); ServerUptime_Struct *sus = (ServerUptime_Struct *) pack->pBuffer; snprintf(sus->adminname, sizeof(sus->adminname), "*%s", connection->UserName().c_str()); - sus->zoneserverid = atoi(args[0].c_str()); + sus->zoneserverid = Strings::ToInt(args[0].c_str()); ZoneServer *zs = zoneserver_list.FindByID(sus->zoneserverid); if (zs) { zs->SendPacket(pack); @@ -284,7 +284,7 @@ void ConsoleEmote( 0, 0, AccountStatus::Player, - atoi(args[1].c_str()), + Strings::ToInt(args[1].c_str()), Strings::Join(join_args, " ").c_str() ); } @@ -295,7 +295,7 @@ void ConsoleEmote( 0, 0, AccountStatus::Player, - atoi(args[1].c_str()), + Strings::ToInt(args[1].c_str()), Strings::Join(join_args, " ").c_str() ); } @@ -304,7 +304,7 @@ void ConsoleEmote( args[0].c_str(), 0, AccountStatus::Player, - atoi(args[1].c_str()), + Strings::ToInt(args[1].c_str()), Strings::Join(join_args, " ").c_str() ); } @@ -422,7 +422,7 @@ void ConsoleGuildSay( } auto from = args[0]; - auto guild_id = Strings::IsNumber(args[1]) ? std::stoul(args[1]) : 0; + auto guild_id = Strings::IsNumber(args[1]) ? Strings::ToUnsignedInt(args[1]) : 0; if (!guild_id) { return; } @@ -585,7 +585,7 @@ void ConsoleZoneShutdown( pack->opcode = ServerOP_ZoneShutdown; strcpy(s->adminname, tmpname); if (Strings::IsNumber(args[0])) { - s->ZoneServerID = atoi(args[0].c_str()); + s->ZoneServerID = Strings::ToInt(args[0].c_str()); } else { s->zoneid = ZoneID(args[0].c_str()); @@ -639,12 +639,12 @@ void ConsoleZoneBootup( if (args.size() > 2) { zoneserver_list.SOPZoneBootup( tmpname, - atoi(args[0].c_str()), + Strings::ToInt(args[0].c_str()), args[1].c_str(), (bool) (strcasecmp(args[1].c_str(), "static") == 0)); } else { - zoneserver_list.SOPZoneBootup(tmpname, atoi(args[0].c_str()), args[1].c_str(), false); + zoneserver_list.SOPZoneBootup(tmpname, Strings::ToInt(args[0].c_str()), args[1].c_str(), false); } } } @@ -751,10 +751,10 @@ void ConsoleFlag( connection->SendLine("Usage: flag [status] [accountname]"); } else { - if (atoi(args[0].c_str()) > connection->Admin()) { + if (Strings::ToInt(args[0].c_str()) > connection->Admin()) { connection->SendLine("You cannot set people's status to higher than your own"); } - else if (!database.SetAccountStatus(args[1].c_str(), atoi(args[0].c_str()))) { + else if (!database.SetAccountStatus(args[1].c_str(), Strings::ToInt(args[0].c_str()))) { connection->SendLine("Unable to flag account!"); } else { @@ -821,8 +821,8 @@ void ConsoleWorldShutdown( { if (args.size() == 2) { int32 time, interval; - if (Strings::IsNumber(args[0]) && Strings::IsNumber(args[1]) && ((time = atoi(args[0].c_str())) > 0) && - ((interval = atoi(args[1].c_str())) > 0)) { + if (Strings::IsNumber(args[0]) && Strings::IsNumber(args[1]) && ((time = Strings::ToInt(args[0].c_str())) > 0) && + ((interval = Strings::ToInt(args[1].c_str())) > 0)) { zoneserver_list.WorldShutDown(time, interval); } else { @@ -886,7 +886,7 @@ void ConsoleSignalCharByName( return; } - connection->SendLine(StringFormat("Signal Sent to %s with ID %i", (char *) args[0].c_str(), atoi(args[1].c_str()))); + connection->SendLine(StringFormat("Signal Sent to %s with ID %i", (char *) args[0].c_str(), Strings::ToInt(args[1].c_str()))); uint32 message_len = strlen((char *) args[0].c_str()) + 1; auto pack = new ServerPacket(ServerOP_CZSignal, sizeof(CZSignal_Struct) + message_len); CZSignal_Struct* CZS = (CZSignal_Struct*) pack->pBuffer; @@ -894,7 +894,7 @@ void ConsoleSignalCharByName( int update_identifier = 0; CZS->update_type = update_type; CZS->update_identifier = update_identifier; - CZS->signal_id = atoi(args[1].c_str()); + CZS->signal_id = Strings::ToInt(args[1].c_str()); strn0cpy(CZS->client_name, (char *) args[0].c_str(), 64); zoneserver_list.SendPacket(pack); safe_delete(pack); diff --git a/world/console.old.cpp b/world/console.old.cpp index 59c7825120..f22d143d17 100644 --- a/world/console.old.cpp +++ b/world/console.old.cpp @@ -494,13 +494,13 @@ void Console::ProcessCommand(const char* command) { // do nothing } else if (strcasecmp(sep.arg[0], "signalcharbyname") == 0) { - SendMessage(1, "Signal Sent to %s with ID %i", (char*) sep.arg[1], atoi(sep.arg[2])); + SendMessage(1, "Signal Sent to %s with ID %i", (char*) sep.arg[1], Strings::ToInt(sep.arg[2])); uint32 message_len = strlen((char*) sep.arg[1]) + 1; auto pack = new ServerPacket(ServerOP_CZSignalClientByName, sizeof(CZClientSignalByName_Struct) + message_len); CZClientSignalByName_Struct* CZSC = (CZClientSignalByName_Struct*) pack->pBuffer; strn0cpy(CZSC->Name, (char*) sep.arg[1], 64); - CZSC->data = atoi(sep.arg[2]); + CZSC->data = Strings::ToInt(sep.arg[2]); zoneserver_list.SendPacket(pack); safe_delete(pack); } @@ -522,11 +522,11 @@ void Console::ProcessCommand(const char* command) { } } else if (strcasecmp(sep.arg[0], "uptime") == 0) { - if (sep.IsNumber(1) && atoi(sep.arg[1]) > 0) { + if (sep.IsNumber(1) && Strings::ToInt(sep.arg[1]) > 0) { auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct)); ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer; snprintf(sus->adminname, sizeof(sus->adminname), "*%s", GetName()); - sus->zoneserverid = atoi(sep.arg[1]); + sus->zoneserverid = Strings::ToInt(sep.arg[1]); ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid); if (zs) zs->SendPacket(pack); @@ -603,13 +603,13 @@ void Console::ProcessCommand(const char* command) { } else if (strcasecmp(sep.arg[0], "emote") == 0) { if (strcasecmp(sep.arg[1], "world") == 0) - zoneserver_list.SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + zoneserver_list.SendEmoteMessageRaw(0, 0, 0, Strings::ToInt(sep.arg[2]), sep.argplus[3]); else { ZoneServer* zs = zoneserver_list.FindByName(sep.arg[1]); if (zs != 0) - zs->SendEmoteMessageRaw(0, 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + zs->SendEmoteMessageRaw(0, 0, 0, Strings::ToInt(sep.arg[2]), sep.argplus[3]); else - zoneserver_list.SendEmoteMessageRaw(sep.arg[1], 0, 0, atoi(sep.arg[2]), sep.argplus[3]); + zoneserver_list.SendEmoteMessageRaw(sep.arg[1], 0, 0, Strings::ToInt(sep.arg[2]), sep.argplus[3]); } } else if (strcasecmp(sep.arg[0], "movechar") == 0) { @@ -634,11 +634,11 @@ void Console::ProcessCommand(const char* command) { SendMessage(1, "Usage: flag [status] [accountname]"); else { - if (atoi(sep.arg[1]) > Admin()) + if (Strings::ToInt(sep.arg[1]) > Admin()) SendMessage(1, "You cannot set people's status to higher than your own"); - else if (atoi(sep.arg[1]) < 0 && Admin() < consoleFlagStatus) + else if (Strings::ToInt(sep.arg[1]) < 0 && Admin() < consoleFlagStatus) SendMessage(1, "You have too low of status to change flags"); - else if (!database.SetAccountStatus(sep.arg[2], atoi(sep.arg[1]))) + else if (!database.SetAccountStatus(sep.arg[2], Strings::ToInt(sep.arg[1]))) SendMessage(1, "Unable to flag account!"); else SendMessage(1, "Account Flaged"); @@ -672,13 +672,13 @@ void Console::ProcessCommand(const char* command) { whom->gmlookup = 1; else if (sep.IsNumber(i)) { if (whom->lvllow == 0xFFFF) { - whom->lvllow = atoi(sep.arg[i]); + whom->lvllow = Strings::ToInt(sep.arg[i]); whom->lvlhigh = whom->lvllow; } - else if (atoi(sep.arg[i]) > int(whom->lvllow)) - whom->lvlhigh = atoi(sep.arg[i]); + else if (Strings::ToInt(sep.arg[i]) > int(whom->lvllow)) + whom->lvlhigh = Strings::ToInt(sep.arg[i]); else - whom->lvllow = atoi(sep.arg[i]); + whom->lvllow = Strings::ToInt(sep.arg[i]); } else strn0cpy(whom->whom, sep.arg[i], sizeof(whom->whom)); @@ -709,7 +709,7 @@ void Console::ProcessCommand(const char* command) { pack->opcode = ServerOP_ZoneShutdown; strcpy(s->adminname, tmpname); if (sep.arg[1][0] >= '0' && sep.arg[1][0] <= '9') - s->ZoneServerID = atoi(sep.arg[1]); + s->ZoneServerID = Strings::ToInt(sep.arg[1]); else s->zoneid = ZoneID(sep.arg[1]); @@ -738,12 +738,12 @@ void Console::ProcessCommand(const char* command) { strcpy(&tmpname[1], paccountname); LogInfo("Console ZoneBootup: [{}], [{}], [{}]",tmpname,sep.arg[2],sep.arg[1]); - zoneserver_list.SOPZoneBootup(tmpname, atoi(sep.arg[1]), sep.arg[2], (bool) (strcasecmp(sep.arg[3], "static") == 0)); + zoneserver_list.SOPZoneBootup(tmpname, Strings::ToInt(sep.arg[1]), sep.arg[2], (bool) (strcasecmp(sep.arg[3], "static") == 0)); } } else if (strcasecmp(sep.arg[0], "worldshutdown") == 0 && admin >= consoleWorldStatus) { int32 time, interval; - if(sep.IsNumber(1) && sep.IsNumber(2) && ((time=atoi(sep.arg[1]))>0) && ((interval=atoi(sep.arg[2]))>0)) { + if(sep.IsNumber(1) && sep.IsNumber(2) && ((time=Strings::ToInt(sep.arg[1]))>0) && ((interval=Strings::ToInt(sep.arg[2]))>0)) { zoneserver_list.WorldShutDown(time, interval); } else if(strcasecmp(sep.arg[1], "now") == 0) { diff --git a/world/eqemu_api_world_data_service.cpp b/world/eqemu_api_world_data_service.cpp index deb1631bef..c9e257a640 100644 --- a/world/eqemu_api_world_data_service.cpp +++ b/world/eqemu_api_world_data_service.cpp @@ -194,7 +194,7 @@ void EQEmuApiWorldDataService::reload(Json::Value &r, const std::vector(std::stoul(args[2])); + global_repop = static_cast(Strings::ToUnsignedInt(args[2])); if (global_repop > ReloadWorld::ForceRepop) { global_repop = ReloadWorld::ForceRepop; diff --git a/world/eql_config.cpp b/world/eql_config.cpp index d35429aae9..c7101cf0ee 100644 --- a/world/eql_config.cpp +++ b/world/eql_config.cpp @@ -47,7 +47,7 @@ void EQLConfig::LoadSettings() { } else { auto row = results.begin(); - m_dynamics = atoi(row[0]); + m_dynamics = Strings::ToInt(row[0]); } query = StringFormat("SELECT zone, port FROM launcher_zones WHERE launcher = '%s'", namebuf); @@ -60,7 +60,7 @@ void EQLConfig::LoadSettings() { LauncherZone zs; for (auto row = results.begin(); row != results.end(); ++row) { zs.name = row[0]; - zs.port = atoi(row[1]); + zs.port = Strings::ToInt(row[1]); m_zones[zs.name] = zs; } diff --git a/world/eqw.cpp b/world/eqw.cpp index 7c37f3e457..1a7e6c147e 100644 --- a/world/eqw.cpp +++ b/world/eqw.cpp @@ -131,7 +131,7 @@ std::vector EQW::ListBootedZones() { std::map EQW::GetZoneDetails(Const_char *zone_ref) { std::map res; - ZoneServer *zs = zoneserver_list.FindByID(atoi(zone_ref)); + ZoneServer *zs = zoneserver_list.FindByID(Strings::ToInt(zone_ref)); if(zs == nullptr) { res["error"] = "Invalid zone."; return(res); @@ -316,7 +316,7 @@ int EQW::CountBugs() { return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } std::vector EQW::ListBugs(uint32 offset) { diff --git a/world/http_request.cpp b/world/http_request.cpp index af4b6c9b23..16be3c8dd9 100644 --- a/world/http_request.cpp +++ b/world/http_request.cpp @@ -54,7 +54,7 @@ int HTTPRequest::getInt(const char *name, int default_value) const { res = m_values.find(name); if(res == m_values.end()) return(default_value); - return(atoi(res->second.c_str())); + return(Strings::ToInt(res->second.c_str())); } float HTTPRequest::getFloat(const char *name, float default_value) const { @@ -62,7 +62,7 @@ float HTTPRequest::getFloat(const char *name, float default_value) const { res = m_values.find(name); if(res == m_values.end()) return(default_value); - return(atof(res->second.c_str())); + return(Strings::ToFloat(res->second.c_str())); } void HTTPRequest::header(Const_char *name, Const_char *value) { diff --git a/world/world_server_cli.cpp b/world/world_server_cli.cpp index 13adb11b5a..58d022ed47 100644 --- a/world/world_server_cli.cpp +++ b/world/world_server_cli.cpp @@ -32,6 +32,7 @@ void WorldserverCLI::CommandHandler(int argc, char **argv) function_map["test:repository"] = &WorldserverCLI::TestRepository; function_map["test:repository2"] = &WorldserverCLI::TestRepository2; function_map["test:db-concurrency"] = &WorldserverCLI::TestDatabaseConcurrency; + function_map["test:string-benchmark"] = &WorldserverCLI::TestStringBenchmarkCommand; EQEmuCommand::HandleMenu(function_map, cmd, argc, argv); } @@ -47,4 +48,5 @@ void WorldserverCLI::CommandHandler(int argc, char **argv) #include "cli/test_expansion.cpp" #include "cli/test_repository.cpp" #include "cli/test_repository_2.cpp" +#include "cli/test_string_benchmark.cpp" #include "cli/version.cpp" diff --git a/world/world_server_cli.h b/world/world_server_cli.h index 4255522390..154de64418 100644 --- a/world/world_server_cli.h +++ b/world/world_server_cli.h @@ -19,6 +19,7 @@ class WorldserverCLI { static void TestRepository(int argc, char **argv, argh::parser &cmd, std::string &description); static void TestRepository2(int argc, char **argv, argh::parser &cmd, std::string &description); static void TestDatabaseConcurrency(int argc, char **argv, argh::parser &cmd, std::string &description); + static void TestStringBenchmarkCommand(int argc, char **argv, argh::parser &cmd, std::string &description); }; diff --git a/world/worlddb.cpp b/world/worlddb.cpp index 70033d9883..4cac30d863 100644 --- a/world/worlddb.cpp +++ b/world/worlddb.cpp @@ -120,22 +120,22 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o inventory_profile.SetInventoryVersion(client_version); inventory_profile.SetGMInventory(true); // charsel can not interact with items..but, no harm in setting to full expansion support - uint32 character_id = (uint32) atoi(row[0]); + uint32 character_id = (uint32) Strings::ToInt(row[0]); uint8 has_home = 0; uint8 has_bind = 0; memset(&pp, 0, sizeof(PlayerProfile_Struct)); memset(p_character_select_entry_struct->Name, 0, sizeof(p_character_select_entry_struct->Name)); strcpy(p_character_select_entry_struct->Name, row[1]); - p_character_select_entry_struct->Class = (uint8) atoi(row[4]); - p_character_select_entry_struct->Race = (uint32) atoi(row[3]); - p_character_select_entry_struct->Level = (uint8) atoi(row[5]); + p_character_select_entry_struct->Class = (uint8) Strings::ToInt(row[4]); + p_character_select_entry_struct->Race = (uint32) Strings::ToInt(row[3]); + p_character_select_entry_struct->Level = (uint8) Strings::ToInt(row[5]); p_character_select_entry_struct->ShroudClass = p_character_select_entry_struct->Class; p_character_select_entry_struct->ShroudRace = p_character_select_entry_struct->Race; - p_character_select_entry_struct->Zone = (uint16) atoi(row[19]); + p_character_select_entry_struct->Zone = (uint16) Strings::ToInt(row[19]); p_character_select_entry_struct->Instance = 0; - p_character_select_entry_struct->Gender = (uint8) atoi(row[2]); - p_character_select_entry_struct->Face = (uint8) atoi(row[15]); + p_character_select_entry_struct->Gender = (uint8) Strings::ToInt(row[2]); + p_character_select_entry_struct->Face = (uint8) Strings::ToInt(row[15]); for (uint32 material_slot = 0; material_slot < EQ::textures::materialCount; material_slot++) { p_character_select_entry_struct->Equip[material_slot].Material = 0; @@ -148,28 +148,28 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o p_character_select_entry_struct->Unknown15 = 0xFF; p_character_select_entry_struct->Unknown19 = 0xFF; - p_character_select_entry_struct->DrakkinTattoo = (uint32) atoi(row[17]); - p_character_select_entry_struct->DrakkinDetails = (uint32) atoi(row[18]); - p_character_select_entry_struct->Deity = (uint32) atoi(row[6]); + p_character_select_entry_struct->DrakkinTattoo = (uint32) Strings::ToInt(row[17]); + p_character_select_entry_struct->DrakkinDetails = (uint32) Strings::ToInt(row[18]); + p_character_select_entry_struct->Deity = (uint32) Strings::ToInt(row[6]); p_character_select_entry_struct->PrimaryIDFile = 0; // Processed Below p_character_select_entry_struct->SecondaryIDFile = 0; // Processed Below - p_character_select_entry_struct->HairColor = (uint8) atoi(row[9]); - p_character_select_entry_struct->BeardColor = (uint8) atoi(row[10]); - p_character_select_entry_struct->EyeColor1 = (uint8) atoi(row[11]); - p_character_select_entry_struct->EyeColor2 = (uint8) atoi(row[12]); - p_character_select_entry_struct->HairStyle = (uint8) atoi(row[13]); - p_character_select_entry_struct->Beard = (uint8) atoi(row[14]); + p_character_select_entry_struct->HairColor = (uint8) Strings::ToInt(row[9]); + p_character_select_entry_struct->BeardColor = (uint8) Strings::ToInt(row[10]); + p_character_select_entry_struct->EyeColor1 = (uint8) Strings::ToInt(row[11]); + p_character_select_entry_struct->EyeColor2 = (uint8) Strings::ToInt(row[12]); + p_character_select_entry_struct->HairStyle = (uint8) Strings::ToInt(row[13]); + p_character_select_entry_struct->Beard = (uint8) Strings::ToInt(row[14]); p_character_select_entry_struct->GoHome = 0; // Processed Below p_character_select_entry_struct->Tutorial = 0; // Processed Below - p_character_select_entry_struct->DrakkinHeritage = (uint32) atoi(row[16]); + p_character_select_entry_struct->DrakkinHeritage = (uint32) Strings::ToInt(row[16]); p_character_select_entry_struct->Unknown1 = 0; p_character_select_entry_struct->Enabled = 1; - p_character_select_entry_struct->LastLogin = (uint32) atoi(row[7]); // RoF2 value: 1212696584 + p_character_select_entry_struct->LastLogin = (uint32) Strings::ToInt(row[7]); // RoF2 value: 1212696584 p_character_select_entry_struct->Unknown2 = 0; if (RuleB(World, EnableReturnHomeButton)) { int now = time(nullptr); - if ((now - atoi(row[7])) >= RuleI(World, MinOfflineTimeToReturnHome)) + if ((now - Strings::ToInt(row[7])) >= RuleI(World, MinOfflineTimeToReturnHome)) p_character_select_entry_struct->GoHome = 1; } @@ -194,20 +194,20 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o auto results_bind = database.QueryDatabase(character_list_query); auto bind_count = results_bind.RowCount(); for (auto row_b = results_bind.begin(); row_b != results_bind.end(); ++row_b) { - if (row_b[6] && atoi(row_b[6]) == 4) { + if (row_b[6] && Strings::ToInt(row_b[6]) == 4) { has_home = 1; // If our bind count is less than 5, we need to actually make use of this data so lets parse it if (bind_count < 5) { - pp.binds[4].zone_id = atoi(row_b[0]); - pp.binds[4].instance_id = atoi(row_b[1]); - pp.binds[4].x = atof(row_b[2]); - pp.binds[4].y = atof(row_b[3]); - pp.binds[4].z = atof(row_b[4]); - pp.binds[4].heading = atof(row_b[5]); + pp.binds[4].zone_id = Strings::ToInt(row_b[0]); + pp.binds[4].instance_id = Strings::ToInt(row_b[1]); + pp.binds[4].x = Strings::ToFloat(row_b[2]); + pp.binds[4].y = Strings::ToFloat(row_b[3]); + pp.binds[4].z = Strings::ToFloat(row_b[4]); + pp.binds[4].heading = Strings::ToFloat(row_b[5]); } } - if (row_b[6] && atoi(row_b[6]) == 0) + if (row_b[6] && Strings::ToInt(row_b[6]) == 0) has_bind = 1; } @@ -233,8 +233,8 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o auto results_bind = content_db.QueryDatabase(character_list_query); for (auto row_d = results_bind.begin(); row_d != results_bind.end(); ++row_d) { /* If a bind_id is specified, make them start there */ - if (atoi(row_d[1]) != 0) { - pp.binds[4].zone_id = (uint32) atoi(row_d[1]); + if (Strings::ToInt(row_d[1]) != 0) { + pp.binds[4].zone_id = (uint32) Strings::ToInt(row_d[1]); auto z = GetZone(pp.binds[4].zone_id); if (z) { @@ -246,11 +246,11 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o } /* Otherwise, use the zone and coordinates given */ else { - pp.binds[4].zone_id = (uint32) atoi(row_d[0]); - float x = atof(row_d[2]); - float y = atof(row_d[3]); - float z = atof(row_d[4]); - float heading = atof(row_d[5]); + pp.binds[4].zone_id = (uint32) Strings::ToInt(row_d[0]); + float x = Strings::ToFloat(row_d[2]); + float y = Strings::ToFloat(row_d[3]); + float z = Strings::ToFloat(row_d[4]); + float heading = Strings::ToFloat(row_d[5]); if (x == 0 && y == 0 && z == 0 && heading == 0) { auto zone = GetZone(pp.binds[4].zone_id); if (zone) { @@ -350,11 +350,11 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o auto results_b = database.QueryDatabase(character_list_query); uint8 slot = 0; for (auto row_b = results_b.begin(); row_b != results_b.end(); ++row_b) { - slot = atoi(row_b[0]); - pp.item_tint.Slot[slot].Red = atoi(row_b[1]); - pp.item_tint.Slot[slot].Green = atoi(row_b[2]); - pp.item_tint.Slot[slot].Blue = atoi(row_b[3]); - pp.item_tint.Slot[slot].UseTint = atoi(row_b[4]); + slot = Strings::ToInt(row_b[0]); + pp.item_tint.Slot[slot].Red = Strings::ToInt(row_b[1]); + pp.item_tint.Slot[slot].Green = Strings::ToInt(row_b[2]); + pp.item_tint.Slot[slot].Blue = Strings::ToInt(row_b[3]); + pp.item_tint.Slot[slot].UseTint = Strings::ToInt(row_b[4]); } if (GetCharSelInventory(account_id, p_character_select_entry_struct->Name, &inventory_profile)) { @@ -380,7 +380,7 @@ void WorldDatabase::GetCharSelectInfo(uint32 account_id, EQApplicationPacket **o p_character_select_entry_struct->Equip[matslot].Material = item_id_file; } else { if (strlen(item->IDFile) > 2) { - item_id_file = atoi(&item->IDFile[2]); + item_id_file = Strings::ToInt(&item->IDFile[2]); p_character_select_entry_struct->Equip[matslot].Material = item_id_file; } } @@ -439,12 +439,12 @@ int WorldDatabase::MoveCharacterToBind(int character_id, uint8 bind_number) int zone_id, instance_id; double x, y, z, heading; for (auto row = results.begin(); row != results.end(); ++row) { - zone_id = atoi(row[0]); - instance_id = atoi(row[1]); - x = atof(row[2]); - y = atof(row[3]); - z = atof(row[4]); - heading = atof(row[5]); + zone_id = Strings::ToInt(row[0]); + instance_id = Strings::ToInt(row[1]); + x = Strings::ToFloat(row[2]); + y = Strings::ToFloat(row[3]); + z = Strings::ToFloat(row[4]); + heading = Strings::ToFloat(row[5]); } query = fmt::format( @@ -596,16 +596,16 @@ bool WorldDatabase::GetStartZone( else { LogInfo("Found starting location in start_zones"); auto row = results.begin(); - pp->x = atof(row[0]); - pp->y = atof(row[1]); - pp->z = atof(row[2]); - pp->heading = atof(row[3]); - pp->zone_id = atoi(row[4]); - pp->binds[0].zone_id = atoi(row[5]); - pp->binds[0].x = atof(row[6]); - pp->binds[0].y = atof(row[7]); - pp->binds[0].z = atof(row[8]); - pp->binds[0].heading = atof(row[3]); + pp->x = Strings::ToFloat(row[0]); + pp->y = Strings::ToFloat(row[1]); + pp->z = Strings::ToFloat(row[2]); + pp->heading = Strings::ToFloat(row[3]); + pp->zone_id = Strings::ToInt(row[4]); + pp->binds[0].zone_id = Strings::ToInt(row[5]); + pp->binds[0].x = Strings::ToFloat(row[6]); + pp->binds[0].y = Strings::ToFloat(row[7]); + pp->binds[0].z = Strings::ToFloat(row[8]); + pp->binds[0].heading = Strings::ToFloat(row[3]); } if ( @@ -792,7 +792,7 @@ bool WorldDatabase::GetCharacterLevel(const char *name, int &level) return false; auto row = results.begin(); - level = atoi(row[0]); + level = Strings::ToInt(row[0]); return true; } @@ -808,21 +808,21 @@ bool WorldDatabase::LoadCharacterCreateAllocations() for (auto row = results.begin(); row != results.end(); ++row) { RaceClassAllocation allocate; - allocate.Index = atoi(row[0]); - allocate.BaseStats[0] = atoi(row[1]); - allocate.BaseStats[3] = atoi(row[2]); - allocate.BaseStats[1] = atoi(row[3]); - allocate.BaseStats[2] = atoi(row[4]); - allocate.BaseStats[4] = atoi(row[5]); - allocate.BaseStats[5] = atoi(row[6]); - allocate.BaseStats[6] = atoi(row[7]); - allocate.DefaultPointAllocation[0] = atoi(row[8]); - allocate.DefaultPointAllocation[3] = atoi(row[9]); - allocate.DefaultPointAllocation[1] = atoi(row[10]); - allocate.DefaultPointAllocation[2] = atoi(row[11]); - allocate.DefaultPointAllocation[4] = atoi(row[12]); - allocate.DefaultPointAllocation[5] = atoi(row[13]); - allocate.DefaultPointAllocation[6] = atoi(row[14]); + allocate.Index = Strings::ToInt(row[0]); + allocate.BaseStats[0] = Strings::ToInt(row[1]); + allocate.BaseStats[3] = Strings::ToInt(row[2]); + allocate.BaseStats[1] = Strings::ToInt(row[3]); + allocate.BaseStats[2] = Strings::ToInt(row[4]); + allocate.BaseStats[4] = Strings::ToInt(row[5]); + allocate.BaseStats[5] = Strings::ToInt(row[6]); + allocate.BaseStats[6] = Strings::ToInt(row[7]); + allocate.DefaultPointAllocation[0] = Strings::ToInt(row[8]); + allocate.DefaultPointAllocation[3] = Strings::ToInt(row[9]); + allocate.DefaultPointAllocation[1] = Strings::ToInt(row[10]); + allocate.DefaultPointAllocation[2] = Strings::ToInt(row[11]); + allocate.DefaultPointAllocation[4] = Strings::ToInt(row[12]); + allocate.DefaultPointAllocation[5] = Strings::ToInt(row[13]); + allocate.DefaultPointAllocation[6] = Strings::ToInt(row[14]); character_create_allocations.push_back(allocate); } @@ -841,12 +841,12 @@ bool WorldDatabase::LoadCharacterCreateCombos() for (auto row = results.begin(); row != results.end(); ++row) { RaceClassCombos combo; - combo.AllocationIndex = atoi(row[0]); - combo.Race = atoi(row[1]); - combo.Class = atoi(row[2]); - combo.Deity = atoi(row[3]); - combo.Zone = atoi(row[4]); - combo.ExpansionRequired = atoi(row[5]); + combo.AllocationIndex = Strings::ToInt(row[0]); + combo.Race = Strings::ToInt(row[1]); + combo.Class = Strings::ToInt(row[2]); + combo.Deity = Strings::ToInt(row[3]); + combo.Zone = Strings::ToInt(row[4]); + combo.ExpansionRequired = Strings::ToInt(row[5]); character_create_race_class_combos.push_back(combo); } @@ -901,7 +901,7 @@ bool WorldDatabase::GetCharSelInventory(uint32 account_id, char *name, EQ::Inven return false; for (auto row = results.begin(); row != results.end(); ++row) { - int16 slot_id = atoi(row[0]); + int16 slot_id = Strings::ToInt(row[0]); switch (slot_id) { case EQ::invslot::slotFace: @@ -916,22 +916,22 @@ bool WorldDatabase::GetCharSelInventory(uint32 account_id, char *name, EQ::Inven break; } - uint32 item_id = atoi(row[1]); - int8 charges = atoi(row[2]); - uint32 color = atoul(row[3]); + uint32 item_id = Strings::ToInt(row[1]); + int8 charges = Strings::ToInt(row[2]); + uint32 color = Strings::ToUnsignedInt(row[3]); uint32 aug[EQ::invaug::SOCKET_COUNT]; - aug[0] = (uint32)atoi(row[4]); - aug[1] = (uint32)atoi(row[5]); - aug[2] = (uint32)atoi(row[6]); - aug[3] = (uint32)atoi(row[7]); - aug[4] = (uint32)atoi(row[8]); - aug[5] = (uint32)atoi(row[9]); - - bool instnodrop = ((row[10] && (uint16)atoi(row[10])) ? true : false); - uint32 ornament_icon = (uint32)atoul(row[12]); - uint32 ornament_idfile = (uint32)atoul(row[13]); - uint32 ornament_hero_model = (uint32)atoul(row[14]); + aug[0] = (uint32)Strings::ToInt(row[4]); + aug[1] = (uint32)Strings::ToInt(row[5]); + aug[2] = (uint32)Strings::ToInt(row[6]); + aug[3] = (uint32)Strings::ToInt(row[7]); + aug[4] = (uint32)Strings::ToInt(row[8]); + aug[5] = (uint32)Strings::ToInt(row[9]); + + bool instnodrop = ((row[10] && (uint16)Strings::ToInt(row[10])) ? true : false); + uint32 ornament_icon = (uint32)Strings::ToUnsignedInt(row[12]); + uint32 ornament_idfile = (uint32)Strings::ToUnsignedInt(row[13]); + uint32 ornament_hero_model = (uint32)Strings::ToUnsignedInt(row[14]); const EQ::ItemData *item = content_db.GetItem(item_id); if (!item) diff --git a/zone/aa.cpp b/zone/aa.cpp index bfe7183a0a..66b5f7b0f9 100644 --- a/zone/aa.cpp +++ b/zone/aa.cpp @@ -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_mapid = 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(ability); @@ -1814,18 +1814,18 @@ bool ZoneDatabase::LoadAlternateAdvancementAbilities(std::unordered_mapid = 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_mapIsClient()) { database.GetVariable("PvPreward", tmp); - auto reward = atoi(tmp.c_str()); + auto reward = Strings::ToInt(tmp.c_str()); if (reward == 3) { database.GetVariable("PvPitem", tmp); - auto pvp_item_id = atoi(tmp.c_str()); + auto pvp_item_id = Strings::ToInt(tmp.c_str()); const auto* item = database.GetItem(pvp_item_id); if (item) { new_corpse->SetPlayerKillItemID(pvp_item_id); diff --git a/zone/aura.cpp b/zone/aura.cpp index 7f41d1b3a6..4fd97dbf63 100644 --- a/zone/aura.cpp +++ b/zone/aura.cpp @@ -946,17 +946,17 @@ bool ZoneDatabase::GetAuraEntry(uint16 spell_id, AuraRecord &record) auto row = results.begin(); - record.npc_type = atoi(row[0]); + record.npc_type = Strings::ToInt(row[0]); strn0cpy(record.name, row[1], 64); - record.spell_id = atoi(row[2]); - record.distance = atoi(row[3]); + record.spell_id = Strings::ToInt(row[2]); + record.distance = Strings::ToInt(row[3]); record.distance *= record.distance; // so we can avoid sqrt - record.aura_type = atoi(row[4]); - record.spawn_type = atoi(row[5]); - record.movement = atoi(row[6]); - record.duration = atoi(row[7]) * 1000; // DB is in seconds - record.icon = atoi(row[8]); - record.cast_time = atoi(row[9]) * 1000; // DB is in seconds + record.aura_type = Strings::ToInt(row[4]); + record.spawn_type = Strings::ToInt(row[5]); + record.movement = Strings::ToInt(row[6]); + record.duration = Strings::ToInt(row[7]) * 1000; // DB is in seconds + record.icon = Strings::ToInt(row[8]); + record.cast_time = Strings::ToInt(row[9]) * 1000; // DB is in seconds return true; } diff --git a/zone/bot.cpp b/zone/bot.cpp index 6a07eca4d7..3d32617fb4 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -4573,7 +4573,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { item = inst->GetItem(); if(item) { if(strlen(item->IDFile) > 2) - ns->spawn.equipment.Primary.Material = atoi(&item->IDFile[2]); + ns->spawn.equipment.Primary.Material = Strings::ToInt(&item->IDFile[2]); ns->spawn.equipment_tint.Primary.Color = GetEquipmentColor(EQ::textures::weaponPrimary); } @@ -4584,7 +4584,7 @@ void Bot::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho) { item = inst->GetItem(); if(item) { if(strlen(item->IDFile) > 2) - ns->spawn.equipment.Secondary.Material = atoi(&item->IDFile[2]); + ns->spawn.equipment.Secondary.Material = Strings::ToInt(&item->IDFile[2]); ns->spawn.equipment_tint.Secondary.Color = GetEquipmentColor(EQ::textures::weaponSecondary); } diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 972169c5ff..a0dd56af8e 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -9464,7 +9464,7 @@ void bot_subcommand_bot_beard_color(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetGender() != MALE && my_bot->GetRace() != DWARF) @@ -9501,7 +9501,7 @@ void bot_subcommand_bot_beard_style(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetGender() != MALE && my_bot->GetRace() != DWARF) @@ -9808,7 +9808,7 @@ void bot_command_view_combos(Client *c, const Seperator *sep) return; } - const uint16 bot_race = static_cast(std::stoul(sep->arg[1])); + const uint16 bot_race = static_cast(Strings::ToUnsignedInt(sep->arg[1])); const std::string race_name = GetRaceIDName(bot_race); if (!Mob::IsPlayerRace(bot_race)) { @@ -10012,14 +10012,14 @@ void bot_subcommand_bot_create(Client *c, const Seperator *sep) return; } - auto bot_class = static_cast(std::stoul(sep->arg[2])); + auto bot_class = static_cast(Strings::ToUnsignedInt(sep->arg[2])); if (arguments < 3 || !sep->IsNumber(3)) { c->Message(Chat::White, "Invalid race!"); return; } - auto bot_race = static_cast(std::stoul(sep->arg[3])); + auto bot_race = static_cast(Strings::ToUnsignedInt(sep->arg[3])); if (arguments < 4) { c->Message(Chat::White, "Invalid gender!"); @@ -10029,7 +10029,7 @@ void bot_subcommand_bot_create(Client *c, const Seperator *sep) auto bot_gender = MALE; if (sep->IsNumber(4)) { - bot_gender = static_cast(std::stoul(sep->arg[4])); + bot_gender = static_cast(Strings::ToUnsignedInt(sep->arg[4])); if (bot_gender == NEUTER) { bot_gender = MALE; } @@ -10105,7 +10105,7 @@ void bot_subcommand_bot_details(Client *c, const Seperator *sep) return; } - uint32 uvalue = atoi(sep->arg[1]); + uint32 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetRace() != DRAKKIN) @@ -10163,8 +10163,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep) c->Message(Chat::White, material_slot_message.c_str()); return; } - - material_slot = std::stoi(sep->arg[1]); + material_slot = Strings::ToInt(sep->arg[1]); slot_id = EQ::InventoryProfile::CalcSlotFromMaterial(material_slot); if (!sep->IsNumber(1) || slot_id == INVALID_INDEX || material_slot > EQ::textures::LastTintableTexture) { @@ -10179,7 +10178,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep) return; } - uint32 red_value = std::stoul(sep->arg[2]); + uint32 red_value = Strings::ToUnsignedInt(sep->arg[2]); if (red_value > 255) { red_value = 255; } @@ -10189,7 +10188,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep) return; } - uint32 green_value = std::stoul(sep->arg[3]); + uint32 green_value = Strings::ToUnsignedInt(sep->arg[3]); if (green_value > 255) { green_value = 255; } @@ -10199,7 +10198,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep) return; } - uint32 blue_value = std::stoul(sep->arg[4]); + uint32 blue_value = Strings::ToUnsignedInt(sep->arg[4]); if (blue_value > 255) { blue_value = 255; } @@ -10279,7 +10278,7 @@ void bot_subcommand_bot_eyes(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); //uint8 eye_bias = 0; //std::string arg2 = sep->arg[2]; @@ -10333,7 +10332,7 @@ void bot_subcommand_bot_face(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (!PlayerAppearance::IsValidFace(my_bot->GetRace(), my_bot->GetGender(), uvalue)) { @@ -10373,7 +10372,7 @@ void bot_subcommand_bot_follow_distance(Client *c, const Seperator *sep) return; } - bfd = atoi(sep->arg[2]); + bfd = Strings::ToInt(sep->arg[2]); if (bfd < 1) bfd = 1; if (bfd > BOT_FOLLOW_DISTANCE_DEFAULT_MAX) @@ -10439,7 +10438,7 @@ void bot_subcommand_bot_hair_color(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (!PlayerAppearance::IsValidHairColor(my_bot->GetRace(), my_bot->GetGender(), uvalue)) @@ -10474,7 +10473,7 @@ void bot_subcommand_bot_hairstyle(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (!PlayerAppearance::IsValidHair(my_bot->GetRace(), my_bot->GetGender(), uvalue)) @@ -10511,7 +10510,7 @@ void bot_subcommand_bot_heritage(Client *c, const Seperator *sep) return; } - uint32 uvalue = atoi(sep->arg[1]); + uint32 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetRace() != DRAKKIN) @@ -10648,13 +10647,13 @@ void bot_subcommand_bot_list(Client *c, const Seperator *sep) if (!strcasecmp(sep->arg[i], "class")) { filter_mask |= MaskClass; - filter_value[FilterClass] = atoi(sep->arg[i + 1]); + filter_value[FilterClass] = Strings::ToInt(sep->arg[i + 1]); continue; } if (!strcasecmp(sep->arg[i], "race")) { filter_mask |= MaskRace; - filter_value[FilterRace] = atoi(sep->arg[i + 1]); + filter_value[FilterRace] = Strings::ToInt(sep->arg[i + 1]); continue; } @@ -11254,7 +11253,7 @@ void bot_subcommand_bot_stance(Client *c, const Seperator *sep) if (!strcasecmp(sep->arg[1], "current")) current_flag = true; else if (sep->IsNumber(1)) { - bst = (EQ::constants::StanceType)atoi(sep->arg[1]); + bst = (EQ::constants::StanceType)Strings::ToInt(sep->arg[1]); if (bst < EQ::constants::stanceUnknown || bst > EQ::constants::stanceBurnAE) bst = EQ::constants::stanceUnknown; } @@ -11313,7 +11312,7 @@ void bot_subcommand_bot_stop_melee_level(Client *c, const Seperator *sep) uint8 sml = RuleI(Bots, CasterStopMeleeLevel); if (sep->IsNumber(1)) { - sml = atoi(sep->arg[1]); + sml = Strings::ToInt(sep->arg[1]); } else if (!strcasecmp(sep->arg[1], "sync")) { sml = my_bot->GetLevel(); @@ -11419,7 +11418,7 @@ void bot_subcommand_bot_tattoo(Client *c, const Seperator *sep) return; } - uint32 uvalue = atoi(sep->arg[1]); + uint32 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetRace() != DRAKKIN) @@ -11663,7 +11662,7 @@ void bot_subcommand_bot_woad(Client *c, const Seperator *sep) return; } - uint8 uvalue = atoi(sep->arg[1]); + uint8 uvalue = Strings::ToInt(sep->arg[1]); auto fail_type = BCEnum::AFT_None; if (my_bot->GetRace() != BARBARIAN) { @@ -12786,7 +12785,7 @@ void bot_subcommand_heal_rotation_adjust_critical(Client *c, const Seperator *se uint8 armor_type_value = 255; if (sep->IsNumber(1)) - armor_type_value = atoi(armor_type_arg.c_str()); + armor_type_value = Strings::ToInt(armor_type_arg.c_str()); if (armor_type_value > ARMOR_TYPE_LAST) { c->Message(Chat::White, "You must specify a valid [armor_type: %u-%u] to use this command", ARMOR_TYPE_FIRST, ARMOR_TYPE_LAST); @@ -12815,7 +12814,7 @@ void bot_subcommand_heal_rotation_adjust_critical(Client *c, const Seperator *se float critical_ratio = CRITICAL_HP_RATIO_BASE; if (sep->IsNumber(2)) - critical_ratio = atof(critical_arg.c_str()); + critical_ratio = Strings::ToFloat(critical_arg.c_str()); else if (!critical_arg.compare("+")) critical_ratio = (*current_member->MemberOfHealRotation())->ArmorTypeCriticalHPRatio(armor_type_value) + HP_RATIO_DELTA; else if (!critical_arg.compare("-")) @@ -12852,7 +12851,7 @@ void bot_subcommand_heal_rotation_adjust_safe(Client *c, const Seperator *sep) uint8 armor_type_value = 255; if (sep->IsNumber(1)) - armor_type_value = atoi(armor_type_arg.c_str()); + armor_type_value = Strings::ToInt(armor_type_arg.c_str()); if (armor_type_value > ARMOR_TYPE_LAST) { c->Message(Chat::White, "You must specify a valid [armor_type: %u-%u] to use this command", ARMOR_TYPE_FIRST, ARMOR_TYPE_LAST); @@ -12881,7 +12880,7 @@ void bot_subcommand_heal_rotation_adjust_safe(Client *c, const Seperator *sep) float safe_ratio = SAFE_HP_RATIO_BASE; if (sep->IsNumber(2)) - safe_ratio = atof(safe_arg.c_str()); + safe_ratio = Strings::ToFloat(safe_arg.c_str()); else if (!safe_arg.compare("+")) safe_ratio = (*current_member->MemberOfHealRotation())->ArmorTypeSafeHPRatio(armor_type_value) + HP_RATIO_DELTA; else if (!safe_arg.compare("-")) @@ -12995,7 +12994,7 @@ void bot_subcommand_heal_rotation_change_interval(Client *c, const Seperator *se uint32 hr_change_interval_s = CASTING_CYCLE_DEFAULT_INTERVAL_S; if (!change_interval_arg.empty()) { - hr_change_interval_s = atoi(change_interval_arg.c_str()); + hr_change_interval_s = Strings::ToInt(change_interval_arg.c_str()); } else { hr_change_interval_s = (*current_member->MemberOfHealRotation())->IntervalS(); @@ -13143,14 +13142,14 @@ void bot_subcommand_heal_rotation_create(Client *c, const Seperator *sep) hr_adaptive_targeting = true; if (!fast_heals_arg.compare("on")) hr_fast_heals = true; - hr_interval_s = atoi(interval_arg.c_str()); + hr_interval_s = Strings::ToInt(interval_arg.c_str()); } else if (!casting_override_arg.compare("off")) { if (!adaptive_targeting_arg.compare("on")) hr_adaptive_targeting = true; if (!fast_heals_arg.compare("on")) hr_fast_heals = true; - hr_interval_s = atoi(interval_arg.c_str()); + hr_interval_s = Strings::ToInt(interval_arg.c_str()); } if (hr_interval_s < CASTING_CYCLE_MINIMUM_INTERVAL_S || hr_interval_s > CASTING_CYCLE_MAXIMUM_INTERVAL_S) @@ -13873,7 +13872,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep) return; } - auto slot_id = static_cast(std::stoul(sep->arg[1])); + auto slot_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (slot_id > EQ::invslot::EQUIPMENT_END || slot_id < EQ::invslot::EQUIPMENT_BEGIN) { c->Message(Chat::White, "Valid slots are 0 to 22."); return; @@ -14949,7 +14948,7 @@ void bot_command_spell_list(Client* c, const Seperator *sep) uint8 min_level = 0; if (sep->IsNumber(1)) { - min_level = static_cast(std::stoul(sep->arg[1])); + min_level = static_cast(Strings::ToUnsignedInt(sep->arg[1])); } my_bot->ListBotSpells(min_level); @@ -14996,7 +14995,7 @@ void bot_command_spell_settings_add(Client *c, const Seperator *sep) return; } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( @@ -15023,9 +15022,9 @@ void bot_command_spell_settings_add(Client *c, const Seperator *sep) return; } - auto priority = static_cast(std::stoi(sep->arg[2])); - auto min_hp = static_cast(EQ::Clamp(std::stoi(sep->arg[3]), -1, 99)); - auto max_hp = static_cast(EQ::Clamp(std::stoi(sep->arg[4]), -1, 100)); + auto priority = static_cast(Strings::ToInt(sep->arg[2])); + auto min_hp = static_cast(EQ::Clamp(Strings::ToInt(sep->arg[3]), -1, 99)); + auto max_hp = static_cast(EQ::Clamp(Strings::ToInt(sep->arg[4]), -1, 100)); BotSpellSetting bs; @@ -15111,7 +15110,7 @@ void bot_command_spell_settings_delete(Client *c, const Seperator *sep) return; } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( @@ -15219,7 +15218,7 @@ void bot_command_spell_settings_toggle(Client *c, const Seperator *sep) return; } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( Chat::White, @@ -15233,7 +15232,7 @@ void bot_command_spell_settings_toggle(Client *c, const Seperator *sep) bool toggle = ( sep->IsNumber(2) ? - (std::stoi(sep->arg[2]) ? true : false) : + (Strings::ToInt(sep->arg[2]) ? true : false) : atobool(sep->arg[2]) ); @@ -15324,7 +15323,7 @@ void bot_command_spell_settings_update(Client *c, const Seperator *sep) return; } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( @@ -15337,9 +15336,9 @@ void bot_command_spell_settings_update(Client *c, const Seperator *sep) return; } - auto priority = static_cast(std::stoi(sep->arg[2])); - auto min_hp = static_cast(EQ::Clamp(std::stoi(sep->arg[3]), -1, 99)); - auto max_hp = static_cast(EQ::Clamp(std::stoi(sep->arg[4]), -1, 100)); + auto priority = static_cast(Strings::ToInt(sep->arg[2])); + auto min_hp = static_cast(EQ::Clamp(Strings::ToInt(sep->arg[3]), -1, 99)); + auto max_hp = static_cast(EQ::Clamp(Strings::ToInt(sep->arg[4]), -1, 100)); BotSpellSetting bs; @@ -15414,7 +15413,7 @@ void bot_spell_info_dialogue_window(Client* c, const Seperator *sep) return; } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); auto min_level = spells[spell_id].classes; auto class_level = min_level[my_bot->GetBotClass() - 1]; diff --git a/zone/bot_database.cpp b/zone/bot_database.cpp index c53e680f61..2629b71e2d 100644 --- a/zone/bot_database.cpp +++ b/zone/bot_database.cpp @@ -43,7 +43,7 @@ bool BotDatabase::LoadBotCommandSettings(std::map= Bot::SPELL_TYPE_COUNT) continue; - uint8 class_index = atoi(row[1]); + uint8 class_index = Strings::ToInt(row[1]); if (class_index < WARRIOR || class_index > BERSERKER) continue; --class_index; - uint8 stance_index = atoi(row[2]); + uint8 stance_index = Strings::ToInt(row[2]); if (stance_index >= EQ::constants::STANCE_TYPE_COUNT) continue; for (uint8 conditional_index = nHSND; conditional_index < cntHSND; ++conditional_index) { - uint8 value = atoi(row[3 + conditional_index]); + uint8 value = Strings::ToInt(row[3 + conditional_index]); if (!value) continue; if (value > 100) @@ -223,7 +223,7 @@ bool BotDatabase::QueryBotCount(const uint32 owner_id, int class_id, uint32& bot } auto row = results.begin(); - bot_count = std::stoul(row[0]); + bot_count = Strings::ToUnsignedInt(row[0]); if (EQ::ValueWithin(class_id, WARRIOR, BERSERKER)) { query = fmt::format( @@ -241,7 +241,7 @@ bool BotDatabase::QueryBotCount(const uint32 owner_id, int class_id, uint32& bot } auto row = results.begin(); - bot_class_count = std::stoul(row[0]); + bot_class_count = Strings::ToUnsignedInt(row[0]); } return true; @@ -270,7 +270,7 @@ bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list(std::stoul(row[1])); + bot_id = Strings::ToUnsignedInt(row[0]); + bot_class_id = static_cast(Strings::ToUnsignedInt(row[1])); return true; } @@ -920,32 +920,32 @@ bool BotDatabase::LoadBuffs(Bot* bot_inst) int buff_count = 0; for (auto row = results.begin(); row != results.end() && buff_count < BUFF_COUNT; ++row) { - bot_buffs[buff_count].spellid = atoul(row[0]); - bot_buffs[buff_count].casterlevel = atoul(row[1]); + bot_buffs[buff_count].spellid = Strings::ToUnsignedInt(row[0]); + bot_buffs[buff_count].casterlevel = Strings::ToUnsignedInt(row[1]); //row[2] (duration_formula) can probably be removed bot_buffs[buff_count].ticsremaining = Strings::ToInt(row[3]); bot_buffs[buff_count].counters = 0; if (CalculatePoisonCounters(bot_buffs[buff_count].spellid) > 0) { - bot_buffs[buff_count].counters = atoul(row[4]); + bot_buffs[buff_count].counters = Strings::ToUnsignedInt(row[4]); } else if (CalculateDiseaseCounters(bot_buffs[buff_count].spellid) > 0) { - bot_buffs[buff_count].counters = atoul(row[5]); + bot_buffs[buff_count].counters = Strings::ToUnsignedInt(row[5]); } else if (CalculateCurseCounters(bot_buffs[buff_count].spellid) > 0) { - bot_buffs[buff_count].counters = atoul(row[6]); + bot_buffs[buff_count].counters = Strings::ToUnsignedInt(row[6]); } else if (CalculateCorruptionCounters(bot_buffs[buff_count].spellid) > 0) { - bot_buffs[buff_count].counters = atoul(row[7]); + bot_buffs[buff_count].counters = Strings::ToUnsignedInt(row[7]); } - bot_buffs[buff_count].hit_number = atoul(row[8]); - bot_buffs[buff_count].melee_rune = atoul(row[9]); - bot_buffs[buff_count].magic_rune = atoul(row[10]); - bot_buffs[buff_count].dot_rune = atoul(row[11]); + bot_buffs[buff_count].hit_number = Strings::ToUnsignedInt(row[8]); + bot_buffs[buff_count].melee_rune = Strings::ToUnsignedInt(row[9]); + bot_buffs[buff_count].magic_rune = Strings::ToUnsignedInt(row[10]); + bot_buffs[buff_count].dot_rune = Strings::ToUnsignedInt(row[11]); bot_buffs[buff_count].persistant_buff = (Strings::ToBool(row[12])) != 0; bot_buffs[buff_count].caston_x = Strings::ToInt(row[13]); bot_buffs[buff_count].caston_y = Strings::ToInt(row[14]); bot_buffs[buff_count].caston_z = Strings::ToInt(row[15]); bot_buffs[buff_count].ExtraDIChance = Strings::ToInt(row[16]); - bot_buffs[buff_count].instrument_mod = atoul(row[17]); + bot_buffs[buff_count].instrument_mod = Strings::ToUnsignedInt(row[17]); bot_buffs[buff_count].casterid = 0; ++buff_count; } @@ -1066,7 +1066,7 @@ bool BotDatabase::LoadStance(const uint32 bot_id, int& bot_stance) return true; auto row = results.begin(); - bot_stance = atoi(row[0]); + bot_stance = Strings::ToInt(row[0]); return true; } @@ -1086,7 +1086,7 @@ bool BotDatabase::LoadStance(Bot* bot_inst, bool& stance_flag) return true; auto row = results.begin(); - bot_inst->SetBotStance((EQ::constants::StanceType)atoi(row[0])); + bot_inst->SetBotStance((EQ::constants::StanceType)Strings::ToInt(row[0])); stance_flag = true; return true; @@ -1179,9 +1179,9 @@ bool BotDatabase::LoadTimers(Bot* bot_inst) uint32 timer_value = 0; uint32 max_value = 0; for (auto row = results.begin(); row != results.end(); ++row) { - timer_id = atoi(row[0]) - 1; - timer_value = atoi(row[1]); - max_value = atoi(row[2]); + timer_id = Strings::ToInt(row[0]) - 1; + timer_value = Strings::ToInt(row[1]); + max_value = Strings::ToInt(row[2]); if (timer_id >= 0 && timer_id < MaxTimer && timer_value < (Timer::GetCurrentTime() + max_value)) bot_timers[timer_id] = timer_value; @@ -1247,7 +1247,7 @@ bool BotDatabase::QueryInventoryCount(const uint32 bot_id, uint32& item_count) return true; auto row = results.begin(); - item_count = atoi(row[0]); + item_count = Strings::ToInt(row[0]); return true; } @@ -1286,22 +1286,22 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQ::InventoryProfile& inventory return true; for (auto row = results.begin(); row != results.end(); ++row) { - int16 slot_id = atoi(row[0]); + int16 slot_id = Strings::ToInt(row[0]); if (slot_id < EQ::invslot::EQUIPMENT_BEGIN || slot_id > EQ::invslot::EQUIPMENT_END) continue; - uint32 item_id = atoi(row[1]); - uint16 item_charges = (uint16)atoi(row[2]); + uint32 item_id = Strings::ToInt(row[1]); + uint16 item_charges = (uint16)Strings::ToInt(row[2]); EQ::ItemInstance* item_inst = database.CreateItem( item_id, item_charges, - (uint32)atoul(row[9]), - (uint32)atoul(row[10]), - (uint32)atoul(row[11]), - (uint32)atoul(row[12]), - (uint32)atoul(row[13]), - (uint32)atoul(row[14]) + (uint32)Strings::ToUnsignedInt(row[9]), + (uint32)Strings::ToUnsignedInt(row[10]), + (uint32)Strings::ToUnsignedInt(row[11]), + (uint32)Strings::ToUnsignedInt(row[12]), + (uint32)Strings::ToUnsignedInt(row[13]), + (uint32)Strings::ToUnsignedInt(row[14]) ); if (!item_inst) { LogError("Warning: bot_id [{}] has an invalid item_id [{}] in inventory slot [{}]", bot_id, item_id, slot_id); @@ -1315,12 +1315,12 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQ::InventoryProfile& inventory else item_inst->SetCharges(item_charges); - uint32 item_color = atoul(row[3]); + uint32 item_color = Strings::ToUnsignedInt(row[3]); if (item_color > 0) item_inst->SetColor(item_color); if (item_inst->GetItem()->Attuneable) { - if (atoi(row[4])) + if (Strings::ToInt(row[4])) item_inst->SetAttuned(true); else if (slot_id >= EQ::invslot::EQUIPMENT_BEGIN && slot_id <= EQ::invslot::EQUIPMENT_END) item_inst->SetAttuned(true); @@ -1352,9 +1352,9 @@ bool BotDatabase::LoadItems(const uint32 bot_id, EQ::InventoryProfile& inventory } } - item_inst->SetOrnamentIcon((uint32)atoul(row[6])); - item_inst->SetOrnamentationIDFile((uint32)atoul(row[7])); - item_inst->SetOrnamentHeroModel((uint32)atoul(row[8])); + item_inst->SetOrnamentIcon((uint32)Strings::ToUnsignedInt(row[6])); + item_inst->SetOrnamentationIDFile((uint32)Strings::ToUnsignedInt(row[7])); + item_inst->SetOrnamentHeroModel((uint32)Strings::ToUnsignedInt(row[8])); if (inventory_inst.PutItem(slot_id, *item_inst) == INVALID_INDEX) LogError("Warning: Invalid slot_id for item in inventory: bot_id = [{}], item_id = [{}], slot_id = [{}]", bot_id, item_id, slot_id); @@ -1401,7 +1401,7 @@ bool BotDatabase::LoadItemBySlot(const uint32 bot_id, const uint32 slot_id, uint return true; auto row = results.begin(); - item_id = atoi(row[0]); + item_id = Strings::ToInt(row[0]); return true; } @@ -1542,7 +1542,7 @@ bool BotDatabase::LoadEquipmentColor(const uint32 bot_id, const uint8 material_s return true; auto row = results.begin(); - rgb = atoul(row[0]); + rgb = Strings::ToUnsignedInt(row[0]); return true; } @@ -1593,7 +1593,7 @@ bool BotDatabase::LoadPetIndex(const uint32 bot_id, uint32& pet_index) return true; auto row = results.begin(); - pet_index = atoi(row[0]); + pet_index = Strings::ToInt(row[0]); return true; } @@ -1611,7 +1611,7 @@ bool BotDatabase::LoadPetSpellID(const uint32 bot_id, uint32& pet_spell_id) return true; auto row = results.begin(); - pet_spell_id = atoi(row[0]); + pet_spell_id = Strings::ToInt(row[0]); return true; } @@ -1635,10 +1635,10 @@ bool BotDatabase::LoadPetStats(const uint32 bot_id, std::string& pet_name, uint3 return true; auto row = results.begin(); - pet_spell_id = atoi(row[0]); + pet_spell_id = Strings::ToInt(row[0]); pet_name = row[1]; - pet_mana = atoi(row[2]); - pet_hp = atoi(row[3]); + pet_mana = Strings::ToInt(row[2]); + pet_hp = Strings::ToInt(row[3]); return true; } @@ -1724,9 +1724,9 @@ bool BotDatabase::LoadPetBuffs(const uint32 bot_id, SpellBuff_Struct* pet_buffs) int buff_index = 0; for (auto row = results.begin(); row != results.end() && buff_index < PET_BUFF_COUNT; ++row) { - pet_buffs[buff_index].spellid = atoi(row[0]); - pet_buffs[buff_index].level = atoi(row[1]); - pet_buffs[buff_index].duration = atoi(row[2]); + pet_buffs[buff_index].spellid = Strings::ToInt(row[0]); + pet_buffs[buff_index].level = Strings::ToInt(row[1]); + pet_buffs[buff_index].duration = Strings::ToInt(row[2]); // Work around for loading the counters and setting them back to max. Need entry in DB for saved counters if (CalculatePoisonCounters(pet_buffs[buff_index].spellid) > 0) @@ -1832,7 +1832,7 @@ bool BotDatabase::LoadPetItems(const uint32 bot_id, uint32* pet_items) int item_index = EQ::invslot::EQUIPMENT_BEGIN; for (auto row = results.begin(); row != results.end() && (item_index >= EQ::invslot::EQUIPMENT_BEGIN && item_index <= EQ::invslot::EQUIPMENT_END); ++row) { - pet_items[item_index] = atoi(row[0]); + pet_items[item_index] = Strings::ToInt(row[0]); ++item_index; } @@ -4126,7 +4126,7 @@ bool BotDatabase::LoadOwnerOptions(Client *owner) for (auto row : results) { - owner->SetBotOption(static_cast(atoul(row[0])), (atoul(row[1]) != 0)); + owner->SetBotOption(static_cast(Strings::ToUnsignedInt(row[0])), (Strings::ToUnsignedInt(row[1]) != 0)); } return true; @@ -4248,7 +4248,7 @@ bool BotDatabase::LoadBotGroupIDByBotGroupName(const std::string& group_name, ui } auto row = results.begin(); - botgroup_id = std::stoul(row[0]); + botgroup_id = Strings::ToUnsignedInt(row[0]); return true; } @@ -4274,7 +4274,7 @@ bool BotDatabase::LoadBotGroupIDByLeaderID(const uint32 leader_id, uint32& botgr } auto row = results.begin(); - botgroup_id = std::stoul(row[0]); + botgroup_id = Strings::ToUnsignedInt(row[0]); return true; } @@ -4300,7 +4300,7 @@ bool BotDatabase::LoadBotGroupIDByMemberID(const uint32 member_id, uint32& botgr } auto row = results.begin(); - botgroup_id = std::stoul(row[0]); + botgroup_id = Strings::ToUnsignedInt(row[0]); return true; } @@ -4326,7 +4326,7 @@ bool BotDatabase::LoadLeaderIDByBotGroupName(const std::string& group_name, uint } auto row = results.begin(); - leader_id = std::stoul(row[0]); + leader_id = Strings::ToUnsignedInt(row[0]); return true; } @@ -4352,7 +4352,7 @@ bool BotDatabase::LoadLeaderIDByBotGroupID(const uint32 group_id, uint32& leader } auto row = results.begin(); - leader_id = std::stoul(row[0]); + leader_id = Strings::ToUnsignedInt(row[0]); return true; } @@ -4574,7 +4574,7 @@ bool BotDatabase::LoadBotGroupIDForLoadBotGroup(const uint32 owner_id, std::stri for (auto row : results) { if (!group_name.compare(row[1])) { - botgroup_id = std::stoul(row[0]); + botgroup_id = Strings::ToUnsignedInt(row[0]); break; } } @@ -4612,7 +4612,7 @@ bool BotDatabase::LoadBotGroup(const std::string& group_name, std::map(row[0], atoul(row[1]))); + botgroups_list.push_back(std::pair(row[0], Strings::ToUnsignedInt(row[1]))); } return true; @@ -4716,7 +4716,7 @@ bool BotDatabase::LoadAutoSpawnBotGroupsByOwnerID(const uint32 owner_id, std::li for (auto row : results) { group_list.push_back( - std::pair(std::stoul(row[0]), row[1]) + std::pair(Strings::ToUnsignedInt(row[0]), row[1]) ); } @@ -4749,8 +4749,9 @@ bool BotDatabase::LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 g if (!results.RowCount()) return true; - for (auto row = results.begin(); row != results.end(); ++row) - group_list.push_back(atoi(row[0])); + for (auto row : results) { + group_list.push_back(Strings::ToUnsignedInt(row[0])); + } return true; } @@ -4770,7 +4771,7 @@ bool BotDatabase::LoadHealRotationIDByBotID(const uint32 bot_id, uint32& hr_inde return true; auto row = results.begin(); - hr_index = atoi(row[0]); + hr_index = Strings::ToInt(row[0]); return true; } @@ -4817,20 +4818,20 @@ bool BotDatabase::LoadHealRotation(Bot* hr_member, std::list& member_lis return true; auto row = results.begin(); - (*hr_member->MemberOfHealRotation())->SetIntervalS((uint32)atoi(row[0])); - (*hr_member->MemberOfHealRotation())->SetFastHeals((bool)atoi(row[1])); - (*hr_member->MemberOfHealRotation())->SetAdaptiveTargeting((bool)atoi(row[2])); - (*hr_member->MemberOfHealRotation())->SetCastingOverride((bool)atoi(row[3])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_UNKNOWN, atof(row[4])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_CLOTH, atof(row[5])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_LEATHER, atof(row[6])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_CHAIN, atof(row[7])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_PLATE, atof(row[8])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_UNKNOWN, atof(row[9])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_CLOTH, atof(row[10])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_LEATHER, atof(row[11])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_CHAIN, atof(row[12])); - (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_PLATE, atof(row[13])); + (*hr_member->MemberOfHealRotation())->SetIntervalS((uint32)Strings::ToInt(row[0])); + (*hr_member->MemberOfHealRotation())->SetFastHeals((bool)Strings::ToInt(row[1])); + (*hr_member->MemberOfHealRotation())->SetAdaptiveTargeting((bool)Strings::ToInt(row[2])); + (*hr_member->MemberOfHealRotation())->SetCastingOverride((bool)Strings::ToInt(row[3])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_UNKNOWN, Strings::ToFloat(row[4])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_CLOTH, Strings::ToFloat(row[5])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_LEATHER, Strings::ToFloat(row[6])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_CHAIN, Strings::ToFloat(row[7])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeSafeHPRatio(ARMOR_TYPE_PLATE, Strings::ToFloat(row[8])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_UNKNOWN, Strings::ToFloat(row[9])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_CLOTH, Strings::ToFloat(row[10])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_LEATHER, Strings::ToFloat(row[11])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_CHAIN, Strings::ToFloat(row[12])); + (*hr_member->MemberOfHealRotation())->SetArmorTypeCriticalHPRatio(ARMOR_TYPE_PLATE, Strings::ToFloat(row[13])); load_flag = true; @@ -4857,7 +4858,7 @@ bool BotDatabase::LoadHealRotationMembers(const uint32 hr_index, std::listCreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3])); + // ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, Strings::ToInt(row[3])); } @@ -9340,8 +9340,8 @@ void Client::SendToGuildHall() uint16 instance_id = 0; std::string guild_hall_instance_key = fmt::format("guild-hall-instance-{}", GuildID()); std::string instance_data = DataBucket::GetData(guild_hall_instance_key); - if (!instance_data.empty() && std::stoi(instance_data) > 0) { - instance_id = std::stoi(instance_data); + if (!instance_data.empty() && Strings::ToInt(instance_data) > 0) { + instance_id = Strings::ToInt(instance_data); } if (instance_id <= 0) { @@ -10472,7 +10472,7 @@ void Client::SendToInstance(std::string instance_type, std::string zone_short_na uint16 instance_id = 0; if (current_bucket_value.length() > 0) { - instance_id = atoi(current_bucket_value.c_str()); + instance_id = Strings::ToInt(current_bucket_value.c_str()); } else { if(!database.GetUnusedInstanceID(instance_id)) { Message(Chat::White, "Server was unable to find a free instance id."); diff --git a/zone/client_bot.cpp b/zone/client_bot.cpp index 680906cc30..426ac504ea 100644 --- a/zone/client_bot.cpp +++ b/zone/client_bot.cpp @@ -33,7 +33,7 @@ uint32 Client::GetBotCreationLimit(uint8 class_id) auto bucket_value = GetBucket(bucket_name); if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) { - bot_creation_limit = std::stoul(bucket_value); + bot_creation_limit = Strings::ToUnsignedInt(bucket_value); } return bot_creation_limit; @@ -57,7 +57,7 @@ int Client::GetBotRequiredLevel(uint8 class_id) auto bucket_value = GetBucket(bucket_name); if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) { - bot_character_level = std::stoi(bucket_value); + bot_character_level = Strings::ToInt(bucket_value); } return bot_character_level; @@ -122,7 +122,7 @@ int Client::GetBotSpawnLimit(uint8 class_id, uint32 spawned_bot_count) auto bucket_value = GetBucket(bucket_name); if (!bucket_value.empty() && Strings::IsNumber(bucket_value)) { - bot_spawn_limit = std::stoi(bucket_value); + bot_spawn_limit = Strings::ToInt(bucket_value); return bot_spawn_limit; } @@ -139,7 +139,7 @@ int Client::GetBotSpawnLimit(uint8 class_id, uint32 spawned_bot_count) } auto row = results.begin(); - bot_spawn_limit = std::stoi(row[0]); + bot_spawn_limit = Strings::ToInt(row[0]); } return bot_spawn_limit; diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 4ca92580e8..9de8835107 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -1269,17 +1269,17 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app) ); auto results = database.QueryDatabase(query); for (auto row : results) { - if (row[4] && atoi(row[4]) > 0) { - guild_id = atoi(row[4]); - guildrank = row[5] ? atoi(row[5]) : GUILD_RANK_NONE; + if (row[4] && Strings::ToInt(row[4]) > 0) { + guild_id = Strings::ToInt(row[4]); + guildrank = row[5] ? Strings::ToInt(row[5]) : GUILD_RANK_NONE; } SetEXPEnabled(atobool(row[6])); - if (LFP) { LFP = atoi(row[0]); } - if (LFG) { LFG = atoi(row[1]); } + if (LFP) { LFP = Strings::ToInt(row[0]); } + if (LFG) { LFG = Strings::ToInt(row[1]); } if (row[3]) - firstlogon = atoi(row[3]); + firstlogon = Strings::ToInt(row[3]); } if (RuleB(Character, SharedBankPlat)) @@ -6839,15 +6839,15 @@ void Client::Handle_OP_GMSearchCorpse(const EQApplicationPacket *app) strn0cpy(charName, row[0], sizeof(charName)); - uint32 ZoneID = atoi(row[1]); - float CorpseX = atof(row[2]); - float CorpseY = atof(row[3]); - float CorpseZ = atof(row[4]); + uint32 ZoneID = Strings::ToInt(row[1]); + float CorpseX = Strings::ToFloat(row[2]); + float CorpseY = Strings::ToFloat(row[3]); + float CorpseZ = Strings::ToFloat(row[4]); strn0cpy(time_of_death, row[5], sizeof(time_of_death)); - bool corpseRezzed = atoi(row[6]); - bool corpseBuried = atoi(row[7]); + bool corpseRezzed = Strings::ToInt(row[6]); + bool corpseBuried = Strings::ToInt(row[7]); popupText += StringFormat("%s%s%8.0f%8.0f%8.0f%s%s%s", charName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, time_of_death, @@ -11599,8 +11599,8 @@ void Client::Handle_OP_PopupResponse(const EQApplicationPacket *app) std::string response; switch (popup_response->popupid) { case POPUPID_REPLACE_SPELLWINDOW: - DeleteItemInInventory(std::stoi(GetEntityVariable("slot_id")), 1, true); - MemorizeSpellFromItem(std::stoi(GetEntityVariable("spell_id"))); + DeleteItemInInventory(Strings::ToInt(GetEntityVariable("slot_id")), 1, true); + MemorizeSpellFromItem(Strings::ToInt(GetEntityVariable("spell_id"))); return; break; @@ -13507,19 +13507,19 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) bool valid_city = false; for (auto row = results.begin(); row != results.end(); ++row) { - if (atoi(row[1]) != 0) - zone_id = atoi(row[1]); + if (Strings::ToInt(row[1]) != 0) + zone_id = Strings::ToInt(row[1]); else - zone_id = atoi(row[0]); + zone_id = Strings::ToInt(row[0]); if (zone_id != start_city) continue; valid_city = true; - x = atof(row[2]); - y = atof(row[3]); - z = atof(row[4]); - heading = atof(row[5]); + x = Strings::ToFloat(row[2]); + y = Strings::ToFloat(row[3]); + z = Strings::ToFloat(row[4]); + heading = Strings::ToFloat(row[5]); } if (valid_city) { @@ -13552,10 +13552,10 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app) Message(Chat::Yellow, "Use \"/setstartcity #\" to choose a home city from the following list:"); for (auto row = results.begin(); row != results.end(); ++row) { - if (atoi(row[1]) != 0) - zone_id = atoi(row[1]); + if (Strings::ToInt(row[1]) != 0) + zone_id = Strings::ToInt(row[1]); else - zone_id = atoi(row[0]); + zone_id = Strings::ToInt(row[0]); std::string zone_long_name = ZoneLongName(zone_id); Message(Chat::Yellow, "%d - %s", zone_id, zone_long_name.c_str()); diff --git a/zone/data_bucket.cpp b/zone/data_bucket.cpp index 46f204ece9..fd05f87951 100644 --- a/zone/data_bucket.cpp +++ b/zone/data_bucket.cpp @@ -23,7 +23,7 @@ void DataBucket::SetData(std::string bucket_key, std::string bucket_value, std:: if (isalpha(expires_time[0]) || isalpha(expires_time[expires_time.length() - 1])) { expires_time_unix = (long long) std::time(nullptr) + Strings::TimeToSeconds(expires_time); } else { - expires_time_unix = (long long) std::time(nullptr) + atoi(expires_time.c_str()); + expires_time_unix = (long long) std::time(nullptr) + Strings::ToInt(expires_time.c_str()); } } @@ -146,7 +146,7 @@ uint64 DataBucket::DoesBucketExist(std::string bucket_key) { if (results.RowCount() != 1) return 0; - return std::stoull(row[0]); + return Strings::ToUnsignedBigInt(row[0]); } /** diff --git a/zone/dialogue_window.cpp b/zone/dialogue_window.cpp index e2cd9e2a1e..e5835794ed 100644 --- a/zone/dialogue_window.cpp +++ b/zone/dialogue_window.cpp @@ -1,6 +1,7 @@ #include #include "dialogue_window.h" +#include "../common/strings.h" void DialogueWindow::Render(Client *c, std::string markdown) { @@ -74,7 +75,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) bool found_animation = false; if (Strings::IsNumber(animation)) { LogDiaWindDetail("Client [{}] Animation is a number, firing animation [{}]", c->GetCleanName(), animation); - target->DoAnim(std::stoi(animation)); + target->DoAnim(Strings::ToInt(animation)); found_animation = true; } else { @@ -126,7 +127,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) c->GetCleanName(), expire_time ); - window_expire_seconds = std::stoi(expire_time); + window_expire_seconds = Strings::ToInt(expire_time); } } @@ -198,7 +199,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) // set the popup id if (!popupid.empty()) { - popup_id = (Strings::IsNumber(popupid) ? std::atoi(popupid.c_str()) : 0); + popup_id = (Strings::IsNumber(popupid) ? Strings::ToInt(popupid.c_str()) : 0); } } } @@ -230,7 +231,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) Strings::FindReplace(output, fmt::format("secondresponseid:{}", secondresponseid), ""); if (!secondresponseid.empty()) { - negative_id = (Strings::IsNumber(secondresponseid) ? std::atoi(secondresponseid.c_str()) : 0); + negative_id = (Strings::IsNumber(secondresponseid) ? Strings::ToInt(secondresponseid.c_str()) : 0); } } } @@ -409,7 +410,7 @@ void DialogueWindow::Render(Client *c, std::string markdown) // click response // window type response - uint32 window_type = (Strings::IsNumber(wintype) ? std::atoi(wintype.c_str()) : 0); + uint32 window_type = (Strings::IsNumber(wintype) ? Strings::ToInt(wintype.c_str()) : 0); std::string click_response_button = (window_type == 1 ? "Yes" : "OK"); std::string click_response = fmt::format( "Click [{}] to continue...", diff --git a/zone/doors.cpp b/zone/doors.cpp index 9dbff46461..0d23b7d8f3 100644 --- a/zone/doors.cpp +++ b/zone/doors.cpp @@ -277,7 +277,7 @@ void Doors::HandleClick(Client *sender, uint8 trigger) // enforce flags before they hit zoning process auto z = GetZone(m_destination_zone_name, 0); - if (z && !z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && std::stoi(z->flag_needed) == 1) { + if (z && !z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToInt(z->flag_needed) == 1) { if (sender->Admin() < minStatusToIgnoreZoneFlags && !sender->HasZoneFlag(z->zoneidnumber)) { LogInfo( "Character [{}] does not have the flag to be in this zone [{}]!", @@ -784,7 +784,7 @@ int ZoneDatabase::GetDoorsDBCountPlusOne(std::string zone_short_name, int16 vers return 0; } - return std::stoi(row[0]) + 1; + return Strings::ToInt(row[0]) + 1; } std::vector ZoneDatabase::LoadDoors(const std::string &zone_name, int16 version) diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 00c72b2edb..e651d0e75b 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -1957,7 +1957,7 @@ void PerlembParser::ExportEventVariables( } case EVENT_CONSIDER: { - ExportVar(package_name.c_str(), "entity_id", std::stoi(data)); + ExportVar(package_name.c_str(), "entity_id", Strings::ToInt(data)); if (extra_pointers && extra_pointers->size() == 1) { ExportVar(package_name.c_str(), "target", "Mob", std::any_cast(extra_pointers->at(0))); } @@ -1965,7 +1965,7 @@ void PerlembParser::ExportEventVariables( } case EVENT_CONSIDER_CORPSE: { - ExportVar(package_name.c_str(), "corpse_entity_id", std::stoi(data)); + ExportVar(package_name.c_str(), "corpse_entity_id", Strings::ToInt(data)); if (extra_pointers && extra_pointers->size() == 1) { ExportVar(package_name.c_str(), "corpse", "Corpse", std::any_cast(extra_pointers->at(0))); } @@ -1973,7 +1973,7 @@ void PerlembParser::ExportEventVariables( } case EVENT_COMBINE: { - ExportVar(package_name.c_str(), "container_slot", std::stoi(data)); + ExportVar(package_name.c_str(), "container_slot", Strings::ToInt(data)); break; } diff --git a/zone/entity.cpp b/zone/entity.cpp index f7a3d4bf1e..88a9fa511a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -3306,7 +3306,7 @@ char *EntityList::MakeNameUnique(char *name) if (it->second->IsMob()) { if (strncasecmp(it->second->CastToMob()->GetName(), name, len) == 0) { if (Seperator::IsNumber(&it->second->CastToMob()->GetName()[len])) { - used[atoi(&it->second->CastToMob()->GetName()[len])] = true; + used[Strings::ToInt(&it->second->CastToMob()->GetName()[len])] = true; } } } @@ -5951,7 +5951,7 @@ void EntityList::DespawnGridNodes(int32 grid_id) { mob->IsNPC() && mob->GetRace() == RACE_NODE_2254 && mob->EntityVariableExists("grid_id") && - std::stoi(mob->GetEntityVariable("grid_id")) == grid_id) + Strings::ToInt(mob->GetEntityVariable("grid_id")) == grid_id) { mob->Depop(); } diff --git a/zone/exp.cpp b/zone/exp.cpp index a894208d5d..c319e4fc7a 100644 --- a/zone/exp.cpp +++ b/zone/exp.cpp @@ -1263,7 +1263,7 @@ uint8 Client::GetCharMaxLevelFromQGlobal() { for (const auto& global : global_map) { if (global.name == "CharMaxLevel") { if (Strings::IsNumber(global.value)) { - return static_cast(std::stoul(global.value)); + return static_cast(Strings::ToUnsignedInt(global.value)); } } } @@ -1281,7 +1281,7 @@ uint8 Client::GetCharMaxLevelFromBucket() auto bucket_value = DataBucket::GetData(new_bucket_name); if (!bucket_value.empty()) { if (Strings::IsNumber(bucket_value)) { - return static_cast(std::stoul(bucket_value)); + return static_cast(Strings::ToUnsignedInt(bucket_value)); } } @@ -1293,7 +1293,7 @@ uint8 Client::GetCharMaxLevelFromBucket() bucket_value = DataBucket::GetData(old_bucket_name); if (!bucket_value.empty()) { if (Strings::IsNumber(bucket_value)) { - return static_cast(std::stoul(bucket_value)); + return static_cast(Strings::ToUnsignedInt(bucket_value)); } } diff --git a/zone/forage.cpp b/zone/forage.cpp index 3812333fee..eba72977d7 100644 --- a/zone/forage.cpp +++ b/zone/forage.cpp @@ -90,9 +90,9 @@ uint32 ZoneDatabase::GetZoneForage(uint32 ZoneID, uint8 skill) { break; } - item[index] = atoi(row[0]); - chance[index] = atoi(row[1]) + chancepool; - chancepool = chance[index]; + item[index] = Strings::ToInt(row[0]); + chance[index] = Strings::ToInt(row[1]) + chancepool; + chancepool = chance[index]; } if(chancepool == 0 || index < 1) @@ -158,12 +158,12 @@ uint32 ZoneDatabase::GetZoneFishing(uint32 ZoneID, uint8 skill, uint32 &npc_id, if (index >= 50) break; - item[index] = atoi(row[0]); - chance[index] = atoi(row[1])+chancepool; + item[index] = Strings::ToInt(row[0]); + chance[index] = Strings::ToInt(row[1])+chancepool; chancepool = chance[index]; - npc_ids[index] = atoi(row[2]); - npc_chances[index] = atoi(row[3]); + npc_ids[index] = Strings::ToInt(row[2]); + npc_chances[index] = Strings::ToInt(row[3]); } npc_id = 0; diff --git a/zone/gm_commands/advnpcspawn.cpp b/zone/gm_commands/advnpcspawn.cpp index 0ec3cbd638..235362f3fa 100755 --- a/zone/gm_commands/advnpcspawn.cpp +++ b/zone/gm_commands/advnpcspawn.cpp @@ -91,9 +91,9 @@ void command_advnpcspawn(Client *c, const Seperator *sep) return; } - auto spawngroup_id = std::stoul(sep->arg[2]); - auto npc_id = std::stoul(sep->arg[3]); - auto spawn_chance = std::stoul(sep->arg[4]); + auto spawngroup_id = Strings::ToUnsignedInt(sep->arg[2]); + auto npc_id = Strings::ToUnsignedInt(sep->arg[3]); + auto spawn_chance = Strings::ToUnsignedInt(sep->arg[4]); auto query = fmt::format( SQL( @@ -129,14 +129,14 @@ void command_advnpcspawn(Client *c, const Seperator *sep) zone->GetInstanceVersion(), c, 0, - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ) ) { c->Message( Chat::White, fmt::format( "Spawn Added | Added spawn from Spawngroup ID {}.", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ).c_str() ); } @@ -149,7 +149,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) auto query = fmt::format( "UPDATE spawngroup SET dist = 0, min_x = 0, max_x = 0, min_y = 0, max_y = 0, delay = 0 WHERE id = {}", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ); auto results = content_db.QueryDatabase(query); if (!results.Success()) { @@ -161,7 +161,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) Chat::White, fmt::format( "Spawngroup {} Roambox Cleared | Delay: 0 Distance: 0.00", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ).c_str() ); @@ -169,7 +169,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) Chat::White, fmt::format( "Spawngroup {} Roambox Cleared | Minimum X: 0.00 Maximum X: 0.00", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ).c_str() ); @@ -177,7 +177,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) Chat::White, fmt::format( "Spawngroup {} Roambox Cleared | Minimum Y: 0.00 Maximum Y: 0.00", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ).c_str() ); return; @@ -231,13 +231,13 @@ void command_advnpcspawn(Client *c, const Seperator *sep) ); return; } - auto spawngroup_id = std::stoul(sep->arg[2]); - auto distance = std::stof(sep->arg[3]); - auto minimum_x = std::stof(sep->arg[4]); - auto maximum_x = std::stof(sep->arg[5]); - auto minimum_y = std::stof(sep->arg[6]); - auto maximum_y = std::stof(sep->arg[7]); - auto delay = std::stoi(sep->arg[8]); + auto spawngroup_id = Strings::ToUnsignedInt(sep->arg[2]); + auto distance = Strings::ToFloat(sep->arg[3]); + auto minimum_x = Strings::ToFloat(sep->arg[4]); + auto maximum_x = Strings::ToFloat(sep->arg[5]); + auto minimum_y = Strings::ToFloat(sep->arg[6]); + auto maximum_y = Strings::ToFloat(sep->arg[7]); + auto delay = Strings::ToInt(sep->arg[8]); auto query = fmt::format( "UPDATE spawngroup SET dist = {:.2f}, min_x = {:.2f}, max_x = {:.2f}, max_y = {:.2f}, min_y = {:.2f}, delay = {} WHERE id = {}", @@ -304,8 +304,8 @@ void command_advnpcspawn(Client *c, const Seperator *sep) } auto spawn2_id = spawn2->GetID(); - auto respawn_timer = std::stoul(sep->arg[2]); - auto variance = sep->IsNumber(3) ? std::stoul(sep->arg[3]) : spawn2->GetVariance(); + auto respawn_timer = Strings::ToUnsignedInt(sep->arg[2]); + auto variance = sep->IsNumber(3) ? Strings::ToUnsignedInt(sep->arg[3]) : spawn2->GetVariance(); auto query = fmt::format( "UPDATE spawn2 SET respawntime = {}, variance = {} WHERE id = {}", @@ -343,13 +343,13 @@ void command_advnpcspawn(Client *c, const Seperator *sep) } std::string spawngroup_name = sep->arg[2]; - auto spawn_limit = sep->IsNumber(3) ? std::stoi(sep->arg[3]) : 0; - auto distance = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f; - auto minimum_x = sep->IsNumber(5) ? std::stof(sep->arg[5]) : 0.0f; - auto maximum_x = sep->IsNumber(6) ? std::stof(sep->arg[6]) : 0.0f; - auto minimum_y = sep->IsNumber(7) ? std::stof(sep->arg[7]) : 0.0f; - auto maximum_y = sep->IsNumber(8) ? std::stof(sep->arg[8]) : 0.0f; - auto delay = sep->IsNumber(9) ? std::stoi(sep->arg[9]) : 0; + auto spawn_limit = sep->IsNumber(3) ? Strings::ToInt(sep->arg[3]) : 0; + auto distance = sep->IsNumber(4) ? Strings::ToFloat(sep->arg[4]) : 0.0f; + auto minimum_x = sep->IsNumber(5) ? Strings::ToFloat(sep->arg[5]) : 0.0f; + auto maximum_x = sep->IsNumber(6) ? Strings::ToFloat(sep->arg[6]) : 0.0f; + auto minimum_y = sep->IsNumber(7) ? Strings::ToFloat(sep->arg[7]) : 0.0f; + auto maximum_y = sep->IsNumber(8) ? Strings::ToFloat(sep->arg[8]) : 0.0f; + auto delay = sep->IsNumber(9) ? Strings::ToInt(sep->arg[9]) : 0; auto query = fmt::format( "INSERT INTO spawngroup" @@ -497,7 +497,7 @@ void command_advnpcspawn(Client *c, const Seperator *sep) } auto target = c->GetTarget()->CastToNPC(); - auto version = std::stoul(sep->arg[2]); + auto version = Strings::ToUnsignedInt(sep->arg[2]); auto query = fmt::format( "UPDATE spawn2 SET version = {} WHERE spawngroupID = {}", diff --git a/zone/gm_commands/aggro.cpp b/zone/gm_commands/aggro.cpp index 90fe9e3357..926904131c 100755 --- a/zone/gm_commands/aggro.cpp +++ b/zone/gm_commands/aggro.cpp @@ -21,7 +21,7 @@ void command_aggro(Client *c, const Seperator *sep) NPC* target = c->GetTarget()->CastToNPC(); - float distance = std::stof(sep->arg[1]); + float distance = Strings::ToFloat(sep->arg[1]); bool verbose = !strcasecmp("-v", sep->arg[2]); entity_list.DescribeAggro(c, target, distance, verbose); } diff --git a/zone/gm_commands/ai.cpp b/zone/gm_commands/ai.cpp index 9ae6351e11..b746ac0b45 100755 --- a/zone/gm_commands/ai.cpp +++ b/zone/gm_commands/ai.cpp @@ -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); diff --git a/zone/gm_commands/appearance.cpp b/zone/gm_commands/appearance.cpp index 4f28fc50f2..5e41138171 100755 --- a/zone/gm_commands/appearance.cpp +++ b/zone/gm_commands/appearance.cpp @@ -13,7 +13,7 @@ void command_appearance(Client *c, const Seperator *sep) if ((c->GetTarget())) { t = c->GetTarget(); } - t->SendAppearancePacket(atoi(sep->arg[1]), atoi(sep->arg[2])); + t->SendAppearancePacket(Strings::ToInt(sep->arg[1]), Strings::ToInt(sep->arg[2])); c->Message( Chat::White, "Sending appearance packet: target=%s, type=%s, value=%s", diff --git a/zone/gm_commands/appearanceeffects.cpp b/zone/gm_commands/appearanceeffects.cpp index 18bcb40f4c..d978c527ec 100644 --- a/zone/gm_commands/appearanceeffects.cpp +++ b/zone/gm_commands/appearanceeffects.cpp @@ -35,8 +35,8 @@ void command_appearanceeffects(Client *c, const Seperator *sep) return; } - const auto effect_id = std::stoul(sep->arg[2]); - const auto slot_id = std::stoul(sep->arg[3]); + const auto effect_id = Strings::ToUnsignedInt(sep->arg[2]); + const auto slot_id = Strings::ToUnsignedInt(sep->arg[3]); t->SendAppearanceEffect( effect_id, diff --git a/zone/gm_commands/bugs.cpp b/zone/gm_commands/bugs.cpp index 44e49686e8..1f3e7a771b 100755 --- a/zone/gm_commands/bugs.cpp +++ b/zone/gm_commands/bugs.cpp @@ -39,7 +39,7 @@ void command_bugs(Client *c, const Seperator *sep) return; } - auto bug_id = std::stoul(sep->arg[2]); + auto bug_id = Strings::ToUnsignedInt(sep->arg[2]); auto r = BugReportsRepository::FindOne(content_db, bug_id); if (!r.id) { @@ -80,7 +80,7 @@ void command_bugs(Client *c, const Seperator *sep) return; } - auto bug_id = std::stoul(sep->arg[2]); + auto bug_id = Strings::ToUnsignedInt(sep->arg[2]); auto deleted_count = BugReportsRepository::DeleteOne(content_db, bug_id); if (!deleted_count) { c->Message( @@ -109,7 +109,7 @@ void command_bugs(Client *c, const Seperator *sep) return; } - auto bug_id = std::stoul(sep->arg[2]); + auto bug_id = Strings::ToUnsignedInt(sep->arg[2]); auto bug_review = sep->argplus[3]; auto r = BugReportsRepository::FindOne(content_db, bug_id); @@ -203,7 +203,7 @@ void command_bugs(Client *c, const Seperator *sep) return; } - auto bug_id = std::stoul(sep->arg[2]); + auto bug_id = Strings::ToUnsignedInt(sep->arg[2]); auto r = BugReportsRepository::FindOne(content_db, bug_id); if (!r.id) { diff --git a/zone/gm_commands/camerashake.cpp b/zone/gm_commands/camerashake.cpp index 9c2e8a5f04..dc6adf7990 100755 --- a/zone/gm_commands/camerashake.cpp +++ b/zone/gm_commands/camerashake.cpp @@ -11,8 +11,8 @@ void command_camerashake(Client *c, const Seperator *sep) return; } - auto duration = std::stoi(sep->arg[1]); - auto intensity = std::stoi(sep->arg[2]); + auto duration = Strings::ToInt(sep->arg[1]); + auto intensity = Strings::ToInt(sep->arg[2]); auto pack = new ServerPacket(ServerOP_CameraShake, sizeof(ServerCameraShake_Struct)); ServerCameraShake_Struct *camera_shake = (ServerCameraShake_Struct *) pack->pBuffer; diff --git a/zone/gm_commands/castspell.cpp b/zone/gm_commands/castspell.cpp index ef0be063d4..bbe134f040 100755 --- a/zone/gm_commands/castspell.cpp +++ b/zone/gm_commands/castspell.cpp @@ -19,7 +19,7 @@ void command_castspell(Client *c, const Seperator *sep) ); } else { - uint16 spell_id = std::stoul(sep->arg[1]); + uint16 spell_id = Strings::ToUnsignedInt(sep->arg[1]); if (CastRestrictedSpell(spell_id) && c->Admin() < commandCastSpecials) { c->Message(Chat::Red, "Unable to cast spell."); @@ -30,8 +30,8 @@ void command_castspell(Client *c, const Seperator *sep) else { bool instant_cast = (c->Admin() >= commandInstacast ? true : false); if (instant_cast && sep->IsNumber(2)) { - instant_cast = std::stoi(sep->arg[2]) ? true : false; - c->Message(Chat::White, fmt::format("{}", std::stoi(sep->arg[2])).c_str()); + instant_cast = Strings::ToInt(sep->arg[2]) ? true : false; + c->Message(Chat::White, fmt::format("{}", Strings::ToInt(sep->arg[2])).c_str()); } if (c->Admin() >= commandInstacast && instant_cast) { diff --git a/zone/gm_commands/chat.cpp b/zone/gm_commands/chat.cpp index 30bbe11d7e..c72f7475c2 100755 --- a/zone/gm_commands/chat.cpp +++ b/zone/gm_commands/chat.cpp @@ -11,7 +11,7 @@ void command_chat(Client *c, const Seperator *sep) return; } - auto channel_id = static_cast(std::stoul(sep->arg[1])); + auto channel_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); std::string message = sep->argplus[2]; if (!worldserver.SendChannelMessage(0, 0, channel_id, 0, 0, 100, message.c_str())) { c->Message(Chat::White, "World server is disconnected."); diff --git a/zone/gm_commands/corpse.cpp b/zone/gm_commands/corpse.cpp index d1176b5994..2c3eae8b3a 100755 --- a/zone/gm_commands/corpse.cpp +++ b/zone/gm_commands/corpse.cpp @@ -81,7 +81,7 @@ void command_corpse(Client *c, const Seperator *sep) auto deleted_string = ( corpses_deleted ? fmt::format( - "{} Player corpse{} deleted.", + "{} Player corpse{} deleted.", corpses_deleted, corpses_deleted != 1 ? "s" : "" ) : @@ -104,7 +104,7 @@ void command_corpse(Client *c, const Seperator *sep) } if ( - target->IsNPCCorpse() || + target->IsNPCCorpse() || c->Admin() >= commandEditPlayerCorpses ) { c->Message( @@ -116,7 +116,7 @@ void command_corpse(Client *c, const Seperator *sep) ).c_str() ); target->CastToCorpse()->Delete(); - } + } } else if (is_list_npc) { entity_list.ListNPCCorpses(c); } else if (is_list_player) { @@ -150,7 +150,7 @@ void command_corpse(Client *c, const Seperator *sep) return; } - auto character_id = std::stoi(sep->arg[2]); + auto character_id = Strings::ToInt(sep->arg[2]); c->Message( Chat::White, fmt::format( @@ -174,7 +174,7 @@ void command_corpse(Client *c, const Seperator *sep) c->Message(Chat::White, "Your status is not high enough to reset looter on a player corpse."); return; } - + target->CastToCorpse()->ResetLooter(); c->Message( Chat::White, @@ -196,7 +196,7 @@ void command_corpse(Client *c, const Seperator *sep) } if ( - target->IsNPCCorpse() || + target->IsNPCCorpse() || c->Admin() >= commandEditPlayerCorpses ) { target->CastToCorpse()->RemoveCash(); @@ -219,7 +219,7 @@ void command_corpse(Client *c, const Seperator *sep) c->Message(Chat::White, "Your status is not high enough to inspect the loot of a player corpse."); return; } - + target->CastToCorpse()->QueryLoot(c); } else if (is_lock) { if (!target || !target->IsCorpse()) { @@ -271,7 +271,7 @@ void command_corpse(Client *c, const Seperator *sep) bool bury_corpse = ( sep->IsNumber(2) ? ( - std::stoi(sep->arg[2]) != 0 ? + Strings::ToInt(sep->arg[2]) != 0 ? true : false ) : @@ -302,7 +302,7 @@ void command_corpse(Client *c, const Seperator *sep) bool bury_corpse = ( sep->IsNumber(2) ? ( - std::stoi(sep->arg[2]) != 0 ? + Strings::ToInt(sep->arg[2]) != 0 ? true : false ) : diff --git a/zone/gm_commands/countitem.cpp b/zone/gm_commands/countitem.cpp index c65e9c46f8..306f489422 100644 --- a/zone/gm_commands/countitem.cpp +++ b/zone/gm_commands/countitem.cpp @@ -18,8 +18,8 @@ void command_countitem(Client *c, const Seperator *sep) ) { target = c->GetTarget(); } - - auto item_id = std::stoul(sep->arg[1]); + + auto item_id = Strings::ToUnsignedInt(sep->arg[1]); if (!database.GetItem(item_id)) { c->Message( Chat::White, diff --git a/zone/gm_commands/damage.cpp b/zone/gm_commands/damage.cpp index fbe1242d5b..2044cc483d 100755 --- a/zone/gm_commands/damage.cpp +++ b/zone/gm_commands/damage.cpp @@ -14,6 +14,6 @@ void command_damage(Client *c, const Seperator *sep) return; } - int64 damage = std::stoll(sep->arg[1], nullptr, 10); + const auto damage = Strings::ToBigInt(sep->arg[1]); target->Damage(c, damage, SPELL_UNKNOWN, EQ::skills::SkillHandtoHand, false); } diff --git a/zone/gm_commands/databuckets.cpp b/zone/gm_commands/databuckets.cpp index 48ad596f20..bcf6b06691 100755 --- a/zone/gm_commands/databuckets.cpp +++ b/zone/gm_commands/databuckets.cpp @@ -16,7 +16,7 @@ void command_databuckets(Client *c, const Seperator *sep) break; } if (strcasecmp(sep->arg[i], "limit") == 0) { - limit = (uint8) atoi(sep->arg[i + 1]); + limit = (uint8) Strings::ToInt(sep->arg[i + 1]); continue; } } @@ -46,7 +46,7 @@ void command_databuckets(Client *c, const Seperator *sep) "Value" ""; for (auto row = results.begin(); row != results.end(); ++row) { - auto id = static_cast(atoi(row[0])); + auto id = static_cast(Strings::ToInt(row[0])); std::string key = row[1]; std::string value = row[2]; std::string expires = row[3]; diff --git a/zone/gm_commands/date.cpp b/zone/gm_commands/date.cpp index 0154f233f9..08cde4e606 100755 --- a/zone/gm_commands/date.cpp +++ b/zone/gm_commands/date.cpp @@ -16,12 +16,12 @@ void command_date(Client *c, const Seperator *sep) TimeOfDay_Struct eq_time; zone->zone_time.GetCurrentEQTimeOfDay(time(0), &eq_time); - auto year = static_cast(std::stoul(sep->arg[1])); - auto month = static_cast(std::stoul(sep->arg[2])); - auto day = static_cast(std::stoul(sep->arg[3])); + auto year = static_cast(Strings::ToUnsignedInt(sep->arg[1])); + auto month = static_cast(Strings::ToUnsignedInt(sep->arg[2])); + auto day = static_cast(Strings::ToUnsignedInt(sep->arg[3])); - auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast(std::stoul(sep->arg[4]) + 1); - auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast(std::stoul(sep->arg[5])); + auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast(Strings::ToUnsignedInt(sep->arg[4]) + 1); + auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast(Strings::ToUnsignedInt(sep->arg[5])); c->Message( Chat::White, diff --git a/zone/gm_commands/dbspawn2.cpp b/zone/gm_commands/dbspawn2.cpp index aa5740b32e..e52419f28a 100755 --- a/zone/gm_commands/dbspawn2.cpp +++ b/zone/gm_commands/dbspawn2.cpp @@ -16,12 +16,12 @@ void command_dbspawn2(Client *c, const Seperator *sep) auto position = c->GetPosition(); - auto spawngroup_id = std::stoul(sep->arg[1]); - auto respawn = std::stoul(sep->arg[2]); - auto variance = std::stoul(sep->arg[3]); + auto spawngroup_id = Strings::ToUnsignedInt(sep->arg[1]); + auto respawn = Strings::ToUnsignedInt(sep->arg[2]); + auto variance = Strings::ToUnsignedInt(sep->arg[3]); - auto condition_id = sep->IsNumber(4) ? static_cast(std::stoul(sep->arg[4])) : static_cast(0); - auto condition_minimum = sep->IsNumber(5) ? static_cast(std::stoul(sep->arg[5])) : static_cast(0); + auto condition_id = sep->IsNumber(4) ? static_cast(Strings::ToUnsignedInt(sep->arg[4])) : static_cast(0); + auto condition_minimum = sep->IsNumber(5) ? static_cast(Strings::ToUnsignedInt(sep->arg[5])) : static_cast(0); if (!database.CreateSpawn2( c, diff --git a/zone/gm_commands/delacct.cpp b/zone/gm_commands/delacct.cpp index ff3a10edd0..a4602a9a30 100755 --- a/zone/gm_commands/delacct.cpp +++ b/zone/gm_commands/delacct.cpp @@ -13,7 +13,7 @@ void command_delacct(Client *c, const Seperator *sep) std::string account_name; if (sep->IsNumber(1)) { - account_id = std::stoul(sep->arg[1]); + account_id = Strings::ToUnsignedInt(sep->arg[1]); auto a = AccountRepository::FindOne(content_db, account_id); if (!a.id) { c->Message( diff --git a/zone/gm_commands/delpetition.cpp b/zone/gm_commands/delpetition.cpp index 556e338663..3630a9b3b2 100755 --- a/zone/gm_commands/delpetition.cpp +++ b/zone/gm_commands/delpetition.cpp @@ -7,14 +7,14 @@ void command_delpetition(Client *c, const Seperator *sep) return; } - c->Message(Chat::Red, "Attempting to delete petition number: %i", atoi(sep->argplus[1])); - std::string query = StringFormat("DELETE FROM petitions WHERE petid = %i", atoi(sep->argplus[1])); + c->Message(Chat::Red, "Attempting to delete petition number: %i", Strings::ToInt(sep->argplus[1])); + std::string query = StringFormat("DELETE FROM petitions WHERE petid = %i", Strings::ToInt(sep->argplus[1])); auto results = database.QueryDatabase(query); if (!results.Success()) { return; } - LogInfo("Delete petition request from [{}], petition number:", c->GetName(), atoi(sep->argplus[1])); + LogInfo("Delete petition request from [{}], petition number:", c->GetName(), Strings::ToInt(sep->argplus[1])); } diff --git a/zone/gm_commands/depop.cpp b/zone/gm_commands/depop.cpp index a2bb85676e..1b69fb8f8a 100755 --- a/zone/gm_commands/depop.cpp +++ b/zone/gm_commands/depop.cpp @@ -11,7 +11,7 @@ void command_depop(Client *c, const Seperator *sep) auto start_spawn_timer = false; if (sep->IsNumber(1)) { - start_spawn_timer = std::stoi(sep->arg[1]) ? true : false; + start_spawn_timer = Strings::ToInt(sep->arg[1]) ? true : false; } c->Message( diff --git a/zone/gm_commands/depopzone.cpp b/zone/gm_commands/depopzone.cpp index e24c45f461..ef90d7c042 100755 --- a/zone/gm_commands/depopzone.cpp +++ b/zone/gm_commands/depopzone.cpp @@ -5,7 +5,7 @@ void command_depopzone(Client *c, const Seperator *sep) auto start_spawn_timers = false; if (sep->IsNumber(1)) { - start_spawn_timers = std::stoi(sep->arg[1]) ? true : false; + start_spawn_timers = Strings::ToInt(sep->arg[1]) ? true : false; } zone->Depop(start_spawn_timers); diff --git a/zone/gm_commands/disablerecipe.cpp b/zone/gm_commands/disablerecipe.cpp index b09a6317c8..f57fa97d00 100755 --- a/zone/gm_commands/disablerecipe.cpp +++ b/zone/gm_commands/disablerecipe.cpp @@ -8,8 +8,8 @@ void command_disablerecipe(Client *c, const Seperator *sep) return; } - auto recipe_id = std::stoul(sep->arg[1]); - if (!recipe_id) { + auto recipe_id = Strings::ToUnsignedInt(sep->arg[1]); + if (!recipe_id) { c->Message(Chat::White, "Usage: #disablerecipe [Recipe ID]"); return; } diff --git a/zone/gm_commands/doanim.cpp b/zone/gm_commands/doanim.cpp index ec57650ff0..1391e54b39 100755 --- a/zone/gm_commands/doanim.cpp +++ b/zone/gm_commands/doanim.cpp @@ -19,7 +19,7 @@ void command_doanim(Client *c, const Seperator *sep) auto animation_speed = 0; if (sep->IsNumber(1)) { - animation_id = std::stoi(sep->arg[1]); + animation_id = Strings::ToInt(sep->arg[1]); const auto& a = animation_names_map.find(animation_id); if (a != animation_names_map.end()) { @@ -69,7 +69,7 @@ void command_doanim(Client *c, const Seperator *sep) } if (sep->IsNumber(2)) { - animation_speed = std::stoi(sep->arg[2]); + animation_speed = Strings::ToInt(sep->arg[2]); } const auto speed_message = ( diff --git a/zone/gm_commands/door_manipulation.cpp b/zone/gm_commands/door_manipulation.cpp index a8660fa8f8..e9c6a4de2b 100644 --- a/zone/gm_commands/door_manipulation.cpp +++ b/zone/gm_commands/door_manipulation.cpp @@ -1,6 +1,7 @@ #include "door_manipulation.h" #include "../doors.h" #include "../../common/misc_functions.h" +#include "../../common/strings.h" #define MAX_CLIENT_MESSAGE_LENGTH 2000 @@ -54,23 +55,23 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep) float set_size = 0.0f; if (arg2 == move_x_action) { - x_move = std::atof(arg3.c_str()); + x_move = Strings::ToFloat(arg3.c_str()); } if (arg2 == move_y_action) { - y_move = std::atof(arg3.c_str()); + y_move = Strings::ToFloat(arg3.c_str()); } if (arg2 == move_z_action) { - z_move = std::atof(arg3.c_str()); + z_move = Strings::ToFloat(arg3.c_str()); } if (arg2 == move_h_action) { - h_move = std::atof(arg3.c_str()); + h_move = Strings::ToFloat(arg3.c_str()); } if (arg2 == set_size_action) { - set_size = std::atof(arg3.c_str()); + set_size = Strings::ToFloat(arg3.c_str()); } door->SetLocation( @@ -369,7 +370,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep) if (arg1 == "opentype" && !arg2.empty() && Strings::IsNumber(arg2)) { Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId()); if (door) { - door->SetOpenType(std::atoi(arg2.c_str())); + door->SetOpenType(Strings::ToInt(arg2.c_str())); } } @@ -377,7 +378,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep) if (arg1 == "setincline" && !arg2.empty() && Strings::IsNumber(arg2)) { Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId()); if (door) { - door->SetIncline(std::atoi(arg2.c_str())); + door->SetIncline(Strings::ToInt(arg2.c_str())); } } @@ -385,7 +386,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep) if (arg1 == "setinvertstate" && !arg2.empty() && Strings::IsNumber(arg2)) { Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId()); if (door) { - door->SetInvertState(std::atoi(arg2.c_str())); + door->SetInvertState(Strings::ToInt(arg2.c_str())); } } @@ -402,7 +403,7 @@ void DoorManipulation::CommandHandler(Client *c, const Seperator *sep) if (arg1 == "setinclineinc" && !arg2.empty() && Strings::IsNumber(arg2)) { Doors *door = entity_list.GetDoorsByID(c->GetDoorToolEntityId()); if (door) { - door->SetIncline(door->GetIncline() + std::atoi(arg2.c_str())); + door->SetIncline(door->GetIncline() + Strings::ToInt(arg2.c_str())); } } diff --git a/zone/gm_commands/dye.cpp b/zone/gm_commands/dye.cpp index 195792f16d..4f2d39c1d2 100755 --- a/zone/gm_commands/dye.cpp +++ b/zone/gm_commands/dye.cpp @@ -48,23 +48,23 @@ void command_dye(Client *c, const Seperator *sep) } if (arguments >= 1 && sep->IsNumber(1)) { - slot = atoi(sep->arg[1]); + slot = Strings::ToInt(sep->arg[1]); } if (arguments >= 2 && sep->IsNumber(2)) { - red = atoi(sep->arg[2]); + red = Strings::ToInt(sep->arg[2]); } if (arguments >= 3 && sep->IsNumber(3)) { - green = atoi(sep->arg[3]); + green = Strings::ToInt(sep->arg[3]); } if (arguments >= 4 && sep->IsNumber(4)) { - blue = atoi(sep->arg[4]); + blue = Strings::ToInt(sep->arg[4]); } if (arguments >= 5 && sep->IsNumber(5)) { - use_tint = atoi(sep->arg[5]); + use_tint = Strings::ToInt(sep->arg[5]); } if (RuleB(Command, DyeCommandRequiresDyes)) { diff --git a/zone/gm_commands/editmassrespawn.cpp b/zone/gm_commands/editmassrespawn.cpp index 32e29cd327..a520ed6ccb 100755 --- a/zone/gm_commands/editmassrespawn.cpp +++ b/zone/gm_commands/editmassrespawn.cpp @@ -14,7 +14,7 @@ void command_editmassrespawn(Client *c, const Seperator *sep) int change_respawn_seconds = 0; if (sep->arg[2] && sep->IsNumber(2)) { - change_respawn_seconds = atoi(sep->arg[2]); + change_respawn_seconds = Strings::ToInt(sep->arg[2]); } bool change_apply = false; diff --git a/zone/gm_commands/emote.cpp b/zone/gm_commands/emote.cpp index f04e2fa3f2..761f1fd12d 100755 --- a/zone/gm_commands/emote.cpp +++ b/zone/gm_commands/emote.cpp @@ -22,7 +22,7 @@ void command_emote(Client *c, const Seperator *sep) bool is_zone = !strcasecmp(sep->arg[1], "zone"); const std::string emote_message = sep->argplus[3]; - const auto emote_type = std::stoul(sep->arg[2]); + const auto emote_type = Strings::ToUnsignedInt(sep->arg[2]); if (is_zone) { if (!Strings::Contains(emote_message, "^")) { diff --git a/zone/gm_commands/emotesearch.cpp b/zone/gm_commands/emotesearch.cpp index 5b8e9d09ef..209f46c711 100755 --- a/zone/gm_commands/emotesearch.cpp +++ b/zone/gm_commands/emotesearch.cpp @@ -21,7 +21,7 @@ void command_emotesearch(Client *c, const Seperator *sep) while (iterator.MoreElements()) { auto &e = iterator.GetData(); auto current_text = Strings::ToLower(e->text); - + if (Strings::Contains(current_text, Strings::ToLower(search_criteria))) { c->Message( Chat::White, @@ -64,8 +64,8 @@ void command_emotesearch(Client *c, const Seperator *sep) iterator.Advance(); } } else { - auto emote_id = std::stoul(search_criteria); - + auto emote_id = Strings::ToUnsignedInt(search_criteria); + LinkedListIterator iterator(zone->NPCEmoteList); iterator.Reset(); while (iterator.MoreElements()) { diff --git a/zone/gm_commands/enablerecipe.cpp b/zone/gm_commands/enablerecipe.cpp index 088907a752..60c8fefbef 100755 --- a/zone/gm_commands/enablerecipe.cpp +++ b/zone/gm_commands/enablerecipe.cpp @@ -8,8 +8,8 @@ void command_enablerecipe(Client *c, const Seperator *sep) return; } - auto recipe_id = std::stoul(sep->arg[1]); - if (!recipe_id) { + auto recipe_id = Strings::ToUnsignedInt(sep->arg[1]); + if (!recipe_id) { c->Message(Chat::White, "Usage: #enablerecipe [Recipe ID]"); return; } diff --git a/zone/gm_commands/equipitem.cpp b/zone/gm_commands/equipitem.cpp index 7ffe8ad84b..4599639dbe 100755 --- a/zone/gm_commands/equipitem.cpp +++ b/zone/gm_commands/equipitem.cpp @@ -2,7 +2,7 @@ void command_equipitem(Client *c, const Seperator *sep) { - uint32 slot_id = atoi(sep->arg[1]); + uint32 slot_id = Strings::ToInt(sep->arg[1]); if (sep->IsNumber(1) && (slot_id >= EQ::invslot::EQUIPMENT_BEGIN && slot_id <= EQ::invslot::EQUIPMENT_END)) { const EQ::ItemInstance *from_inst = c->GetInv().GetItem(EQ::invslot::slotCursor); const EQ::ItemInstance *to_inst = c->GetInv().GetItem(slot_id); // added (desync issue when forcing stack to stack) diff --git a/zone/gm_commands/faction.cpp b/zone/gm_commands/faction.cpp index 87a8ef5aa6..b7ca12a65d 100755 --- a/zone/gm_commands/faction.cpp +++ b/zone/gm_commands/faction.cpp @@ -53,7 +53,7 @@ void command_faction(Client *c, const Seperator *sep) uint32 found_count = 0; for (auto row : results) { uint32 faction_number = (found_count + 1); - auto faction_id = std::stoul(row[0]); + auto faction_id = Strings::ToUnsignedInt(row[0]); std::string faction_name = row[1]; std::string faction_value = row[2]; std::string reset_link = Saylink::Silent( @@ -107,7 +107,7 @@ void command_faction(Client *c, const Seperator *sep) ) ) { uint32 character_id = target->CharacterID(); - uint32 faction_id = std::stoul(faction_filter.c_str()); + uint32 faction_id = Strings::ToUnsignedInt(faction_filter.c_str()); if (target->ReloadCharacterFaction(target, faction_id, character_id)) { c->Message( Chat::White, diff --git a/zone/gm_commands/faction_association.cpp b/zone/gm_commands/faction_association.cpp index 47410f248a..a39f25dbce 100644 --- a/zone/gm_commands/faction_association.cpp +++ b/zone/gm_commands/faction_association.cpp @@ -14,5 +14,5 @@ void command_faction_association(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - target->RewardFaction(atoi(sep->arg[1]), atoi(sep->arg[2])); + target->RewardFaction(Strings::ToInt(sep->arg[1]), Strings::ToInt(sep->arg[2])); } diff --git a/zone/gm_commands/feature.cpp b/zone/gm_commands/feature.cpp index 55b6648d93..835ddd91f4 100644 --- a/zone/gm_commands/feature.cpp +++ b/zone/gm_commands/feature.cpp @@ -116,11 +116,11 @@ void command_feature(Client *c, const Seperator *sep) float value_changed = 0.0f; if (is_beard) { - face.beard = static_cast(std::stoul(sep->arg[2])); + face.beard = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Beard"; value_changed = face.beard; } else if (is_beard_color) { - face.beardcolor = static_cast(std::stoul(sep->arg[2])); + face.beardcolor = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Beard Color"; value_changed = face.beardcolor; } else if (is_details) { @@ -129,31 +129,31 @@ void command_feature(Client *c, const Seperator *sep) return; } - face.drakkin_details = static_cast(std::stoul(sep->arg[2])); + face.drakkin_details = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Drakkin Details"; value_changed = static_cast(face.drakkin_details); } else if (is_eyes) { - face.eyecolor1 = static_cast(std::stoul(sep->arg[2])); + face.eyecolor1 = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Eyes"; value_changed = face.eyecolor1; // eyecolor2 isn't used } else if (is_face) { - face.face = static_cast(std::stoul(sep->arg[2])); + face.face = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Face"; value_changed = face.face; } else if (is_gender) { - gender = static_cast(std::stoul(sep->arg[2])); + gender = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Gender"; value_changed = gender; } else if (is_hair) { - face.hairstyle = static_cast(std::stoul(sep->arg[2])); + face.hairstyle = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Hair"; value_changed = face.hairstyle; } else if (is_hair_color) { - face.haircolor = static_cast(std::stoul(sep->arg[2])); + face.haircolor = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Hair Color"; value_changed = face.haircolor; } else if (is_helm) { - helm_texture = static_cast(std::stoul(sep->arg[2])); + helm_texture = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Helmet Texture"; value_changed = helm_texture; } else if (is_heritage) { @@ -162,11 +162,11 @@ void command_feature(Client *c, const Seperator *sep) return; } - face.drakkin_heritage = static_cast(std::stoul(sep->arg[2])); + face.drakkin_heritage = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Drakkin Heritage"; value_changed = static_cast(face.drakkin_heritage); } else if (is_race) { - race = static_cast(std::stoul(sep->arg[2])); + race = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Race"; value_changed = race; } else if (is_size) { @@ -174,11 +174,11 @@ void command_feature(Client *c, const Seperator *sep) if (is_size_alias) { c->Message(Chat::White, "Usage: #feature size [Size] - Change your or your target's Size temporarily (Valid values are 0 to 255, decimal increments are allowed.)"); if (sep->arg[1] && Strings::IsFloat(sep->arg[1])) { - size = std::stof(sep->arg[1]); + size = Strings::ToFloat(sep->arg[1]); } } else { - size = std::stof(sep->arg[2]); + size = Strings::ToFloat(sep->arg[2]); } if (size < 0 || size > 255) { @@ -194,11 +194,11 @@ void command_feature(Client *c, const Seperator *sep) return; } - face.drakkin_tattoo = static_cast(std::stoul(sep->arg[2])); + face.drakkin_tattoo = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Drakkin Tattoos"; value_changed = static_cast(face.drakkin_tattoo); } else if (is_texture) { - texture = static_cast(std::stoul(sep->arg[2])); + texture = static_cast(Strings::ToUnsignedInt(sep->arg[2])); feature_changed = "Texture"; value_changed = texture; } diff --git a/zone/gm_commands/findaa.cpp b/zone/gm_commands/findaa.cpp index 0774e2e49e..3a0640153e 100755 --- a/zone/gm_commands/findaa.cpp +++ b/zone/gm_commands/findaa.cpp @@ -9,7 +9,7 @@ void command_findaa(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - int aa_id = std::stoi(sep->arg[1]); + int aa_id = Strings::ToInt(sep->arg[1]); auto aa_name = zone->GetAAName(aa_id); if (!aa_name.empty()) { c->Message( diff --git a/zone/gm_commands/findcharacter.cpp b/zone/gm_commands/findcharacter.cpp index 811978af56..fccd7bf20d 100755 --- a/zone/gm_commands/findcharacter.cpp +++ b/zone/gm_commands/findcharacter.cpp @@ -10,7 +10,7 @@ void command_findcharacter(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - const auto character_id = std::stoul(sep->arg[1]); + const auto character_id = Strings::ToUnsignedInt(sep->arg[1]); const auto& e = CharacterDataRepository::FindOne(content_db, character_id); if (!e.id) { diff --git a/zone/gm_commands/findclass.cpp b/zone/gm_commands/findclass.cpp index 62e484e815..a1ddaa18f1 100755 --- a/zone/gm_commands/findclass.cpp +++ b/zone/gm_commands/findclass.cpp @@ -9,7 +9,7 @@ void command_findclass(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - int class_id = std::stoi(sep->arg[1]); + int class_id = Strings::ToInt(sep->arg[1]); if (class_id >= WARRIOR && class_id <= MERCENARY_MASTER) { std::string class_name = GetClassIDName(class_id); c->Message( diff --git a/zone/gm_commands/findfaction.cpp b/zone/gm_commands/findfaction.cpp index 8038a2e002..a6d75874da 100755 --- a/zone/gm_commands/findfaction.cpp +++ b/zone/gm_commands/findfaction.cpp @@ -10,7 +10,7 @@ void command_findfaction(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - int faction_id = std::stoi(sep->arg[1]); + int faction_id = Strings::ToInt(sep->arg[1]); auto faction_name = content_db.GetFactionName(faction_id); if (!faction_name.empty()) { c->Message( diff --git a/zone/gm_commands/findrace.cpp b/zone/gm_commands/findrace.cpp index 6e02a70411..b0bee13c10 100755 --- a/zone/gm_commands/findrace.cpp +++ b/zone/gm_commands/findrace.cpp @@ -9,7 +9,7 @@ void command_findrace(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - auto race_id = static_cast(std::stoul(sep->arg[1])); + auto race_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); std::string race_name = GetRaceIDName(race_id); if ( race_id >= RACE_HUMAN_1 && diff --git a/zone/gm_commands/findrecipe.cpp b/zone/gm_commands/findrecipe.cpp index fdcdb9169f..4b3593ea9d 100755 --- a/zone/gm_commands/findrecipe.cpp +++ b/zone/gm_commands/findrecipe.cpp @@ -11,7 +11,7 @@ void command_findrecipe(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - auto recipe_id = static_cast(std::stoul(sep->arg[1])); + auto recipe_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); auto r = TradeskillRecipeRepository::GetWhere( database, fmt::format("id = {}", recipe_id) @@ -42,7 +42,7 @@ void command_findrecipe(Client *c, const Seperator *sep) } else { auto search_criteria = Strings::ToLower(sep->argplus[1]); int found_count = 0; - + auto rl = TradeskillRecipeRepository::GetWhere( database, fmt::format("`name` LIKE '%{}%' ORDER BY `id` ASC", search_criteria) diff --git a/zone/gm_commands/findskill.cpp b/zone/gm_commands/findskill.cpp index 5c9a3b50e2..68231200f7 100755 --- a/zone/gm_commands/findskill.cpp +++ b/zone/gm_commands/findskill.cpp @@ -11,7 +11,7 @@ void command_findskill(Client *c, const Seperator *sep) std::map skills = EQ::skills::GetSkillTypeMap(); if (sep->IsNumber(1)) { - int skill_id = std::stoi(sep->arg[1]); + int skill_id = Strings::ToInt(sep->arg[1]); if (skill_id >= EQ::skills::Skill1HBlunt && skill_id < EQ::skills::SkillCount) { for (auto skill : skills) { if (skill_id == skill.first) { diff --git a/zone/gm_commands/findspell.cpp b/zone/gm_commands/findspell.cpp index 0585bda1c3..1ec4f1d10e 100755 --- a/zone/gm_commands/findspell.cpp +++ b/zone/gm_commands/findspell.cpp @@ -15,7 +15,7 @@ void command_findspell(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - int spell_id = std::stoi(sep->arg[1]); + int spell_id = Strings::ToInt(sep->arg[1]); if (!IsValidSpell(spell_id)) { c->Message( Chat::White, diff --git a/zone/gm_commands/findtask.cpp b/zone/gm_commands/findtask.cpp index a643b28a33..78556a158e 100755 --- a/zone/gm_commands/findtask.cpp +++ b/zone/gm_commands/findtask.cpp @@ -11,7 +11,7 @@ void command_findtask(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - auto task_id = std::stoul(sep->arg[1]); + auto task_id = Strings::ToUnsignedInt(sep->arg[1]); auto task_name = task_manager->GetTaskName(task_id); std::string task_message = ( diff --git a/zone/gm_commands/findzone.cpp b/zone/gm_commands/findzone.cpp index c803461591..baba6b63a4 100755 --- a/zone/gm_commands/findzone.cpp +++ b/zone/gm_commands/findzone.cpp @@ -9,7 +9,7 @@ void command_findzone(Client *c, const Seperator *sep) } std::string query; - int id = atoi((const char *) sep->arg[1]); + int id = Strings::ToInt((const char *) sep->arg[1]); std::string arg1 = sep->arg[1]; @@ -53,7 +53,7 @@ void command_findzone(Client *c, const Seperator *sep) std::string zone_id = row[0]; std::string short_name = row[1]; std::string long_name = row[2]; - int version = atoi(row[3]); + int version = Strings::ToInt(row[3]); if (++count > maxrows) { c->Message(Chat::White, "%i zones shown. Too many results.", maxrows); diff --git a/zone/gm_commands/flag.cpp b/zone/gm_commands/flag.cpp index b49011ba2e..12135fbe39 100755 --- a/zone/gm_commands/flag.cpp +++ b/zone/gm_commands/flag.cpp @@ -30,8 +30,8 @@ void command_flag(Client *c, const Seperator *sep) target->UpdateAdmin(); return; } - - + + if ( !sep->IsNumber(1) || strlen(sep->arg[2]) == 0 @@ -40,7 +40,7 @@ void command_flag(Client *c, const Seperator *sep) return; } - auto status = std::stoi(sep->arg[1]); + auto status = Strings::ToInt(sep->arg[1]); if (status < -2 || status > 255) { c->Message(Chat::White, "The lowest a status level can go is -2 and the highest a status level can go is 255."); return; @@ -48,7 +48,7 @@ void command_flag(Client *c, const Seperator *sep) std::string account_name = sep->argplus[2]; auto account_id = database.GetAccountIDByChar(account_name.c_str()); - + if (c->Admin() < commandChangeFlags) { //this check makes banning players by less than this level impossible, but i'll leave it in anyways c->Message(Chat::White, "You may only refresh your own flag, doing so now."); c->UpdateAdmin(); diff --git a/zone/gm_commands/flagedit.cpp b/zone/gm_commands/flagedit.cpp index 85d76392a6..bb29620f1e 100755 --- a/zone/gm_commands/flagedit.cpp +++ b/zone/gm_commands/flagedit.cpp @@ -82,7 +82,7 @@ void command_flagedit(Client *c, const Seperator *sep) if (is_give) { uint32 zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); std::string zone_short_name = Strings::ToLower(ZoneName(zone_id, true)); @@ -129,7 +129,7 @@ void command_flagedit(Client *c, const Seperator *sep) row[0], row[1], ( - std::stoi(row[2]) != 0 ? + Strings::ToInt(row[2]) != 0 ? fmt::format( "[Version {}]", row[2] @@ -151,7 +151,7 @@ void command_flagedit(Client *c, const Seperator *sep) } else if (is_lock) { uint32 zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); std::string zone_short_name = Strings::ToLower(ZoneName(zone_id, true)); @@ -206,7 +206,7 @@ void command_flagedit(Client *c, const Seperator *sep) } else if (is_take) { uint32 zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); std::string zone_short_name = Strings::ToLower(ZoneName(zone_id, true)); @@ -234,7 +234,7 @@ void command_flagedit(Client *c, const Seperator *sep) } else if (is_unlock) { uint32 zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); std::string zone_short_name = Strings::ToLower(ZoneName(zone_id, true)); diff --git a/zone/gm_commands/flymode.cpp b/zone/gm_commands/flymode.cpp index 591977939d..46ebc40b92 100755 --- a/zone/gm_commands/flymode.cpp +++ b/zone/gm_commands/flymode.cpp @@ -13,7 +13,7 @@ void command_flymode(Client *c, const Seperator *sep) target = c->GetTarget(); } - auto flymode_id = std::stoul(sep->arg[1]); + auto flymode_id = Strings::ToUnsignedInt(sep->arg[1]); if (!EQ::ValueWithin(flymode_id, EQ::constants::GravityBehavior::Ground, EQ::constants::GravityBehavior::LevitateWhileRunning)) { c->Message(Chat::White, "Usage:: #flymode [Flymode ID]"); c->Message(Chat::White, "0 = Ground, 1 = Flying, 2 = Levitating, 3 = Water, 4 = Floating, 5 = Levitating While Running"); diff --git a/zone/gm_commands/gassign.cpp b/zone/gm_commands/gassign.cpp index 81260ff8af..4c4b61aa96 100755 --- a/zone/gm_commands/gassign.cpp +++ b/zone/gm_commands/gassign.cpp @@ -13,7 +13,7 @@ void command_gassign(Client *c, const Seperator *sep) return; } - auto grid_id = std::stoul(sep->arg[1]); + auto grid_id = Strings::ToUnsignedInt(sep->arg[1]); auto target = c->GetTarget()->CastToNPC(); if (target->GetSpawnPointID() > 0) { diff --git a/zone/gm_commands/gearup.cpp b/zone/gm_commands/gearup.cpp index 879ca66ce9..2d9cbc1c55 100755 --- a/zone/gm_commands/gearup.cpp +++ b/zone/gm_commands/gearup.cpp @@ -97,8 +97,8 @@ void command_gearup(Client *c, const Seperator *sep) std::set equipped; for (auto row : results) { - auto item_id = std::stoul(row[0]); - auto slot_id = static_cast(std::stoul(row[1])); + auto item_id = Strings::ToUnsignedInt(row[0]); + auto slot_id = static_cast(Strings::ToUnsignedInt(row[1])); if (equipped.find(slot_id) != equipped.end()) { if (slot_id == EQ::invslot::slotEar1) { @@ -178,7 +178,7 @@ void command_gearup(Client *c, const Seperator *sep) c->Message(Chat::White, "Choose Armor by Expansion:"); std::string message; for (auto row : results) { - const auto expansion = std::stoi(row[0]); + const auto expansion = Strings::ToInt(row[0]); message += fmt::format( "[{}] ", Saylink::Silent( diff --git a/zone/gm_commands/gender.cpp b/zone/gm_commands/gender.cpp index 6e611e04a9..42e7396c4a 100755 --- a/zone/gm_commands/gender.cpp +++ b/zone/gm_commands/gender.cpp @@ -14,7 +14,7 @@ void command_gender(Client *c, const Seperator *sep) target = c->GetTarget(); } - auto gender_id = std::stoi(sep->arg[1]); + auto gender_id = Strings::ToInt(sep->arg[1]); if (gender_id < 0 || gender_id > 2) { c->Message(Chat::White, "Usage: #gender [Gender ID]"); c->Message(Chat::White, "Genders: 0 = Male, 1 = Female, 2 = Neuter"); diff --git a/zone/gm_commands/giveitem.cpp b/zone/gm_commands/giveitem.cpp index 17458182b5..0e4c894ee2 100755 --- a/zone/gm_commands/giveitem.cpp +++ b/zone/gm_commands/giveitem.cpp @@ -34,7 +34,7 @@ void command_giveitem(Client *c, const Seperator *sep) augment_six = link_body.augment_6; } else if (sep->IsNumber(1)) { - item_id = atoi(sep->arg[1]); + item_id = Strings::ToInt(sep->arg[1]); } else if (!sep->IsNumber(1)) { c->Message( @@ -65,31 +65,31 @@ void command_giveitem(Client *c, const Seperator *sep) } if (arguments >= 2 && sep->IsNumber(2)) { - charges = atoi(sep->arg[2]); + charges = Strings::ToInt(sep->arg[2]); } if (arguments >= 3 && sep->IsNumber(3)) { - augment_one = atoi(sep->arg[3]); + augment_one = Strings::ToInt(sep->arg[3]); } if (arguments >= 4 && sep->IsNumber(4)) { - augment_two = atoi(sep->arg[4]); + augment_two = Strings::ToInt(sep->arg[4]); } if (arguments >= 5 && sep->IsNumber(5)) { - augment_three = atoi(sep->arg[5]); + augment_three = Strings::ToInt(sep->arg[5]); } if (arguments >= 6 && sep->IsNumber(6)) { - augment_four = atoi(sep->arg[6]); + augment_four = Strings::ToInt(sep->arg[6]); } if (arguments >= 7 && sep->IsNumber(7)) { - augment_five = atoi(sep->arg[7]); + augment_five = Strings::ToInt(sep->arg[7]); } if (arguments == 8 && sep->IsNumber(8)) { - augment_six = atoi(sep->arg[8]); + augment_six = Strings::ToInt(sep->arg[8]); } client_target->SummonItem( diff --git a/zone/gm_commands/givemoney.cpp b/zone/gm_commands/givemoney.cpp index 9aa17e76dd..dd8499ee7e 100755 --- a/zone/gm_commands/givemoney.cpp +++ b/zone/gm_commands/givemoney.cpp @@ -14,10 +14,10 @@ void command_givemoney(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - uint32 platinum = std::stoul(sep->arg[1]); - uint32 gold = sep->IsNumber(2) ? std::stoul(sep->arg[2]) : 0; - uint32 silver = sep->IsNumber(3) ? std::stoul(sep->arg[3]) : 0; - uint32 copper = sep->IsNumber(4) ? std::stoul(sep->arg[4]) : 0; + uint32 platinum = Strings::ToUnsignedInt(sep->arg[1]); + uint32 gold = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : 0; + uint32 silver = sep->IsNumber(3) ? Strings::ToUnsignedInt(sep->arg[3]) : 0; + uint32 copper = sep->IsNumber(4) ? Strings::ToUnsignedInt(sep->arg[4]) : 0; if (!platinum && !gold && !silver && !copper) { c->Message(Chat::Red, "Usage: #Usage: #givemoney [Platinum] [Gold] [Silver] [Copper]"); return; diff --git a/zone/gm_commands/gmzone.cpp b/zone/gm_commands/gmzone.cpp index 94b4627065..d10885d62b 100755 --- a/zone/gm_commands/gmzone.cpp +++ b/zone/gm_commands/gmzone.cpp @@ -11,7 +11,7 @@ void command_gmzone(Client *c, const Seperator *sep) std::string zone_short_name = Strings::ToLower( sep->IsNumber(1) ? - ZoneName(std::stoul(sep->arg[1]), true) : + ZoneName(Strings::ToUnsignedInt(sep->arg[1]), true) : sep->arg[1] ); bool is_unknown_zone = zone_short_name.find("unknown") != std::string::npos; @@ -41,7 +41,7 @@ void command_gmzone(Client *c, const Seperator *sep) auto zone_version = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : 0 ); @@ -63,7 +63,7 @@ void command_gmzone(Client *c, const Seperator *sep) uint32 duration = 100000000; if (!existing_zone_instance.empty()) { - instance_id = std::stoi(existing_zone_instance); + instance_id = Strings::ToInt(existing_zone_instance); c->Message( Chat::White, fmt::format( diff --git a/zone/gm_commands/goto.cpp b/zone/gm_commands/goto.cpp index cdc8da2e2d..b3b4cccf0f 100755 --- a/zone/gm_commands/goto.cpp +++ b/zone/gm_commands/goto.cpp @@ -49,10 +49,10 @@ void command_goto(Client *c, const Seperator *sep) c->MovePC( zone->GetZoneID(), zone->GetInstanceID(), - atof(sep->arg[1]), - atof(sep->arg[2]), - atof(sep->arg[3]), - (sep->arg[4] ? atof(sep->arg[4]) : c->GetHeading()) + Strings::ToFloat(sep->arg[1]), + Strings::ToFloat(sep->arg[2]), + Strings::ToFloat(sep->arg[3]), + (sep->arg[4] ? Strings::ToFloat(sep->arg[4]) : c->GetHeading()) ); } else { diff --git a/zone/gm_commands/grid.cpp b/zone/gm_commands/grid.cpp index 3ff62539cf..3a346807ea 100755 --- a/zone/gm_commands/grid.cpp +++ b/zone/gm_commands/grid.cpp @@ -14,9 +14,9 @@ void command_grid(Client *c, const Seperator *sep) ); } else if (strcasecmp("add", command_type) == 0) { - auto grid_id = atoi(sep->arg[2]); - auto wander_type = atoi(sep->arg[3]); - auto pause_type = atoi(sep->arg[4]); + auto grid_id = Strings::ToInt(sep->arg[2]); + auto wander_type = Strings::ToInt(sep->arg[3]); + auto pause_type = Strings::ToInt(sep->arg[4]); if (!content_db.GridExistsInZone(zone_id, grid_id)) { content_db.ModifyGrid(c, false, grid_id, wander_type, pause_type, zone_id); c->Message( @@ -76,7 +76,7 @@ void command_grid(Client *c, const Seperator *sep) // Spawn grid nodes std::map, int32> zoffset; for (auto row : results) { - glm::vec4 node_position = glm::vec4(atof(row[0]), atof(row[1]), atof(row[2]), atof(row[3])); + glm::vec4 node_position = glm::vec4(Strings::ToFloat(row[0]), Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3])); std::vector node_loc{ node_position.x, node_position.y, @@ -95,7 +95,7 @@ void command_grid(Client *c, const Seperator *sep) } node_position.z += zoffset[node_loc]; - NPC::SpawnGridNodeNPC(node_position, grid_id, atoi(row[4]), zoffset[node_loc]); + NPC::SpawnGridNodeNPC(node_position, grid_id, Strings::ToInt(row[4]), zoffset[node_loc]); } c->Message( Chat::White, @@ -123,7 +123,7 @@ void command_grid(Client *c, const Seperator *sep) ); } else if (strcasecmp("delete", command_type) == 0) { - auto grid_id = atoi(sep->arg[2]); + auto grid_id = Strings::ToInt(sep->arg[2]); content_db.ModifyGrid(c, true, grid_id, 0, 0, zone_id); c->Message( Chat::White, diff --git a/zone/gm_commands/guild.cpp b/zone/gm_commands/guild.cpp index 13fd07cb46..3d1ad27173 100755 --- a/zone/gm_commands/guild.cpp +++ b/zone/gm_commands/guild.cpp @@ -53,7 +53,7 @@ void command_guild(Client *c, const Seperator *sep) } else { auto leader_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : database.GetCharacterID(sep->arg[2]) ); auto leader_name = database.GetCharNameByID(leader_id); @@ -132,7 +132,7 @@ void command_guild(Client *c, const Seperator *sep) if (!sep->IsNumber(2)) { c->Message(Chat::White, "Usage: #guild delete [Guild ID]"); } else { - auto guild_id = std::stoul(sep->arg[2]); + auto guild_id = Strings::ToUnsignedInt(sep->arg[2]); if (!guild_mgr.GuildExists(guild_id)) { c->Message( Chat::White, @@ -185,7 +185,7 @@ void command_guild(Client *c, const Seperator *sep) if (arguments != 2 || !sep->IsNumber(2)) { guild_id = c->GuildID(); } else if (c->Admin() >= minStatusToEditOtherGuilds) { - guild_id = std::stoul(sep->arg[2]); + guild_id = Strings::ToUnsignedInt(sep->arg[2]); } if (guild_id != GUILD_NONE) { @@ -203,7 +203,7 @@ void command_guild(Client *c, const Seperator *sep) if (!sep->IsNumber(2)) { c->Message(Chat::White, "Usage: #guild rename [Guild ID] [New Guild Name]"); } else { - auto guild_id = std::stoul(sep->arg[2]); + auto guild_id = Strings::ToUnsignedInt(sep->arg[2]); if (!guild_mgr.GuildExists(guild_id)) { c->Message( Chat::White, @@ -246,7 +246,7 @@ void command_guild(Client *c, const Seperator *sep) } } else if (is_search) { if (Strings::IsNumber(sep->arg[2])) { - const auto guild_id = std::stoul(sep->arg[2]); + const auto guild_id = Strings::ToUnsignedInt(sep->arg[2]); guild_mgr.ListGuilds(c, guild_id); } else { @@ -262,7 +262,7 @@ void command_guild(Client *c, const Seperator *sep) c->Message(Chat::White, "#guild set [Character ID|Character Name] [Guild ID] (Guild ID 0 is Guildless)"); return; } else { - auto guild_id = std::stoul(sep->arg[3]); + auto guild_id = Strings::ToUnsignedInt(sep->arg[3]); if (!guild_id) { guild_id = GUILD_NONE; } else if (!guild_mgr.GuildExists(guild_id)) { @@ -278,7 +278,7 @@ void command_guild(Client *c, const Seperator *sep) auto character_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : database.GetCharacterID(sep->arg[2]) ); auto character_name = database.GetCharNameByID(character_id); @@ -348,7 +348,7 @@ void command_guild(Client *c, const Seperator *sep) } else { auto leader_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : database.GetCharacterID(sep->arg[2]) ); auto leader_name = database.GetCharNameByID(leader_id); @@ -377,7 +377,7 @@ void command_guild(Client *c, const Seperator *sep) ); } else { - auto guild_id = std::stoul(sep->arg[2]); + auto guild_id = Strings::ToUnsignedInt(sep->arg[2]); if (!guild_mgr.GuildExists(guild_id)) { c->Message( Chat::White, @@ -419,7 +419,7 @@ void command_guild(Client *c, const Seperator *sep) } } } else if (is_set_rank) { - auto rank = static_cast(std::stoul(sep->arg[3])); + auto rank = static_cast(Strings::ToUnsignedInt(sep->arg[3])); if (!sep->IsNumber(3)) { c->Message(Chat::White, "#guild setrank [Character ID|Character Name] [Rank]"); } else if (rank < 0 || rank > GUILD_MAX_RANK) { @@ -433,7 +433,7 @@ void command_guild(Client *c, const Seperator *sep) } else { auto character_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : database.GetCharacterID(sep->arg[2]) ); auto character_name = database.GetCharNameByID(character_id); diff --git a/zone/gm_commands/haste.cpp b/zone/gm_commands/haste.cpp index bf5be4d262..705781f350 100755 --- a/zone/gm_commands/haste.cpp +++ b/zone/gm_commands/haste.cpp @@ -4,7 +4,7 @@ void command_haste(Client *c, const Seperator *sep) { // #haste command to set client attack speed. Takes a percentage (100 = twice normal attack speed) if (sep->arg[1][0] != 0) { - uint16 Haste = atoi(sep->arg[1]); + uint16 Haste = Strings::ToInt(sep->arg[1]); if (Haste > 85) { Haste = 85; } diff --git a/zone/gm_commands/heromodel.cpp b/zone/gm_commands/heromodel.cpp index 9cd3c44786..f6c35b142f 100755 --- a/zone/gm_commands/heromodel.cpp +++ b/zone/gm_commands/heromodel.cpp @@ -21,10 +21,10 @@ void command_heromodel(Client *c, const Seperator *sep) t = c->GetTarget(); } - auto hero_forge_model = Strings::IsNumber(sep->arg[1]) ? std::stoul(sep->arg[1]) : 0; + auto hero_forge_model = Strings::IsNumber(sep->arg[1]) ? Strings::ToUnsignedInt(sep->arg[1]) : 0; if (arguments > 1) { - auto slot = static_cast(std::stoul(sep->arg[2])); + auto slot = static_cast(Strings::ToUnsignedInt(sep->arg[2])); c->GetTarget()->SendTextureWC(slot, 0, hero_forge_model, 0, 0, 0); } else { if (hero_forge_model) { diff --git a/zone/gm_commands/incstat.cpp b/zone/gm_commands/incstat.cpp index 6a09c17854..14ad4a2358 100755 --- a/zone/gm_commands/incstat.cpp +++ b/zone/gm_commands/incstat.cpp @@ -3,7 +3,7 @@ void command_incstat(Client *c, const Seperator *sep) { if (sep->arg[1][0] && sep->arg[2][0] && c->GetTarget() != 0 && c->GetTarget()->IsClient()) { - c->GetTarget()->CastToClient()->IncStats(atoi(sep->arg[1]), atoi(sep->arg[2])); + c->GetTarget()->CastToClient()->IncStats(Strings::ToInt(sep->arg[1]), Strings::ToInt(sep->arg[2])); } else { c->Message(Chat::White, "This command is used to permanently increase or decrease a players stats."); diff --git a/zone/gm_commands/instance.cpp b/zone/gm_commands/instance.cpp index 83ca06d9e2..413eeebed2 100755 --- a/zone/gm_commands/instance.cpp +++ b/zone/gm_commands/instance.cpp @@ -79,7 +79,7 @@ void command_instance(Client *c, const Seperator *sep) } std::string character_name = sep->arg[3]; - uint16 instance_id = static_cast(std::stoul(sep->arg[2])); + uint16 instance_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); uint32 character_id = database.GetCharacterID(character_name.c_str()); if (instance_id <= 0 || character_id <= 0) { c->Message(Chat::White, "You must enter a valid Instance ID and player name."); @@ -146,11 +146,11 @@ void command_instance(Client *c, const Seperator *sep) uint32 zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); - uint32 version = std::stoul(sep->arg[3]); - uint32 duration = std::stoul(sep->arg[4]); + uint32 version = Strings::ToUnsignedInt(sep->arg[3]); + uint32 duration = Strings::ToUnsignedInt(sep->arg[4]); std::string zone_short_name = ZoneName(zone_id); if (zone_short_name.empty()) { c->Message( @@ -210,7 +210,7 @@ void command_instance(Client *c, const Seperator *sep) return; } - uint16 instance_id = std::stoul(sep->arg[2]); + uint16 instance_id = Strings::ToUnsignedInt(sep->arg[2]); if (!database.CheckInstanceExists(instance_id)) { c->Message( Chat::White, @@ -269,7 +269,7 @@ void command_instance(Client *c, const Seperator *sep) } std::string character_name = sep->arg[3]; - uint16 instance_id = static_cast(std::stoul(sep->arg[2])); + uint16 instance_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); uint32 character_id = database.GetCharacterID(character_name.c_str()); if (instance_id <= 0 || character_id <= 0) { c->Message(Chat::White, "You must enter a valid Instance ID and player name."); diff --git a/zone/gm_commands/interrupt.cpp b/zone/gm_commands/interrupt.cpp index 1126a850c7..b9e10b3818 100755 --- a/zone/gm_commands/interrupt.cpp +++ b/zone/gm_commands/interrupt.cpp @@ -5,10 +5,10 @@ void command_interrupt(Client *c, const Seperator *sep) uint16 ci_message = 0x01b7, ci_color = 0x0121; if (sep->arg[1][0]) { - ci_message = atoi(sep->arg[1]); + ci_message = Strings::ToInt(sep->arg[1]); } if (sep->arg[2][0]) { - ci_color = atoi(sep->arg[2]); + ci_color = Strings::ToInt(sep->arg[2]); } c->InterruptSpell(ci_message, ci_color); diff --git a/zone/gm_commands/invsnapshot.cpp b/zone/gm_commands/invsnapshot.cpp index 6e818524a6..4c60fb8ce8 100755 --- a/zone/gm_commands/invsnapshot.cpp +++ b/zone/gm_commands/invsnapshot.cpp @@ -189,7 +189,7 @@ void command_invsnapshot(Client *c, const Seperator *sep) auto list_count = 0; if (sep->IsNumber(2)) { - list_count = atoi(sep->arg[2]); + list_count = Strings::ToInt(sep->arg[2]); } if (list_count < 1 || list_count > is_list.size()) { list_count = is_list.size(); @@ -237,7 +237,7 @@ void command_invsnapshot(Client *c, const Seperator *sep) return; } - uint32 timestamp = atoul(sep->arg[2]); + uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]); if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) { c->Message( @@ -285,7 +285,7 @@ void command_invsnapshot(Client *c, const Seperator *sep) return; } - uint32 timestamp = atoul(sep->arg[2]); + uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]); if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) { c->Message( @@ -374,7 +374,7 @@ void command_invsnapshot(Client *c, const Seperator *sep) return; } - uint32 timestamp = atoul(sep->arg[2]); + uint32 timestamp = Strings::ToUnsignedInt(sep->arg[2]); if (!database.ValidateCharacterInvSnapshotTimestamp(tc->CharacterID(), timestamp)) { c->Message( diff --git a/zone/gm_commands/itemsearch.cpp b/zone/gm_commands/itemsearch.cpp index be720275f1..084b38833e 100755 --- a/zone/gm_commands/itemsearch.cpp +++ b/zone/gm_commands/itemsearch.cpp @@ -13,7 +13,7 @@ void command_itemsearch(Client *c, const Seperator *sep) linker.SetLinkType(EQ::saylink::SayLinkItemData); if (Seperator::IsNumber(search_criteria)) { - item = database.GetItem(atoi(search_criteria)); + item = database.GetItem(Strings::ToInt(search_criteria)); if (item) { linker.SetItemData(item); std::string item_id = std::to_string(item->ID); diff --git a/zone/gm_commands/level.cpp b/zone/gm_commands/level.cpp index 663633cd77..393e8fdea6 100644 --- a/zone/gm_commands/level.cpp +++ b/zone/gm_commands/level.cpp @@ -14,7 +14,7 @@ void command_level(Client *c, const Seperator *sep) return; } - auto level = static_cast(std::stoul(sep->arg[1])); + auto level = static_cast(Strings::ToUnsignedInt(sep->arg[1])); auto max_level = static_cast(RuleI(Character, MaxLevel)); if (c->Admin() < RuleI(GM, MinStatusToLevelTarget)) { diff --git a/zone/gm_commands/logs.cpp b/zone/gm_commands/logs.cpp index 9a05745e6c..f7029ee406 100755 --- a/zone/gm_commands/logs.cpp +++ b/zone/gm_commands/logs.cpp @@ -53,7 +53,7 @@ void command_logs(Client *c, const Seperator *sep) if (is_list || (is_set && !sep->IsNumber(3))) { uint32 start_category_id = 1; if (sep->IsNumber(2)) { - start_category_id = std::stoul(sep->arg[2]); + start_category_id = Strings::ToUnsignedInt(sep->arg[2]); } uint32 max_category_id = (start_category_id + 49); @@ -204,8 +204,8 @@ void command_logs(Client *c, const Seperator *sep) logs_set = true; - auto category_id = std::stoul(sep->arg[3]); - auto setting = std::stoul(sep->arg[4]); + auto category_id = Strings::ToUnsignedInt(sep->arg[3]); + auto setting = Strings::ToUnsignedInt(sep->arg[4]); if (is_console) { LogSys.log_settings[category_id].log_to_console = setting; diff --git a/zone/gm_commands/lootsim.cpp b/zone/gm_commands/lootsim.cpp index 2213c12a1f..e7d28b7fc9 100755 --- a/zone/gm_commands/lootsim.cpp +++ b/zone/gm_commands/lootsim.cpp @@ -8,10 +8,10 @@ void command_lootsim(Client *c, const Seperator *sep) return; } - auto npc_id = std::stoul(sep->arg[1]); - auto loottable_id = std::stoul(sep->arg[2]); - auto iterations = std::stoul(sep->arg[3]) > 1000 ? 1000 : std::stoul(sep->arg[3]); - auto log_enabled = arguments > 3 ? std::stoul(sep->arg[4]) : false; + auto npc_id = Strings::ToUnsignedInt(sep->arg[1]); + auto loottable_id = Strings::ToUnsignedInt(sep->arg[2]); + auto iterations = Strings::ToUnsignedInt(sep->arg[3]) > 1000 ? 1000 : Strings::ToUnsignedInt(sep->arg[3]); + auto log_enabled = arguments > 3 ? Strings::ToUnsignedInt(sep->arg[4]) : false; // temporarily disable loot logging unless set explicitly LogSys.log_settings[Logs::Loot].log_to_console = log_enabled ? LogSys.log_settings[Logs::Loot].log_to_console : 0; diff --git a/zone/gm_commands/memspell.cpp b/zone/gm_commands/memspell.cpp index e0fc422a48..c48e986a70 100755 --- a/zone/gm_commands/memspell.cpp +++ b/zone/gm_commands/memspell.cpp @@ -16,7 +16,7 @@ void command_memspell(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( Chat::White, @@ -43,7 +43,7 @@ void command_memspell(Client *c, const Seperator *sep) return; } - auto spell_gem = sep->IsNumber(2) ? std::stoul(sep->arg[2]) : empty_slot; + auto spell_gem = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : empty_slot; if (spell_gem > EQ::spells::SPELL_GEM_COUNT) { c->Message( Chat::White, diff --git a/zone/gm_commands/movechar.cpp b/zone/gm_commands/movechar.cpp index 83e72cc37f..1acde33a1b 100755 --- a/zone/gm_commands/movechar.cpp +++ b/zone/gm_commands/movechar.cpp @@ -10,7 +10,7 @@ void command_movechar(Client *c, const Seperator *sep) std::string character_name = ( sep->IsNumber(1) ? - database.GetCharNameByID(std::stoul(sep->arg[1])) : + database.GetCharNameByID(Strings::ToUnsignedInt(sep->arg[1])) : sep->arg[1] ); auto character_id = database.GetCharacterID(character_name.c_str()); @@ -29,7 +29,7 @@ void command_movechar(Client *c, const Seperator *sep) std::string zone_short_name = Strings::ToLower( sep->IsNumber(2) ? - ZoneName(std::stoul(sep->arg[2]), true) : + ZoneName(Strings::ToUnsignedInt(sep->arg[2]), true) : sep->arg[2] ); @@ -39,7 +39,7 @@ void command_movechar(Client *c, const Seperator *sep) Chat::White, fmt::format( "Zone ID {} could not be found.", - std::stoul(sep->arg[2]) + Strings::ToUnsignedInt(sep->arg[2]) ).c_str() ); return; diff --git a/zone/gm_commands/movement.cpp b/zone/gm_commands/movement.cpp index f934f900c0..daaedd7a52 100755 --- a/zone/gm_commands/movement.cpp +++ b/zone/gm_commands/movement.cpp @@ -61,11 +61,11 @@ void command_movement(Client *c, const Seperator *sep) mgr.SendCommandToClients( target, - atof(sep->arg[2]), - atof(sep->arg[3]), - atof(sep->arg[4]), - atof(sep->arg[5]), - atoi(sep->arg[6]), + Strings::ToFloat(sep->arg[2]), + Strings::ToFloat(sep->arg[3]), + Strings::ToFloat(sep->arg[4]), + Strings::ToFloat(sep->arg[5]), + Strings::ToInt(sep->arg[6]), ClientRangeAny ); } diff --git a/zone/gm_commands/network.cpp b/zone/gm_commands/network.cpp index 1c35d28ec2..7f18e86ac8 100755 --- a/zone/gm_commands/network.cpp +++ b/zone/gm_commands/network.cpp @@ -86,11 +86,11 @@ void command_network(Client *c, const Seperator *sep) std::string value = sep->arg[3]; if (!strcasecmp(sep->arg[2], "max_connection_count")) { - opts.daybreak_options.max_connection_count = std::stoull(value); + opts.daybreak_options.max_connection_count = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "keepalive_delay_ms")) { - opts.daybreak_options.keepalive_delay_ms = std::stoull(value); + opts.daybreak_options.keepalive_delay_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "resend_delay_factor")) { @@ -98,51 +98,51 @@ void command_network(Client *c, const Seperator *sep) manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "resend_delay_ms")) { - opts.daybreak_options.resend_delay_ms = std::stoull(value); + opts.daybreak_options.resend_delay_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "resend_delay_min")) { - opts.daybreak_options.resend_delay_min = std::stoull(value); + opts.daybreak_options.resend_delay_min = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "resend_delay_max")) { - opts.daybreak_options.resend_delay_max = std::stoull(value); + opts.daybreak_options.resend_delay_max = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "connect_delay_ms")) { - opts.daybreak_options.connect_delay_ms = std::stoull(value); + opts.daybreak_options.connect_delay_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "connect_stale_ms")) { - opts.daybreak_options.connect_stale_ms = std::stoull(value); + opts.daybreak_options.connect_stale_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "stale_connection_ms")) { - opts.daybreak_options.stale_connection_ms = std::stoull(value); + opts.daybreak_options.stale_connection_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "hold_size")) { - opts.daybreak_options.hold_size = std::stoull(value); + opts.daybreak_options.hold_size = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "hold_length_ms")) { - opts.daybreak_options.hold_length_ms = std::stoull(value); + opts.daybreak_options.hold_length_ms = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "simulated_in_packet_loss")) { - opts.daybreak_options.simulated_in_packet_loss = std::stoull(value); + opts.daybreak_options.simulated_in_packet_loss = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "simulated_out_packet_loss")) { - opts.daybreak_options.simulated_out_packet_loss = std::stoull(value); + opts.daybreak_options.simulated_out_packet_loss = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "resend_timeout")) { - opts.daybreak_options.resend_timeout = std::stoull(value); + opts.daybreak_options.resend_timeout = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else if (!strcasecmp(sep->arg[2], "connection_close_time")) { - opts.daybreak_options.connection_close_time = std::stoull(value); + opts.daybreak_options.connection_close_time = Strings::ToUnsignedBigInt(value); manager->SetOptions(opts); } else { diff --git a/zone/gm_commands/npccast.cpp b/zone/gm_commands/npccast.cpp index 408e5e576f..14cdb8395f 100755 --- a/zone/gm_commands/npccast.cpp +++ b/zone/gm_commands/npccast.cpp @@ -10,7 +10,7 @@ void command_npccast(Client *c, const Seperator *sep) auto target = c->GetTarget()->CastToNPC(); if (!sep->IsNumber(1) && sep->arg[1] && sep->IsNumber(2)) { std::string entity_name = sep->arg[1] ? sep->arg[1] : 0; - auto spell_id = sep->arg[2] ? std::stoul(sep->arg[2]) : 0; + auto spell_id = sep->arg[2] ? Strings::ToUnsignedInt(sep->arg[2]) : 0; auto spell_target = entity_list.GetMob(entity_name.c_str()); if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { c->Message( @@ -45,8 +45,8 @@ void command_npccast(Client *c, const Seperator *sep) } } } else if (sep->IsNumber(1) && sep->IsNumber(2)) { - uint16 entity_id = static_cast(std::stoul(sep->arg[1])); - auto spell_id = std::stoul(sep->arg[2]); + uint16 entity_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); + auto spell_id = Strings::ToUnsignedInt(sep->arg[2]); auto spell_target = entity_list.GetMob(entity_id); if (spell_target && IsValidSpell(spell_id) && spell_id < SPDAT_RECORDS) { c->Message( diff --git a/zone/gm_commands/npcedit.cpp b/zone/gm_commands/npcedit.cpp index a55037d05b..26e449498c 100755 --- a/zone/gm_commands/npcedit.cpp +++ b/zone/gm_commands/npcedit.cpp @@ -59,7 +59,7 @@ void command_npcedit(Client *c, const Seperator *sep) ); } else if (!strcasecmp(sep->arg[1], "level")) { if (sep->IsNumber(2)) { - auto level = static_cast(std::stoul(sep->arg[2])); + auto level = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.level = level; d = fmt::format( "{} is now level {}.", @@ -72,7 +72,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "race")) { if (sep->IsNumber(2)) { - auto race_id = static_cast(std::stoul(sep->arg[2])); + auto race_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.race = race_id; d = fmt::format( "{} is now a(n) {} ({}).", @@ -86,7 +86,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "class")) { if (sep->IsNumber(2)) { - auto class_id = static_cast(std::stoul(sep->arg[2])); + auto class_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.class_ = class_id; d = fmt::format( "{} is now a(n) {} ({}).", @@ -100,7 +100,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "bodytype")) { if (sep->IsNumber(2)) { - auto body_type_id = static_cast(std::stoul(sep->arg[2])); + auto body_type_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); auto body_type_name = EQ::constants::GetBodyTypeName(static_cast(body_type_id)); n.bodytype = body_type_id; d = fmt::format( @@ -122,7 +122,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "hp")) { if (sep->IsNumber(2)) { - auto hp = std::stoll(sep->arg[2]); + auto hp = Strings::ToBigInt(sep->arg[2]); n.hp = hp; d = fmt::format( "{} now has {} Health.", @@ -135,7 +135,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "mana")) { if (sep->IsNumber(2)) { - auto mana = std::stoll(sep->arg[2]); + auto mana = Strings::ToBigInt(sep->arg[2]); n.mana = mana; d = fmt::format( "{} now has {} Mana.", @@ -148,7 +148,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "gender")) { if (sep->IsNumber(2)) { - auto gender_id = static_cast(std::stoul(sep->arg[2])); + auto gender_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.gender = gender_id; d = fmt::format( "{} is now a {} ({}).", @@ -162,7 +162,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "texture")) { if (sep->IsNumber(2)) { - auto texture = static_cast(std::stoul(sep->arg[2])); + auto texture = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.texture = texture; d = fmt::format( "{} is now using Texture {}.", @@ -175,7 +175,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "helmtexture")) { if (sep->IsNumber(2)) { - auto helmet_texture = static_cast(std::stoul(sep->arg[2])); + auto helmet_texture = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.helmtexture = helmet_texture; d = fmt::format( "{} is now using Helmet Texture {}.", @@ -188,7 +188,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "herosforgemodel")) { if (sep->IsNumber(2)) { - auto heros_forge_model = std::stoi(sep->arg[2]); + auto heros_forge_model = Strings::ToInt(sep->arg[2]); n.herosforgemodel = heros_forge_model; d = fmt::format( "{} is now using Hero's Forge Model {}.", @@ -204,7 +204,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "size")) { if (sep->IsNumber(2)) { - auto size = std::stof(sep->arg[2]); + auto size = Strings::ToFloat(sep->arg[2]); n.size = size; d = fmt::format( "{} is now Size {:.2f}.", @@ -217,7 +217,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "hpregen")) { if (sep->IsNumber(2)) { - auto hp_regen = std::stoll(sep->arg[2]); + auto hp_regen = Strings::ToBigInt(sep->arg[2]); n.hp_regen_rate = hp_regen; d = fmt::format( "{} now regenerates {} Health per Tick.", @@ -230,7 +230,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "hp_regen_per_second")) { if (sep->IsNumber(2)) { - auto hp_regen_per_second = std::stoll(sep->arg[2]); + auto hp_regen_per_second = Strings::ToBigInt(sep->arg[2]); n.hp_regen_per_second = hp_regen_per_second; d = fmt::format( "{} now regenerates {} HP per Second.", @@ -246,7 +246,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "manaregen")) { if (sep->IsNumber(2)) { - auto mana_regen = std::stoll(sep->arg[2]); + auto mana_regen = Strings::ToBigInt(sep->arg[2]); n.mana_regen_rate = mana_regen; d = fmt::format( "{} now regenerates {} Mana per Tick.", @@ -259,7 +259,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "loottable")) { if (sep->IsNumber(2)) { - auto loottable_id = std::stoul(sep->arg[2]); + auto loottable_id = Strings::ToUnsignedInt(sep->arg[2]); n.loottable_id = loottable_id; d = fmt::format( "{} is now using Loottable ID {}.", @@ -272,7 +272,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "merchantid")) { if (sep->IsNumber(2)) { - auto merchant_id = std::stoul(sep->arg[2]); + auto merchant_id = Strings::ToUnsignedInt(sep->arg[2]); n.merchant_id = merchant_id; d = fmt::format( "{} is now using Merchant ID {}.", @@ -285,7 +285,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "alt_currency_id")) { if (sep->IsNumber(2)) { - auto alternate_currency_id = std::stoul(sep->arg[2]); + auto alternate_currency_id = Strings::ToUnsignedInt(sep->arg[2]); auto alternate_currency_item_id = zone->GetCurrencyItemID(alternate_currency_id); n.alt_currency_id = alternate_currency_id; d = fmt::format( @@ -310,7 +310,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "spell")) { if (sep->IsNumber(2)) { - auto spell_list_id = std::stoul(sep->arg[2]); + auto spell_list_id = Strings::ToUnsignedInt(sep->arg[2]); n.npc_spells_id = spell_list_id; d = fmt::format( "{} is now using Spell List ID {}.", @@ -323,7 +323,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "npc_spells_effects_id")) { if (sep->IsNumber(2)) { - auto spell_effects_id = std::stoul(sep->arg[2]); + auto spell_effects_id = Strings::ToUnsignedInt(sep->arg[2]); n.npc_spells_effects_id = spell_effects_id; d = fmt::format( "{} is now using Spells Effects ID {}.", @@ -339,7 +339,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "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); n.npc_faction_id = faction_id; d = fmt::format( @@ -361,7 +361,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "adventure_template_id")) { if (sep->IsNumber(2)) { - auto adventure_template_id = std::stoul(sep->arg[2]); + auto adventure_template_id = Strings::ToUnsignedInt(sep->arg[2]); n.adventure_template_id = adventure_template_id; d = fmt::format( "{} is now using Adventure Template ID {}.", @@ -377,7 +377,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "trap_template")) { if (sep->IsNumber(2)) { - auto trap_template = std::stoul(sep->arg[2]); + auto trap_template = Strings::ToUnsignedInt(sep->arg[2]); n.trap_template = trap_template; d = fmt::format( "{} is now using Trap Template ID {}.", @@ -390,8 +390,8 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "damage")) { if (sep->IsNumber(2) && sep->IsNumber(3)) { - auto minimum_damage = std::stoul(sep->arg[2]); - auto maximum_damage = std::stoul(sep->arg[3]); + auto minimum_damage = Strings::ToUnsignedInt(sep->arg[2]); + auto maximum_damage = Strings::ToUnsignedInt(sep->arg[3]); n.mindmg = minimum_damage; n.maxdmg = maximum_damage; d = fmt::format( @@ -406,7 +406,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "attackcount")) { if (sep->IsNumber(2)) { - auto attack_count = static_cast(std::stoi(sep->arg[2])); + auto attack_count = static_cast(Strings::ToInt(sep->arg[2])); n.attack_count = attack_count; d = fmt::format( "{} now has an Attack Count of {}.", @@ -441,7 +441,7 @@ void command_npcedit(Client *c, const Seperator *sep) ); } else if (!strcasecmp(sep->arg[1], "aggroradius")) { if (sep->IsNumber(2)) { - auto aggro_radius = std::stoul(sep->arg[2]); + auto aggro_radius = Strings::ToUnsignedInt(sep->arg[2]); n.aggroradius = aggro_radius; d = fmt::format( "{} now has an Aggro Radius of {}.", @@ -454,7 +454,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "assistradius")) { if (sep->IsNumber(2)) { - auto assist_radius = std::stoul(sep->arg[2]); + auto assist_radius = Strings::ToUnsignedInt(sep->arg[2]); n.assistradius = assist_radius; d = fmt::format( "{} now has an Assist Radius of {}", @@ -487,7 +487,7 @@ void command_npcedit(Client *c, const Seperator *sep) n.drakkin_details = t->GetDrakkinDetails(); } else if (!strcasecmp(sep->arg[1], "armortint_id")) { if (sep->IsNumber(2)) { - auto armor_tint_id = std::stoul(sep->arg[2]); + auto armor_tint_id = Strings::ToUnsignedInt(sep->arg[2]); n.armortint_id = armor_tint_id; d = fmt::format( "{} is now using Armor Tint ID {}.", @@ -500,9 +500,9 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "color")) { if (sep->IsNumber(2)) { - auto red = static_cast(std::stoul(sep->arg[2])); - uint8_t green = sep->IsNumber(3) ? static_cast(std::stoul(sep->arg[3])) : 0; - uint8_t blue = sep->IsNumber(4) ? static_cast(std::stoul(sep->arg[4])) : 0; + auto red = static_cast(Strings::ToUnsignedInt(sep->arg[2])); + uint8_t green = sep->IsNumber(3) ? static_cast(Strings::ToUnsignedInt(sep->arg[3])) : 0; + uint8_t blue = sep->IsNumber(4) ? static_cast(Strings::ToUnsignedInt(sep->arg[4])) : 0; n.armortint_red = red; n.armortint_green = green; n.armortint_blue = blue; @@ -522,7 +522,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "ammoidfile")) { if (sep->IsNumber(2)) { - auto ammo_id_file = std::stoul(sep->arg[2]); + auto ammo_id_file = Strings::ToUnsignedInt(sep->arg[2]); n.ammo_idfile = ammo_id_file; d = fmt::format( "{} is now using Ammo ID File {}.", @@ -535,8 +535,8 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "weapon")) { if (sep->IsNumber(2)) { - auto primary_model = std::stoul(sep->arg[2]); - uint32_t secondary_model = sep->arg[3] && sep->IsNumber(3) ? std::stoul(sep->arg[3]) : 0; + auto primary_model = Strings::ToUnsignedInt(sep->arg[2]); + uint32_t secondary_model = sep->arg[3] && sep->IsNumber(3) ? Strings::ToUnsignedInt(sep->arg[3]) : 0; n.d_melee_texture1 = primary_model; n.d_melee_texture2 = secondary_model; d = fmt::format( @@ -554,8 +554,8 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "meleetype")) { if (sep->IsNumber(2)) { - auto primary_type = std::stoul(sep->arg[2]); - uint32_t secondary_type = sep->IsNumber(3) ? std::stoul(sep->arg[3]) : 0; + auto primary_type = Strings::ToUnsignedInt(sep->arg[2]); + uint32_t secondary_type = sep->IsNumber(3) ? Strings::ToUnsignedInt(sep->arg[3]) : 0; auto primary_skill = EQ::skills::GetSkillName(static_cast(primary_type)); auto secondary_skill = EQ::skills::GetSkillName(static_cast(secondary_type)); @@ -594,7 +594,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "rangedtype")) { if (sep->IsNumber(2)) { - auto ranged_type = std::stoul(sep->arg[2]); + auto ranged_type = Strings::ToUnsignedInt(sep->arg[2]); auto ranged_skill = EQ::skills::GetSkillName(static_cast(ranged_type)); @@ -619,7 +619,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "runspeed")) { if (sep->IsNumber(2)) { - auto run_speed = std::stof(sep->arg[2]); + auto run_speed = Strings::ToFloat(sep->arg[2]); n.runspeed = run_speed; d = fmt::format( "{} now runs at a Run Speed of {:.2f}.", @@ -632,7 +632,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "mr")) { if (sep->IsNumber(2)) { - auto magic_resist = static_cast(std::stoul(sep->arg[2])); + auto magic_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.MR = magic_resist; d = fmt::format( "{} now has a Magic Resistance of {}.", @@ -645,7 +645,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "pr")) { if (sep->IsNumber(2)) { - auto poison_resist = static_cast(std::stoul(sep->arg[2])); + auto poison_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.PR = poison_resist; d = fmt::format( "{} now has a Poison Resistance of {}.", @@ -658,7 +658,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "dr")) { if (sep->IsNumber(2)) { - auto disease_resist = static_cast(std::stoul(sep->arg[2])); + auto disease_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.DR = disease_resist; d = fmt::format( "{} now has a Disease Resistance of {}.", @@ -671,7 +671,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "fr")) { if (sep->IsNumber(2)) { - auto fire_resist = static_cast(std::stoul(sep->arg[2])); + auto fire_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.FR = fire_resist; d = fmt::format( "{} now has a Fire Resistance of {}.", @@ -684,7 +684,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "cr")) { if (sep->IsNumber(2)) { - auto cold_resist = static_cast(std::stoul(sep->arg[2])); + auto cold_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.CR = cold_resist; d = fmt::format( "{} now has a Cold Resistance of {}.", @@ -697,7 +697,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "corrup")) { if (sep->IsNumber(2)) { - auto corruption_resist = static_cast(std::stoul(sep->arg[2])); + auto corruption_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.Corrup = corruption_resist; d = fmt::format( "{} now has a Corruption Resistance of {}.", @@ -710,7 +710,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "phr")) { if (sep->IsNumber(2)) { - auto physical_resist = static_cast(std::stoul(sep->arg[2])); + auto physical_resist = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.PhR = physical_resist; d = fmt::format( "{} now has a Physical Resistance of {}.", @@ -723,7 +723,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "seeinvis")) { if (sep->IsNumber(2)) { - auto see_invisible = static_cast(std::stoul(sep->arg[2])); + auto see_invisible = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.see_invis = see_invisible; d = fmt::format( "{} can {} See Invisible.", @@ -739,7 +739,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "seeinvisundead")) { if (sep->IsNumber(2)) { - auto see_invisible_undead = static_cast(std::stoul(sep->arg[2])); + auto see_invisible_undead = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.see_invis_undead = see_invisible_undead; d = fmt::format( "{} can {} See Invisible vs. Undead.", @@ -755,7 +755,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "qglobal")) { if (sep->IsNumber(2)) { - auto use_qglobals = std::stoul(sep->arg[2]); + auto use_qglobals = Strings::ToUnsignedInt(sep->arg[2]); n.qglobal = use_qglobals; d = fmt::format( "{} can {} use Quest Globals.", @@ -771,7 +771,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "ac")) { if (sep->IsNumber(2)) { - auto armor_class = static_cast(std::stoul(sep->arg[2])); + auto armor_class = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.AC = armor_class; d = fmt::format( "{} now has {} Armor Class.", @@ -784,7 +784,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "npcaggro")) { if (sep->IsNumber(2)) { - auto aggro_npcs = static_cast(std::stoul(sep->arg[2])); + auto aggro_npcs = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.npc_aggro = aggro_npcs; d = fmt::format( "{} will {} aggro other NPCs that have a hostile faction.", @@ -800,7 +800,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "spawn_limit")) { if (sep->IsNumber(2)) { - auto spawn_limit = static_cast(std::stoul(sep->arg[2])); + auto spawn_limit = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.spawn_limit = spawn_limit; d = fmt::format( "{} now has a Spawn Limit of {}.", @@ -813,7 +813,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "attackspeed")) { if (sep->IsNumber(2)) { - auto attack_speed = std::stof(sep->arg[2]); + auto attack_speed = Strings::ToFloat(sep->arg[2]); n.attack_speed = attack_speed; d = fmt::format( "{} now has an Attack Speed of {:.2f}.", @@ -826,7 +826,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "attackdelay")) { if (sep->IsNumber(2)) { - auto attack_delay = static_cast(std::stoul(sep->arg[2])); + auto attack_delay = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.attack_delay = attack_delay; d = fmt::format( "{} now has an Attack Delay of {}.", @@ -839,7 +839,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "findable")) { if (sep->IsNumber(2)) { - auto is_findable = static_cast(std::stoul(sep->arg[2])); + auto is_findable = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.findable = is_findable; d = fmt::format( "{} is {} Findable.", @@ -855,7 +855,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "str")) { if (sep->IsNumber(2)) { - auto strength = std::stoul(sep->arg[2]); + auto strength = Strings::ToUnsignedInt(sep->arg[2]); n.STR = strength; d = fmt::format( "{} now has {} Strength.", @@ -868,7 +868,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "sta")) { if (sep->IsNumber(2)) { - auto stamina = std::stoul(sep->arg[2]); + auto stamina = Strings::ToUnsignedInt(sep->arg[2]); n.STA = stamina; d = fmt::format( "{} now has {} Stamina.", @@ -881,7 +881,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "agi")) { if (sep->IsNumber(2)) { - auto agility = std::stoul(sep->arg[2]); + auto agility = Strings::ToUnsignedInt(sep->arg[2]); n.AGI = agility; d = fmt::format( "{} now has {} Agility.", @@ -894,7 +894,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "dex")) { if (sep->IsNumber(2)) { - auto dexterity = std::stoul(sep->arg[2]); + auto dexterity = Strings::ToUnsignedInt(sep->arg[2]); n.DEX = dexterity; d = fmt::format( "{} now has {} Dexterity.", @@ -907,7 +907,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "int")) { if (sep->IsNumber(2)) { - auto intelligence = std::stoul(sep->arg[2]); + auto intelligence = Strings::ToUnsignedInt(sep->arg[2]); n._INT = intelligence; d = fmt::format( "{} now has {} Intelligence.", @@ -920,7 +920,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "wis")) { if (sep->IsNumber(2)) { - auto wisdom = std::stoul(sep->arg[2]); + auto wisdom = Strings::ToUnsignedInt(sep->arg[2]); n.WIS = wisdom; d = fmt::format( "{} now has {} Wisdom.", @@ -933,7 +933,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "cha")) { if (sep->IsNumber(2)) { - auto charisma = std::stoul(sep->arg[2]); + auto charisma = Strings::ToUnsignedInt(sep->arg[2]); n.CHA = charisma; d = fmt::format( "{} now has {} Charisma.", @@ -946,7 +946,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "seehide")) { if (sep->IsNumber(2)) { - auto see_hide = static_cast(std::stoi(sep->arg[2])); + auto see_hide = static_cast(Strings::ToInt(sep->arg[2])); n.see_hide = see_hide; d = fmt::format( "{} can {} See Hide.", @@ -962,7 +962,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "seeimprovedhide")) { if (sep->IsNumber(2)) { - auto see_improved_hide = static_cast(std::stoi(sep->arg[2])); + auto see_improved_hide = static_cast(Strings::ToInt(sep->arg[2])); n.see_improved_hide = see_improved_hide; d = fmt::format( "{} can {} See Improved Hide.", @@ -978,7 +978,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "trackable")) { if (sep->IsNumber(2)) { - auto is_trackable = static_cast(std::stoi(sep->arg[2])); + auto is_trackable = static_cast(Strings::ToInt(sep->arg[2])); n.trackable = is_trackable; d = fmt::format( "{} is {} Trackable.", @@ -994,7 +994,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "atk")) { if (sep->IsNumber(2)) { - auto attack = std::stoi(sep->arg[2]); + auto attack = Strings::ToInt(sep->arg[2]); n.ATK = attack; d = fmt::format( "{} now has {} Attack.", @@ -1007,7 +1007,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "accuracy")) { if (sep->IsNumber(2)) { - auto accuracy = std::stoi(sep->arg[2]); + auto accuracy = Strings::ToInt(sep->arg[2]); n.Accuracy = accuracy; d = fmt::format( "{} now has {} Accuracy.", @@ -1020,7 +1020,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "avoidance")) { if (sep->IsNumber(2)) { - auto avoidance = std::stoul(sep->arg[2]); + auto avoidance = Strings::ToUnsignedInt(sep->arg[2]); n.Avoidance = avoidance; d = fmt::format( "{} now has {} Avoidance.", @@ -1033,7 +1033,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "slow_mitigation")) { if (sep->IsNumber(2)) { - auto slow_mitigation = static_cast(std::stoi(sep->arg[2])); + auto slow_mitigation = static_cast(Strings::ToInt(sep->arg[2])); n.slow_mitigation = slow_mitigation; d = fmt::format( "{} now has {} Slow Mitigation.", @@ -1049,7 +1049,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "version")) { if (sep->IsNumber(2)) { - auto version = static_cast(std::stoul(sep->arg[2])); + auto version = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.version = version; d = fmt::format( "{} is now using Version {}.", @@ -1062,7 +1062,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "maxlevel")) { if (sep->IsNumber(2)) { - auto max_level = static_cast(std::stoi(sep->arg[2])); + auto max_level = static_cast(Strings::ToInt(sep->arg[2])); n.maxlevel = max_level; d = fmt::format( "{} now has a Maximum Level of {}.", @@ -1075,7 +1075,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "scalerate")) { if (sep->IsNumber(2)) { - auto scale_rate = std::stoi(sep->arg[2]); + auto scale_rate = Strings::ToInt(sep->arg[2]); n.scalerate = scale_rate; d = fmt::format( "{} now has a Scaling Rate of {}%%.", @@ -1091,7 +1091,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "spellscale")) { if (sep->IsNumber(2)) { - auto spell_scale = std::stoul(sep->arg[2]); + auto spell_scale = Strings::ToUnsignedInt(sep->arg[2]); n.spellscale = static_cast(spell_scale); d = fmt::format( "{} now has a Spell Scaling Rate of {}%%.", @@ -1107,7 +1107,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "healscale")) { if (sep->IsNumber(2)) { - auto heal_scale = std::stoul(sep->arg[2]); + auto heal_scale = Strings::ToUnsignedInt(sep->arg[2]); n.healscale = static_cast(heal_scale); d = fmt::format( "{} now has a Heal Scaling Rate of {}%%.", @@ -1123,7 +1123,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "no_target")) { if (sep->IsNumber(2)) { - auto is_no_target = static_cast(std::stoul(sep->arg[2])); + auto is_no_target = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.no_target_hotkey = is_no_target; d = fmt::format( "{} is {} Targetable with Target Hotkey.", @@ -1139,7 +1139,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "raidtarget")) { if (sep->IsNumber(2)) { - auto is_raid_target = static_cast(std::stoul(sep->arg[2])); + auto is_raid_target = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.raid_target = is_raid_target; d = fmt::format( "{} is {} designated as a Raid Target.", @@ -1155,7 +1155,7 @@ void command_npcedit(Client *c, const Seperator *sep) return; } else if (!strcasecmp(sep->arg[1], "armtexture")) { if (sep->IsNumber(2)) { - auto arm_texture = static_cast(std::stoi(sep->arg[2])); + auto arm_texture = static_cast(Strings::ToInt(sep->arg[2])); n.armtexture = arm_texture; d = fmt::format( "{} is now using Arm Texture {}.", @@ -1168,7 +1168,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "bracertexture")) { if (sep->IsNumber(2)) { - auto bracer_texture = static_cast(std::stoi(sep->arg[2])); + auto bracer_texture = static_cast(Strings::ToInt(sep->arg[2])); n.bracertexture = bracer_texture; d = fmt::format( "{} is now using Bracer Texture {}.", @@ -1181,7 +1181,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "handtexture")) { if (sep->IsNumber(2)) { - auto hand_texture = static_cast(std::stoi(sep->arg[2])); + auto hand_texture = static_cast(Strings::ToInt(sep->arg[2])); n.handtexture = hand_texture; d = fmt::format( "{} is now using Hand Texture {}.", @@ -1194,7 +1194,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "legtexture")) { if (sep->IsNumber(2)) { - auto leg_texture = static_cast(std::stoi(sep->arg[2])); + auto leg_texture = static_cast(Strings::ToInt(sep->arg[2])); n.legtexture = leg_texture; d = fmt::format( "{} is now using Leg Texture {}.", @@ -1207,7 +1207,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "feettexture")) { if (sep->IsNumber(2)) { - auto feet_texture = static_cast(std::stoi(sep->arg[2])); + auto feet_texture = static_cast(Strings::ToInt(sep->arg[2])); n.feettexture = feet_texture; d = fmt::format( "{} is now using Feet Texture {}.", @@ -1220,7 +1220,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "walkspeed")) { if (sep->IsNumber(2)) { - auto walk_speed = static_cast(std::stoi(sep->arg[2])); + auto walk_speed = static_cast(Strings::ToInt(sep->arg[2])); n.walkspeed = walk_speed; d = fmt::format( "{} now walks at a Walk Speed of {}.", @@ -1233,7 +1233,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "show_name")) { if (sep->IsNumber(2)) { - auto show_name = static_cast(std::stoi(sep->arg[2])); + auto show_name = static_cast(Strings::ToInt(sep->arg[2])); n.show_name = show_name; d = fmt::format( "{} will {} show their name.", @@ -1249,7 +1249,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "untargetable")) { if (sep->IsNumber(2)) { - auto is_untargetable = static_cast(std::stoi(sep->arg[2])); + auto is_untargetable = static_cast(Strings::ToInt(sep->arg[2])); n.untargetable = is_untargetable; d = fmt::format( "{} will {} be untargetable.", @@ -1265,7 +1265,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_ac")) { if (sep->IsNumber(2)) { - auto charm_armor_class = static_cast(std::stoi(sep->arg[2])); + auto charm_armor_class = static_cast(Strings::ToInt(sep->arg[2])); n.charm_ac = charm_armor_class; d = fmt::format( "{} now has {} Armor Class while Charmed.", @@ -1278,7 +1278,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_min_dmg")) { if (sep->IsNumber(2)) { - auto charm_minimum_damage = std::stoi(sep->arg[2]); + auto charm_minimum_damage = Strings::ToInt(sep->arg[2]); n.charm_min_dmg = charm_minimum_damage; d = fmt::format( "{} now does {} Minimum Damage while Charmed.", @@ -1294,7 +1294,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_max_dmg")) { if (sep->IsNumber(2)) { - auto charm_maximum_damage = std::stoi(sep->arg[2]); + auto charm_maximum_damage = Strings::ToInt(sep->arg[2]); n.charm_max_dmg = charm_maximum_damage; d = fmt::format( "{} now does {} Maximum Damage while Charmed.", @@ -1310,7 +1310,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_attack_delay")) { if (sep->IsNumber(2)) { - auto charm_attack_delay = static_cast(std::stoi(sep->arg[2])); + auto charm_attack_delay = static_cast(Strings::ToInt(sep->arg[2])); n.charm_attack_delay = charm_attack_delay; d = fmt::format( "{} now has {} Attack Delay while Charmed.", @@ -1326,7 +1326,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_accuracy_rating")) { if (sep->IsNumber(2)) { - auto charm_accuracy_rating = std::stoi(sep->arg[2]); + auto charm_accuracy_rating = Strings::ToInt(sep->arg[2]); n.charm_accuracy_rating = charm_accuracy_rating; d = fmt::format( "{} now has {} Accuracy Rating while Charmed.", @@ -1342,7 +1342,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_avoidance_rating")) { if (sep->IsNumber(2)) { - auto charm_avoidance_rating = std::stoi(sep->arg[2]); + auto charm_avoidance_rating = Strings::ToInt(sep->arg[2]); n.charm_avoidance_rating = charm_avoidance_rating; d = fmt::format( "{} now has {} Avoidance Rating while Charmed.", @@ -1358,7 +1358,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "charm_atk")) { if (sep->IsNumber(2)) { - auto charm_attack = std::stoi(sep->arg[2]); + auto charm_attack = Strings::ToInt(sep->arg[2]); n.charm_atk = charm_attack; d = fmt::format( "{} now has {} Attack while Charmed.", @@ -1371,7 +1371,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "skip_global_loot")) { if (sep->IsNumber(2)) { - auto skip_global_loot = static_cast(std::stoi(sep->arg[2])); + auto skip_global_loot = static_cast(Strings::ToInt(sep->arg[2])); n.skip_global_loot = skip_global_loot; d = fmt::format( "{} will {} skip Global Loot.", @@ -1387,7 +1387,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "rarespawn")) { if (sep->IsNumber(2)) { - auto is_rare_spawn = static_cast(std::stoi(sep->arg[2])); + auto is_rare_spawn = static_cast(Strings::ToInt(sep->arg[2])); n.rare_spawn = is_rare_spawn; d = fmt::format( "{} is {} designated as a Rare Spawn.", @@ -1403,7 +1403,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "stuck_behavior")) { if (sep->IsNumber(2)) { - auto behavior_id = static_cast(std::stoi(sep->arg[2])); + auto behavior_id = static_cast(Strings::ToInt(sep->arg[2])); if (behavior_id > EQ::constants::StuckBehavior::EvadeCombat) { behavior_id = EQ::constants::StuckBehavior::EvadeCombat; } @@ -1432,7 +1432,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "flymode")) { if (sep->IsNumber(2)) { - auto flymode_id = static_cast(std::stoi(sep->arg[2])); + auto flymode_id = static_cast(Strings::ToInt(sep->arg[2])); if (flymode_id > GravityBehavior::LevitateWhileRunning) { flymode_id = GravityBehavior::LevitateWhileRunning; } @@ -1461,7 +1461,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "always_aggro")) { if (sep->IsNumber(2)) { - auto always_aggro = static_cast(std::stoi(sep->arg[2])); + auto always_aggro = static_cast(Strings::ToInt(sep->arg[2])); n.always_aggro = always_aggro; d = fmt::format( "{} will {} Always Aggro.", @@ -1477,7 +1477,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "exp_mod")) { if (sep->IsNumber(2)) { - auto experience_modifier = std::stoi(sep->arg[2]); + auto experience_modifier = Strings::ToInt(sep->arg[2]); n.exp_mod = experience_modifier; d = fmt::format( "{} now has an Experience Modifier of {}%%.", @@ -1493,7 +1493,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "keeps_sold_items")) { if (sep->IsNumber(2)) { - auto keeps_sold_items = static_cast(std::stoul(sep->arg[2])); + auto keeps_sold_items = static_cast(Strings::ToUnsignedInt(sep->arg[2])); n.keeps_sold_items = keeps_sold_items; d = fmt::format( "{} will {} Keep Sold Items.", @@ -1509,7 +1509,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "setanimation")) { if (sep->IsNumber(2)) { - auto animation_id = std::stoul(sep->arg[2]); + auto animation_id = Strings::ToUnsignedInt(sep->arg[2]); if (animation_id > EQ::constants::SpawnAnimations::Looting) { animation_id = EQ::constants::SpawnAnimations::Looting; } @@ -1546,7 +1546,7 @@ void command_npcedit(Client *c, const Seperator *sep) } } else if (!strcasecmp(sep->arg[1], "respawntime")) { if (sep->IsNumber(2)) { - auto respawn_time = std::stoul(sep->arg[2]); + auto respawn_time = Strings::ToUnsignedInt(sep->arg[2]); if (respawn_time) { d = fmt::format( "{} now has a Respawn Timer of {} ({}) on Spawn Group ID {}.", diff --git a/zone/gm_commands/npcloot.cpp b/zone/gm_commands/npcloot.cpp index a3c50854f1..2bb8873bb5 100755 --- a/zone/gm_commands/npcloot.cpp +++ b/zone/gm_commands/npcloot.cpp @@ -42,15 +42,15 @@ void command_npcloot(Client *c, const Seperator *sep) return; } - auto item_id = std::stoul(sep->arg[2]); - auto item_charges = sep->IsNumber(3) ? static_cast(std::stoul(sep->arg[3])) : 1; + auto item_id = Strings::ToUnsignedInt(sep->arg[2]); + auto item_charges = sep->IsNumber(3) ? static_cast(Strings::ToUnsignedInt(sep->arg[3])) : 1; bool equip_item = arguments >= 4 ? atobool(sep->arg[4]) : false; - auto augment_one_id = sep->IsNumber(5) ? std::stoul(sep->arg[5]) : 0; - auto augment_two_id = sep->IsNumber(6) ? std::stoul(sep->arg[6]) : 0; - auto augment_three_id = sep->IsNumber(7) ? std::stoul(sep->arg[7]) : 0; - auto augment_four_id = sep->IsNumber(8) ? std::stoul(sep->arg[8]) : 0; - auto augment_five_id = sep->IsNumber(9) ? std::stoul(sep->arg[9]) : 0; - auto augment_six_id = sep->IsNumber(10) ? std::stoul(sep->arg[10]) : 0; + auto augment_one_id = sep->IsNumber(5) ? Strings::ToUnsignedInt(sep->arg[5]) : 0; + auto augment_two_id = sep->IsNumber(6) ? Strings::ToUnsignedInt(sep->arg[6]) : 0; + auto augment_three_id = sep->IsNumber(7) ? Strings::ToUnsignedInt(sep->arg[7]) : 0; + auto augment_four_id = sep->IsNumber(8) ? Strings::ToUnsignedInt(sep->arg[8]) : 0; + auto augment_five_id = sep->IsNumber(9) ? Strings::ToUnsignedInt(sep->arg[9]) : 0; + auto augment_six_id = sep->IsNumber(10) ? Strings::ToUnsignedInt(sep->arg[10]) : 0; auto item_data = database.GetItem(item_id); @@ -114,10 +114,10 @@ void command_npcloot(Client *c, const Seperator *sep) auto target = c->GetTarget()->CastToNPC(); if (sep->IsNumber(2)) { - uint16 platinum = EQ::Clamp(std::stoi(sep->arg[2]), 0, 65535); - uint16 gold = sep->IsNumber(3) ? EQ::Clamp(std::stoi(sep->arg[3]), 0, 65535) : 0; - uint16 silver = sep->IsNumber(4) ? EQ::Clamp(std::stoi(sep->arg[4]), 0, 65535) : 0; - uint16 copper = sep->IsNumber(5) ? EQ::Clamp(std::stoi(sep->arg[5]), 0, 65535) : 0; + uint16 platinum = EQ::Clamp(Strings::ToInt(sep->arg[2]), 0, 65535); + uint16 gold = sep->IsNumber(3) ? EQ::Clamp(Strings::ToInt(sep->arg[3]), 0, 65535) : 0; + uint16 silver = sep->IsNumber(4) ? EQ::Clamp(Strings::ToInt(sep->arg[4]), 0, 65535) : 0; + uint16 copper = sep->IsNumber(5) ? EQ::Clamp(Strings::ToInt(sep->arg[5]), 0, 65535) : 0; target->AddCash( copper, silver, @@ -204,7 +204,7 @@ void command_npcloot(Client *c, const Seperator *sep) } } else { if (sep->IsNumber(2)) { - auto item_id = std::stoul(sep->arg[2]); + auto item_id = Strings::ToUnsignedInt(sep->arg[2]); auto item_count = target->CountItem(item_id); if (item_count) { target->RemoveItem(item_id); diff --git a/zone/gm_commands/npcspawn.cpp b/zone/gm_commands/npcspawn.cpp index a6ea888991..8c18152141 100755 --- a/zone/gm_commands/npcspawn.cpp +++ b/zone/gm_commands/npcspawn.cpp @@ -36,7 +36,7 @@ void command_npcspawn(Client *c, const Seperator *sep) sep->IsNumber(2) ? ( is_add ? - std::stoi(sep->arg[2]) : + Strings::ToInt(sep->arg[2]) : 1 ) : ( is_add ? diff --git a/zone/gm_commands/npctypespawn.cpp b/zone/gm_commands/npctypespawn.cpp index 81d47cfcdb..9bbc77ba7b 100755 --- a/zone/gm_commands/npctypespawn.cpp +++ b/zone/gm_commands/npctypespawn.cpp @@ -8,7 +8,7 @@ void command_npctypespawn(Client *c, const Seperator *sep) return; } - auto npc_id = std::stoul(sep->arg[1]); + auto npc_id = Strings::ToUnsignedInt(sep->arg[1]); int faction_id = 0; auto npc_type = content_db.LoadNPCTypesData(npc_id); @@ -16,7 +16,7 @@ void command_npctypespawn(Client *c, const Seperator *sep) auto npc = new NPC(npc_type, 0, c->GetPosition(), GravityBehavior::Water); if (npc) { if (sep->IsNumber(2)) { - faction_id = std::stoi(sep->arg[2]); + faction_id = Strings::ToInt(sep->arg[2]); npc->SetNPCFactionID(faction_id); } diff --git a/zone/gm_commands/nudge.cpp b/zone/gm_commands/nudge.cpp index 0d80acacdf..d1219261ea 100755 --- a/zone/gm_commands/nudge.cpp +++ b/zone/gm_commands/nudge.cpp @@ -39,16 +39,16 @@ void command_nudge(Client *c, const Seperator *sep) switch (argsep.arg[0][0]) { case 'x': - position_offset.x = std::stof(argsep.arg[1]); + position_offset.x = Strings::ToFloat(argsep.arg[1]); break; case 'y': - position_offset.y = std::stof(argsep.arg[1]); + position_offset.y = Strings::ToFloat(argsep.arg[1]); break; case 'z': - position_offset.z = std::stof(argsep.arg[1]); + position_offset.z = Strings::ToFloat(argsep.arg[1]); break; case 'h': - position_offset.w = std::stof(argsep.arg[1]); + position_offset.w = Strings::ToFloat(argsep.arg[1]); break; default: break; diff --git a/zone/gm_commands/nukeitem.cpp b/zone/gm_commands/nukeitem.cpp index d31cba7aa8..0918ce1e01 100755 --- a/zone/gm_commands/nukeitem.cpp +++ b/zone/gm_commands/nukeitem.cpp @@ -12,8 +12,8 @@ void command_nukeitem(Client *c, const Seperator *sep) if (c->GetTarget() && c->GetTarget()->IsClient()) { target = c->GetTarget()->CastToClient(); } - - auto item_id = std::stoi(sep->arg[1]); + + auto item_id = Strings::ToInt(sep->arg[1]); auto deleted_count = target->NukeItem(item_id); if (deleted_count) { c->Message( diff --git a/zone/gm_commands/object.cpp b/zone/gm_commands/object.cpp index 0784ec2d2f..df8f090f8b 100755 --- a/zone/gm_commands/object.cpp +++ b/zone/gm_commands/object.cpp @@ -50,7 +50,7 @@ void command_object(Client *c, const Seperator *sep) if ((sep->arg[2][0] & 0xDF) == 'A') { radius = 0; // List All } - else if ((radius = atoi(sep->arg[2])) <= 0) { + else if ((radius = Strings::ToInt(sep->arg[2])) <= 0) { radius = 500; } // Invalid radius. Default to 500 units. @@ -89,21 +89,21 @@ void command_object(Client *c, const Seperator *sep) } for (auto row = results.begin(); row != results.end(); ++row) { - id = atoi(row[0]); - od.x = atof(row[1]); - od.y = atof(row[2]); - od.z = atof(row[3]); - od.heading = atof(row[4]); - itemid = atoi(row[5]); + id = Strings::ToInt(row[0]); + od.x = Strings::ToFloat(row[1]); + od.y = Strings::ToFloat(row[2]); + od.z = Strings::ToFloat(row[3]); + od.heading = Strings::ToFloat(row[4]); + itemid = Strings::ToInt(row[5]); strn0cpy(od.object_name, row[6], sizeof(od.object_name)); od.object_name[sizeof(od.object_name) - 1] = '\0'; // Required if strlen(row[col++]) exactly == sizeof(object_name) - od.object_type = atoi(row[7]); - icon = atoi(row[8]); - od.size = atoi(row[9]); - od.solidtype = atoi(row[10]); - od.unknown020 = atoi(row[11]); + od.object_type = Strings::ToInt(row[7]); + icon = Strings::ToInt(row[8]); + od.size = Strings::ToInt(row[9]); + od.solidtype = Strings::ToInt(row[10]); + od.unknown020 = Strings::ToInt(row[11]); switch (od.object_type) { case 0: // Static Object @@ -162,7 +162,7 @@ void command_object(Client *c, const Seperator *sep) if (sep->argnum > 3) { // Model name in arg3? if ((sep->arg[3][0] <= '9') && (sep->arg[3][0] >= '0')) { // Nope, user must have specified ObjectID. Extract it. - id = atoi(sep->arg[2]); + id = Strings::ToInt(sep->arg[2]); col = 1; // Bump all other arguments one to the right. Model is in arg4. } else { @@ -179,18 +179,18 @@ void command_object(Client *c, const Seperator *sep) memset(&od, 0, sizeof(od)); - od.object_type = atoi(sep->arg[2 + col]); + od.object_type = Strings::ToInt(sep->arg[2 + col]); switch (od.object_type) { case 0: // Static Object if ((sep->argnum - col) > 3) { - od.size = atoi(sep->arg[4 + col]); // Size specified + od.size = Strings::ToInt(sep->arg[4 + col]); // Size specified if ((sep->argnum - col) > 4) { - od.solidtype = atoi(sep->arg[5 + col]); // SolidType specified + od.solidtype = Strings::ToInt(sep->arg[5 + col]); // SolidType specified if ((sep->argnum - col) > 5) { - od.unknown020 = atoi(sep->arg[6 + col]); + od.unknown020 = Strings::ToInt(sep->arg[6 + col]); } // Incline specified } } @@ -205,7 +205,7 @@ void command_object(Client *c, const Seperator *sep) return; default: // Everything else == Tradeskill Object - icon = ((sep->argnum - col) > 3) ? atoi(sep->arg[4 + col]) : 0; + icon = ((sep->argnum - col) > 3) ? Strings::ToInt(sep->arg[4 + col]) : 0; if (icon == 0) { c->Message(Chat::White, "ERROR: Required property 'Icon' not specified for Tradeskill Object"); @@ -227,7 +227,7 @@ void command_object(Client *c, const Seperator *sep) auto results = content_db.QueryDatabase(query); if (results.Success() && results.RowCount() != 0) { auto row = results.begin(); - if (atoi(row[0]) > 0) { // Yep, in database already. + if (Strings::ToInt(row[0]) > 0) { // Yep, in database already. id = 0; } } @@ -239,7 +239,7 @@ void command_object(Client *c, const Seperator *sep) } if (id == 0) { - c->Message(Chat::White, "ERROR: An object already exists with the id %u", atoi(sep->arg[2])); + c->Message(Chat::White, "ERROR: An object already exists with the id %u", Strings::ToInt(sep->arg[2])); return; } } @@ -260,7 +260,7 @@ void command_object(Client *c, const Seperator *sep) auto results = content_db.QueryDatabase(query); if (results.Success() && results.RowCount() != 0) { auto row = results.begin(); - objectsFound = atoi(row[0]); // Number of nearby objects from database + objectsFound = Strings::ToInt(row[0]); // Number of nearby objects from database } // No objects found in database too close. How about spawned but not yet saved? @@ -304,7 +304,7 @@ void command_object(Client *c, const Seperator *sep) results = content_db.QueryDatabase(query); if (results.Success() && results.RowCount() != 0) { auto row = results.begin(); - id = atoi(row[0]); + id = Strings::ToInt(row[0]); } id++; @@ -352,7 +352,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "edit") == 0) { - if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) < 1)) { + if ((sep->argnum < 2) || ((id = Strings::ToInt(sep->arg[2])) < 1)) { c->Message(Chat::White, "Usage: #object Edit (ObjectID) [PropertyName] [NewValue]"); c->Message(Chat::White, "- Static Object (Type 0) Properties: model, type, size, solidtype, incline"); c->Message(Chat::White, "- Tradeskill Object (Type 2+) Properties: model, type, icon"); @@ -381,9 +381,9 @@ void command_object(Client *c, const Seperator *sep) } auto row = results.begin(); - od.zone_id = atoi(row[0]); - od.zone_instance = atoi(row[1]); - od.object_type = atoi(row[2]); + od.zone_id = Strings::ToInt(row[0]); + od.zone_instance = Strings::ToInt(row[1]); + od.object_type = Strings::ToInt(row[2]); uint32 objectsFound = 1; // Object not in this zone? @@ -471,7 +471,7 @@ void command_object(Client *c, const Seperator *sep) return; } - od.object_type = atoi(sep->arg[4]); + od.object_type = Strings::ToInt(sep->arg[4]); switch (od.object_type) { case 0: @@ -514,7 +514,7 @@ void command_object(Client *c, const Seperator *sep) return; } - od.size = atoi(sep->arg[4]); + od.size = Strings::ToInt(sep->arg[4]); o->SetObjectData(&od); if (od.size == 0) { // 0 == unspecified == 100% @@ -544,7 +544,7 @@ void command_object(Client *c, const Seperator *sep) return; } - od.solidtype = atoi(sep->arg[4]); + od.solidtype = Strings::ToInt(sep->arg[4]); o->SetObjectData(&od); c->Message( @@ -565,7 +565,7 @@ void command_object(Client *c, const Seperator *sep) return; } - if ((icon = atoi(sep->arg[4])) == 0) { + if ((icon = Strings::ToInt(sep->arg[4])) == 0) { c->Message(Chat::White, "ERROR: Invalid Icon specified. Please enter an icon number."); return; } @@ -591,7 +591,7 @@ void command_object(Client *c, const Seperator *sep) return; } - od.unknown020 = atoi(sep->arg[4]); + od.unknown020 = Strings::ToInt(sep->arg[4]); o->SetObjectData(&od); c->Message( @@ -622,7 +622,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "move") == 0) { if ((sep->argnum < 2) || // Not enough arguments - ((id = atoi(sep->arg[2])) == 0) || // ID not specified + ((id = Strings::ToInt(sep->arg[2])) == 0) || // ID not specified (((sep->arg[3][0] < '0') || (sep->arg[3][0] > '9')) && ((sep->arg[3][0] & 0xDF) != 'T') && (sep->arg[3][0] != '-') && (sep->arg[3][0] != '.'))) { // Location argument not specified correctly c->Message(Chat::White, "Usage: #object Move (ObjectID) ToMe|(x y z [h])"); @@ -638,9 +638,9 @@ void command_object(Client *c, const Seperator *sep) } auto row = results.begin(); - od.zone_id = atoi(row[0]); - od.zone_instance = atoi(row[1]); - od.object_type = atoi(row[2]); + od.zone_id = Strings::ToInt(row[0]); + od.zone_instance = Strings::ToInt(row[1]); + od.object_type = Strings::ToInt(row[2]); if (od.zone_id != zone->GetZoneID()) { c->Message(Chat::White, "ERROR: Object %u is not in this zone", id); @@ -702,23 +702,23 @@ void command_object(Client *c, const Seperator *sep) c->MovePC(c->GetX() - x2, c->GetY() - y2, c->GetZ(), c->GetHeading()); } // Move to x, y, z [h] else { - od.x = atof(sep->arg[3]); + od.x = Strings::ToFloat(sep->arg[3]); if (sep->argnum > 3) { - od.y = atof(sep->arg[4]); + od.y = Strings::ToFloat(sep->arg[4]); } else { o->GetLocation(nullptr, &od.y, nullptr); } if (sep->argnum > 4) { - od.z = atof(sep->arg[5]); + od.z = Strings::ToFloat(sep->arg[5]); } else { o->GetLocation(nullptr, nullptr, &od.z); } if (sep->argnum > 5) { - o->SetHeading(atof(sep->arg[6])); + o->SetHeading(Strings::ToFloat(sep->arg[6])); } } @@ -739,7 +739,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "rotate") == 0) { // Insufficient or invalid arguments - if ((sep->argnum < 3) || ((id = atoi(sep->arg[2])) == 0)) { + if ((sep->argnum < 3) || ((id = Strings::ToInt(sep->arg[2])) == 0)) { c->Message(Chat::White, "Usage: #object Rotate (ObjectID) (Heading, 0-512)"); return; } @@ -753,7 +753,7 @@ void command_object(Client *c, const Seperator *sep) return; } - o->SetHeading(atof(sep->arg[3])); + o->SetHeading(Strings::ToFloat(sep->arg[3])); // Despawn and respawn object to reflect change app = new EQApplicationPacket(); @@ -770,7 +770,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "save") == 0) { // Insufficient or invalid arguments - if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) == 0)) { + if ((sep->argnum < 2) || ((id = Strings::ToInt(sep->arg[2])) == 0)) { c->Message(Chat::White, "Usage: #object Save (ObjectID)"); return; } @@ -787,9 +787,9 @@ void command_object(Client *c, const Seperator *sep) auto results = content_db.QueryDatabase(query); if (results.Success() && results.RowCount() != 0) { auto row = results.begin(); - od.zone_id = atoi(row[0]); - od.zone_instance = atoi(row[1]); - od.object_type = atoi(row[2]); + od.zone_id = Strings::ToInt(row[0]); + od.zone_instance = Strings::ToInt(row[1]); + od.object_type = Strings::ToInt(row[2]); // ID already in database. Not a new object. bNewObject = false; @@ -1014,7 +1014,7 @@ void command_object(Client *c, const Seperator *sep) return; } - od.zone_instance = atoi(sep->arg[3]); + od.zone_instance = Strings::ToInt(sep->arg[3]); if (od.zone_instance == zone->GetInstanceVersion()) { c->Message(Chat::White, "ERROR: Source and destination instance versions are the same."); @@ -1046,7 +1046,7 @@ void command_object(Client *c, const Seperator *sep) return; } - id = atoi(sep->arg[2]); + id = Strings::ToInt(sep->arg[2]); std::string query = StringFormat( "INSERT INTO object " @@ -1085,13 +1085,13 @@ void command_object(Client *c, const Seperator *sep) auto row = results.begin(); // Wrong ZoneID? - if (atoi(row[0]) != zone->GetZoneID()) { + if (Strings::ToInt(row[0]) != zone->GetZoneID()) { c->Message(Chat::White, "ERROR: Object %u is not part of this zone.", id); return; } // Wrong Instance Version? - if (atoi(row[1]) != zone->GetInstanceVersion()) { + if (Strings::ToInt(row[1]) != zone->GetInstanceVersion()) { c->Message(Chat::White, "ERROR: Object %u is not part of this instance version.", id); return; } @@ -1106,7 +1106,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "delete") == 0) { - if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) <= 0)) { + if ((sep->argnum < 2) || ((id = Strings::ToInt(sep->arg[2])) <= 0)) { c->Message( Chat::White, "Usage: #object Delete (ObjectID) -- NOTE: Object deletions are permanent and " "cannot be undone!" @@ -1156,7 +1156,7 @@ void command_object(Client *c, const Seperator *sep) auto row = results.begin(); - switch (atoi(row[0])) { + switch (Strings::ToInt(row[0])) { case 0: // Static Object query = StringFormat( "DELETE FROM object WHERE id = %u " @@ -1185,7 +1185,7 @@ void command_object(Client *c, const Seperator *sep) if (strcasecmp(sep->arg[1], "undo") == 0) { // Insufficient or invalid arguments - if ((sep->argnum < 2) || ((id = atoi(sep->arg[2])) == 0)) { + if ((sep->argnum < 2) || ((id = Strings::ToInt(sep->arg[2])) == 0)) { c->Message( Chat::White, "Usage: #object Undo (ObjectID) -- Reload object from database, undoing any " "changes you have made" @@ -1236,16 +1236,16 @@ void command_object(Client *c, const Seperator *sep) auto row = results.begin(); - od.x = atof(row[0]); - od.y = atof(row[1]); - od.z = atof(row[2]); - od.heading = atof(row[3]); + od.x = Strings::ToFloat(row[0]); + od.y = Strings::ToFloat(row[1]); + od.z = Strings::ToFloat(row[2]); + od.heading = Strings::ToFloat(row[3]); strn0cpy(od.object_name, row[4], sizeof(od.object_name)); - od.object_type = atoi(row[5]); - icon = atoi(row[6]); - od.size = atoi(row[7]); - od.solidtype = atoi(row[8]); - od.unknown020 = atoi(row[9]); + od.object_type = Strings::ToInt(row[5]); + icon = Strings::ToInt(row[6]); + od.size = Strings::ToInt(row[7]); + od.solidtype = Strings::ToInt(row[8]); + od.unknown020 = Strings::ToInt(row[9]); if (od.object_type == 0) { od.object_type = staticType; diff --git a/zone/gm_commands/oocmute.cpp b/zone/gm_commands/oocmute.cpp index a19f424eca..d8711eccfa 100755 --- a/zone/gm_commands/oocmute.cpp +++ b/zone/gm_commands/oocmute.cpp @@ -10,7 +10,7 @@ void command_oocmute(Client *c, const Seperator *sep) return; } - bool is_muted = std::stoi(sep->arg[1]) ? true : false; + bool is_muted = Strings::ToInt(sep->arg[1]) ? true : false; ServerPacket pack(ServerOP_OOCMute, sizeof(ServerOOCMute_Struct)); auto o = (ServerOOCMute_Struct*) pack.pBuffer; diff --git a/zone/gm_commands/peqzone.cpp b/zone/gm_commands/peqzone.cpp index cf4d66c4f4..15b4109af5 100755 --- a/zone/gm_commands/peqzone.cpp +++ b/zone/gm_commands/peqzone.cpp @@ -49,7 +49,7 @@ void command_peqzone(Client *c, const Seperator *sep) auto zone_id = ( sep->IsNumber(1) ? - static_cast(std::stoul(sep->arg[1])) : + static_cast(Strings::ToUnsignedInt(sep->arg[1])) : static_cast(ZoneID(sep->arg[1])) ); auto zone_short_name = ZoneName(zone_id); diff --git a/zone/gm_commands/permaclass.cpp b/zone/gm_commands/permaclass.cpp index 648c61169d..1c8d9924f8 100755 --- a/zone/gm_commands/permaclass.cpp +++ b/zone/gm_commands/permaclass.cpp @@ -13,8 +13,8 @@ void command_permaclass(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto class_id = std::stoi(sep->arg[1]); - + auto class_id = Strings::ToInt(sep->arg[1]); + LogInfo("Class changed by {} for {} to {} ({})", c->GetCleanName(), c->GetTargetDescription(target), diff --git a/zone/gm_commands/permagender.cpp b/zone/gm_commands/permagender.cpp index f4f2f16f3a..a23cbce95c 100755 --- a/zone/gm_commands/permagender.cpp +++ b/zone/gm_commands/permagender.cpp @@ -14,13 +14,13 @@ void command_permagender(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto gender_id = std::stoi(sep->arg[1]); + auto gender_id = Strings::ToInt(sep->arg[1]); if (gender_id < 0 || gender_id > 2) { c->Message(Chat::White, "Usage: #permagender [Gender ID]"); c->Message(Chat::White, "Genders: 0 = Male, 1 = Female, 2 = Neuter"); return; } - + LogInfo("Gender changed by {} for {} to {} ({})", c->GetCleanName(), c->GetTargetDescription(target), diff --git a/zone/gm_commands/permarace.cpp b/zone/gm_commands/permarace.cpp index b84157f3b1..2595e18380 100755 --- a/zone/gm_commands/permarace.cpp +++ b/zone/gm_commands/permarace.cpp @@ -17,9 +17,9 @@ void command_permarace(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto race_id = std::stoi(sep->arg[1]); + auto race_id = Strings::ToInt(sep->arg[1]); auto gender_id = Mob::GetDefaultGender(race_id, target->GetBaseGender()); - + LogInfo("Race changed by {} for {} to {} ({})", c->GetCleanName(), c->GetTargetDescription(target), diff --git a/zone/gm_commands/petitioninfo.cpp b/zone/gm_commands/petitioninfo.cpp index 1700e41005..c9c1e49f51 100755 --- a/zone/gm_commands/petitioninfo.cpp +++ b/zone/gm_commands/petitioninfo.cpp @@ -13,7 +13,7 @@ void command_petitioninfo(Client *c, const Seperator *sep) return; } - LogInfo("Petition information request from [{}], petition number:", c->GetName(), atoi(sep->argplus[1])); + LogInfo("Petition information request from [{}], petition number:", c->GetName(), Strings::ToInt(sep->argplus[1])); if (results.RowCount() == 0) { c->Message(Chat::Red, "There was an error in your request: ID not found! Please check the Id and try again."); diff --git a/zone/gm_commands/push.cpp b/zone/gm_commands/push.cpp index 7d693cff15..05042fb744 100755 --- a/zone/gm_commands/push.cpp +++ b/zone/gm_commands/push.cpp @@ -17,11 +17,11 @@ void command_push(Client *c, const Seperator *sep) } auto target = c->GetTarget(); - auto back = std::stof(sep->arg[1]); + auto back = Strings::ToFloat(sep->arg[1]); auto up = 0.0f; if (arguments == 2 && sep->IsNumber(2)) { - up = std::stof(sep->arg[2]); + up = Strings::ToFloat(sep->arg[2]); } c->Message( diff --git a/zone/gm_commands/race.cpp b/zone/gm_commands/race.cpp index 2729965b14..cc3b518886 100755 --- a/zone/gm_commands/race.cpp +++ b/zone/gm_commands/race.cpp @@ -5,7 +5,7 @@ void command_race(Client *c, const Seperator *sep) Mob *target = c->CastToMob(); if (sep->IsNumber(1)) { - auto race = atoi(sep->arg[1]); + auto race = Strings::ToInt(sep->arg[1]); if ((race >= 0 && race <= RuleI(NPC, MaxRaceID)) || (race >= 2253 && race <= 2259)) { if ((c->GetTarget()) && c->Admin() >= commandRaceOthers) { target = c->GetTarget(); diff --git a/zone/gm_commands/reload.cpp b/zone/gm_commands/reload.cpp index 2f4e9511e1..09db786eaf 100644 --- a/zone/gm_commands/reload.cpp +++ b/zone/gm_commands/reload.cpp @@ -135,7 +135,7 @@ void command_reload(Client *c, const Seperator *sep) bool stop_timers = false; if (sep->IsNumber(2)) { - stop_timers = std::stoi(sep->arg[2]) != 0 ? true : false; + stop_timers = Strings::ToInt(sep->arg[2]) != 0 ? true : false; } std::string stop_timers_message = stop_timers ? " and timers stopped" : ""; @@ -167,7 +167,7 @@ void command_reload(Client *c, const Seperator *sep) pack = new ServerPacket(ServerOP_ReloadTasks, sizeof(ReloadTasks_Struct)); } else { - task_id = std::stoul(sep->arg[2]); + task_id = Strings::ToUnsignedInt(sep->arg[2]); } auto rts = (ReloadTasks_Struct *) pack->pBuffer; @@ -191,7 +191,7 @@ void command_reload(Client *c, const Seperator *sep) return; } - bool global = std::stoi(sep->arg[2]) ? true : false; + bool global = Strings::ToInt(sep->arg[2]) ? true : false; if (!global) { entity_list.UpdateAllTraps(true, true); @@ -220,7 +220,7 @@ void command_reload(Client *c, const Seperator *sep) uint8 global_repop = ReloadWorld::NoRepop; if (sep->IsNumber(2)) { - global_repop = static_cast(std::stoul(sep->arg[2])); + global_repop = static_cast(Strings::ToUnsignedInt(sep->arg[2])); if (global_repop > ReloadWorld::ForceRepop) { global_repop = ReloadWorld::ForceRepop; @@ -268,7 +268,7 @@ void command_reload(Client *c, const Seperator *sep) auto zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); if (!zone_id) { @@ -286,7 +286,7 @@ void command_reload(Client *c, const Seperator *sep) auto zone_long_name = ZoneLongName(zone_id); auto version = ( sep->IsNumber(3) ? - std::stoul(sep->arg[3]) : + Strings::ToUnsignedInt(sep->arg[3]) : 0 ); diff --git a/zone/gm_commands/removeitem.cpp b/zone/gm_commands/removeitem.cpp index 44ad46d84b..0ed69eb454 100644 --- a/zone/gm_commands/removeitem.cpp +++ b/zone/gm_commands/removeitem.cpp @@ -12,8 +12,8 @@ void command_removeitem(Client *c, const Seperator *sep) if (c->GetTarget() && c->GetTarget()->IsClient()) { target = c->GetTarget()->CastToClient(); } - - auto item_id = std::stoi(sep->arg[1]); + + auto item_id = Strings::ToInt(sep->arg[1]); if (!database.GetItem(item_id)) { c->Message( Chat::White, @@ -24,9 +24,9 @@ void command_removeitem(Client *c, const Seperator *sep) ); return; } - + auto item_link = database.CreateItemLink(item_id); - auto amount = sep->IsNumber(2) ? std::stoul(sep->arg[2]) : 1; + auto amount = sep->IsNumber(2) ? Strings::ToUnsignedInt(sep->arg[2]) : 1; auto item_count = target->CountItem(item_id); if (item_count) { if (item_count >= amount) { diff --git a/zone/gm_commands/resetaa_timer.cpp b/zone/gm_commands/resetaa_timer.cpp index bb108c6c4c..bdc185e3a2 100755 --- a/zone/gm_commands/resetaa_timer.cpp +++ b/zone/gm_commands/resetaa_timer.cpp @@ -29,7 +29,7 @@ void command_resetaa_timer(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - int timer_id = std::stoi(sep->arg[1]); + int timer_id = Strings::ToInt(sep->arg[1]); c->Message( Chat::White, fmt::format( diff --git a/zone/gm_commands/resetdisc_timer.cpp b/zone/gm_commands/resetdisc_timer.cpp index 305ae5c3a8..4223aab620 100755 --- a/zone/gm_commands/resetdisc_timer.cpp +++ b/zone/gm_commands/resetdisc_timer.cpp @@ -29,7 +29,7 @@ void command_resetdisc_timer(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - auto timer_id = std::stoul(sep->arg[1]); + auto timer_id = Strings::ToUnsignedInt(sep->arg[1]); c->Message( Chat::White, fmt::format( diff --git a/zone/gm_commands/revoke.cpp b/zone/gm_commands/revoke.cpp index 50eba21a25..abad1655b2 100755 --- a/zone/gm_commands/revoke.cpp +++ b/zone/gm_commands/revoke.cpp @@ -25,7 +25,7 @@ void command_revoke(Client *c, const Seperator *sep) return; } - bool revoked = std::stoi(sep->arg[2]) ? true : false; + bool revoked = Strings::ToInt(sep->arg[2]) ? true : false; auto query = fmt::format( "UPDATE account SET revoked = {} WHERE id = {}", diff --git a/zone/gm_commands/roambox.cpp b/zone/gm_commands/roambox.cpp index 1955fb09cb..410928f9d2 100755 --- a/zone/gm_commands/roambox.cpp +++ b/zone/gm_commands/roambox.cpp @@ -52,10 +52,10 @@ void command_roambox(Client *c, const Seperator *sep) int delay = 15000; if (arguments >= 2) { - box_size = std::stof(sep->arg[2]); + box_size = Strings::ToFloat(sep->arg[2]); if (arguments == 3) { - delay = std::stoi(sep->arg[3]); + delay = Strings::ToInt(sep->arg[3]); } } diff --git a/zone/gm_commands/scribespell.cpp b/zone/gm_commands/scribespell.cpp index a5c843f498..03594464f9 100755 --- a/zone/gm_commands/scribespell.cpp +++ b/zone/gm_commands/scribespell.cpp @@ -13,7 +13,7 @@ void command_scribespell(Client *c, const Seperator *sep) t = c->GetTarget()->CastToClient(); } - const auto spell_id = std::stoul(sep->arg[1]); + const auto spell_id = Strings::ToUnsignedInt(sep->arg[1]); if (IsValidSpell(spell_id)) { t->Message( diff --git a/zone/gm_commands/scribespells.cpp b/zone/gm_commands/scribespells.cpp index 2a141de4b3..93ce215381 100755 --- a/zone/gm_commands/scribespells.cpp +++ b/zone/gm_commands/scribespells.cpp @@ -14,10 +14,10 @@ void command_scribespells(Client *c, const Seperator *sep) } uint8 rule_max_level = RuleI(Character, MaxLevel); - auto max_level = static_cast(std::stoul(sep->arg[1])); + auto max_level = static_cast(Strings::ToUnsignedInt(sep->arg[1])); uint8 min_level = ( sep->IsNumber(2) ? - static_cast(std::stoul(sep->arg[2])) : + static_cast(Strings::ToUnsignedInt(sep->arg[2])) : 1 ); // Default to Level 1 if there isn't a 2nd argument diff --git a/zone/gm_commands/serverlock.cpp b/zone/gm_commands/serverlock.cpp index 59a43f9122..cd2c38ff94 100644 --- a/zone/gm_commands/serverlock.cpp +++ b/zone/gm_commands/serverlock.cpp @@ -9,8 +9,8 @@ void command_serverlock(Client *c, const Seperator *sep) c->Message(Chat::White, "Usage: #serverlock [0|1] - Lock or Unlock the World Server (0 = Unlocked, 1 = Locked)"); return; } - - auto is_locked = std::stoi(sep->arg[1]) ? true : false; + + auto is_locked = Strings::ToInt(sep->arg[1]) ? true : false; auto pack = new ServerPacket(ServerOP_Lock, sizeof(ServerLock_Struct)); auto l = (ServerLock_Struct *) pack->pBuffer; diff --git a/zone/gm_commands/set_adventure_points.cpp b/zone/gm_commands/set_adventure_points.cpp index 8518f2aa8f..160344fd21 100755 --- a/zone/gm_commands/set_adventure_points.cpp +++ b/zone/gm_commands/set_adventure_points.cpp @@ -4,7 +4,7 @@ void command_set_adventure_points(Client *c, const Seperator *sep) { int arguments = sep->argnum; - + if ( !arguments || !sep->IsNumber(1) || @@ -32,7 +32,7 @@ void command_set_adventure_points(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto theme_id = std::stoul(sep->arg[1]); + auto theme_id = Strings::ToUnsignedInt(sep->arg[1]); if (!EQ::ValueWithin(theme_id, LDoNThemes::Unused, LDoNThemes::TAK)) { c->Message(Chat::White, "Valid themes are as follows."); auto theme_map = EQ::constants::GetLDoNThemeMap(); @@ -45,12 +45,12 @@ void command_set_adventure_points(Client *c, const Seperator *sep) theme.second ).c_str() ); - } + } c->Message(Chat::White, "Note: Theme 0 splits the points evenly across all Themes."); return; } - auto points = std::stoi(sep->arg[2]); + auto points = Strings::ToInt(sep->arg[2]); c->Message( Chat::White, diff --git a/zone/gm_commands/setaapts.cpp b/zone/gm_commands/setaapts.cpp index c1c730a5f4..86b8c2994a 100755 --- a/zone/gm_commands/setaapts.cpp +++ b/zone/gm_commands/setaapts.cpp @@ -18,7 +18,7 @@ void command_setaapts(Client *c, const Seperator *sep) std::string aa_type = Strings::ToLower(sep->arg[1]); std::string group_raid_string; - uint32 aa_points = static_cast(std::min(std::stoull(sep->arg[2]), (unsigned long long) 2000000000)); + uint32 aa_points = static_cast(std::min(Strings::ToUnsignedBigInt(sep->arg[2]), (uint64) 2000000000)); bool is_aa = aa_type.find("aa") != std::string::npos; bool is_group = aa_type.find("group") != std::string::npos; bool is_raid = aa_type.find("raid") != std::string::npos; diff --git a/zone/gm_commands/setaaxp.cpp b/zone/gm_commands/setaaxp.cpp index 12339c3ed0..dbf81320f1 100755 --- a/zone/gm_commands/setaaxp.cpp +++ b/zone/gm_commands/setaaxp.cpp @@ -19,8 +19,8 @@ void command_setaaxp(Client *c, const Seperator *sep) std::string aa_type = Strings::ToLower(sep->arg[1]); std::string group_raid_string; uint32 aa_experience = static_cast(std::min( - std::stoull(sep->arg[2]), - (unsigned long long) 2000000000 + Strings::ToUnsignedBigInt(sep->arg[2]), + (uint64) 2000000000 )); bool is_aa = aa_type.find("aa") != std::string::npos; bool is_group = aa_type.find("group") != std::string::npos; diff --git a/zone/gm_commands/setaltcurrency.cpp b/zone/gm_commands/setaltcurrency.cpp index d484ee3b15..d3208cc0c0 100644 --- a/zone/gm_commands/setaltcurrency.cpp +++ b/zone/gm_commands/setaltcurrency.cpp @@ -17,8 +17,8 @@ void command_setaltcurrency(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto currency_id = std::stoul(sep->arg[1]); - auto amount = static_cast(std::min(std::stoll(sep->arg[2]), (long long) 2000000000)); + auto currency_id = Strings::ToUnsignedInt(sep->arg[1]); + auto amount = static_cast(std::min(Strings::ToBigInt(sep->arg[2]), (int64) 2000000000)); uint32 currency_item_id = zone->GetCurrencyItemID(currency_id); if (!currency_item_id) { c->Message( @@ -32,7 +32,7 @@ void command_setaltcurrency(Client *c, const Seperator *sep) } target->SetAlternateCurrencyValue(currency_id, amount); - + c->Message( Chat::White, fmt::format( diff --git a/zone/gm_commands/setanim.cpp b/zone/gm_commands/setanim.cpp index b6deeec014..2a191aac21 100755 --- a/zone/gm_commands/setanim.cpp +++ b/zone/gm_commands/setanim.cpp @@ -14,7 +14,7 @@ void command_setanim(Client *c, const Seperator *sep) } - int animation_id = std::stoi(sep->arg[1]); + int animation_id = Strings::ToInt(sep->arg[1]); if ( animation_id < 0 || animation_id > eaLooting @@ -36,7 +36,7 @@ void command_setanim(Client *c, const Seperator *sep) } else if (animation_id == eaLooting) { animation_name = "Looting"; } - + c->Message( Chat::White, fmt::format( diff --git a/zone/gm_commands/setanon.cpp b/zone/gm_commands/setanon.cpp index 955bbd8843..2b50c3defd 100755 --- a/zone/gm_commands/setanon.cpp +++ b/zone/gm_commands/setanon.cpp @@ -12,7 +12,7 @@ void command_setanon(Client *c, const Seperator *sep) } if (arguments == 1) { - const uint8 anon_flag = static_cast(std::stoul(sep->arg[1])); + const uint8 anon_flag = static_cast(Strings::ToUnsignedInt(sep->arg[1])); auto t = c; if (c->GetTarget() && c->GetTarget()->IsClient() && c->GetGM()) { t = c->GetTarget()->CastToClient(); @@ -44,8 +44,8 @@ void command_setanon(Client *c, const Seperator *sep) ).c_str() ); } else if (arguments == 2) { - const auto character_id = std::stoi(sep->arg[1]); - const uint8 anon_flag = static_cast(std::stoul(sep->arg[2])); + const auto character_id = Strings::ToInt(sep->arg[1]); + const uint8 anon_flag = static_cast(Strings::ToUnsignedInt(sep->arg[2])); auto e = CharacterDataRepository::FindOne(content_db, character_id); if (!e.id) { diff --git a/zone/gm_commands/setcrystals.cpp b/zone/gm_commands/setcrystals.cpp index 95a537e9a0..b2befc92ae 100755 --- a/zone/gm_commands/setcrystals.cpp +++ b/zone/gm_commands/setcrystals.cpp @@ -15,8 +15,8 @@ void command_setcrystals(Client *c, const Seperator *sep) std::string crystal_type = Strings::ToLower(sep->arg[1]); uint32 crystal_amount = static_cast(std::min( - std::stoull(sep->arg[2]), - (unsigned long long) 2000000000 + Strings::ToUnsignedBigInt(sep->arg[2]), + (uint64) 2000000000 )); bool is_ebon = crystal_type.find("ebon") != std::string::npos; bool is_radiant = crystal_type.find("radiant") != std::string::npos; diff --git a/zone/gm_commands/setendurance.cpp b/zone/gm_commands/setendurance.cpp index 920b30829e..86da260084 100644 --- a/zone/gm_commands/setendurance.cpp +++ b/zone/gm_commands/setendurance.cpp @@ -8,13 +8,13 @@ void command_setendurance(Client *c, const Seperator *sep) return; } - auto endurance = static_cast(std::min(std::stoll(sep->arg[1]), (long long) 2000000000)); + auto endurance = static_cast(std::min(Strings::ToBigInt(sep->arg[1]), (int64) 2000000000)); bool set_to_max = false; Mob* target = c; if (c->GetTarget()) { target = c->GetTarget(); } - + if (target->IsClient()) { if (endurance >= target->CastToClient()->GetMaxEndurance()) { endurance = target->CastToClient()->GetMaxEndurance(); @@ -51,4 +51,4 @@ void command_setendurance(Client *c, const Seperator *sep) ) ).c_str() ); -} \ No newline at end of file +} diff --git a/zone/gm_commands/setfaction.cpp b/zone/gm_commands/setfaction.cpp index 17b3c288fa..a3d8a82a34 100755 --- a/zone/gm_commands/setfaction.cpp +++ b/zone/gm_commands/setfaction.cpp @@ -7,7 +7,7 @@ void command_setfaction(Client *c, const Seperator *sep) c->Message(Chat::White, "Usage: #setfaction [Faction ID]"); return; } - + if ( !c->GetTarget() || ( @@ -21,7 +21,7 @@ void command_setfaction(Client *c, const Seperator *sep) NPC* target = c->GetTarget()->CastToNPC(); auto npc_id = target->GetNPCTypeID(); - auto faction_id = std::stoi(sep->arg[1]); + auto faction_id = Strings::ToInt(sep->arg[1]); auto faction_name = content_db.GetFactionName(faction_id); if (!faction_name.empty()) { c->Message( diff --git a/zone/gm_commands/sethp.cpp b/zone/gm_commands/sethp.cpp index e3efbc955a..9c1463e130 100644 --- a/zone/gm_commands/sethp.cpp +++ b/zone/gm_commands/sethp.cpp @@ -8,7 +8,7 @@ void command_sethp(Client *c, const Seperator *sep) return; } - auto health = static_cast(std::min(std::stoll(sep->arg[1]), (long long) 2000000000)); + auto health = static_cast(std::min(Strings::ToBigInt(sep->arg[1]), (int64) 2000000000)); bool set_to_max = false; Mob* target = c; if (c->GetTarget()) { diff --git a/zone/gm_commands/setlanguage.cpp b/zone/gm_commands/setlanguage.cpp index 5b8073b8df..ad9b400efb 100755 --- a/zone/gm_commands/setlanguage.cpp +++ b/zone/gm_commands/setlanguage.cpp @@ -9,8 +9,8 @@ void command_setlanguage(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto language_id = sep->IsNumber(1) ? std::stoi(sep->arg[1]) : -1; - auto language_value = sep->IsNumber(2) ? std::stoi(sep->arg[2]) : -1; + auto language_id = sep->IsNumber(1) ? Strings::ToInt(sep->arg[1]) : -1; + auto language_value = sep->IsNumber(2) ? Strings::ToInt(sep->arg[2]) : -1; if (!strcasecmp(sep->arg[1], "list")) { for (const auto& language : EQ::constants::GetLanguageMap()) { c->Message( diff --git a/zone/gm_commands/setmana.cpp b/zone/gm_commands/setmana.cpp index 3b1c1132bc..57e2e6ece7 100644 --- a/zone/gm_commands/setmana.cpp +++ b/zone/gm_commands/setmana.cpp @@ -8,7 +8,7 @@ void command_setmana(Client *c, const Seperator *sep) return; } - auto mana = static_cast(std::min(std::stoll(sep->arg[1]), (long long) 2000000000)); + auto mana = static_cast(std::min(Strings::ToBigInt(sep->arg[1]), (int64) 2000000000)); bool set_to_max = false; Mob* target = c; if (c->GetTarget()) { diff --git a/zone/gm_commands/setpvppoints.cpp b/zone/gm_commands/setpvppoints.cpp index b6d3a05983..15b24a01a4 100755 --- a/zone/gm_commands/setpvppoints.cpp +++ b/zone/gm_commands/setpvppoints.cpp @@ -13,7 +13,7 @@ void command_setpvppoints(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - uint32 pvp_points = static_cast(std::min(std::stoull(sep->arg[1]), (unsigned long long) 2000000000)); + uint32 pvp_points = static_cast(std::min(Strings::ToUnsignedBigInt(sep->arg[1]), (uint64) 2000000000)); target->SetPVPPoints(pvp_points); target->Save(); target->SendPVPStats(); diff --git a/zone/gm_commands/setskill.cpp b/zone/gm_commands/setskill.cpp index fd6cacaa52..297b366883 100755 --- a/zone/gm_commands/setskill.cpp +++ b/zone/gm_commands/setskill.cpp @@ -7,8 +7,8 @@ void command_setskill(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto skill_id = sep->IsNumber(1) ? std::stoi(sep->arg[1]) : -1; - auto skill_value = sep->IsNumber(2) ? std::stoi(sep->arg[2]) : -1; + auto skill_id = sep->IsNumber(1) ? Strings::ToInt(sep->arg[1]) : -1; + auto skill_value = sep->IsNumber(2) ? Strings::ToInt(sep->arg[2]) : -1; if ( skill_id < 0 || skill_id > EQ::skills::HIGHEST_SKILL || diff --git a/zone/gm_commands/setskillall.cpp b/zone/gm_commands/setskillall.cpp index f9ec1e3e48..e3652aef01 100755 --- a/zone/gm_commands/setskillall.cpp +++ b/zone/gm_commands/setskillall.cpp @@ -24,7 +24,7 @@ void command_setskillall(Client *c, const Seperator *sep) c->GetTargetDescription(target) ); - auto skill_level = static_cast(std::stoul(sep->arg[1])); + auto skill_level = static_cast(Strings::ToUnsignedInt(sep->arg[1])); c->Message( Chat::White, diff --git a/zone/gm_commands/setstartzone.cpp b/zone/gm_commands/setstartzone.cpp index 16e66bb6e5..7accda12ef 100755 --- a/zone/gm_commands/setstartzone.cpp +++ b/zone/gm_commands/setstartzone.cpp @@ -19,7 +19,7 @@ void command_setstartzone(Client *c, const Seperator *sep) auto zone_id = ( sep->IsNumber(1) ? - std::stoul(sep->arg[1]) : + Strings::ToUnsignedInt(sep->arg[1]) : ZoneID(sep->arg[1]) ); diff --git a/zone/gm_commands/setstat.cpp b/zone/gm_commands/setstat.cpp index 56ff81a05f..7e4c42cd3f 100755 --- a/zone/gm_commands/setstat.cpp +++ b/zone/gm_commands/setstat.cpp @@ -3,7 +3,7 @@ void command_setstat(Client *c, const Seperator *sep) { if (sep->arg[1][0] && sep->arg[2][0] && c->GetTarget() != 0 && c->GetTarget()->IsClient()) { - c->GetTarget()->CastToClient()->SetStats(atoi(sep->arg[1]), atoi(sep->arg[2])); + c->GetTarget()->CastToClient()->SetStats(Strings::ToInt(sep->arg[1]), Strings::ToInt(sep->arg[2])); } else { c->Message(Chat::White, "This command is used to permanently increase or decrease a players stats."); diff --git a/zone/gm_commands/setxp.cpp b/zone/gm_commands/setxp.cpp index c82bb87a3b..8aa810b0b0 100755 --- a/zone/gm_commands/setxp.cpp +++ b/zone/gm_commands/setxp.cpp @@ -9,11 +9,11 @@ void command_setxp(Client *c, const Seperator *sep) } if (sep->IsNumber(1)) { - if (atoi(sep->arg[1]) > 9999999) { + if (Strings::ToInt(sep->arg[1]) > 9999999) { c->Message(Chat::White, "Error: Value too high."); } else { - t->AddEXP(atoi(sep->arg[1])); + t->AddEXP(Strings::ToInt(sep->arg[1])); } } else { diff --git a/zone/gm_commands/showskills.cpp b/zone/gm_commands/showskills.cpp index d4c23d91ab..d70df99741 100755 --- a/zone/gm_commands/showskills.cpp +++ b/zone/gm_commands/showskills.cpp @@ -9,7 +9,7 @@ void command_showskills(Client *c, const Seperator *sep) uint32 start_skill_id = 0; if (sep->IsNumber(1)) { - start_skill_id = std::stoul(sep->arg[1]); + start_skill_id = Strings::ToUnsignedInt(sep->arg[1]); } bool show_all = !strcasecmp(sep->arg[2], "all"); diff --git a/zone/gm_commands/spawneditmass.cpp b/zone/gm_commands/spawneditmass.cpp index 8321cf840f..8e66d0fcaa 100644 --- a/zone/gm_commands/spawneditmass.cpp +++ b/zone/gm_commands/spawneditmass.cpp @@ -66,7 +66,7 @@ void command_spawneditmass(Client *c, const Seperator *sep) Strings::Commify(spawn2_id), Strings::Commify(npc_id), npc_name, - Strings::SecondsToTime(std::stoi(respawn_time)), + Strings::SecondsToTime(Strings::ToInt(respawn_time)), Strings::Commify(respawn_time) ).c_str() ); @@ -131,7 +131,7 @@ void command_spawneditmass(Client *c, const Seperator *sep) SQL( UPDATE spawn2 SET respawntime = {} WHERE id IN ({}) ), - std::stoi(edit_value), + Strings::ToInt(edit_value), spawn2_ids_string ) ); diff --git a/zone/gm_commands/spawnstatus.cpp b/zone/gm_commands/spawnstatus.cpp index ed465899c7..5b88e6c50c 100755 --- a/zone/gm_commands/spawnstatus.cpp +++ b/zone/gm_commands/spawnstatus.cpp @@ -38,7 +38,7 @@ void command_spawnstatus(Client *c, const Seperator *sep) uint32 spawn_id = 0; if (is_search) { - spawn_id = std::stoul(sep->arg[1]); + spawn_id = Strings::ToUnsignedInt(sep->arg[1]); } LinkedListIterator iterator(zone->spawn2_list); diff --git a/zone/gm_commands/spellinfo.cpp b/zone/gm_commands/spellinfo.cpp index 7b9720fe1f..83c6c5cfe4 100755 --- a/zone/gm_commands/spellinfo.cpp +++ b/zone/gm_commands/spellinfo.cpp @@ -6,7 +6,7 @@ void command_spellinfo(Client *c, const Seperator *sep) c->Message(Chat::White, "Usage: #spellinfo [spell_id]"); } else { - int32_t spell_id = atoi(sep->arg[1]); + int32_t spell_id = Strings::ToInt(sep->arg[1]); const struct SPDat_Spell_Struct *s = &spells[spell_id]; c->Message(Chat::White, "Spell info for spell #%d:", spell_id); c->Message(Chat::White, " name: %s", s->name); diff --git a/zone/gm_commands/stun.cpp b/zone/gm_commands/stun.cpp index 8468aad601..32da4593ce 100755 --- a/zone/gm_commands/stun.cpp +++ b/zone/gm_commands/stun.cpp @@ -9,7 +9,7 @@ void command_stun(Client *c, const Seperator *sep) } Mob *target = c; - int duration = static_cast(std::min(std::stoll(sep->arg[1]), (long long) 2000000000)); + int duration = static_cast(std::min(Strings::ToBigInt(sep->arg[1]), (int64) 2000000000)); if (duration < 0) { duration = 0; diff --git a/zone/gm_commands/summonitem.cpp b/zone/gm_commands/summonitem.cpp index e3053bd713..65a744dea2 100755 --- a/zone/gm_commands/summonitem.cpp +++ b/zone/gm_commands/summonitem.cpp @@ -33,7 +33,7 @@ void command_summonitem(Client *c, const Seperator *sep) return; } else { - item_id = atoi(sep->arg[1]); + item_id = Strings::ToInt(sep->arg[1]); } if (!item_id) { @@ -60,31 +60,31 @@ void command_summonitem(Client *c, const Seperator *sep) } if (arguments >= 2 && sep->IsNumber(2)) { - charges = atoi(sep->arg[2]); + charges = Strings::ToInt(sep->arg[2]); } if (arguments >= 3 && sep->IsNumber(3)) { - augment_one = atoi(sep->arg[3]); + augment_one = Strings::ToInt(sep->arg[3]); } if (arguments >= 4 && sep->IsNumber(4)) { - augment_two = atoi(sep->arg[4]); + augment_two = Strings::ToInt(sep->arg[4]); } if (arguments >= 5 && sep->IsNumber(5)) { - augment_three = atoi(sep->arg[5]); + augment_three = Strings::ToInt(sep->arg[5]); } if (arguments >= 6 && sep->IsNumber(6)) { - augment_four = atoi(sep->arg[6]); + augment_four = Strings::ToInt(sep->arg[6]); } if (arguments >= 7 && sep->IsNumber(7)) { - augment_five = atoi(sep->arg[7]); + augment_five = Strings::ToInt(sep->arg[7]); } if (arguments == 8 && sep->IsNumber(8)) { - augment_six = atoi(sep->arg[8]); + augment_six = Strings::ToInt(sep->arg[8]); } c->SummonItem(item_id, charges, augment_one, augment_two, augment_three, augment_four, augment_five, augment_six); diff --git a/zone/gm_commands/suspend.cpp b/zone/gm_commands/suspend.cpp index c11daff537..8ee19cd42d 100755 --- a/zone/gm_commands/suspend.cpp +++ b/zone/gm_commands/suspend.cpp @@ -14,7 +14,7 @@ void command_suspend(Client *c, const Seperator *sep) } const std::string character_name = Strings::ToLower(sep->arg[1]); - auto days = std::stoul(sep->arg[2]); + auto days = Strings::ToUnsignedInt(sep->arg[2]); const std::string reason = sep->arg[3] ? sep->argplus[3] : ""; diff --git a/zone/gm_commands/suspendmulti.cpp b/zone/gm_commands/suspendmulti.cpp index 9f77aaf7ca..b2ff2fb1ca 100755 --- a/zone/gm_commands/suspendmulti.cpp +++ b/zone/gm_commands/suspendmulti.cpp @@ -19,7 +19,7 @@ void command_suspendmulti(Client *c, const Seperator *sep) v.push_back(fmt::format("'{}'", Strings::ToLower(c))); } - auto days = std::stoul(sep->arg[2]); + auto days = Strings::ToUnsignedInt(sep->arg[2]); const std::string reason = sep->arg[3] ? sep->argplus[3] : ""; diff --git a/zone/gm_commands/task.cpp b/zone/gm_commands/task.cpp index 6ae2c7d69b..723e461bcf 100755 --- a/zone/gm_commands/task.cpp +++ b/zone/gm_commands/task.cpp @@ -246,7 +246,7 @@ void command_task(Client *c, const Seperator *sep) return; } else if (is_uncomplete) { if (sep->IsNumber(2)) { - auto task_id = std::stoul(sep->arg[2]); + auto task_id = Strings::ToUnsignedInt(sep->arg[2]); if (!task_id) { c->Message(Chat::White, "Invalid task ID specified."); return; diff --git a/zone/gm_commands/texture.cpp b/zone/gm_commands/texture.cpp index 1a5c94a169..24dde1f0f0 100755 --- a/zone/gm_commands/texture.cpp +++ b/zone/gm_commands/texture.cpp @@ -8,10 +8,10 @@ void command_texture(Client *c, const Seperator *sep) return; } - auto texture = static_cast(std::min(std::stoul(sep->arg[1]), (unsigned long) 65535)); + auto texture = static_cast(std::min(Strings::ToUnsignedInt(sep->arg[1]), (uint32) 65535)); auto helmet_texture = static_cast( sep->IsNumber(2) ? - std::min(std::stoul(sep->arg[2]), (unsigned long) 255) : + std::min(Strings::ToUnsignedInt(sep->arg[2]), (uint32) 255) : 0 ); diff --git a/zone/gm_commands/time.cpp b/zone/gm_commands/time.cpp index 8254a3de19..7df178eca4 100755 --- a/zone/gm_commands/time.cpp +++ b/zone/gm_commands/time.cpp @@ -8,7 +8,7 @@ void command_time(Client *c, const Seperator *sep) TimeOfDay_Struct world_time; zone->zone_time.GetCurrentEQTimeOfDay(time(0), &world_time); - + auto time_string = fmt::format( "{:02}:{:02} {} (Timezone: {:02}:{:02} {})", ( @@ -47,7 +47,7 @@ void command_time(Client *c, const Seperator *sep) } uint8 minutes = 0; - auto hours = static_cast(std::stoul(sep->arg[1]) + 1); + auto hours = static_cast(Strings::ToUnsignedInt(sep->arg[1]) + 1); if (hours > 24) { hours = 24; @@ -60,7 +60,7 @@ void command_time(Client *c, const Seperator *sep) ); if (sep->IsNumber(2)) { - minutes = static_cast(std::stoul(sep->arg[2])); + minutes = static_cast(Strings::ToUnsignedInt(sep->arg[2])); if (minutes > 59) { minutes = 59; diff --git a/zone/gm_commands/timezone.cpp b/zone/gm_commands/timezone.cpp index 4e73a8108f..9270f1445e 100755 --- a/zone/gm_commands/timezone.cpp +++ b/zone/gm_commands/timezone.cpp @@ -26,7 +26,7 @@ void command_timezone(Client *c, const Seperator *sep) } uint8 minutes = 0; - auto hours = static_cast(std::stoul(sep->arg[1])); + auto hours = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (hours > 24) { hours = 24; @@ -39,7 +39,7 @@ void command_timezone(Client *c, const Seperator *sep) ); if (sep->IsNumber(2)) { - minutes = static_cast(std::stoul(sep->arg[2])); + minutes = static_cast(Strings::ToUnsignedInt(sep->arg[2])); if (minutes > 59) { minutes = 59; diff --git a/zone/gm_commands/traindisc.cpp b/zone/gm_commands/traindisc.cpp index 4392aa1269..aeb4e8d9f0 100755 --- a/zone/gm_commands/traindisc.cpp +++ b/zone/gm_commands/traindisc.cpp @@ -13,11 +13,11 @@ void command_traindisc(Client *c, const Seperator *sep) } uint8 rule_max_level = (uint8) RuleI(Character, MaxLevel); - uint8 max_level = (uint8) std::stoi(sep->arg[1]); + uint8 max_level = (uint8) Strings::ToInt(sep->arg[1]); uint8 min_level = ( sep->IsNumber(2) ? (uint8) - std::stoi(sep->arg[2]) : + Strings::ToInt(sep->arg[2]) : 1 ); // Default to Level 1 if there isn't a 2nd argument diff --git a/zone/gm_commands/tune.cpp b/zone/gm_commands/tune.cpp index e34f9aa49b..7174039e9c 100755 --- a/zone/gm_commands/tune.cpp +++ b/zone/gm_commands/tune.cpp @@ -197,11 +197,11 @@ void command_tune(Client *c, const Seperator *sep) } if (!strcasecmp(sep->arg[1], "FindATK")) { - float pct_mitigation = atof(sep->arg[3]); - int interval = atoi(sep->arg[4]); - int max_loop = atoi(sep->arg[5]); - int ac_override = atoi(sep->arg[6]); - int info_level = atoi(sep->arg[7]); + float pct_mitigation = Strings::ToFloat(sep->arg[3]); + int interval = Strings::ToInt(sep->arg[4]); + int max_loop = Strings::ToInt(sep->arg[5]); + int ac_override = Strings::ToInt(sep->arg[6]); + int info_level = Strings::ToInt(sep->arg[7]); if (!pct_mitigation) { c->Message(Chat::White, "[#Tune] - Error must enter the desired percent mitigation on defender."); @@ -277,11 +277,11 @@ void command_tune(Client *c, const Seperator *sep) } if (!strcasecmp(sep->arg[1], "FindAC")) { - float pct_mitigation = atof(sep->arg[3]); - int interval = atoi(sep->arg[4]); - int max_loop = atoi(sep->arg[5]); - int atk_override = atoi(sep->arg[6]); - int info_level = atoi(sep->arg[7]); + float pct_mitigation = Strings::ToFloat(sep->arg[3]); + int interval = Strings::ToInt(sep->arg[4]); + int max_loop = Strings::ToInt(sep->arg[5]); + int atk_override = Strings::ToInt(sep->arg[6]); + int info_level = Strings::ToInt(sep->arg[7]); if (!pct_mitigation) { c->Message(Chat::White, "#Tune - Error must enter the desired percent mitigation on defender."); @@ -358,11 +358,11 @@ void command_tune(Client *c, const Seperator *sep) } if (!strcasecmp(sep->arg[1], "FindAccuracy")) { - float hit_chance = atof(sep->arg[3]); - int interval = atoi(sep->arg[4]); - int max_loop = atoi(sep->arg[5]); - int avoid_override = atoi(sep->arg[6]); - int info_level = atoi(sep->arg[7]); + float hit_chance = Strings::ToFloat(sep->arg[3]); + int interval = Strings::ToInt(sep->arg[4]); + int max_loop = Strings::ToInt(sep->arg[5]); + int avoid_override = Strings::ToInt(sep->arg[6]); + int info_level = Strings::ToInt(sep->arg[7]); if (!hit_chance) { c->Message(Chat::White, "#Tune - Error must enter the desired hit chance on defender."); @@ -439,11 +439,11 @@ void command_tune(Client *c, const Seperator *sep) } if (!strcasecmp(sep->arg[1], "FindAvoidance")) { - float hit_chance = atof(sep->arg[3]); - int interval = atoi(sep->arg[4]); - int max_loop = atoi(sep->arg[5]); - int acc_override = atoi(sep->arg[6]); - int info_level = atoi(sep->arg[7]); + float hit_chance = Strings::ToFloat(sep->arg[3]); + int interval = Strings::ToInt(sep->arg[4]); + int max_loop = Strings::ToInt(sep->arg[5]); + int acc_override = Strings::ToInt(sep->arg[6]); + int info_level = Strings::ToInt(sep->arg[7]); if (!hit_chance) { c->Message(Chat::White, "#Tune - Error must enter the desired hit chance on defender."); diff --git a/zone/gm_commands/unmemspell.cpp b/zone/gm_commands/unmemspell.cpp index 56589f9eca..b5450035f0 100644 --- a/zone/gm_commands/unmemspell.cpp +++ b/zone/gm_commands/unmemspell.cpp @@ -16,7 +16,7 @@ void command_unmemspell(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - auto spell_id = static_cast(std::stoul(sep->arg[1])); + auto spell_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!IsValidSpell(spell_id)) { c->Message( Chat::White, diff --git a/zone/gm_commands/unscribespell.cpp b/zone/gm_commands/unscribespell.cpp index bbb59af07e..423288c3bd 100755 --- a/zone/gm_commands/unscribespell.cpp +++ b/zone/gm_commands/unscribespell.cpp @@ -14,7 +14,7 @@ void command_unscribespell(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - uint16 spell_id = EQ::Clamp(std::stoi(sep->arg[1]), 0, 65535); + uint16 spell_id = EQ::Clamp(Strings::ToInt(sep->arg[1]), 0, 65535); if (!IsValidSpell(spell_id)) { c->Message( @@ -28,7 +28,7 @@ void command_unscribespell(Client *c, const Seperator *sep) } auto spell_name = GetSpellName(spell_id); - + if (target->HasSpellScribed(spell_id)) { target->UnscribeSpellBySpellID(spell_id); diff --git a/zone/gm_commands/untraindisc.cpp b/zone/gm_commands/untraindisc.cpp index 31620d78a2..2337d7ae97 100755 --- a/zone/gm_commands/untraindisc.cpp +++ b/zone/gm_commands/untraindisc.cpp @@ -14,7 +14,7 @@ void command_untraindisc(Client *c, const Seperator *sep) target = c->GetTarget()->CastToClient(); } - uint16 spell_id = EQ::Clamp(std::stoi(sep->arg[1]), 0, 65535); + uint16 spell_id = EQ::Clamp(Strings::ToInt(sep->arg[1]), 0, 65535); if (!IsValidSpell(spell_id)) { c->Message( diff --git a/zone/gm_commands/uptime.cpp b/zone/gm_commands/uptime.cpp index 3c1c7bfbcb..00b247d9f6 100755 --- a/zone/gm_commands/uptime.cpp +++ b/zone/gm_commands/uptime.cpp @@ -12,8 +12,8 @@ void command_uptime(Client *c, const Seperator *sep) auto pack = new ServerPacket(ServerOP_Uptime, sizeof(ServerUptime_Struct)); ServerUptime_Struct *sus = (ServerUptime_Struct *) pack->pBuffer; strcpy(sus->adminname, c->GetName()); - if (sep->IsNumber(1) && atoi(sep->arg[1]) > 0) { - sus->zoneserverid = atoi(sep->arg[1]); + if (sep->IsNumber(1) && Strings::ToInt(sep->arg[1]) > 0) { + sus->zoneserverid = Strings::ToInt(sep->arg[1]); } worldserver.SendPacket(pack); safe_delete(pack); diff --git a/zone/gm_commands/viewnpctype.cpp b/zone/gm_commands/viewnpctype.cpp index bf3cc8fef2..80c73bfefd 100755 --- a/zone/gm_commands/viewnpctype.cpp +++ b/zone/gm_commands/viewnpctype.cpp @@ -3,7 +3,7 @@ void command_viewnpctype(Client *c, const Seperator *sep) { if (sep->IsNumber(1)) { - uint32 npc_id = std::stoul(sep->arg[1]); + uint32 npc_id = Strings::ToUnsignedInt(sep->arg[1]); const NPCType *npc_type_data = content_db.LoadNPCTypesData(npc_id); if (npc_type_data) { auto npc = new NPC( diff --git a/zone/gm_commands/viewpetition.cpp b/zone/gm_commands/viewpetition.cpp index a59821a818..eaff518a97 100755 --- a/zone/gm_commands/viewpetition.cpp +++ b/zone/gm_commands/viewpetition.cpp @@ -15,7 +15,7 @@ void command_viewpetition(Client *c, const Seperator *sep) return; } - LogInfo("View petition request from [{}], petition number: [{}]", c->GetName(), atoi(sep->argplus[1])); + LogInfo("View petition request from [{}], petition number: [{}]", c->GetName(), Strings::ToInt(sep->argplus[1])); if (results.RowCount() == 0) { c->Message(Chat::Red, "There was an error in your request: ID not found! Please check the Id and try again."); diff --git a/zone/gm_commands/viewrecipe.cpp b/zone/gm_commands/viewrecipe.cpp index d8eb820f35..74035de2a2 100755 --- a/zone/gm_commands/viewrecipe.cpp +++ b/zone/gm_commands/viewrecipe.cpp @@ -11,7 +11,7 @@ void command_viewrecipe(Client *c, const Seperator *sep) return; } - auto recipe_id = static_cast(std::stoul(sep->arg[1])); + auto recipe_id = static_cast(Strings::ToUnsignedInt(sep->arg[1])); auto re = TradeskillRecipeEntriesRepository::GetWhere( database, fmt::format("recipe_id = {} ORDER BY id ASC", recipe_id) @@ -55,7 +55,7 @@ void command_viewrecipe(Client *c, const Seperator *sep) can_summon_items && e.item_id > 1000 ? fmt::format(" | {}", Saylink::Silent(fmt::format("#si {}", e.item_id), "Summon")) : "" ).c_str() ); - + std::vector emv; bool has_message = false; @@ -69,7 +69,7 @@ void command_viewrecipe(Client *c, const Seperator *sep) has_message = true; } - + if (e.failcount) { emv.push_back( fmt::format( @@ -80,7 +80,7 @@ void command_viewrecipe(Client *c, const Seperator *sep) has_message = true; } - + if (e.salvagecount) { emv.push_back( fmt::format( @@ -91,7 +91,7 @@ void command_viewrecipe(Client *c, const Seperator *sep) has_message = true; } - + if (e.successcount) { emv.push_back( fmt::format( diff --git a/zone/gm_commands/viewzoneloot.cpp b/zone/gm_commands/viewzoneloot.cpp index 24818663c9..3f48a38475 100755 --- a/zone/gm_commands/viewzoneloot.cpp +++ b/zone/gm_commands/viewzoneloot.cpp @@ -6,7 +6,7 @@ void command_viewzoneloot(Client *c, const Seperator *sep) auto npc_list = entity_list.GetNPCList(); uint32 loot_amount = 0, loot_id = 1, search_item_id = 0; if (sep->argnum == 1 && sep->IsNumber(1)) { - search_item_id = atoi(sep->arg[1]); + search_item_id = Strings::ToInt(sep->arg[1]); } else if (sep->argnum == 1 && !sep->IsNumber(1)) { c->Message( diff --git a/zone/gm_commands/wc.cpp b/zone/gm_commands/wc.cpp index 0ec247acaf..c9520f46a9 100755 --- a/zone/gm_commands/wc.cpp +++ b/zone/gm_commands/wc.cpp @@ -13,11 +13,11 @@ void command_wc(Client *c, const Seperator *sep) } else { uint32 hero_forge_model = 0; - uint32 wearslot = atoi(sep->arg[1]); + uint32 wearslot = Strings::ToInt(sep->arg[1]); // Hero Forge if (sep->argnum > 2) { - hero_forge_model = atoi(sep->arg[3]); + hero_forge_model = Strings::ToInt(sep->arg[3]); if (hero_forge_model != 0 && hero_forge_model < 1000) { // Shorthand Hero Forge ID. Otherwise use the value the user entered. @@ -28,17 +28,17 @@ void command_wc(Client *c, const Seperator *sep) // Leaving here to add color option to the #wc command eventually uint32 Color; if (c->GetTarget()->IsClient()) - Color = c->GetTarget()->GetEquipmentColor(atoi(sep->arg[1])); + Color = c->GetTarget()->GetEquipmentColor(Strings::ToInt(sep->arg[1])); else - Color = c->GetTarget()->GetArmorTint(atoi(sep->arg[1])); + Color = c->GetTarget()->GetArmorTint(Strings::ToInt(sep->arg[1])); */ c->GetTarget()->SendTextureWC( wearslot, - atoi(sep->arg[2]), + Strings::ToInt(sep->arg[2]), hero_forge_model, - atoi(sep->arg[4]), - atoi(sep->arg[5]), - atoi(sep->arg[6])); + Strings::ToInt(sep->arg[4]), + Strings::ToInt(sep->arg[5]), + Strings::ToInt(sep->arg[6])); } } diff --git a/zone/gm_commands/weather.cpp b/zone/gm_commands/weather.cpp index 00e1845249..6289275f17 100755 --- a/zone/gm_commands/weather.cpp +++ b/zone/gm_commands/weather.cpp @@ -10,11 +10,11 @@ void command_weather(Client *c, const Seperator *sep) int arguments = sep->argnum; if (arguments == 1) { - auto new_weather = static_cast(std::stoul(sep->arg[1])); + auto new_weather = static_cast(Strings::ToUnsignedInt(sep->arg[1])); uint8 new_intensity = 0; std::string weather_message = "The sky clears."; - if (new_weather == EQ::constants::WeatherTypes::Snowing) { + if (new_weather == EQ::constants::WeatherTypes::Snowing) { weather_message = "Snowflakes begin to fall from the sky."; new_weather = EQ::constants::WeatherTypes::Snowing; new_intensity = 0x02; @@ -41,15 +41,15 @@ void command_weather(Client *c, const Seperator *sep) safe_delete(outapp); } else if (arguments == 3) { - auto command_type = static_cast(std::stoul(sep->arg[1])); + auto command_type = static_cast(Strings::ToUnsignedInt(sep->arg[1])); uint8 new_weather = EQ::constants::WeatherTypes::None; uint8 new_intensity = 0; std::string weather_message; if (zone->zone_weather == EQ::constants::WeatherTypes::None) { if (command_type > EQ::constants::WeatherTypes::Snowing) { - new_weather = static_cast(std::stoul(sep->arg[2])); - new_intensity = static_cast(std::stoul(sep->arg[3])); + new_weather = static_cast(Strings::ToUnsignedInt(sep->arg[2])); + new_intensity = static_cast(Strings::ToUnsignedInt(sep->arg[3])); weather_message = fmt::format( "Sending {} ({}) with an intensity of {}.", @@ -57,7 +57,7 @@ void command_weather(Client *c, const Seperator *sep) new_weather, new_intensity ); - } else if (command_type == EQ::constants::WeatherTypes::Snowing) { + } else if (command_type == EQ::constants::WeatherTypes::Snowing) { weather_message = "Snowflakes begin to fall from the sky."; new_weather = EQ::constants::WeatherTypes::Snowing; new_intensity = 0x02; @@ -73,9 +73,9 @@ void command_weather(Client *c, const Seperator *sep) if (new_weather != EQ::constants::WeatherTypes::Raining) { outapp->pBuffer[0] = new_weather; } - + outapp->pBuffer[4] = new_intensity; - + c->Message(Chat::White, weather_message.c_str()); entity_list.QueueClients(c, outapp); diff --git a/zone/gm_commands/who.cpp b/zone/gm_commands/who.cpp index 0b833eaad0..a67cc27994 100755 --- a/zone/gm_commands/who.cpp +++ b/zone/gm_commands/who.cpp @@ -64,17 +64,17 @@ void command_who(Client *c, const Seperator *sep) c->Message(Chat::Who, "------------------------------"); for (auto row : results) { - auto account_id = std::stoul(row[0]); + auto account_id = Strings::ToUnsignedInt(row[0]); std::string player_name = row[1]; - auto zone_id = std::stoul(row[2]); + auto zone_id = Strings::ToUnsignedInt(row[2]); std::string zone_short_name = ZoneName(zone_id); std::string zone_long_name = ZoneLongName(zone_id); - auto zone_instance = std::stoul(row[3]); + auto zone_instance = Strings::ToUnsignedInt(row[3]); std::string guild_name = row[4]; - auto player_level = std::stoul(row[5]); - auto player_race = std::stoul(row[6]); - auto player_class = std::stoul(row[7]); - auto account_status = std::stoul(row[8]); + auto player_level = Strings::ToUnsignedInt(row[5]); + auto player_race = Strings::ToUnsignedInt(row[6]); + auto player_class = Strings::ToUnsignedInt(row[7]); + auto account_status = Strings::ToUnsignedInt(row[8]); std::string account_name = row[9]; std::string account_ip = row[10]; std::string base_class_name = GetClassIDName(static_cast(player_class)); diff --git a/zone/gm_commands/worldshutdown.cpp b/zone/gm_commands/worldshutdown.cpp index 9c173c7d00..e42bcd29aa 100755 --- a/zone/gm_commands/worldshutdown.cpp +++ b/zone/gm_commands/worldshutdown.cpp @@ -12,8 +12,8 @@ void command_worldshutdown(Client *c, const Seperator *sep) if ( sep->IsNumber(1) && sep->IsNumber(2) && - ((time = std::stoi(sep->arg[1])) > 0) && - ((interval = std::stoi(sep->arg[2])) > 0) + ((time = Strings::ToInt(sep->arg[1])) > 0) && + ((interval = Strings::ToInt(sep->arg[2])) > 0) ) { int time_minutes = (time / 60); quest_manager.WorldWideMessage( diff --git a/zone/gm_commands/worldwide.cpp b/zone/gm_commands/worldwide.cpp index 8962ef1328..a61be457bf 100755 --- a/zone/gm_commands/worldwide.cpp +++ b/zone/gm_commands/worldwide.cpp @@ -11,7 +11,7 @@ void command_worldwide(Client *c, const Seperator *sep) c->Message(Chat::White, "Usage: #worldwide remove [Spell ID] - Remove a spell worldwide"); return; } - + bool is_cast = !strcasecmp(sep->arg[1], "cast"); bool is_remove = !strcasecmp(sep->arg[1], "remove"); bool is_message = !strcasecmp(sep->arg[1], "message"); @@ -36,10 +36,10 @@ void command_worldwide(Client *c, const Seperator *sep) if (is_cast) { if (sep->IsNumber(2)) { uint8 update_type = WWSpellUpdateType_Cast; - auto spell_id = std::stoul(sep->arg[2]); + auto spell_id = Strings::ToUnsignedInt(sep->arg[2]); bool disable_message = false; if (sep->IsNumber(3)) { - disable_message = std::stoi(sep->arg[3]) ? true : false; + disable_message = Strings::ToInt(sep->arg[3]) ? true : false; } if (!IsValidSpell(spell_id)) { @@ -93,7 +93,7 @@ void command_worldwide(Client *c, const Seperator *sep) uint8 update_type = WWMoveUpdateType_MoveZone; auto zone_id = ( sep->IsNumber(2) ? - static_cast(std::stoul(sep->arg[2])) : + static_cast(Strings::ToUnsignedInt(sep->arg[2])) : static_cast(ZoneID(sep->arg[2])) ); auto zone_short_name = ZoneName(zone_id); @@ -127,7 +127,7 @@ void command_worldwide(Client *c, const Seperator *sep) if (sep->IsNumber(2)) { uint8 update_type = WWMoveUpdateType_MoveZoneInstance; const char *zone_short_name = ""; - auto instance_id = static_cast(std::stoul(sep->arg[2])); + auto instance_id = static_cast(Strings::ToUnsignedInt(sep->arg[2])); c->Message( Chat::White, @@ -144,7 +144,7 @@ void command_worldwide(Client *c, const Seperator *sep) } else if (is_remove) { if (sep->IsNumber(2)) { uint8 update_type = WWSpellUpdateType_Remove; - auto spell_id = std::stoul(sep->arg[2]); + auto spell_id = Strings::ToUnsignedInt(sep->arg[2]); if (!IsValidSpell(spell_id)) { c->Message( diff --git a/zone/gm_commands/wp.cpp b/zone/gm_commands/wp.cpp index 4f0b9330e2..407a76d2ec 100755 --- a/zone/gm_commands/wp.cpp +++ b/zone/gm_commands/wp.cpp @@ -3,10 +3,10 @@ void command_wp(Client *c, const Seperator *sep) { auto command_type = sep->arg[1]; - auto grid_id = atoi(sep->arg[2]); + auto grid_id = Strings::ToInt(sep->arg[2]); if (grid_id != 0) { - auto pause = atoi(sep->arg[3]); - auto waypoint = atoi(sep->arg[4]); + auto pause = Strings::ToInt(sep->arg[3]); + auto waypoint = Strings::ToInt(sep->arg[4]); auto zone_id = zone->GetZoneID(); if (strcasecmp("add", command_type) == 0) { if (waypoint == 0) { // Default to highest if it's left blank, or we enter 0 diff --git a/zone/gm_commands/wpadd.cpp b/zone/gm_commands/wpadd.cpp index df74c03e49..2ce56faacc 100755 --- a/zone/gm_commands/wpadd.cpp +++ b/zone/gm_commands/wpadd.cpp @@ -15,8 +15,8 @@ void command_wpadd(Client *c, const Seperator *sep) } if (sep->arg[1][0]) { - if (atoi(sep->arg[1]) >= 0) { - pause = atoi(sep->arg[1]); + if (Strings::ToInt(sep->arg[1]) >= 0) { + pause = Strings::ToInt(sep->arg[1]); } else { c->Message(Chat::White, "Usage: #wpadd [pause] [-h]"); diff --git a/zone/gm_commands/xtargets.cpp b/zone/gm_commands/xtargets.cpp index c352b26b3c..e153c477c6 100755 --- a/zone/gm_commands/xtargets.cpp +++ b/zone/gm_commands/xtargets.cpp @@ -14,7 +14,7 @@ void command_xtargets(Client *c, const Seperator *sep) return; } - const auto new_max = static_cast(std::stoul(sep->arg[1])); + const auto new_max = static_cast(Strings::ToUnsignedInt(sep->arg[1])); if (!EQ::ValueWithin(new_max, 5, XTARGET_HARDCAP)) { c->Message( diff --git a/zone/gm_commands/zclip.cpp b/zone/gm_commands/zclip.cpp index 957464c727..09c7e0e64c 100755 --- a/zone/gm_commands/zclip.cpp +++ b/zone/gm_commands/zclip.cpp @@ -11,10 +11,10 @@ void command_zclip(Client *c, const Seperator *sep) return; } - auto minimum_clip = sep->arg[1] ? std::stof(sep->arg[1]) : 0; - auto maximum_clip = sep->arg[2] ? std::stof(sep->arg[2]) : 0; - auto minimum_fog_clip = sep->arg[3] ? std::stof(sep->arg[3]) : 0; - auto maximum_fog_clip = sep->arg[4] ? std::stof(sep->arg[4]) : 0; + auto minimum_clip = sep->arg[1] ? Strings::ToFloat(sep->arg[1]) : 0; + auto maximum_clip = sep->arg[2] ? Strings::ToFloat(sep->arg[2]) : 0; + auto minimum_fog_clip = sep->arg[3] ? Strings::ToFloat(sep->arg[3]) : 0; + auto maximum_fog_clip = sep->arg[4] ? Strings::ToFloat(sep->arg[4]) : 0; auto permanent = sep->arg[5] ? atobool(sep->arg[5]) : false; if (minimum_clip <= 0 || maximum_clip <= 0) { diff --git a/zone/gm_commands/zcolor.cpp b/zone/gm_commands/zcolor.cpp index 77f7379ca5..9e107d1f6a 100755 --- a/zone/gm_commands/zcolor.cpp +++ b/zone/gm_commands/zcolor.cpp @@ -13,9 +13,9 @@ void command_zcolor(Client *c, const Seperator *sep) return; } - auto red = std::stoul(sep->arg[1]); - auto green = std::stoul(sep->arg[2]); - auto blue = std::stoul(sep->arg[3]); + auto red = Strings::ToUnsignedInt(sep->arg[1]); + auto green = Strings::ToUnsignedInt(sep->arg[2]); + auto blue = Strings::ToUnsignedInt(sep->arg[3]); auto permanent = sep->arg[4] ? atobool(sep->arg[4]) : false; if ( red < 0 || @@ -29,7 +29,7 @@ void command_zcolor(Client *c, const Seperator *sep) return; } - if (permanent) { + if (permanent) { auto query = fmt::format( "UPDATE zone SET fog_red = {}, fog_green = {}, fog_blue = {} " "WHERE zoneidnumber = {} AND version = {}", diff --git a/zone/gm_commands/zheader.cpp b/zone/gm_commands/zheader.cpp index f7449344c6..5d91fd9a2f 100755 --- a/zone/gm_commands/zheader.cpp +++ b/zone/gm_commands/zheader.cpp @@ -10,7 +10,7 @@ void command_zheader(Client *c, const Seperator *sep) auto zone_id = ( sep->IsNumber(2) ? - std::stoul(sep->arg[2]) : + Strings::ToUnsignedInt(sep->arg[2]) : ZoneID(sep->arg[2]) ); if (!zone_id) { @@ -28,7 +28,7 @@ void command_zheader(Client *c, const Seperator *sep) auto zone_long_name = ZoneLongName(zone_id); auto version = ( sep->IsNumber(3) ? - std::stoul(sep->arg[3]) : + Strings::ToUnsignedInt(sep->arg[3]) : 0 ); diff --git a/zone/gm_commands/zone.cpp b/zone/gm_commands/zone.cpp index 19deb45545..13601da4d5 100644 --- a/zone/gm_commands/zone.cpp +++ b/zone/gm_commands/zone.cpp @@ -15,7 +15,7 @@ void command_zone(Client *c, const Seperator *sep) // if input is id if (Strings::IsNumber(zone_input)) { - zone_id = std::stoi(zone_input); + zone_id = Strings::ToInt(zone_input); // validate if (zone_id != 0 && !GetZone(zone_id)) { @@ -66,9 +66,9 @@ void command_zone(Client *c, const Seperator *sep) } // coordinates - auto x = sep->IsNumber(2) ? std::stof(sep->arg[2]) : 0.0f; - auto y = sep->IsNumber(3) ? std::stof(sep->arg[3]) : 0.0f; - auto z = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f; + auto x = sep->IsNumber(2) ? Strings::ToFloat(sep->arg[2]) : 0.0f; + auto y = sep->IsNumber(3) ? Strings::ToFloat(sep->arg[3]) : 0.0f; + auto z = sep->IsNumber(4) ? Strings::ToFloat(sep->arg[4]) : 0.0f; auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords; c->MovePC( diff --git a/zone/gm_commands/zone_instance.cpp b/zone/gm_commands/zone_instance.cpp index e18d439903..5101468ba7 100644 --- a/zone/gm_commands/zone_instance.cpp +++ b/zone/gm_commands/zone_instance.cpp @@ -8,7 +8,7 @@ void command_zone_instance(Client *c, const Seperator *sep) return; } - auto instance_id = std::stoul(sep->arg[1]); + auto instance_id = Strings::ToUnsignedInt(sep->arg[1]); if (!instance_id) { c->Message(Chat::White, "You must enter a valid Instance ID."); return; @@ -52,9 +52,9 @@ void command_zone_instance(Client *c, const Seperator *sep) return; } - auto x = sep->IsNumber(2) ? std::stof(sep->arg[2]) : 0.0f; - auto y = sep->IsNumber(3) ? std::stof(sep->arg[3]) : 0.0f; - auto z = sep->IsNumber(4) ? std::stof(sep->arg[4]) : 0.0f; + auto x = sep->IsNumber(2) ? Strings::ToFloat(sep->arg[2]) : 0.0f; + auto y = sep->IsNumber(3) ? Strings::ToFloat(sep->arg[3]) : 0.0f; + auto z = sep->IsNumber(4) ? Strings::ToFloat(sep->arg[4]) : 0.0f; auto zone_mode = sep->IsNumber(2) ? ZoneSolicited : ZoneToSafeCoords; c->MovePC( diff --git a/zone/gm_commands/zonebootup.cpp b/zone/gm_commands/zonebootup.cpp index 7c54e24fbd..d071d9426b 100755 --- a/zone/gm_commands/zonebootup.cpp +++ b/zone/gm_commands/zonebootup.cpp @@ -14,7 +14,7 @@ void command_zonebootup(Client *c, const Seperator *sep) else { auto pack = new ServerPacket(ServerOP_ZoneBootup, sizeof(ServerZoneStateChange_struct)); ServerZoneStateChange_struct *s = (ServerZoneStateChange_struct *) pack->pBuffer; - s->ZoneServerID = atoi(sep->arg[1]); + s->ZoneServerID = Strings::ToInt(sep->arg[1]); strcpy(s->adminname, c->GetName()); s->zoneid = ZoneID(sep->arg[2]); s->makestatic = (bool) (strcasecmp(sep->arg[3], "static") == 0); diff --git a/zone/gm_commands/zonelock.cpp b/zone/gm_commands/zonelock.cpp index b304f1a0f7..1f0de1f0a2 100755 --- a/zone/gm_commands/zonelock.cpp +++ b/zone/gm_commands/zonelock.cpp @@ -51,7 +51,7 @@ void command_zonelock(Client *c, const Seperator *sep) else if (!is_list && c->Admin() >= commandLockZones) { auto zone_id = ( sep->IsNumber(2) ? - static_cast(std::stoul(sep->arg[2])) : + static_cast(Strings::ToUnsignedInt(sep->arg[2])) : static_cast(ZoneID(sep->arg[2])) ); std::string zone_short_name = Strings::ToLower(ZoneName(zone_id, true)); diff --git a/zone/gm_commands/zoneshutdown.cpp b/zone/gm_commands/zoneshutdown.cpp index 14550b9db1..31b09849ba 100755 --- a/zone/gm_commands/zoneshutdown.cpp +++ b/zone/gm_commands/zoneshutdown.cpp @@ -18,7 +18,7 @@ void command_zoneshutdown(Client *c, const Seperator *sep) ServerZoneStateChange_struct *s = (ServerZoneStateChange_struct *) pack->pBuffer; strcpy(s->adminname, c->GetName()); if (sep->arg[1][0] >= '0' && sep->arg[1][0] <= '9') { - s->ZoneServerID = atoi(sep->arg[1]); + s->ZoneServerID = Strings::ToInt(sep->arg[1]); } else { s->zoneid = ZoneID(sep->arg[1]); diff --git a/zone/gm_commands/zopp.cpp b/zone/gm_commands/zopp.cpp index 08f10395ba..ef6c7ce8f0 100755 --- a/zone/gm_commands/zopp.cpp +++ b/zone/gm_commands/zopp.cpp @@ -25,9 +25,9 @@ void command_zopp(Client *c, const Seperator *sep) packettype = ItemPacketLimbo; } - int16 slotid = atoi(sep->arg[2]); - uint32 itemid = atoi(sep->arg[3]); - int16 charges = sep->argnum == 4 ? atoi(sep->arg[4]) : 1; // defaults to 1 charge if not specified + int16 slotid = Strings::ToInt(sep->arg[2]); + uint32 itemid = Strings::ToInt(sep->arg[3]); + int16 charges = sep->argnum == 4 ? Strings::ToInt(sep->arg[4]) : 1; // defaults to 1 charge if not specified const EQ::ItemData *FakeItem = database.GetItem(itemid); diff --git a/zone/gm_commands/zsafecoords.cpp b/zone/gm_commands/zsafecoords.cpp index 25be803914..4f3e5be4bf 100755 --- a/zone/gm_commands/zsafecoords.cpp +++ b/zone/gm_commands/zsafecoords.cpp @@ -14,10 +14,10 @@ void command_zsafecoords(Client *c, const Seperator *sep) return; } - auto x = std::stof(sep->arg[1]); - auto y = std::stof(sep->arg[2]); - auto z = std::stof(sep->arg[3]); - auto heading = sep->arg[3] ? std::stof(sep->arg[3]) : c->GetHeading(); + auto x = Strings::ToFloat(sep->arg[1]); + auto y = Strings::ToFloat(sep->arg[2]); + auto z = Strings::ToFloat(sep->arg[3]); + auto heading = sep->arg[3] ? Strings::ToFloat(sep->arg[3]) : c->GetHeading(); auto permanent = sep->arg[4] ? atobool(sep->arg[4]) : false; if (permanent) { auto query = fmt::format( @@ -31,7 +31,7 @@ void command_zsafecoords(Client *c, const Seperator *sep) ); database.QueryDatabase(query); } - + zone->newzone_data.safe_x = x; zone->newzone_data.safe_y = y; zone->newzone_data.safe_z = z; diff --git a/zone/gm_commands/zsky.cpp b/zone/gm_commands/zsky.cpp index ed3ef2dc8c..5802b7011e 100755 --- a/zone/gm_commands/zsky.cpp +++ b/zone/gm_commands/zsky.cpp @@ -8,7 +8,7 @@ void command_zsky(Client *c, const Seperator *sep) return; } - auto sky_type = std::stoul(sep->arg[1]); + auto sky_type = Strings::ToUnsignedInt(sep->arg[1]); auto permanent = sep->arg[2] ? atobool(sep->arg[2]) : false; if (sky_type < 0 || sky_type > 255) { c->Message(Chat::White, "Sky Type cannot be less than 0 or greater than 255!"); diff --git a/zone/gm_commands/zunderworld.cpp b/zone/gm_commands/zunderworld.cpp index be55236ef0..8f7c8832db 100755 --- a/zone/gm_commands/zunderworld.cpp +++ b/zone/gm_commands/zunderworld.cpp @@ -8,7 +8,7 @@ void command_zunderworld(Client *c, const Seperator *sep) return; } - auto z = std::stof(sep->arg[1]); + auto z = Strings::ToFloat(sep->arg[1]); auto permanent = sep->arg[2] ? atobool(sep->arg[2]) : false; if (permanent) { auto query = fmt::format( diff --git a/zone/guild_mgr.cpp b/zone/guild_mgr.cpp index 812fe2785f..ea71c00d4d 100644 --- a/zone/guild_mgr.cpp +++ b/zone/guild_mgr.cpp @@ -692,17 +692,17 @@ bool GuildBankManager::Load(uint32 guildID) char donator[64], whoFor[64]; for (auto row = results.begin(); row != results.end(); ++row) { - int area = atoi(row[0]); - int slot = atoi(row[1]); - int itemID = atoi(row[2]); - int qty = atoi(row[3]); + int area = Strings::ToInt(row[0]); + int slot = Strings::ToInt(row[1]); + int itemID = Strings::ToInt(row[2]); + int qty = Strings::ToInt(row[3]); if (row[4]) strn0cpy(donator, row[4], sizeof(donator)); else donator[0] = '\0'; - int permissions = atoi(row[5]); + int permissions = Strings::ToInt(row[5]); if (row[6]) strn0cpy(whoFor, row[6], sizeof(whoFor)); diff --git a/zone/horse.cpp b/zone/horse.cpp index 43c04202f1..36dd4aa8e5 100644 --- a/zone/horse.cpp +++ b/zone/horse.cpp @@ -92,16 +92,16 @@ const NPCType *Horse::BuildHorseType(uint16 spell_id) { strcpy(npc_type->special_abilities, "19,1^20,1^24,1"); npc_type->current_hp = 1; npc_type->max_hp = 1; - npc_type->race = atoi(row[0]); - npc_type->gender = atoi(row[1]); // Drogmor's are female horses. Yuck. + npc_type->race = Strings::ToInt(row[0]); + npc_type->gender = Strings::ToInt(row[1]); // Drogmor's are female horses. Yuck. npc_type->class_ = 1; npc_type->deity = 1; npc_type->level = 1; npc_type->npc_id = 0; npc_type->loottable_id = 0; - npc_type->texture = atoi(row[2]); // mount color - npc_type->helmtexture = atoi(row[2]); // mount color - npc_type->runspeed = atof(row[3]); + npc_type->texture = Strings::ToInt(row[2]); // mount color + npc_type->helmtexture = Strings::ToInt(row[2]); // mount color + npc_type->runspeed = Strings::ToFloat(row[3]); npc_type->light = 0; npc_type->STR = 75; diff --git a/zone/inventory.cpp b/zone/inventory.cpp index f1b2c4f4bc..4ae041af79 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -4066,7 +4066,7 @@ const int EQ::InventoryProfile::GetItemStatValue(uint32 item_id, std::string ide } if (Strings::EqualFold(identifier, "idfile")) { - stat = Strings::IsNumber(&item->IDFile[2]) ? std::stoi(&item->IDFile[2]) : 0; + stat = Strings::IsNumber(&item->IDFile[2]) ? Strings::ToInt(&item->IDFile[2]) : 0; } if (Strings::EqualFold(identifier, "weight")) { diff --git a/zone/loottables.cpp b/zone/loottables.cpp index 7afe959ff2..ed9c8e5cc3 100644 --- a/zone/loottables.cpp +++ b/zone/loottables.cpp @@ -434,7 +434,7 @@ void NPC::AddLootDrop( } } - emat = atoi(newid); + emat = Strings::ToInt(newid); } else { emat = item2->Material; } @@ -485,12 +485,12 @@ void NPC::AddLootDrop( what was this about??? if (((npc->GetRace()==127) && (npc->CastToMob()->GetOwnerID()!=0)) && (item2->Slots==24576) || (item2->Slots==8192) || (item2->Slots==16384)){ - npc->d_melee_texture2=atoi(newid); + npc->d_melee_texture2=Strings::ToInt(newid); wc->wear_slot_id=8; if (item2->Material >0) wc->material=item2->Material; else - wc->material=atoi(newid); + wc->material=Strings::ToInt(newid); npc->AC+=item2->AC; npc->STR+=item2->STR; npc->INT+=item2->INT; @@ -633,52 +633,52 @@ void ZoneDatabase::LoadGlobalLoot() } } - GlobalLootEntry e(atoi(row[0]), atoi(row[1]), row[2] ? row[2] : ""); + GlobalLootEntry e(Strings::ToInt(row[0]), Strings::ToInt(row[1]), row[2] ? row[2] : ""); - auto min_level = atoi(row[3]); + auto min_level = Strings::ToInt(row[3]); if (min_level) { e.AddRule(GlobalLoot::RuleTypes::LevelMin, min_level); } - auto max_level = atoi(row[4]); + auto max_level = Strings::ToInt(row[4]); if (max_level) { e.AddRule(GlobalLoot::RuleTypes::LevelMax, max_level); } // null is not used if (row[5]) { - e.AddRule(GlobalLoot::RuleTypes::Rare, atoi(row[5])); + e.AddRule(GlobalLoot::RuleTypes::Rare, Strings::ToInt(row[5])); } // null is not used if (row[6]) { - e.AddRule(GlobalLoot::RuleTypes::Raid, atoi(row[6])); + e.AddRule(GlobalLoot::RuleTypes::Raid, Strings::ToInt(row[6])); } if (row[7]) { auto races = Strings::Split(row[7], '|'); for (auto &r : races) - e.AddRule(GlobalLoot::RuleTypes::Race, std::stoi(r)); + e.AddRule(GlobalLoot::RuleTypes::Race, Strings::ToInt(r)); } if (row[8]) { auto classes = Strings::Split(row[8], '|'); for (auto &c : classes) - e.AddRule(GlobalLoot::RuleTypes::Class, std::stoi(c)); + e.AddRule(GlobalLoot::RuleTypes::Class, Strings::ToInt(c)); } if (row[9]) { auto bodytypes = Strings::Split(row[9], '|'); for (auto &b : bodytypes) - e.AddRule(GlobalLoot::RuleTypes::BodyType, std::stoi(b)); + e.AddRule(GlobalLoot::RuleTypes::BodyType, Strings::ToInt(b)); } // null is not used if (row[11]) { - e.AddRule(GlobalLoot::RuleTypes::HotZone, atoi(row[11])); + e.AddRule(GlobalLoot::RuleTypes::HotZone, Strings::ToInt(row[11])); } zone->AddGlobalLootEntry(e); diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 15d85d442a..9844fb4334 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -82,25 +82,25 @@ void handle_npc_event_trade( } auto money_string = fmt::format("platinum.{}", npc_id); - uint32 money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + uint32 money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "platinum"); money_string = fmt::format("gold.{}", npc_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "gold"); money_string = fmt::format("silver.{}", npc_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "silver"); money_string = fmt::format("copper.{}", npc_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "copper"); @@ -468,31 +468,31 @@ void handle_npc_damage( ) { Seperator sep(data.c_str()); - lua_pushnumber(L, std::stoul(sep.arg[0])); + lua_pushnumber(L, Strings::ToUnsignedInt(sep.arg[0])); lua_setfield(L, -2, "entity_id"); - lua_pushnumber(L, std::stoll(sep.arg[1])); + lua_pushnumber(L, Strings::ToBigInt(sep.arg[1])); lua_setfield(L, -2, "damage"); - lua_pushnumber(L, std::stoi(sep.arg[2])); + lua_pushnumber(L, Strings::ToInt(sep.arg[2])); lua_setfield(L, -2, "spell_id"); - lua_pushnumber(L, std::stoi(sep.arg[3])); + lua_pushnumber(L, Strings::ToInt(sep.arg[3])); lua_setfield(L, -2, "skill_id"); - lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[4]) == 0 ? false : true); lua_setfield(L, -2, "is_damage_shield"); - lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[5]) == 0 ? false : true); lua_setfield(L, -2, "is_avoidable"); - lua_pushnumber(L, std::stoi(sep.arg[6])); + lua_pushnumber(L, Strings::ToInt(sep.arg[6])); lua_setfield(L, -2, "buff_slot"); - lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[7]) == 0 ? false : true); lua_setfield(L, -2, "is_buff_tic"); - lua_pushnumber(L, std::stoi(sep.arg[8])); + lua_pushnumber(L, Strings::ToInt(sep.arg[8])); lua_setfield(L, -2, "special_attack"); Lua_Mob l_mob(init); @@ -848,7 +848,7 @@ void handle_player_task_accepted( uint32 extra_data, std::vector* extra_pointers ) { - lua_pushinteger(L, std::stoi(data)); + lua_pushinteger(L, Strings::ToInt(data)); lua_setfield(L, -2, "task_id"); } @@ -1073,13 +1073,13 @@ void handle_player_warp( std::vector *extra_pointers ) { Seperator sep(data.c_str()); - lua_pushnumber(L, std::stof(sep.arg[0])); + lua_pushnumber(L, Strings::ToFloat(sep.arg[0])); lua_setfield(L, -2, "from_x"); - lua_pushnumber(L, std::stof(sep.arg[1])); + lua_pushnumber(L, Strings::ToFloat(sep.arg[1])); lua_setfield(L, -2, "from_y"); - lua_pushnumber(L, std::stof(sep.arg[2])); + lua_pushnumber(L, Strings::ToFloat(sep.arg[2])); lua_setfield(L, -2, "from_z"); lua_pushnumber(L, std::stof(sep.arg[3])); @@ -1201,7 +1201,7 @@ void handle_player_aa_exp_gain( uint32 extra_data, std::vector *extra_pointers ) { - lua_pushinteger(L, std::stoull(data)); + lua_pushinteger(L, Strings::ToUnsignedBigInt(data)); lua_setfield(L, -2, "aa_exp_gained"); } @@ -1213,7 +1213,7 @@ void handle_player_exp_gain( uint32 extra_data, std::vector *extra_pointers ) { - lua_pushinteger(L, std::stoull(data)); + lua_pushinteger(L, Strings::ToUnsignedBigInt(data)); lua_setfield(L, -2, "exp_gained"); } @@ -1225,7 +1225,7 @@ void handle_player_level_up( uint32 extra_data, std::vector *extra_pointers ) { - lua_pushinteger(L, std::stoul(data)); + lua_pushinteger(L, Strings::ToUnsignedInt(data)); lua_setfield(L, -2, "levels_gained"); } @@ -1237,7 +1237,7 @@ void handle_player_level_down( uint32 extra_data, std::vector *extra_pointers ) { - lua_pushinteger(L, std::stoul(data)); + lua_pushinteger(L, Strings::ToUnsignedInt(data)); lua_setfield(L, -2, "levels_lost"); } @@ -1288,31 +1288,31 @@ void handle_player_damage( ) { Seperator sep(data.c_str()); - lua_pushnumber(L, std::stoul(sep.arg[0])); + lua_pushnumber(L, Strings::ToUnsignedInt(sep.arg[0])); lua_setfield(L, -2, "entity_id"); - lua_pushnumber(L, std::stoll(sep.arg[1])); + lua_pushnumber(L, Strings::ToBigInt(sep.arg[1])); lua_setfield(L, -2, "damage"); - lua_pushnumber(L, std::stoi(sep.arg[2])); + lua_pushnumber(L, Strings::ToInt(sep.arg[2])); lua_setfield(L, -2, "spell_id"); - lua_pushnumber(L, std::stoi(sep.arg[3])); + lua_pushnumber(L, Strings::ToInt(sep.arg[3])); lua_setfield(L, -2, "skill_id"); - lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[4]) == 0 ? false : true); lua_setfield(L, -2, "is_damage_shield"); - lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[5]) == 0 ? false : true); lua_setfield(L, -2, "is_avoidable"); - lua_pushnumber(L, std::stoi(sep.arg[6])); + lua_pushnumber(L, Strings::ToInt(sep.arg[6])); lua_setfield(L, -2, "buff_slot"); - lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[7]) == 0 ? false : true); lua_setfield(L, -2, "is_buff_tic"); - lua_pushnumber(L, std::stoi(sep.arg[8])); + lua_pushnumber(L, Strings::ToInt(sep.arg[8])); lua_setfield(L, -2, "special_attack"); if (extra_pointers && extra_pointers->size() >= 1) { @@ -1331,7 +1331,7 @@ void handle_player_item_click( uint32 extra_data, std::vector *extra_pointers ) { - lua_pushnumber(L, std::stoi(data)); + lua_pushnumber(L, Strings::ToInt(data)); lua_setfield(L, -2, "slot_id"); if (extra_pointers && extra_pointers->size() >= 1) { @@ -1874,16 +1874,16 @@ void handle_player_augment_insert( lua_setfield(L, -2, "augment"); Seperator sep(data.c_str()); - lua_pushinteger(L, std::stoul(sep.arg[0])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[0])); lua_setfield(L, -2, "item_id"); lua_pushinteger(L, Strings::ToInt(sep.arg[1])); lua_setfield(L, -2, "item_slot"); - lua_pushinteger(L, std::stoul(sep.arg[2])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[2])); lua_setfield(L, -2, "augment_id"); - lua_pushinteger(L, std::stoul(sep.arg[3])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[3])); lua_setfield(L, -2, "augment_slot"); } @@ -1906,16 +1906,16 @@ void handle_player_augment_remove( lua_setfield(L, -2, "augment"); Seperator sep(data.c_str()); - lua_pushinteger(L, std::stoul(sep.arg[0])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[0])); lua_setfield(L, -2, "item_id"); lua_pushinteger(L, Strings::ToInt(sep.arg[1])); lua_setfield(L, -2, "item_slot"); - lua_pushinteger(L, std::stoul(sep.arg[2])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[2])); lua_setfield(L, -2, "augment_id"); - lua_pushinteger(L, std::stoul(sep.arg[3])); + lua_pushinteger(L, Strings::ToUnsignedInt(sep.arg[3])); lua_setfield(L, -2, "augment_slot"); lua_pushboolean(L, Strings::ToBool(sep.arg[4])); @@ -2166,25 +2166,25 @@ void handle_bot_trade( } auto money_string = fmt::format("platinum.{}", bot_id); - uint32 money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + uint32 money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "platinum"); money_string = fmt::format("gold.{}", bot_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "gold"); money_string = fmt::format("silver.{}", bot_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "silver"); money_string = fmt::format("copper.{}", bot_id); - money_value = !parse->GetVar(money_string).empty() ? std::stoul(parse->GetVar(money_string)) : 0; + money_value = !parse->GetVar(money_string).empty() ? Strings::ToUnsignedInt(parse->GetVar(money_string)) : 0; lua_pushinteger(L, money_value); lua_setfield(L, -2, "copper"); @@ -2223,10 +2223,10 @@ void handle_bot_equip_item( Seperator sep(data.c_str()); - lua_pushnumber(L, std::stoi(sep.arg[0])); + lua_pushnumber(L, Strings::ToInt(sep.arg[0])); lua_setfield(L, -2, "item_quantity"); - lua_pushnumber(L, std::stoi(sep.arg[1])); + lua_pushnumber(L, Strings::ToInt(sep.arg[1])); lua_setfield(L, -2, "slot_id"); Lua_ItemInst l_item(extra_data); @@ -2246,31 +2246,31 @@ void handle_bot_damage( ) { Seperator sep(data.c_str()); - lua_pushnumber(L, std::stoul(sep.arg[0])); + lua_pushnumber(L, Strings::ToUnsignedInt(sep.arg[0])); lua_setfield(L, -2, "entity_id"); - lua_pushnumber(L, std::stoll(sep.arg[1])); + lua_pushnumber(L, Strings::ToBigInt(sep.arg[1])); lua_setfield(L, -2, "damage"); - lua_pushnumber(L, std::stoi(sep.arg[2])); + lua_pushnumber(L, Strings::ToInt(sep.arg[2])); lua_setfield(L, -2, "spell_id"); - lua_pushnumber(L, std::stoi(sep.arg[3])); + lua_pushnumber(L, Strings::ToInt(sep.arg[3])); lua_setfield(L, -2, "skill_id"); - lua_pushboolean(L, std::stoi(sep.arg[4]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[4]) == 0 ? false : true); lua_setfield(L, -2, "is_damage_shield"); - lua_pushboolean(L, std::stoi(sep.arg[5]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[5]) == 0 ? false : true); lua_setfield(L, -2, "is_avoidable"); - lua_pushnumber(L, std::stoi(sep.arg[6])); + lua_pushnumber(L, Strings::ToInt(sep.arg[6])); lua_setfield(L, -2, "buff_slot"); - lua_pushboolean(L, std::stoi(sep.arg[7]) == 0 ? false : true); + lua_pushboolean(L, Strings::ToInt(sep.arg[7]) == 0 ? false : true); lua_setfield(L, -2, "is_buff_tic"); - lua_pushnumber(L, std::stoi(sep.arg[8])); + lua_pushnumber(L, Strings::ToInt(sep.arg[8])); lua_setfield(L, -2, "special_attack"); Lua_Mob l_mob(init); diff --git a/zone/main.cpp b/zone/main.cpp index ad8931a0a6..cb16f13aa9 100644 --- a/zone/main.cpp +++ b/zone/main.cpp @@ -163,7 +163,7 @@ int main(int argc, char** argv) { uint32 instance_id = 0; std::string z_name; if (argc == 4) { - instance_id = atoi(argv[3]); + instance_id = Strings::ToInt(argv[3]); worldserver.SetLauncherName(argv[2]); auto zone_port = Strings::Split(argv[1], ':'); @@ -173,7 +173,7 @@ int main(int argc, char** argv) { if (zone_port.size() > 1) { std::string p_name = zone_port[1]; - Config->SetZonePort(atoi(p_name.c_str())); + Config->SetZonePort(Strings::ToInt(p_name.c_str())); } worldserver.SetLaunchedName(z_name.c_str()); @@ -194,7 +194,7 @@ int main(int argc, char** argv) { if (zone_port.size() > 1) { std::string p_name = zone_port[1]; - Config->SetZonePort(atoi(p_name.c_str())); + Config->SetZonePort(Strings::ToInt(p_name.c_str())); } worldserver.SetLaunchedName(z_name.c_str()); @@ -215,7 +215,7 @@ int main(int argc, char** argv) { if (zone_port.size() > 1) { std::string p_name = zone_port[1]; - Config->SetZonePort(atoi(p_name.c_str())); + Config->SetZonePort(Strings::ToInt(p_name.c_str())); } worldserver.SetLaunchedName(z_name.c_str()); diff --git a/zone/merc.cpp b/zone/merc.cpp index e2945ba216..47e1794cd9 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -6121,8 +6121,8 @@ void NPC::LoadMercTypes() { { MercType tempMercType; - tempMercType.Type = atoi(row[0]); - tempMercType.ClientVersion = atoi(row[1]); + tempMercType.Type = Strings::ToInt(row[0]); + tempMercType.ClientVersion = Strings::ToInt(row[1]); mercTypeList.push_back(tempMercType); } @@ -6154,12 +6154,12 @@ void NPC::LoadMercs() { { MercData tempMerc; - tempMerc.MercTemplateID = atoi(row[0]); - tempMerc.MercType = atoi(row[1]); - tempMerc.MercSubType = atoi(row[2]); - tempMerc.CostFormula = atoi(row[3]); - tempMerc.ClientVersion = atoi(row[4]); - tempMerc.NPCID = atoi(row[5]); + tempMerc.MercTemplateID = Strings::ToInt(row[0]); + tempMerc.MercType = Strings::ToInt(row[1]); + tempMerc.MercSubType = Strings::ToInt(row[2]); + tempMerc.CostFormula = Strings::ToInt(row[3]); + tempMerc.ClientVersion = Strings::ToInt(row[4]); + tempMerc.NPCID = Strings::ToInt(row[5]); mercDataList.push_back(tempMerc); } diff --git a/zone/mob.cpp b/zone/mob.cpp index 5a89141080..8a921c79ee 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -5351,7 +5351,7 @@ int Mob::QGVarDuration(const char *fmt) // Set val to value after type character // e.g., for "M3924", set to 3924 - int val = atoi(&fmt[0] + 1); + int val = Strings::ToInt(&fmt[0] + 1); switch (fmt[0]) { @@ -6429,8 +6429,8 @@ void Mob::ProcessSpecialAbilities(const std::string &str) { Strings::IsNumber(sub_sp[0]) && Strings::IsNumber(sub_sp[1]) ) { - int ability_id = std::stoi(sub_sp[0]); - int value = std::stoi(sub_sp[1]); + int ability_id = Strings::ToInt(sub_sp[0]); + int value = Strings::ToInt(sub_sp[1]); SetSpecialAbility(ability_id, value); @@ -6457,7 +6457,7 @@ void Mob::ProcessSpecialAbilities(const std::string &str) { } if (Strings::IsNumber(sub_sp[i])) { - SetSpecialAbilityParam(ability_id, param_id, std::stoi(sub_sp[i])); + SetSpecialAbilityParam(ability_id, param_id, Strings::ToInt(sub_sp[i])); } } } @@ -7066,9 +7066,9 @@ std::string Mob::GetBucketKey() { std::string Mob::GetBucketRemaining(std::string bucket_name) { std::string full_bucket_name = fmt::format("{}-{}", GetBucketKey(), bucket_name); std::string bucket_remaining = DataBucket::GetDataRemaining(full_bucket_name); - if (!bucket_remaining.empty() && atoi(bucket_remaining.c_str()) > 0) { + if (!bucket_remaining.empty() && Strings::ToInt(bucket_remaining.c_str()) > 0) { return bucket_remaining; - } else if (atoi(bucket_remaining.c_str()) == 0) { + } else if (Strings::ToInt(bucket_remaining.c_str()) == 0) { return "0"; } return std::string(); diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp index 9152b076d8..2041fe9e66 100644 --- a/zone/mob_ai.cpp +++ b/zone/mob_ai.cpp @@ -2858,25 +2858,25 @@ DBnpcspells_Struct *ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) auto row = results.begin(); DBnpcspells_Struct spell_set; - spell_set.parent_list = atoi(row[1]); - spell_set.attack_proc = atoi(row[2]); - spell_set.proc_chance = atoi(row[3]); - spell_set.range_proc = atoi(row[4]); - spell_set.rproc_chance = atoi(row[5]); - spell_set.defensive_proc = atoi(row[6]); - spell_set.dproc_chance = atoi(row[7]); - spell_set.fail_recast = atoi(row[8]); - spell_set.engaged_no_sp_recast_min = atoi(row[9]); - spell_set.engaged_no_sp_recast_max = atoi(row[10]); - spell_set.engaged_beneficial_self_chance = atoi(row[11]); - spell_set.engaged_beneficial_other_chance = atoi(row[12]); - spell_set.engaged_detrimental_chance = atoi(row[13]); - spell_set.pursue_no_sp_recast_min = atoi(row[14]); - spell_set.pursue_no_sp_recast_max = atoi(row[15]); - spell_set.pursue_detrimental_chance = atoi(row[16]); - spell_set.idle_no_sp_recast_min = atoi(row[17]); - spell_set.idle_no_sp_recast_max = atoi(row[18]); - spell_set.idle_beneficial_chance = atoi(row[19]); + spell_set.parent_list = Strings::ToInt(row[1]); + spell_set.attack_proc = Strings::ToInt(row[2]); + spell_set.proc_chance = Strings::ToInt(row[3]); + spell_set.range_proc = Strings::ToInt(row[4]); + spell_set.rproc_chance = Strings::ToInt(row[5]); + spell_set.defensive_proc = Strings::ToInt(row[6]); + spell_set.dproc_chance = Strings::ToInt(row[7]); + spell_set.fail_recast = Strings::ToInt(row[8]); + spell_set.engaged_no_sp_recast_min = Strings::ToInt(row[9]); + spell_set.engaged_no_sp_recast_max = Strings::ToInt(row[10]); + spell_set.engaged_beneficial_self_chance = Strings::ToInt(row[11]); + spell_set.engaged_beneficial_other_chance = Strings::ToInt(row[12]); + spell_set.engaged_detrimental_chance = Strings::ToInt(row[13]); + spell_set.pursue_no_sp_recast_min = Strings::ToInt(row[14]); + spell_set.pursue_no_sp_recast_max = Strings::ToInt(row[15]); + spell_set.pursue_detrimental_chance = Strings::ToInt(row[16]); + spell_set.idle_no_sp_recast_min = Strings::ToInt(row[17]); + spell_set.idle_no_sp_recast_max = Strings::ToInt(row[18]); + spell_set.idle_beneficial_chance = Strings::ToInt(row[19]); // pulling fixed values from an auto-increment field is dangerous... query = StringFormat( @@ -2894,23 +2894,23 @@ DBnpcspells_Struct *ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) int entryIndex = 0; for (row = results.begin(); row != results.end(); ++row, ++entryIndex) { DBnpcspells_entries_Struct entry; - int spell_id = atoi(row[0]); + int spell_id = Strings::ToInt(row[0]); entry.spellid = spell_id; - entry.type = atoul(row[1]); - entry.minlevel = atoi(row[2]); - entry.maxlevel = atoi(row[3]); - entry.manacost = atoi(row[4]); - entry.recast_delay = atoi(row[5]); - entry.priority = atoi(row[6]); - entry.min_hp = atoi(row[7]); - entry.max_hp = atoi(row[8]); + entry.type = Strings::ToUnsignedInt(row[1]); + entry.minlevel = Strings::ToInt(row[2]); + entry.maxlevel = Strings::ToInt(row[3]); + entry.manacost = Strings::ToInt(row[4]); + entry.recast_delay = Strings::ToInt(row[5]); + entry.priority = Strings::ToInt(row[6]); + entry.min_hp = Strings::ToInt(row[7]); + entry.max_hp = Strings::ToInt(row[8]); // some spell types don't make much since to be priority 0, so fix that if (!(entry.type & SPELL_TYPES_INNATE) && entry.priority == 0) entry.priority = 1; if (row[9]) - entry.resist_adjust = atoi(row[9]); + entry.resist_adjust = Strings::ToInt(row[9]); else if (IsValidSpell(spell_id)) entry.resist_adjust = spells[spell_id].resist_difficulty; @@ -2941,7 +2941,7 @@ uint32 ZoneDatabase::GetMaxNPCSpellsID() { if (!row[0]) return 0; - return atoi(row[0]); + return Strings::ToInt(row[0]); } DBnpcspellseffects_Struct *ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEffectsID) @@ -2981,7 +2981,7 @@ DBnpcspellseffects_Struct *ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEff return nullptr; auto row = results.begin(); - uint32 tmpparent_list = atoi(row[1]); + uint32 tmpparent_list = Strings::ToInt(row[1]); query = StringFormat("SELECT spell_effect_id, minlevel, " "maxlevel,se_base, se_limit, se_max " @@ -3001,13 +3001,13 @@ DBnpcspellseffects_Struct *ZoneDatabase::GetNPCSpellsEffects(uint32 iDBSpellsEff int entryIndex = 0; for (row = results.begin(); row != results.end(); ++row, ++entryIndex) { - int spell_effect_id = atoi(row[0]); + int spell_effect_id = Strings::ToInt(row[0]); npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].spelleffectid = spell_effect_id; - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].minlevel = atoi(row[1]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].maxlevel = atoi(row[2]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].base_value = atoi(row[3]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].limit = atoi(row[4]); - npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].max_value = atoi(row[5]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].minlevel = Strings::ToInt(row[1]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].maxlevel = Strings::ToInt(row[2]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].base_value = Strings::ToInt(row[3]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].limit = Strings::ToInt(row[4]); + npc_spellseffects_cache[iDBSpellsEffectsID]->entries[entryIndex].max_value = Strings::ToInt(row[5]); } return npc_spellseffects_cache[iDBSpellsEffectsID]; @@ -3028,6 +3028,6 @@ uint32 ZoneDatabase::GetMaxNPCSpellsEffectsID() { if (!row[0]) return 0; - return atoi(row[0]); + return Strings::ToInt(row[0]); } diff --git a/zone/mob_appearance.cpp b/zone/mob_appearance.cpp index 192e5d0022..4441d840a9 100644 --- a/zone/mob_appearance.cpp +++ b/zone/mob_appearance.cpp @@ -239,7 +239,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const if (inst->GetOrnamentationAug(ornamentation_augment_type)) { item = inst->GetOrnamentationAug(ornamentation_augment_type)->GetItem(); if (item && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) { - equipment_material = std::stoi(&item->IDFile[2]); + equipment_material = Strings::ToInt(&item->IDFile[2]); } } else if (inst->GetOrnamentationIDFile()) { equipment_material = inst->GetOrnamentationIDFile(); @@ -248,7 +248,7 @@ int32 Mob::GetEquipmentMaterial(uint8 material_slot) const } if (!equipment_material && strlen(item->IDFile) > 2 && Strings::IsNumber(&item->IDFile[2])) { - equipment_material = std::stoi(&item->IDFile[2]); + equipment_material = Strings::ToInt(&item->IDFile[2]); } } else { diff --git a/zone/npc.cpp b/zone/npc.cpp index 150e52688f..aabfe2a80c 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1397,7 +1397,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client* if (!sep.IsNumber(3)) { sprintf(sep.arg[3], "0"); } - if (atoi(sep.arg[4]) > 2100000000 || atoi(sep.arg[4]) <= 0) { + if (Strings::ToInt(sep.arg[4]) > 2100000000 || Strings::ToInt(sep.arg[4]) <= 0) { sprintf(sep.arg[4], " "); } if (!strcmp(sep.arg[5], "-")) { @@ -1431,7 +1431,7 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client* // Autoselect NPC Gender if (sep.arg[5][0] == 0) { - sprintf(sep.arg[5], "%i", (int) Mob::GetDefaultGender(atoi(sep.arg[1]))); + sprintf(sep.arg[5], "%i", (int) Mob::GetDefaultGender(Strings::ToInt(sep.arg[1]))); } //Time to create the NPC!! @@ -1439,22 +1439,22 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client* memset(npc_type, 0, sizeof(NPCType)); strncpy(npc_type->name, sep.arg[0], 60); - npc_type->current_hp = atoi(sep.arg[4]); - npc_type->max_hp = atoi(sep.arg[4]); - npc_type->race = atoi(sep.arg[1]); - npc_type->gender = atoi(sep.arg[5]); - npc_type->class_ = atoi(sep.arg[6]); + npc_type->current_hp = Strings::ToInt(sep.arg[4]); + npc_type->max_hp = Strings::ToInt(sep.arg[4]); + npc_type->race = Strings::ToInt(sep.arg[1]); + npc_type->gender = Strings::ToInt(sep.arg[5]); + npc_type->class_ = Strings::ToInt(sep.arg[6]); npc_type->deity = 1; - npc_type->level = atoi(sep.arg[2]); + npc_type->level = Strings::ToInt(sep.arg[2]); npc_type->npc_id = 0; npc_type->loottable_id = 0; - npc_type->texture = atoi(sep.arg[3]); + npc_type->texture = Strings::ToInt(sep.arg[3]); npc_type->light = 0; // spawncommand needs update npc_type->runspeed = 1.25; - npc_type->d_melee_texture1 = atoi(sep.arg[7]); - npc_type->d_melee_texture2 = atoi(sep.arg[8]); - npc_type->merchanttype = atoi(sep.arg[9]); - npc_type->bodytype = atoi(sep.arg[10]); + npc_type->d_melee_texture1 = Strings::ToInt(sep.arg[7]); + npc_type->d_melee_texture2 = Strings::ToInt(sep.arg[8]); + npc_type->merchanttype = Strings::ToInt(sep.arg[9]); + npc_type->bodytype = Strings::ToInt(sep.arg[10]); npc_type->STR = 0; npc_type->STA = 0; @@ -1517,7 +1517,7 @@ uint32 ZoneDatabase::CreateNewNPCCommand( if (results.Success()) { if (results.RowCount() != 0) { auto row = results.begin(); - npc_type_id = atoi(row[0]) + 1; + npc_type_id = Strings::ToInt(row[0]) + 1; // Prevent the npc_type id from exceeding the range for this zone if (npc_type_id >= (starting_npc_id + 1000)) { npc_type_id = 0; @@ -1676,10 +1676,10 @@ uint32 ZoneDatabase::DeleteSpawnLeaveInNPCTypeTable(const char *zone, Client *cl auto row = results.begin(); if (row[0]) - id = atoi(row[0]); + id = Strings::ToInt(row[0]); if (row[1]) - spawngroupID = atoi(row[1]); + spawngroupID = Strings::ToInt(row[1]); query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id); results = QueryDatabase(query); @@ -1718,10 +1718,10 @@ uint32 ZoneDatabase::DeleteSpawnRemoveFromNPCTypeTable(const char *zone, uint32 auto row = results.begin(); if (row[0]) - id = atoi(row[0]); + id = Strings::ToInt(row[0]); if (row[1]) - spawngroupID = atoi(row[1]); + spawngroupID = Strings::ToInt(row[1]); query = StringFormat("DELETE FROM spawn2 WHERE id = '%i'", id); results = QueryDatabase(query); @@ -2488,43 +2488,43 @@ void NPC::ModifyNPCStat(std::string stat, std::string value) LogNPCScaling("NPC::ModifyNPCStat: Key [{}] Value [{}] ", variable_key, value); if (stat_lower == "ac") { - AC = atoi(value.c_str()); + AC = Strings::ToInt(value.c_str()); CalcAC(); return; } else if (stat_lower == "str") { - STR = atoi(value.c_str()); + STR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "sta") { - STA = atoi(value.c_str()); + STA = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "agi") { - AGI = atoi(value.c_str()); + AGI = Strings::ToInt(value.c_str()); CalcAC(); return; } else if (stat_lower == "dex") { - DEX = atoi(value.c_str()); + DEX = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "wis") { - WIS = atoi(value.c_str()); + WIS = Strings::ToInt(value.c_str()); CalcMaxMana(); return; } else if (stat_lower == "int" || stat_lower == "_int") { - INT = atoi(value.c_str()); + INT = Strings::ToInt(value.c_str()); CalcMaxMana(); return; } else if (stat_lower == "cha") { - CHA = atoi(value.c_str()); + CHA = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "max_hp") { - base_hp = std::stoull(value.c_str()); + base_hp = Strings::ToUnsignedBigInt(value.c_str()); CalcMaxHP(); if (current_hp > max_hp) { @@ -2534,7 +2534,7 @@ void NPC::ModifyNPCStat(std::string stat, std::string value) return; } else if (stat_lower == "max_mana") { - npc_mana = std::stoull(value.c_str()); + npc_mana = Strings::ToUnsignedBigInt(value.c_str()); CalcMaxMana(); if (current_mana > max_mana) { current_mana = max_mana; @@ -2542,35 +2542,35 @@ void NPC::ModifyNPCStat(std::string stat, std::string value) return; } else if (stat_lower == "mr") { - MR = atoi(value.c_str()); + MR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "fr") { - FR = atoi(value.c_str()); + FR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "cr") { - CR = atoi(value.c_str()); + CR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "cor") { - Corrup = atoi(value.c_str()); + Corrup = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "pr") { - PR = atoi(value.c_str()); + PR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "dr") { - DR = atoi(value.c_str()); + DR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "phr") { - PhR = atoi(value.c_str()); + PhR = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "runspeed") { - runspeed = (float) atof(value.c_str()); + runspeed = (float) Strings::ToFloat(value.c_str()); base_runspeed = (int) ((float) runspeed * 40.0f); base_walkspeed = base_runspeed * 100 / 265; walkspeed = ((float) base_walkspeed) * 0.025f; @@ -2588,64 +2588,64 @@ void NPC::ModifyNPCStat(std::string stat, std::string value) return; } else if (stat_lower == "attack_speed") { - attack_speed = (float) atof(value.c_str()); + attack_speed = (float) Strings::ToFloat(value.c_str()); CalcBonuses(); return; } else if (stat_lower == "attack_delay") { /* TODO: fix DB */ - attack_delay = atoi(value.c_str()) * 100; + attack_delay = Strings::ToInt(value.c_str()) * 100; CalcBonuses(); return; } else if (stat_lower == "atk") { - ATK = atoi(value.c_str()); + ATK = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "accuracy") { - accuracy_rating = atoi(value.c_str()); + accuracy_rating = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "avoidance") { - avoidance_rating = atoi(value.c_str()); + avoidance_rating = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "trackable") { - trackable = atoi(value.c_str()); + trackable = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "min_hit") { - min_dmg = atoi(value.c_str()); + min_dmg = Strings::ToInt(value.c_str()); // TODO: fix DB base_damage = round((max_dmg - min_dmg) / 1.9); min_damage = min_dmg - round(base_damage / 10.0); return; } else if (stat_lower == "max_hit") { - max_dmg = atoi(value.c_str()); + max_dmg = Strings::ToInt(value.c_str()); // TODO: fix DB base_damage = round((max_dmg - min_dmg) / 1.9); min_damage = min_dmg - round(base_damage / 10.0); return; } else if (stat_lower == "attack_count") { - attack_count = atoi(value.c_str()); + attack_count = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "see_invis") { - see_invis = atoi(value.c_str()); + see_invis = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "see_invis_undead") { - see_invis_undead = atoi(value.c_str()); + see_invis_undead = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "see_hide") { - see_hide = atoi(value.c_str()); + see_hide = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "see_improved_hide") { - see_improved_hide = atoi(value.c_str()); + see_improved_hide = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "hp_regen") { @@ -2661,44 +2661,44 @@ void NPC::ModifyNPCStat(std::string stat, std::string value) return; } else if (stat_lower == "level") { - SetLevel(atoi(value.c_str())); + SetLevel(Strings::ToInt(value.c_str())); return; } else if (stat_lower == "aggro") { - pAggroRange = atof(value.c_str()); + pAggroRange = Strings::ToFloat(value.c_str()); return; } else if (stat_lower == "assist") { - pAssistRange = atof(value.c_str()); + pAssistRange = Strings::ToFloat(value.c_str()); return; } else if (stat_lower == "slow_mitigation") { - slow_mitigation = atoi(value.c_str()); + slow_mitigation = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "loottable_id") { - loottable_id = atof(value.c_str()); + loottable_id = Strings::ToFloat(value.c_str()); return; } else if (stat_lower == "healscale") { - healscale = atof(value.c_str()); + healscale = Strings::ToFloat(value.c_str()); return; } else if (stat_lower == "spellscale") { - spellscale = atof(value.c_str()); + spellscale = Strings::ToFloat(value.c_str()); return; } else if (stat_lower == "npc_spells_id") { - AI_AddNPCSpells(atoi(value.c_str())); + AI_AddNPCSpells(Strings::ToInt(value.c_str())); return; } else if (stat_lower == "npc_spells_effects_id") { - AI_AddNPCSpellsEffects(atoi(value.c_str())); + AI_AddNPCSpellsEffects(Strings::ToInt(value.c_str())); CalcBonuses(); return; } else if (stat_lower == "heroic_strikethrough") { - heroic_strikethrough = atoi(value.c_str()); + heroic_strikethrough = Strings::ToInt(value.c_str()); return; } else if (stat_lower == "keeps_sold_items") { diff --git a/zone/object.cpp b/zone/object.cpp index c223ec248b..1c8931b0e6 100644 --- a/zone/object.cpp +++ b/zone/object.cpp @@ -774,16 +774,16 @@ Ground_Spawns* ZoneDatabase::LoadGroundSpawns(uint32 zone_id, int16 version, Gro int spawnIndex=0; for (auto row = results.begin(); row != results.end(); ++row, ++spawnIndex) { - gs->spawn[spawnIndex].max_x=atof(row[0]); - gs->spawn[spawnIndex].max_y=atof(row[1]); - gs->spawn[spawnIndex].max_z=atof(row[2]); - gs->spawn[spawnIndex].min_x=atof(row[3]); - gs->spawn[spawnIndex].min_y=atof(row[4]); - gs->spawn[spawnIndex].heading=atof(row[5]); + gs->spawn[spawnIndex].max_x=Strings::ToFloat(row[0]); + gs->spawn[spawnIndex].max_y=Strings::ToFloat(row[1]); + gs->spawn[spawnIndex].max_z=Strings::ToFloat(row[2]); + gs->spawn[spawnIndex].min_x=Strings::ToFloat(row[3]); + gs->spawn[spawnIndex].min_y=Strings::ToFloat(row[4]); + gs->spawn[spawnIndex].heading=Strings::ToFloat(row[5]); strcpy(gs->spawn[spawnIndex].name,row[6]); - gs->spawn[spawnIndex].item=atoi(row[7]); - gs->spawn[spawnIndex].max_allowed=atoi(row[8]); - gs->spawn[spawnIndex].respawntimer=atoi(row[9]); + gs->spawn[spawnIndex].item=Strings::ToInt(row[7]); + gs->spawn[spawnIndex].max_allowed=Strings::ToInt(row[8]); + gs->spawn[spawnIndex].respawntimer=Strings::ToInt(row[9]); } return gs; } diff --git a/zone/petitions.cpp b/zone/petitions.cpp index d5accbbd32..5e2f60cd7f 100644 --- a/zone/petitions.cpp +++ b/zone/petitions.cpp @@ -270,22 +270,22 @@ void ZoneDatabase::RefreshPetitionsFromDB() } for (auto row = results.begin(); row != results.end(); ++row) { - newpet = new Petition(atoi(row[0])); + newpet = new Petition(Strings::ToInt(row[0])); newpet->SetCName(row[1]); newpet->SetAName(row[2]); newpet->SetLastGM(row[3]); newpet->SetPetitionText(row[4]); - newpet->SetZone(atoi(row[5])); - newpet->SetUrgency(atoi(row[6])); - newpet->SetClass(atoi(row[7])); - newpet->SetRace(atoi(row[8])); - newpet->SetLevel(atoi(row[9])); - newpet->SetCheckouts(atoi(row[10])); - newpet->SetUnavails(atoi(row[11])); + newpet->SetZone(Strings::ToInt(row[5])); + newpet->SetUrgency(Strings::ToInt(row[6])); + newpet->SetClass(Strings::ToInt(row[7])); + newpet->SetRace(Strings::ToInt(row[8])); + newpet->SetLevel(Strings::ToInt(row[9])); + newpet->SetCheckouts(Strings::ToInt(row[10])); + newpet->SetUnavails(Strings::ToInt(row[11])); newpet->SetSentTime2(atol(row[13])); newpet->SetGMText(row[14]); - if (atoi(row[12]) == 1) + if (Strings::ToInt(row[12]) == 1) newpet->SetCheckedOut(true); else newpet->SetCheckedOut(false); diff --git a/zone/pets.cpp b/zone/pets.cpp index b169f7afe1..8c50185188 100644 --- a/zone/pets.cpp +++ b/zone/pets.cpp @@ -327,7 +327,7 @@ void Mob::MakePoweredPet(uint16 spell_id, const char* pettype, int16 petpower, if (results.RowCount() != 0) { auto row = results.begin(); - monsterid = atoi(row[0]); + monsterid = Strings::ToInt(row[0]); } // since we don't have any monsters, just make it look like an earth pet for now @@ -491,13 +491,13 @@ bool ZoneDatabase::GetPoweredPetEntry(const char *pet_type, int16 petpower, PetR auto row = results.begin(); - into->npc_type = atoi(row[0]); - into->temporary = atoi(row[1]); - into->petpower = atoi(row[2]); - into->petcontrol = atoi(row[3]); - into->petnaming = atoi(row[4]); - into->monsterflag = atoi(row[5]); - into->equipmentset = atoi(row[6]); + into->npc_type = Strings::ToInt(row[0]); + into->temporary = Strings::ToInt(row[1]); + into->petpower = Strings::ToInt(row[2]); + into->petcontrol = Strings::ToInt(row[3]); + into->petnaming = Strings::ToInt(row[4]); + into->monsterflag = Strings::ToInt(row[5]); + into->equipmentset = Strings::ToInt(row[6]); return true; } @@ -719,20 +719,20 @@ bool ZoneDatabase::GetBasePetItems(int32 equipmentset, uint32 *items) { } auto row = results.begin(); - nextset = atoi(row[0]); + nextset = Strings::ToInt(row[0]); query = StringFormat("SELECT slot, item_id FROM pets_equipmentset_entries WHERE set_id='%d'", curset); results = QueryDatabase(query); if (results.Success()) { for (row = results.begin(); row != results.end(); ++row) { - slot = atoi(row[0]); + slot = Strings::ToInt(row[0]); if (slot > EQ::invslot::EQUIPMENT_END) continue; if (items[slot] == 0) - items[slot] = atoi(row[1]); + items[slot] = Strings::ToInt(row[1]); } } @@ -768,11 +768,11 @@ BeastlordPetData::PetStruct ZoneDatabase::GetBeastlordPetData(uint16 race_id) { } auto row = results.begin(); - beastlord_pet_data.race_id = atoi(row[0]); - beastlord_pet_data.texture = atoi(row[1]); - beastlord_pet_data.helm_texture = atoi(row[2]); - beastlord_pet_data.gender = atoi(row[3]); - beastlord_pet_data.size_modifier = atof(row[4]); - beastlord_pet_data.face = atoi(row[5]); + beastlord_pet_data.race_id = Strings::ToInt(row[0]); + beastlord_pet_data.texture = Strings::ToInt(row[1]); + beastlord_pet_data.helm_texture = Strings::ToInt(row[2]); + beastlord_pet_data.gender = Strings::ToInt(row[3]); + beastlord_pet_data.size_modifier = Strings::ToFloat(row[4]); + beastlord_pet_data.face = Strings::ToInt(row[5]); return beastlord_pet_data; } diff --git a/zone/qglobals.cpp b/zone/qglobals.cpp index fee93765d3..ce65598c37 100644 --- a/zone/qglobals.cpp +++ b/zone/qglobals.cpp @@ -171,5 +171,5 @@ void QGlobalCache::LoadBy(const std::string &query) return; for (auto row = results.begin(); row != results.end(); ++row) - AddGlobal(0, QGlobal(row[0], atoi(row[1]), atoi(row[2]), atoi(row[3]), row[4], row[5] ? atoi(row[5]) : 0xFFFFFFFF)); + AddGlobal(0, QGlobal(row[0], Strings::ToInt(row[1]), Strings::ToInt(row[2]), Strings::ToInt(row[3]), row[4], row[5] ? Strings::ToInt(row[5]) : 0xFFFFFFFF)); } diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 152dc670c4..7669512c1e 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -1660,7 +1660,7 @@ int QuestManager::QGVarDuration(const char *fmt) // Set val to value after type character // e.g., for "M3924", set to 3924 - int val = atoi(&fmt[0] + 1); + int val = Strings::ToInt(&fmt[0] + 1); switch (fmt[0]) { @@ -1925,9 +1925,9 @@ void QuestManager::showgrid(int grid) { } for(auto row = results.begin(); row != results.end(); ++row) { - pt.x = atof(row[0]); - pt.y = atof(row[1]); - pt.z = atof(row[2]); + pt.x = Strings::ToFloat(row[0]); + pt.y = Strings::ToFloat(row[1]); + pt.z = Strings::ToFloat(row[2]); pts.push_back(pt); } @@ -3064,7 +3064,7 @@ uint32 QuestManager::GetInstanceTimerByID(uint16 instance_id) { if (results.Success()) { auto row = results.begin(); - uint32 timer = atoi(row[0]); + uint32 timer = Strings::ToInt(row[0]); return timer; } return 0; @@ -3544,71 +3544,71 @@ std::string QuestManager::GetEncounter() const { void QuestManager::UpdateZoneHeader(std::string type, std::string value) { if (strcasecmp(type.c_str(), "ztype") == 0) - zone->newzone_data.ztype = atoi(value.c_str()); + zone->newzone_data.ztype = Strings::ToInt(value.c_str()); else if (strcasecmp(type.c_str(), "fog_red") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.fog_red[i] = atoi(value.c_str()); + zone->newzone_data.fog_red[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "fog_green") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.fog_green[i] = atoi(value.c_str()); + zone->newzone_data.fog_green[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "fog_blue") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.fog_blue[i] = atoi(value.c_str()); + zone->newzone_data.fog_blue[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "fog_minclip") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.fog_minclip[i] = atof(value.c_str()); + zone->newzone_data.fog_minclip[i] = Strings::ToFloat(value.c_str()); } } else if (strcasecmp(type.c_str(), "fog_maxclip") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.fog_maxclip[i] = atof(value.c_str()); + zone->newzone_data.fog_maxclip[i] = Strings::ToFloat(value.c_str()); } } else if (strcasecmp(type.c_str(), "gravity") == 0) { - zone->newzone_data.gravity = atof(value.c_str()); + zone->newzone_data.gravity = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "time_type") == 0) { - zone->newzone_data.time_type = atoi(value.c_str()); + zone->newzone_data.time_type = Strings::ToInt(value.c_str()); } else if (strcasecmp(type.c_str(), "rain_chance") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.rain_chance[i] = atoi(value.c_str()); + zone->newzone_data.rain_chance[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "rain_duration") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.rain_duration[i] = atoi(value.c_str()); + zone->newzone_data.rain_duration[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "snow_chance") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.snow_chance[i] = atoi(value.c_str()); + zone->newzone_data.snow_chance[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "snow_duration") == 0) { for (int i = 0; i < 4; i++) { - zone->newzone_data.snow_duration[i] = atoi(value.c_str()); + zone->newzone_data.snow_duration[i] = Strings::ToInt(value.c_str()); } } else if (strcasecmp(type.c_str(), "sky") == 0) { - zone->newzone_data.sky = atoi(value.c_str()); + zone->newzone_data.sky = Strings::ToInt(value.c_str()); } else if (strcasecmp(type.c_str(), "safe_x") == 0) { - zone->newzone_data.safe_x = atof(value.c_str()); + zone->newzone_data.safe_x = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "safe_y") == 0) { - zone->newzone_data.safe_y = atof(value.c_str()); + zone->newzone_data.safe_y = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "safe_z") == 0) { - zone->newzone_data.safe_z = atof(value.c_str()); + zone->newzone_data.safe_z = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "max_z") == 0) { - zone->newzone_data.max_z = atof(value.c_str()); + zone->newzone_data.max_z = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "underworld") == 0) { - zone->newzone_data.underworld = atof(value.c_str()); + zone->newzone_data.underworld = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "minclip") == 0) { - zone->newzone_data.minclip = atof(value.c_str()); + zone->newzone_data.minclip = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "maxclip") == 0) { - zone->newzone_data.maxclip = atof(value.c_str()); + zone->newzone_data.maxclip = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "fog_density") == 0) { - zone->newzone_data.fog_density = atof(value.c_str()); + zone->newzone_data.fog_density = Strings::ToFloat(value.c_str()); } else if (strcasecmp(type.c_str(), "suspendbuffs") == 0) { - zone->newzone_data.suspend_buffs = atoi(value.c_str()); + zone->newzone_data.suspend_buffs = Strings::ToInt(value.c_str()); } else if (strcasecmp(type.c_str(), "lavadamage") == 0) { - zone->newzone_data.lava_damage = atoi(value.c_str()); + zone->newzone_data.lava_damage = Strings::ToInt(value.c_str()); } else if (strcasecmp(type.c_str(), "minlavadamage") == 0) { - zone->newzone_data.min_lava_damage = atoi(value.c_str()); + zone->newzone_data.min_lava_damage = Strings::ToInt(value.c_str()); } auto outapp = new EQApplicationPacket(OP_NewZone, sizeof(NewZone_Struct)); @@ -4054,16 +4054,17 @@ void QuestManager::SendPlayerHandinEvent() { Strings::IsNumber(item_data[1]) && Strings::IsNumber(item_data[2]) ) { - const auto item_id = static_cast(std::stoul(item_data[0])); + const auto item_id = static_cast(Strings::ToUnsignedInt(item_data[0])); if (item_id != 0) { const auto *item = database.GetItem(item_id); + if (item) { hi.emplace_back( PlayerEvent::HandinEntry{ .item_id = item_id, .item_name = item->Name, - .charges = static_cast(std::stoul(item_data[1])), - .attuned = std::stoi(item_data[2]) ? true : false + .charges = static_cast(Strings::ToUnsignedInt(item_data[1])), + .attuned = Strings::ToInt(item_data[2]) ? true : false } ); } @@ -4079,15 +4080,16 @@ void QuestManager::SendPlayerHandinEvent() { Strings::IsNumber(item_data[1]) && Strings::IsNumber(item_data[2]) ) { - const auto item_id = static_cast(std::stoul(item_data[0])); + const auto item_id = static_cast(Strings::ToUnsignedInt(item_data[0])); const auto *item = database.GetItem(item_id); + if (item) { hi.emplace_back( PlayerEvent::HandinEntry{ .item_id = item_id, .item_name = item->Name, - .charges = static_cast(std::stoul(item_data[1])), - .attuned = std::stoi(item_data[2]) ? true : false + .charges = static_cast(Strings::ToUnsignedInt(item_data[1])), + .attuned = Strings::ToInt(item_data[2]) ? true : false } ); } @@ -4098,10 +4100,10 @@ void QuestManager::SendPlayerHandinEvent() { // Handin Money if (!handin_money.empty()) { const auto hms = Strings::Split(handin_money, "|"); - hm.copper = static_cast(std::stoul(hms[0])); - hm.silver = static_cast(std::stoul(hms[1])); - hm.gold = static_cast(std::stoul(hms[2])); - hm.platinum = static_cast(std::stoul(hms[3])); + hm.copper = static_cast(Strings::ToUnsignedInt(hms[0])); + hm.silver = static_cast(Strings::ToUnsignedInt(hms[1])); + hm.gold = static_cast(Strings::ToUnsignedInt(hms[2])); + hm.platinum = static_cast(Strings::ToUnsignedInt(hms[3])); } // Return Items @@ -4116,7 +4118,7 @@ void QuestManager::SendPlayerHandinEvent() { Strings::IsNumber(item_data[1]) && Strings::IsNumber(item_data[2]) ) { - const auto item_id = static_cast(std::stoul(item_data[0])); + const auto item_id = static_cast(Strings::ToUnsignedInt(item_data[0])); const auto *item = database.GetItem(item_id); if (item) { @@ -4124,8 +4126,8 @@ void QuestManager::SendPlayerHandinEvent() { PlayerEvent::HandinEntry{ .item_id = item_id, .item_name = item->Name, - .charges = static_cast(std::stoul(item_data[1])), - .attuned = std::stoi(item_data[2]) ? true : false + .charges = static_cast(Strings::ToUnsignedInt(item_data[1])), + .attuned = Strings::ToInt(item_data[2]) ? true : false } ); } @@ -4140,7 +4142,7 @@ void QuestManager::SendPlayerHandinEvent() { Strings::IsNumber(item_data[1]) && Strings::IsNumber(item_data[2]) ) { - const auto item_id = static_cast(std::stoul(item_data[0])); + const auto item_id = static_cast(Strings::ToUnsignedInt(item_data[0])); const auto *item = database.GetItem(item_id); if (item) { @@ -4148,8 +4150,8 @@ void QuestManager::SendPlayerHandinEvent() { PlayerEvent::HandinEntry{ .item_id = item_id, .item_name = item->Name, - .charges = static_cast(std::stoul(item_data[1])), - .attuned = std::stoi(item_data[2]) ? true : false + .charges = static_cast(Strings::ToUnsignedInt(item_data[1])), + .attuned = Strings::ToInt(item_data[2]) ? true : false } ); } @@ -4160,10 +4162,10 @@ void QuestManager::SendPlayerHandinEvent() { // Return Money if (!return_money.empty()) { const auto rms = Strings::Split(return_money, "|"); - rm.copper = static_cast(std::stoul(rms[0])); - rm.silver = static_cast(std::stoul(rms[1])); - rm.gold = static_cast(std::stoul(rms[2])); - rm.platinum = static_cast(std::stoul(rms[3])); + rm.copper = static_cast(Strings::ToUnsignedInt(rms[0])); + rm.silver = static_cast(Strings::ToUnsignedInt(rms[1])); + rm.gold = static_cast(Strings::ToUnsignedInt(rms[2])); + rm.platinum = static_cast(Strings::ToUnsignedInt(rms[3])); } initiator->DeleteEntityVariable("HANDIN_ITEMS"); diff --git a/zone/raids.cpp b/zone/raids.cpp index 1fef457474..0b7e928574 100644 --- a/zone/raids.cpp +++ b/zone/raids.cpp @@ -1597,8 +1597,8 @@ void Raid::GetRaidDetails() auto row = results.begin(); - locked = atoi(row[0]); - LootType = atoi(row[1]); + locked = Strings::ToInt(row[0]); + LootType = Strings::ToInt(row[1]); motd = std::string(row[2]); } @@ -1641,24 +1641,24 @@ bool Raid::LearnMembers() if (!row[0]) continue; - members[index].member = nullptr; - strn0cpy(members[index].membername, row[0], 64); - int groupNum = atoi(row[1]); - if (groupNum > 11) - members[index].GroupNumber = 0xFFFFFFFF; - else - members[index].GroupNumber = groupNum; - - members[index]._class = atoi(row[2]); - members[index].level = atoi(row[3]); - members[index].IsGroupLeader = atoi(row[4]); - members[index].IsRaidLeader = atoi(row[5]); - members[index].IsLooter = atoi(row[6]); + members[index].member = nullptr; + strn0cpy(members[index].membername, row[0], 64); + int groupNum = Strings::ToInt(row[1]); + if(groupNum > 11) + members[index].GroupNumber = 0xFFFFFFFF; + else + members[index].GroupNumber = groupNum; + + members[index]._class = Strings::ToInt(row[2]); + members[index].level = Strings::ToInt(row[3]); + members[index].IsGroupLeader = Strings::ToInt(row[4]); + members[index].IsRaidLeader = Strings::ToInt(row[5]); + members[index].IsLooter = Strings::ToInt(row[6]); //if (RuleB(Bots, Enabled)) { - members[index].IsBot = atoi(row[7]); - members[index].BotOwnerID = atoi(row[8]); + members[index].IsBot = Strings::ToInt(row[7]); + members[index].BotOwnerID = Strings::ToInt(row[8]); //} - ++index; + ++index; } return true; diff --git a/zone/spawn2.cpp b/zone/spawn2.cpp index 5aebf8166c..5c98fcd9a3 100644 --- a/zone/spawn2.cpp +++ b/zone/spawn2.cpp @@ -454,16 +454,16 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList ); auto results = QueryDatabase(spawn_query); for (auto row = results.begin(); row != results.end(); ++row) { - uint32 start_duration = atoi(row[1]) > 0 ? atoi(row[1]) : 0; - uint32 end_duration = atoi(row[2]) > 0 ? atoi(row[2]) : 0; + uint32 start_duration = Strings::ToInt(row[1]) > 0 ? Strings::ToInt(row[1]) : 0; + uint32 end_duration = Strings::ToInt(row[2]) > 0 ? Strings::ToInt(row[2]) : 0; /* Our current time was expired */ if ((start_duration + end_duration) <= tv.tv_sec) { - spawn_times[atoi(row[0])] = 0; + spawn_times[Strings::ToInt(row[0])] = 0; } /* We still have time left on this timer */ else { - spawn_times[atoi(row[0])] = ((start_duration + end_duration) - tv.tv_sec) * 1000; + spawn_times[Strings::ToInt(row[0])] = ((start_duration + end_duration) - tv.tv_sec) * 1000; } } @@ -500,14 +500,14 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList uint32 spawn_time_left = 0; Spawn2* new_spawn = 0; - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = Strings::ToInt(row[12]) == 1 ? true : false; - if (spawn_times.count(atoi(row[0])) != 0) - spawn_time_left = spawn_times[atoi(row[0])]; + if (spawn_times.count(Strings::ToInt(row[0])) != 0) + spawn_time_left = spawn_times[Strings::ToInt(row[0])]; glm::vec4 point; - point.x = atof(row[2]); - point.y = atof(row[3]); + point.x = Strings::ToFloat(row[2]); + point.y = Strings::ToFloat(row[3]); mob_distance = DistanceNoZ(client_position, point); @@ -515,21 +515,21 @@ bool ZoneDatabase::PopulateZoneSpawnListClose(uint32 zoneid, LinkedList continue; new_spawn = new Spawn2( - atoi(row[0]), // uint32 in_spawn2_id - atoi(row[1]), // uint32 spawngroup_id - atof(row[2]), // float in_x - atof(row[3]), // float in_y - atof(row[4]), // float in_z - atof(row[5]), // float in_heading - atoi(row[6]), // uint32 respawn - atoi(row[7]), // uint32 variance + Strings::ToInt(row[0]), // uint32 in_spawn2_id + Strings::ToInt(row[1]), // uint32 spawngroup_id + Strings::ToFloat(row[2]), // float in_x + Strings::ToFloat(row[3]), // float in_y + Strings::ToFloat(row[4]), // float in_z + Strings::ToFloat(row[5]), // float in_heading + Strings::ToInt(row[6]), // uint32 respawn + Strings::ToInt(row[7]), // uint32 variance spawn_time_left, // uint32 timeleft - atoi(row[8]), // uint32 grid - (bool)atoi(row[9]), // bool path_when_zone_idle - atoi(row[10]), // uint16 in_cond_id - atoi(row[11]), // int16 in_min_value + Strings::ToInt(row[8]), // uint32 grid + (bool)Strings::ToInt(row[9]), // bool path_when_zone_idle + Strings::ToInt(row[10]), // uint16 in_cond_id + Strings::ToInt(row[11]), // int16 in_min_value perl_enabled, // bool in_enabled - (EmuAppearance)atoi(row[13]) // EmuAppearance anim + (EmuAppearance)Strings::ToInt(row[13]) // EmuAppearance anim ); spawn2_list.Insert(new_spawn); @@ -560,16 +560,16 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa ); auto results = database.QueryDatabase(spawn_query); for (auto row = results.begin(); row != results.end(); ++row) { - uint32 start_duration = atoi(row[1]) > 0 ? atoi(row[1]) : 0; - uint32 end_duration = atoi(row[2]) > 0 ? atoi(row[2]) : 0; + uint32 start_duration = Strings::ToInt(row[1]) > 0 ? Strings::ToInt(row[1]) : 0; + uint32 end_duration = Strings::ToInt(row[2]) > 0 ? Strings::ToInt(row[2]) : 0; /* Our current time was expired */ if ((start_duration + end_duration) <= tv.tv_sec) { - spawn_times[atoi(row[0])] = 0; + spawn_times[Strings::ToInt(row[0])] = 0; } /* We still have time left on this timer */ else { - spawn_times[atoi(row[0])] = ((start_duration + end_duration) - tv.tv_sec) * 1000; + spawn_times[Strings::ToInt(row[0])] = ((start_duration + end_duration) - tv.tv_sec) * 1000; } } @@ -608,27 +608,27 @@ bool ZoneDatabase::PopulateZoneSpawnList(uint32 zoneid, LinkedList &spa uint32 spawn_time_left = 0; Spawn2* new_spawn = 0; - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = Strings::ToInt(row[12]) == 1 ? true : false; - if (spawn_times.count(atoi(row[0])) != 0) - spawn_time_left = spawn_times[atoi(row[0])]; + if (spawn_times.count(Strings::ToInt(row[0])) != 0) + spawn_time_left = spawn_times[Strings::ToInt(row[0])]; new_spawn = new Spawn2( - atoi(row[0]), // uint32 in_spawn2_id - atoi(row[1]), // uint32 spawngroup_id - atof(row[2]), // float in_x - atof(row[3]), // float in_y - atof(row[4]), // float in_z - atof(row[5]), // float in_heading - atoi(row[6]), // uint32 respawn - atoi(row[7]), // uint32 variance + Strings::ToInt(row[0]), // uint32 in_spawn2_id + Strings::ToInt(row[1]), // uint32 spawngroup_id + Strings::ToFloat(row[2]), // float in_x + Strings::ToFloat(row[3]), // float in_y + Strings::ToFloat(row[4]), // float in_z + Strings::ToFloat(row[5]), // float in_heading + Strings::ToInt(row[6]), // uint32 respawn + Strings::ToInt(row[7]), // uint32 variance spawn_time_left, // uint32 timeleft - atoi(row[8]), // uint32 grid - (bool)atoi(row[9]), // bool path_when_zone_idle - atoi(row[10]), // uint16 in_cond_id - atoi(row[11]), // int16 in_min_value + Strings::ToInt(row[8]), // uint32 grid + (bool)Strings::ToInt(row[9]), // bool path_when_zone_idle + Strings::ToInt(row[10]), // uint16 in_cond_id + Strings::ToInt(row[11]), // int16 in_min_value perl_enabled, // bool in_enabled - (EmuAppearance)atoi(row[13]) // EmuAppearance anim + (EmuAppearance)Strings::ToInt(row[13]) // EmuAppearance anim ); spawn2_list.Insert(new_spawn); @@ -660,12 +660,12 @@ Spawn2* ZoneDatabase::LoadSpawn2(LinkedList &spawn2_list, uint32 spawn2 auto row = results.begin(); - bool perl_enabled = atoi(row[12]) == 1 ? true : false; + bool perl_enabled = Strings::ToInt(row[12]) == 1 ? true : false; - auto newSpawn = new Spawn2(atoi(row[0]), atoi(row[1]), atof(row[2]), - atof(row[3]), atof(row[4]), atof(row[5]), atoi(row[6]), atoi(row[7]), - timeleft, atoi(row[8]), (bool) atoi(row[9]), atoi(row[10]), - atoi(row[11]), perl_enabled, (EmuAppearance)atoi(row[13])); + auto newSpawn = new Spawn2(Strings::ToInt(row[0]), Strings::ToInt(row[1]), Strings::ToFloat(row[2]), + Strings::ToFloat(row[3]), Strings::ToFloat(row[4]), Strings::ToFloat(row[5]), Strings::ToInt(row[6]), Strings::ToInt(row[7]), + timeleft, Strings::ToInt(row[8]), (bool) Strings::ToInt(row[9]), Strings::ToInt(row[10]), + Strings::ToInt(row[11]), perl_enabled, (EmuAppearance)Strings::ToInt(row[13])); spawn2_list.Insert(newSpawn); @@ -959,20 +959,20 @@ bool SpawnConditionManager::LoadDBEvent(uint32 event_id, SpawnEvent &event, std: auto row = results.begin(); - event.id = atoi(row[0]); - event.condition_id = atoi(row[1]); - event.period = atoi(row[2]); + event.id = Strings::ToInt(row[0]); + event.condition_id = Strings::ToInt(row[1]); + event.period = Strings::ToInt(row[2]); - event.next.minute = atoi(row[3]); - event.next.hour = atoi(row[4]); - event.next.day = atoi(row[5]); - event.next.month = atoi(row[6]); - event.next.year = atoi(row[7]); + event.next.minute = Strings::ToInt(row[3]); + event.next.hour = Strings::ToInt(row[4]); + event.next.day = Strings::ToInt(row[5]); + event.next.month = Strings::ToInt(row[6]); + event.next.year = Strings::ToInt(row[7]); - event.enabled = atoi(row[8]) != 0; - event.action = (SpawnEvent::Action) atoi(row[9]); - event.argument = atoi(row[10]); - event.strict = atoi(row[11]) != 0; + event.enabled = Strings::ToInt(row[8]) != 0; + event.action = (SpawnEvent::Action) Strings::ToInt(row[9]); + event.argument = Strings::ToInt(row[10]); + event.strict = Strings::ToInt(row[11]) != 0; zone_name = row[12]; std::string timeAsString; @@ -1000,9 +1000,9 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in //load spawn conditions SpawnCondition cond; - cond.condition_id = atoi(row[0]); - cond.value = atoi(row[2]); - cond.on_change = (SpawnCondition::OnChange) atoi(row[1]); + cond.condition_id = Strings::ToInt(row[0]); + cond.value = Strings::ToInt(row[2]); + cond.on_change = (SpawnCondition::OnChange) Strings::ToInt(row[1]); spawn_conditions[cond.condition_id] = cond; LogSpawns("Loaded spawn condition [{}] with value [{}] and on_change [{}]", cond.condition_id, cond.value, cond.on_change); @@ -1021,10 +1021,10 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in } for (auto row = results.begin(); row != results.end(); ++row) { - auto iter = spawn_conditions.find(atoi(row[0])); + auto iter = spawn_conditions.find(Strings::ToInt(row[0])); if(iter != spawn_conditions.end()) - iter->second.value = atoi(row[1]); + iter->second.value = Strings::ToInt(row[1]); } //load spawn events @@ -1041,25 +1041,25 @@ bool SpawnConditionManager::LoadSpawnConditions(const char* zone_name, uint32 in for (auto row = results.begin(); row != results.end(); ++row) { SpawnEvent event; - event.id = atoi(row[0]); - event.condition_id = atoi(row[1]); - event.period = atoi(row[2]); + event.id = Strings::ToInt(row[0]); + event.condition_id = Strings::ToInt(row[1]); + event.period = Strings::ToInt(row[2]); if (event.period == 0) { LogError("Refusing to load spawn event #[{}] because it has a period of 0\n", event.id); continue; } - event.next.minute = atoi(row[3]); - event.next.hour = atoi(row[4]); - event.next.day = atoi(row[5]); - event.next.month = atoi(row[6]); - event.next.year = atoi(row[7]); + event.next.minute = Strings::ToInt(row[3]); + event.next.hour = Strings::ToInt(row[4]); + event.next.day = Strings::ToInt(row[5]); + event.next.month = Strings::ToInt(row[6]); + event.next.year = Strings::ToInt(row[7]); - event.enabled = atoi(row[8]) == 0 ? false : true; - event.action = (SpawnEvent::Action) atoi(row[9]); - event.argument = atoi(row[10]); - event.strict = atoi(row[11]) == 0 ? false : true; + event.enabled = Strings::ToInt(row[8]) == 0 ? false : true; + event.action = (SpawnEvent::Action) Strings::ToInt(row[9]); + event.argument = Strings::ToInt(row[10]); + event.strict = Strings::ToInt(row[11]) == 0 ? false : true; spawn_events.push_back(event); @@ -1416,7 +1416,7 @@ int16 SpawnConditionManager::GetCondition(const char *zone_short, uint32 instanc auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool SpawnConditionManager::Check(uint16 condition, int16 min_value) { diff --git a/zone/spawngroup.cpp b/zone/spawngroup.cpp index f20f19977e..88935e2211 100644 --- a/zone/spawngroup.cpp +++ b/zone/spawngroup.cpp @@ -207,19 +207,19 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG for (auto row = results.begin(); row != results.end(); ++row) { auto new_spawn_group = std::make_unique( - atoi(row[0]), + Strings::ToInt(row[0]), row[1], - atoi(row[2]), - atof(row[3]), - atof(row[4]), - atof(row[5]), - atof(row[6]), - atof(row[7]), - atoi(row[8]), - atoi(row[9]), - atoi(row[10]), - atoi(row[11]), - atoi(row[12]) + Strings::ToInt(row[2]), + Strings::ToFloat(row[3]), + Strings::ToFloat(row[4]), + Strings::ToFloat(row[5]), + Strings::ToFloat(row[6]), + Strings::ToFloat(row[7]), + Strings::ToInt(row[8]), + Strings::ToInt(row[9]), + Strings::ToInt(row[10]), + Strings::ToInt(row[11]), + Strings::ToInt(row[12]) ); spawn_group_list->AddSpawnGroup(new_spawn_group); @@ -260,13 +260,13 @@ bool ZoneDatabase::LoadSpawnGroups(const char *zone_name, uint16 version, SpawnG for (auto row = results.begin(); row != results.end(); ++row) { auto new_spawn_entry = std::make_unique( - atoi(row[1]), - atoi(row[2]), - atoi(row[3]), - (row[4] ? atoi(row[4]) : 0) + Strings::ToInt(row[1]), + Strings::ToInt(row[2]), + Strings::ToInt(row[3]), + (row[4] ? Strings::ToInt(row[4]) : 0) ); - SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); + SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(Strings::ToInt(row[0])); if (!spawn_group) { continue; @@ -327,19 +327,19 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn ); auto new_spawn_group = std::make_unique( - atoi(row[0]), + Strings::ToInt(row[0]), row[1], - atoi(row[2]), - atof(row[3]), - atof(row[4]), - atof(row[5]), - atof(row[6]), - atof(row[7]), - atoi(row[8]), - atoi(row[9]), - atoi(row[10]), - atoi(row[11]), - atoi(row[12]) + Strings::ToInt(row[2]), + Strings::ToFloat(row[3]), + Strings::ToFloat(row[4]), + Strings::ToFloat(row[5]), + Strings::ToFloat(row[6]), + Strings::ToFloat(row[7]), + Strings::ToInt(row[8]), + Strings::ToInt(row[9]), + Strings::ToInt(row[10]), + Strings::ToInt(row[11]), + Strings::ToInt(row[12]) ); spawn_group_list->AddSpawnGroup(new_spawn_group); @@ -370,10 +370,10 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn for (auto row = results.begin(); row != results.end(); ++row) { auto new_spawn_entry = std::make_unique( - atoi(row[1]), - atoi(row[2]), - atoi(row[3]), - (row[4] ? atoi(row[4]) : 0) + Strings::ToInt(row[1]), + Strings::ToInt(row[2]), + Strings::ToInt(row[3]), + (row[4] ? Strings::ToInt(row[4]) : 0) ); LogSpawnsDetail( @@ -385,7 +385,7 @@ bool ZoneDatabase::LoadSpawnGroupsByID(int spawn_group_id, SpawnGroupList *spawn row[4] ); - SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(atoi(row[0])); + SpawnGroup *spawn_group = spawn_group_list->GetSpawnGroup(Strings::ToInt(row[0])); if (!spawn_group) { continue; } diff --git a/zone/spells.cpp b/zone/spells.cpp index 84d7061f5e..479de65f82 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -5784,7 +5784,7 @@ std::unordered_map> Client::LoadSpellGroupCache(uint } for (auto row : results) { - spell_group_cache[std::stoul(row[0])].push_back(static_cast(std::stoul(row[1]))); + spell_group_cache[Strings::ToUnsignedInt(row[0])].push_back(static_cast(Strings::ToUnsignedInt(row[1]))); } return spell_group_cache; @@ -5845,7 +5845,7 @@ bool Client::SpellGlobalCheck(uint16 spell_id, uint32 character_id) { row = results.begin(); std::string global_value = row[0]; if (Strings::IsNumber(global_value) && Strings::IsNumber(spell_global_value)) { - if (std::stoi(global_value) >= std::stoi(spell_global_value)) { + if (Strings::ToInt(global_value) >= Strings::ToInt(spell_global_value)) { return true; // If value is greater than or equal to spell global value, allow scribing. } } else { @@ -5899,7 +5899,7 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) { auto bucket_value = DataBucket::GetData(new_bucket_name); if (!bucket_value.empty()) { if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) { - if (std::stoi(bucket_value) >= std::stoi(spell_bucket_value)) { + if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) { return true; // If value is greater than or equal to spell bucket value, allow scribing. } } else { @@ -5918,7 +5918,7 @@ bool Client::SpellBucketCheck(uint16 spell_id, uint32 character_id) { bucket_value = DataBucket::GetData(old_bucket_name); if (!bucket_value.empty()) { if (Strings::IsNumber(bucket_value) && Strings::IsNumber(spell_bucket_value)) { - if (std::stoi(bucket_value) >= std::stoi(spell_bucket_value)) { + if (Strings::ToInt(bucket_value) >= Strings::ToInt(spell_bucket_value)) { return true; // If value is greater than or equal to spell bucket value, allow scribing. } } else { diff --git a/zone/task_client_state.cpp b/zone/task_client_state.cpp index e82ffc49bd..a838a581bf 100644 --- a/zone/task_client_state.cpp +++ b/zone/task_client_state.cpp @@ -1048,12 +1048,12 @@ void ClientTaskState::RewardTask(Client *c, const TaskInformation *ti, ClientTas for (const auto &i: Strings::Split(ti->reward_id_list, "|")) { // handle charges int16 charges = -1; - uint32 item_id = Strings::IsNumber(i) ? std::stoi(i) : 0; + uint32 item_id = Strings::IsNumber(i) ? Strings::ToInt(i) : 0; if (Strings::Contains(i, ",")) { auto s = Strings::Split(i, ","); if (!s.empty() && s.size() == 2) { - item_id = Strings::IsNumber(s[0]) ? std::stoi(s[0]) : 0; - charges = Strings::IsNumber(s[1]) ? std::stoi(s[1]) : 0; + item_id = Strings::IsNumber(s[0]) ? Strings::ToInt(s[0]) : 0; + charges = Strings::IsNumber(s[1]) ? Strings::ToInt(s[1]) : 0; } } diff --git a/zone/task_manager.cpp b/zone/task_manager.cpp index 4b88719986..0711b09771 100644 --- a/zone/task_manager.cpp +++ b/zone/task_manager.cpp @@ -199,9 +199,9 @@ bool TaskManager::LoadTasks(int single_task) ad->target_name = a.target_name; ad->item_list = a.item_list; ad->skill_list = a.skill_list; - ad->skill_id = Strings::IsNumber(a.skill_list) ? std::stoi(a.skill_list) : 0; // for older clients + ad->skill_id = Strings::IsNumber(a.skill_list) ? Strings::ToInt(a.skill_list) : 0; // for older clients ad->spell_list = a.spell_list; - ad->spell_id = Strings::IsNumber(a.spell_list) ? std::stoi(a.spell_list) : 0; // for older clients + ad->spell_id = Strings::IsNumber(a.spell_list) ? Strings::ToInt(a.spell_list) : 0; // for older clients ad->description_override = a.description_override; ad->npc_match_list = a.npc_match_list; ad->item_id_list = a.item_id_list; @@ -233,7 +233,7 @@ bool TaskManager::LoadTasks(int single_task) for (auto &&e : zones) { if (Strings::IsNumber(e)) { - ad->zone_ids.push_back(std::stoi(e)); + ad->zone_ids.push_back(Strings::ToInt(e)); } } @@ -1164,7 +1164,7 @@ void TaskManager::SendActiveTaskDescription( if (!t->reward_id_list.empty() && t->item_link.empty()) { auto items = Strings::Split(t->reward_id_list, "|"); auto item = items.front(); - int item_id = Strings::IsNumber(items.front()) ? std::stoi(items.front()) : 0; + int item_id = Strings::IsNumber(items.front()) ? Strings::ToInt(items.front()) : 0; if (item_id) { const EQ::ItemData *reward_item = database.GetItem(item_id); @@ -1517,7 +1517,7 @@ bool TaskManager::LoadClientState(Client *client, ClientTaskState *cts) auto results = database.QueryDatabase(query); if (results.Success()) { for (auto row = results.begin(); row != results.end(); ++row) { - int task_id = atoi(row[0]); + int task_id = Strings::ToInt(row[0]); cts->m_enabled_tasks.push_back(task_id); LogTasksDetail("Adding task_id [{}] to enabled tasks", task_id); } diff --git a/zone/titles.cpp b/zone/titles.cpp index 526773323f..bb4e185fc0 100644 --- a/zone/titles.cpp +++ b/zone/titles.cpp @@ -47,20 +47,20 @@ bool TitleManager::LoadTitles() for (auto row : results) { TitleEntry title; - title.title_id = std::stoi(row[0]); - title.skill_id = (EQ::skills::SkillType) std::stoi(row[1]); - title.min_skill_value = std::stoi(row[2]); - title.max_skill_value = std::stoi(row[3]); - title.min_aa_points = std::stoi(row[4]); - title.max_aa_points = std::stoi(row[5]); - title.class_id = std::stoi(row[6]); - title.gender_id = std::stoi(row[7]); - title.character_id = std::stoi(row[8]); - title.status = std::stoi(row[9]); - title.item_id = std::stoi(row[10]); + title.title_id = Strings::ToInt(row[0]); + title.skill_id = (EQ::skills::SkillType) Strings::ToInt(row[1]); + title.min_skill_value = Strings::ToInt(row[2]); + title.max_skill_value = Strings::ToInt(row[3]); + title.min_aa_points = Strings::ToInt(row[4]); + title.max_aa_points = Strings::ToInt(row[5]); + title.class_id = Strings::ToInt(row[6]); + title.gender_id = Strings::ToInt(row[7]); + title.character_id = Strings::ToInt(row[8]); + title.status = Strings::ToInt(row[9]); + title.item_id = Strings::ToInt(row[10]); title.prefix = row[11]; title.suffix = row[12]; - title.titleset = std::stoi(row[13]); + title.titleset = Strings::ToInt(row[13]); titles.push_back(title); } diff --git a/zone/tradeskills.cpp b/zone/tradeskills.cpp index 7d7ef14056..2d8e03002b 100644 --- a/zone/tradeskills.cpp +++ b/zone/tradeskills.cpp @@ -336,7 +336,7 @@ void Object::HandleCombine(Client* user, const NewCombine_Struct* in_combine, Ob inst->IsAttuned(), EQ::invslot::slotCursor, container->GetItem()->Icon, - atoi(container->GetItem()->IDFile + 2) + Strings::ToInt(container->GetItem()->IDFile + 2) ); user->MessageString(Chat::LightBlue, TRANSFORM_COMPLETE, inst->GetItem()->Name); @@ -650,8 +650,8 @@ void Object::HandleAutoCombine(Client* user, const RecipeAutoCombine_Struct* rac uint8 needItemIndex = 0; for (auto row = results.begin(); row != results.end(); ++row, ++needItemIndex) { - uint32 item = (uint32)atoi(row[0]); - uint8 num = (uint8) atoi(row[1]); + uint32 item = (uint32)Strings::ToInt(row[0]); + uint8 num = (uint8) Strings::ToInt(row[1]); needcount += num; @@ -870,12 +870,12 @@ void Client::SendTradeskillSearchResults( continue; } - uint32 recipe_id = (uint32) atoi(row[0]); + uint32 recipe_id = (uint32) Strings::ToInt(row[0]); const char *name = row[1]; - uint32 trivial = (uint32) atoi(row[2]); - uint32 comp_count = (uint32) atoi(row[3]); - uint32 tradeskill = (uint16) atoi(row[4]); - uint32 must_learn = (uint16) atoi(row[5]); + uint32 trivial = (uint32) Strings::ToInt(row[2]); + uint32 comp_count = (uint32) Strings::ToInt(row[3]); + uint32 tradeskill = (uint16) Strings::ToInt(row[4]); + uint32 must_learn = (uint16) Strings::ToInt(row[5]); // Skip the recipes that exceed the threshold in skill difference @@ -972,9 +972,9 @@ void Client::SendTradeskillDetails(uint32 recipe_id) { if(row[2] == nullptr || row[3] == nullptr) continue; - uint32 item = (uint32)atoi(row[0]); - uint8 num = (uint8) atoi(row[1]); - uint32 icon = (uint32) atoi(row[2]); + uint32 item = (uint32)Strings::ToInt(row[0]); + uint8 num = (uint8) Strings::ToInt(row[1]); + uint32 icon = (uint32) Strings::ToInt(row[2]); const char *name = row[3]; len = strlen(name); @@ -1390,7 +1390,7 @@ bool ZoneDatabase::GetTradeRecipe( uint32 index = 0; buf2 = ""; for (auto row = results.begin(); row != results.end(); ++row, ++index) { - uint32 recipeid = (uint32)atoi(row[0]); + uint32 recipeid = (uint32)Strings::ToInt(row[0]); if(first) { buf2 += StringFormat("%u", recipeid); first = false; @@ -1463,7 +1463,7 @@ bool ZoneDatabase::GetTradeRecipe( } auto row = results.begin(); - uint32 recipe_id = (uint32)atoi(row[0]); + uint32 recipe_id = (uint32)Strings::ToInt(row[0]); //Right here we verify that we actually have ALL of the tradeskill components.. //instead of part which is possible with experimentation. @@ -1494,7 +1494,7 @@ bool ZoneDatabase::GetTradeRecipe( if (!item) continue; - if (item->ID == atoi(row[0])) { + if (item->ID == Strings::ToInt(row[0])) { component_count++; } @@ -1502,11 +1502,11 @@ bool ZoneDatabase::GetTradeRecipe( "Component count loop [{}] item [{}] recipe component_count [{}]", component_count, item->ID, - atoi(row[1]) + Strings::ToInt(row[1]) ); } - if (component_count != atoi(row[1])) { + if (component_count != Strings::ToInt(row[1])) { return false; } } @@ -1571,14 +1571,14 @@ bool ZoneDatabase::GetTradeRecipe( auto row = results.begin(); - spec->tradeskill = (EQ::skills::SkillType) atoi(row[1]); - spec->skill_needed = (int16) atoi(row[2]); - spec->trivial = (uint16) atoi(row[3]); - spec->nofail = atoi(row[4]) ? true : false; - spec->replace_container = atoi(row[5]) ? true : false; + spec->tradeskill = (EQ::skills::SkillType) Strings::ToInt(row[1]); + spec->skill_needed = (int16) Strings::ToInt(row[2]); + spec->trivial = (uint16) Strings::ToInt(row[3]); + spec->nofail = Strings::ToInt(row[4]) ? true : false; + spec->replace_container = Strings::ToInt(row[5]) ? true : false; spec->name = row[6]; - spec->must_learn = (uint8) atoi(row[7]); - spec->quest = atoi(row[8]) ? true : false; + spec->must_learn = (uint8) Strings::ToInt(row[7]); + spec->quest = Strings::ToInt(row[8]) ? true : false; spec->has_learnt = false; spec->madecount = 0; spec->recipe_id = recipe_id; @@ -1610,8 +1610,8 @@ bool ZoneDatabase::GetTradeRecipe( spec->onsuccess.clear(); for(auto row = results.begin(); row != results.end(); ++row) { - uint32 item = (uint32)atoi(row[0]); - uint8 num = (uint8) atoi(row[1]); + uint32 item = (uint32)Strings::ToInt(row[0]); + uint8 num = (uint8) Strings::ToInt(row[1]); spec->onsuccess.push_back(std::pair(item, num)); } @@ -1624,8 +1624,8 @@ bool ZoneDatabase::GetTradeRecipe( results = QueryDatabase(query); if (results.Success()) { for (auto row = results.begin(); row != results.end(); ++row) { - uint32 item = (uint32) atoi(row[0]); - uint8 num = (uint8) atoi(row[1]); + uint32 item = (uint32) Strings::ToInt(row[0]); + uint8 num = (uint8) Strings::ToInt(row[1]); spec->onfail.push_back(std::pair(item, num)); } } @@ -1647,8 +1647,8 @@ bool ZoneDatabase::GetTradeRecipe( results = QueryDatabase(query); if (results.Success()) { for (auto row = results.begin(); row != results.end(); ++row) { - uint32 item = (uint32) atoi(row[0]); - uint8 num = (uint8) atoi(row[1]); + uint32 item = (uint32) Strings::ToInt(row[0]); + uint8 num = (uint8) Strings::ToInt(row[1]); spec->salvage.push_back(std::pair(item, num)); } } diff --git a/zone/trading.cpp b/zone/trading.cpp index 53732fa766..ebcdbefcb5 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1664,8 +1664,8 @@ void Client::SendBazaarWelcome() bws->Beginning.Action = BazaarWelcome; - bws->Traders = atoi(row[0]); - bws->Items = atoi(row[1]); + bws->Traders = Strings::ToInt(row[0]); + bws->Items = Strings::ToInt(row[1]); if (ClientVersion() >= EQ::versions::ClientVersion::RoF) { @@ -1684,7 +1684,7 @@ void Client::SendBazaarWelcome() auto row = results.begin(); Message(Chat::NPCQuestSay, "There are %i Buyers waiting to purchase your loot. Type /barter to search for them, " - "or use /buyer to set up your own Buy Lines.", atoi(row[0])); + "or use /buyer to set up your own Buy Lines.", Strings::ToInt(row[0])); } void Client::SendBazaarResults( @@ -1928,26 +1928,26 @@ void Client::SendBazaarResults( for (auto row = results.begin(); row != results.end(); ++row) { VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Action); - Count = atoi(row[0]); + Count = Strings::ToInt(row[0]); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Count); - SerialNumber = atoi(row[3]); + SerialNumber = Strings::ToInt(row[3]); VARSTRUCT_ENCODE_TYPE(int32, bufptr, SerialNumber); - Client *Trader2 = entity_list.GetClientByCharID(atoi(row[1])); + Client *Trader2 = entity_list.GetClientByCharID(Strings::ToInt(row[1])); if (Trader2) { ID = Trader2->GetID(); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, ID); } else { - LogTrading("Unable to find trader: [{}]\n", atoi(row[1])); + LogTrading("Unable to find trader: [{}]\n", Strings::ToInt(row[1])); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, 0); } - Cost = atoi(row[5]); + Cost = Strings::ToInt(row[5]); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Cost); - StatValue = atoi(row[8]); + StatValue = Strings::ToInt(row[8]); VARSTRUCT_ENCODE_TYPE(uint32, bufptr, StatValue); - bool Stackable = atoi(row[10]); + bool Stackable = Strings::ToInt(row[10]); if (Stackable) { - int Charges = atoi(row[9]); + int Charges = Strings::ToInt(row[9]); sprintf(temp_buffer, "%s(%i)", row[7], Charges); } else { @@ -1971,7 +1971,7 @@ void Client::SendBazaarResults( bufptr += 64; - VARSTRUCT_ENCODE_TYPE(uint32, bufptr, atoi(row[1])); // ItemID + VARSTRUCT_ENCODE_TYPE(uint32, bufptr, Strings::ToInt(row[1])); // ItemID } auto outapp = new EQApplicationPacket(OP_BazaarSearch, Size); @@ -2360,12 +2360,12 @@ void Client::SendBuyerResults(char* searchString, uint32 searchID) { for (auto row = results.begin(); row != results.end(); ++row) { char itemName[64]; - uint32 charID = atoi(row[0]); - uint32 buySlot = atoi(row[1]); - uint32 itemID = atoi(row[2]); + uint32 charID = Strings::ToInt(row[0]); + uint32 buySlot = Strings::ToInt(row[1]); + uint32 itemID = Strings::ToInt(row[2]); strcpy(itemName, row[3]); - uint32 quantity = atoi(row[4]); - uint32 price = atoi(row[5]); + uint32 quantity = Strings::ToInt(row[4]); + uint32 price = Strings::ToInt(row[5]); // Each item in the search results is sent as a single fixed length packet, although the position of // the fields varies due to the use of variable length strings. The reason the packet is so big, is @@ -2462,11 +2462,11 @@ void Client::ShowBuyLines(const EQApplicationPacket *app) { for (auto row = results.begin(); row != results.end(); ++row) { char ItemName[64]; - uint32 BuySlot = atoi(row[1]); - uint32 ItemID = atoi(row[2]); + uint32 BuySlot = Strings::ToInt(row[1]); + uint32 ItemID = Strings::ToInt(row[2]); strcpy(ItemName, row[3]); - uint32 Quantity = atoi(row[4]); - uint32 Price = atoi(row[5]); + uint32 Quantity = Strings::ToInt(row[4]); + uint32 Price = Strings::ToInt(row[5]); auto outapp = new EQApplicationPacket(OP_Barter, 936); diff --git a/zone/trap.cpp b/zone/trap.cpp index 37436fa3af..02061e3d15 100644 --- a/zone/trap.cpp +++ b/zone/trap.cpp @@ -460,8 +460,8 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 tid = atoi(row[0]); - uint8 grp = atoi(row[15]); + uint32 tid = Strings::ToInt(row[0]); + uint8 grp = Strings::ToInt(row[15]); if (grp > 0) { @@ -474,20 +474,20 @@ bool ZoneDatabase::LoadTraps(const char* zonename, int16 version) { auto trap = new Trap(); trap->trap_id = tid; trap->db_id = tid; - trap->m_Position = glm::vec3(atof(row[1]), atof(row[2]), atof(row[3])); - trap->effect = atoi(row[4]); - trap->effectvalue = atoi(row[5]); - trap->effectvalue2 = atoi(row[6]); - trap->skill = atoi(row[7]); - trap->maxzdiff = atof(row[8]); - trap->radius = atof(row[9]); - trap->chance = atoi(row[10]); + trap->m_Position = glm::vec3(Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3])); + trap->effect = Strings::ToInt(row[4]); + trap->effectvalue = Strings::ToInt(row[5]); + trap->effectvalue2 = Strings::ToInt(row[6]); + trap->skill = Strings::ToInt(row[7]); + trap->maxzdiff = Strings::ToFloat(row[8]); + trap->radius = Strings::ToFloat(row[9]); + trap->chance = Strings::ToInt(row[10]); trap->message = row[11]; - trap->respawn_time = atoi(row[12]); - trap->respawn_var = atoi(row[13]); - trap->level = atoi(row[14]); + trap->respawn_time = Strings::ToInt(row[12]); + trap->respawn_var = Strings::ToInt(row[13]); + trap->level = Strings::ToInt(row[14]); trap->group = grp; - trap->triggered_number = atoi(row[16]); + trap->triggered_number = Strings::ToInt(row[16]); trap->despawn_when_triggered = atobool(row[17]); trap->undetectable = atobool(row[18]); entity_list.AddTrap(trap); @@ -555,20 +555,20 @@ bool ZoneDatabase::SetTrapData(Trap* trap, bool repopnow) { for (auto row = results.begin(); row != results.end(); ++row) { - trap->db_id = atoi(row[0]); - trap->m_Position = glm::vec3(atof(row[1]), atof(row[2]), atof(row[3])); - trap->effect = atoi(row[4]); - trap->effectvalue = atoi(row[5]); - trap->effectvalue2 = atoi(row[6]); - trap->skill = atoi(row[7]); - trap->maxzdiff = atof(row[8]); - trap->radius = atof(row[9]); - trap->chance = atoi(row[10]); + trap->db_id = Strings::ToInt(row[0]); + trap->m_Position = glm::vec3(Strings::ToFloat(row[1]), Strings::ToFloat(row[2]), Strings::ToFloat(row[3])); + trap->effect = Strings::ToInt(row[4]); + trap->effectvalue = Strings::ToInt(row[5]); + trap->effectvalue2 = Strings::ToInt(row[6]); + trap->skill = Strings::ToInt(row[7]); + trap->maxzdiff = Strings::ToFloat(row[8]); + trap->radius = Strings::ToFloat(row[9]); + trap->chance = Strings::ToInt(row[10]); trap->message = row[11]; - trap->respawn_time = atoi(row[12]); - trap->respawn_var = atoi(row[13]); - trap->level = atoi(row[14]); - trap->triggered_number = atoi(row[15]); + trap->respawn_time = Strings::ToInt(row[12]); + trap->respawn_var = Strings::ToInt(row[13]); + trap->level = Strings::ToInt(row[14]); + trap->triggered_number = Strings::ToInt(row[15]); trap->despawn_when_triggered = atobool(row[16]); trap->undetectable = atobool(row[17]); trap->CreateHiddenTrigger(); diff --git a/zone/tribute.cpp b/zone/tribute.cpp index 5e80585f06..4f6588e401 100644 --- a/zone/tribute.cpp +++ b/zone/tribute.cpp @@ -392,7 +392,7 @@ bool ZoneDatabase::LoadTributes() { } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 id = atoul(row[0]); + uint32 id = Strings::ToUnsignedInt(row[0]); tributeData.name = row[1]; tributeData.description = row[2]; tributeData.unknown = strtoul(row[3], nullptr, 10); @@ -410,7 +410,7 @@ bool ZoneDatabase::LoadTributes() { } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 id = atoul(row[0]); + uint32 id = Strings::ToUnsignedInt(row[0]); if (tribute_list.count(id) != 1) { LogError("Error in LoadTributes: unknown tribute [{}] in tribute_levels", (unsigned long) id); @@ -426,9 +426,9 @@ bool ZoneDatabase::LoadTributes() { TributeLevel_Struct &s = cur.tiers[cur.tier_count]; - s.level = atoul(row[1]); - s.cost = atoul(row[2]); - s.tribute_item_id = atoul(row[3]); + s.level = Strings::ToUnsignedInt(row[1]); + s.cost = Strings::ToUnsignedInt(row[2]); + s.tribute_item_id = Strings::ToUnsignedInt(row[3]); cur.tier_count++; } diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp index 28892f157d..6ef49d924a 100644 --- a/zone/waypoints.cpp +++ b/zone/waypoints.cpp @@ -1047,7 +1047,7 @@ int ZoneDatabase::GetHighestGrid(uint32 zoneid) { return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) { @@ -1064,7 +1064,7 @@ uint8 ZoneDatabase::GetGridType2(uint32 grid, uint16 zoneid) { auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* wp) { @@ -1084,11 +1084,11 @@ bool ZoneDatabase::GetWaypoints(uint32 grid, uint16 zoneid, uint32 num, wplist* auto row = results.begin(); - wp->x = atof(row[0]); - wp->y = atof(row[1]); - wp->z = atof(row[2]); - wp->pause = atoi(row[3]); - wp->heading = atof(row[4]); + wp->x = Strings::ToFloat(row[0]); + wp->y = Strings::ToFloat(row[1]); + wp->z = Strings::ToFloat(row[2]); + wp->pause = Strings::ToInt(row[3]); + wp->heading = Strings::ToFloat(row[4]); return true; } @@ -1229,7 +1229,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v return 0; auto row = results.begin(); - grid_num = atoi(row[0]); + grid_num = Strings::ToInt(row[0]); if (grid_num == 0) { // Our spawn doesn't have a grid assigned to it -- we need to create a new grid and assign it to the spawn @@ -1259,7 +1259,7 @@ uint32 ZoneDatabase::AddWPForSpawn(Client *client, uint32 spawn2id, const glm::v row = results.begin(); if (row[0] != 0) - next_wp_num = atoi(row[0]) + 1; + next_wp_num = Strings::ToInt(row[0]) + 1; else // No waypoints in this grid yet next_wp_num = 1; @@ -1283,7 +1283,7 @@ uint32 ZoneDatabase::GetFreeGrid(uint16 zoneid) { return 0; auto row = results.begin(); - uint32 freeGridID = row[0] ? atoi(row[0]) + 1 : 1; + uint32 freeGridID = row[0] ? Strings::ToInt(row[0]) + 1 : 1; return freeGridID; } @@ -1301,7 +1301,7 @@ int ZoneDatabase::GetHighestWaypoint(uint32 zoneid, uint32 gridid) { return 0; auto row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, int grid) @@ -1326,10 +1326,10 @@ int ZoneDatabase::GetRandomWaypointLocFromGrid(glm::vec4 &loc, uint16 zoneid, in row++; i++; } - loc.x = atof(row[0]); - loc.y = atof(row[1]); - loc.z = atof(row[2]); - loc.w = atof(row[3]); + loc.x = Strings::ToFloat(row[0]); + loc.y = Strings::ToFloat(row[1]); + loc.z = Strings::ToFloat(row[2]); + loc.w = Strings::ToFloat(row[3]); return i; } return 0; diff --git a/zone/zone.cpp b/zone/zone.cpp index 411549ecae..97e5b74c93 100644 --- a/zone/zone.cpp +++ b/zone/zone.cpp @@ -116,7 +116,7 @@ bool Zone::Bootup(uint32 iZoneID, uint32 iInstanceID, bool is_static) { std::string tmp; if (database.GetVariable("loglevel", tmp)) { int log_levels[4]; - int tmp_i = atoi(tmp.c_str()); + int tmp_i = Strings::ToInt(tmp.c_str()); if (tmp_i>9){ //Server is using the new code for(int i=0;i<4;i++){ if (((int)tmp[i]>=48) && ((int)tmp[i]<=57)) @@ -195,9 +195,9 @@ bool Zone::LoadZoneObjects() } for (auto row = results.begin(); row != results.end(); ++row) { - if (atoi(row[9]) == 0) { + if (Strings::ToInt(row[9]) == 0) { // Type == 0 - Static Object - const char *shortname = ZoneName(atoi(row[1]), false); // zoneid -> zone_shortname + const char *shortname = ZoneName(Strings::ToInt(row[1]), false); // zoneid -> zone_shortname if (!shortname) continue; @@ -206,12 +206,12 @@ bool Zone::LoadZoneObjects() auto d = DoorsRepository::NewEntity(); d.zone = shortname; - d.id = 1000000000 + atoi(row[0]); // Out of range of normal use for doors.id + d.id = 1000000000 + Strings::ToInt(row[0]); // Out of range of normal use for doors.id d.doorid = -1; // Client doesn't care if these are all the same door_id - d.pos_x = atof(row[2]); // xpos - d.pos_y = atof(row[3]); // ypos - d.pos_z = atof(row[4]); // zpos - d.heading = atof(row[5]); // heading + d.pos_x = Strings::ToFloat(row[2]); // xpos + d.pos_y = Strings::ToFloat(row[3]); // ypos + d.pos_z = Strings::ToFloat(row[4]); // zpos + d.heading = Strings::ToFloat(row[5]); // heading d.name = row[8]; // objectname @@ -224,10 +224,10 @@ bool Zone::LoadZoneObjects() d.dest_zone = "NONE"; - if ((d.size = atoi(row[11])) == 0) // unknown08 = optional size percentage + if ((d.size = Strings::ToInt(row[11])) == 0) // unknown08 = optional size percentage d.size = 100; - switch (d.opentype = atoi(row[12])) // unknown10 = optional request_nonsolid (0 or 1 or experimental number) + switch (d.opentype = Strings::ToInt(row[12])) // unknown10 = optional request_nonsolid (0 or 1 or experimental number) { case 0: d.opentype = 31; @@ -237,7 +237,7 @@ bool Zone::LoadZoneObjects() break; } - d.incline = atoi(row[13]); // unknown20 = optional model incline value + d.incline = Strings::ToInt(row[13]); // unknown20 = optional model incline value d.client_version_mask = 0xFFFFFFFF; // We should load the mask from the zone. auto door = new Doors(d); @@ -252,28 +252,28 @@ bool Zone::LoadZoneObjects() uint32 idx = 0; int16 charges = 0; - id = (uint32)atoi(row[0]); - data.zone_id = atoi(row[1]); - data.x = atof(row[2]); - data.y = atof(row[3]); - data.z = atof(row[4]); - data.heading = atof(row[5]); - itemid = (uint32)atoi(row[6]); - charges = (int16)atoi(row[7]); + id = (uint32)Strings::ToInt(row[0]); + data.zone_id = Strings::ToInt(row[1]); + data.x = Strings::ToFloat(row[2]); + data.y = Strings::ToFloat(row[3]); + data.z = Strings::ToFloat(row[4]); + data.heading = Strings::ToFloat(row[5]); + itemid = (uint32)Strings::ToInt(row[6]); + charges = (int16)Strings::ToInt(row[7]); strcpy(data.object_name, row[8]); - type = (uint8)atoi(row[9]); - icon = (uint32)atoi(row[10]); + type = (uint8)Strings::ToInt(row[9]); + icon = (uint32)Strings::ToInt(row[10]); data.object_type = type; data.linked_list_addr[0] = 0; data.linked_list_addr[1] = 0; - data.solidtype = (uint32)atoi(row[12]); - data.unknown020 = (uint32)atoi(row[13]); - data.unknown024 = (uint32)atoi(row[14]); - data.unknown076 = (uint32)atoi(row[15]); - data.size = atof(row[16]); - data.tilt_x = atof(row[17]); - data.tilt_y = atof(row[18]); + data.solidtype = (uint32)Strings::ToInt(row[12]); + data.unknown020 = (uint32)Strings::ToInt(row[13]); + data.unknown024 = (uint32)Strings::ToInt(row[14]); + data.unknown076 = (uint32)Strings::ToInt(row[15]); + data.size = Strings::ToFloat(row[16]); + data.tilt_x = Strings::ToFloat(row[17]); + data.tilt_y = Strings::ToFloat(row[18]); data.unknown084 = 0; @@ -579,7 +579,7 @@ void Zone::LoadTempMerchantData() uint32 npc_id = 0; for (auto row = results.begin(); row != results.end(); ++row) { TempMerchantList temp_merchant_list; - temp_merchant_list.npcid = atoul(row[0]); + temp_merchant_list.npcid = Strings::ToUnsignedInt(row[0]); if (npc_id != temp_merchant_list.npcid) { temp_merchant_table_entry = tmpmerchanttable.find(temp_merchant_list.npcid); if (temp_merchant_table_entry == tmpmerchanttable.end()) { @@ -590,9 +590,9 @@ void Zone::LoadTempMerchantData() npc_id = temp_merchant_list.npcid; } - temp_merchant_list.slot = atoul(row[1]); - temp_merchant_list.charges = atoul(row[2]); - temp_merchant_list.item = atoul(row[3]); + temp_merchant_list.slot = Strings::ToUnsignedInt(row[1]); + temp_merchant_list.charges = Strings::ToUnsignedInt(row[2]); + temp_merchant_list.item = Strings::ToUnsignedInt(row[3]); temp_merchant_list.origslot = temp_merchant_list.slot; LogMerchants( @@ -693,7 +693,7 @@ void Zone::GetMerchantDataForZoneLoad() { for (auto row : results) { MerchantList mle{}; - mle.id = std::stoul(row[0]); + mle.id = Strings::ToUnsignedInt(row[0]); if (npc_id != mle.id) { merchant_list = merchanttable.find(mle.id); if (merchant_list == merchanttable.end()) { @@ -717,18 +717,18 @@ void Zone::GetMerchantDataForZoneLoad() { continue; } - mle.slot = std::stoul(row[1]); - mle.item = std::stoul(row[2]); - mle.faction_required = static_cast(std::stoi(row[3])); - mle.level_required = static_cast(std::stoul(row[4])); - mle.min_status = static_cast(std::stoul(row[5])); - mle.max_status = static_cast(std::stoul(row[6])); - mle.alt_currency_cost = static_cast(std::stoul(row[7])); - mle.classes_required = std::stoul(row[8]); - mle.probability = static_cast(std::stoul(row[9])); + mle.slot = Strings::ToUnsignedInt(row[1]); + mle.item = Strings::ToUnsignedInt(row[2]); + mle.faction_required = static_cast(Strings::ToInt(row[3])); + mle.level_required = static_cast(Strings::ToUnsignedInt(row[4])); + mle.min_status = static_cast(Strings::ToUnsignedInt(row[5])); + mle.max_status = static_cast(Strings::ToUnsignedInt(row[6])); + mle.alt_currency_cost = static_cast(Strings::ToUnsignedInt(row[7])); + mle.classes_required = Strings::ToUnsignedInt(row[8]); + mle.probability = static_cast(Strings::ToUnsignedInt(row[9])); mle.bucket_name = row[10]; mle.bucket_value = row[11]; - mle.bucket_comparison = static_cast(std::stoul(row[12])); + mle.bucket_comparison = static_cast(Strings::ToUnsignedInt(row[12])); merchant_list->second.push_back(mle); } @@ -748,10 +748,10 @@ void Zone::LoadMercTemplates(){ for (auto row = results.begin(); row != results.end(); ++row) { MercStanceInfo tempMercStanceInfo; - tempMercStanceInfo.ClassID = atoi(row[0]); - tempMercStanceInfo.ProficiencyID = atoi(row[1]); - tempMercStanceInfo.StanceID = atoi(row[2]); - tempMercStanceInfo.IsDefault = atoi(row[3]); + tempMercStanceInfo.ClassID = Strings::ToInt(row[0]); + tempMercStanceInfo.ProficiencyID = Strings::ToInt(row[1]); + tempMercStanceInfo.StanceID = Strings::ToInt(row[2]); + tempMercStanceInfo.IsDefault = Strings::ToInt(row[3]); merc_stances.push_back(tempMercStanceInfo); } @@ -774,16 +774,16 @@ void Zone::LoadMercTemplates(){ MercTemplate tempMercTemplate; - tempMercTemplate.MercTemplateID = atoi(row[0]); - tempMercTemplate.MercType = atoi(row[1]); - tempMercTemplate.MercSubType = atoi(row[2]); - tempMercTemplate.RaceID = atoi(row[3]); - tempMercTemplate.ClassID = atoi(row[4]); - tempMercTemplate.ProficiencyID = atoi(row[5]); - tempMercTemplate.TierID = atoi(row[6]); - tempMercTemplate.CostFormula = atoi(row[7]); - tempMercTemplate.ClientVersion = atoi(row[8]); - tempMercTemplate.MercNPCID = atoi(row[9]); + tempMercTemplate.MercTemplateID = Strings::ToInt(row[0]); + tempMercTemplate.MercType = Strings::ToInt(row[1]); + tempMercTemplate.MercSubType = Strings::ToInt(row[2]); + tempMercTemplate.RaceID = Strings::ToInt(row[3]); + tempMercTemplate.ClassID = Strings::ToInt(row[4]); + tempMercTemplate.ProficiencyID = Strings::ToInt(row[5]); + tempMercTemplate.TierID = Strings::ToInt(row[6]); + tempMercTemplate.CostFormula = Strings::ToInt(row[7]); + tempMercTemplate.ClientVersion = Strings::ToInt(row[8]); + tempMercTemplate.MercNPCID = Strings::ToInt(row[9]); for(int i = 0; i < MaxMercStanceID; i++) tempMercTemplate.Stances[i] = 0; @@ -815,9 +815,9 @@ void Zone::LoadLevelEXPMods(){ } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 index = atoi(row[0]); - float exp_mod = atof(row[1]); - float aa_exp_mod = atof(row[2]); + uint32 index = Strings::ToInt(row[0]); + float exp_mod = Strings::ToFloat(row[1]); + float aa_exp_mod = Strings::ToFloat(row[2]); level_exp_mod[index].ExpMod = exp_mod; level_exp_mod[index].AAExpMod = aa_exp_mod; } @@ -842,15 +842,15 @@ void Zone::LoadMercSpells(){ uint32 classid; MercSpellEntry tempMercSpellEntry; - classid = atoi(row[0]); - tempMercSpellEntry.proficiencyid = atoi(row[1]); - tempMercSpellEntry.spellid = atoi(row[2]); - tempMercSpellEntry.type = atoi(row[3]); - tempMercSpellEntry.stance = atoi(row[4]); - tempMercSpellEntry.minlevel = atoi(row[5]); - tempMercSpellEntry.maxlevel = atoi(row[6]); - tempMercSpellEntry.slot = atoi(row[7]); - tempMercSpellEntry.proc_chance = atoi(row[8]); + classid = Strings::ToInt(row[0]); + tempMercSpellEntry.proficiencyid = Strings::ToInt(row[1]); + tempMercSpellEntry.spellid = Strings::ToInt(row[2]); + tempMercSpellEntry.type = Strings::ToInt(row[3]); + tempMercSpellEntry.stance = Strings::ToInt(row[4]); + tempMercSpellEntry.minlevel = Strings::ToInt(row[5]); + tempMercSpellEntry.maxlevel = Strings::ToInt(row[6]); + tempMercSpellEntry.slot = Strings::ToInt(row[7]); + tempMercSpellEntry.proc_chance = Strings::ToInt(row[8]); merc_spells_list[classid].push_back(tempMercSpellEntry); } @@ -2166,10 +2166,10 @@ bool ZoneDatabase::GetDecayTimes(npcDecayTimes_Struct *npcCorpseDecayTimes) int index = 0; for (auto row = results.begin(); row != results.end(); ++row, ++index) { Seperator sep(row[0]); - npcCorpseDecayTimes[index].minlvl = atoi(sep.arg[1]); - npcCorpseDecayTimes[index].maxlvl = atoi(sep.arg[2]); + npcCorpseDecayTimes[index].minlvl = Strings::ToInt(sep.arg[1]); + npcCorpseDecayTimes[index].maxlvl = Strings::ToInt(sep.arg[2]); - npcCorpseDecayTimes[index].seconds = std::min(24 * 60 * 60, atoi(row[1])); + npcCorpseDecayTimes[index].seconds = std::min(24 * 60 * 60, Strings::ToInt(row[1])); } LogInfo("Loaded [{}] decay timers", Strings::Commify(results.RowCount())); @@ -2338,11 +2338,11 @@ void Zone::LoadLDoNTraps() for (auto row = results.begin(); row != results.end(); ++row) { auto lt = new LDoNTrapTemplate; - lt->id = atoi(row[0]); - lt->type = (LDoNChestTypes) atoi(row[1]); - lt->spell_id = atoi(row[2]); - lt->skill = atoi(row[3]); - lt->locked = atoi(row[4]); + lt->id = Strings::ToInt(row[0]); + lt->type = (LDoNChestTypes) Strings::ToInt(row[1]); + lt->spell_id = Strings::ToInt(row[2]); + lt->skill = Strings::ToInt(row[3]); + lt->locked = Strings::ToInt(row[4]); ldon_trap_list[lt->id] = lt; } @@ -2358,8 +2358,8 @@ void Zone::LoadLDoNTrapEntries() for (auto row = results.begin(); row != results.end(); ++row) { - uint32 id = atoi(row[0]); - uint32 trap_id = atoi(row[1]); + uint32 id = Strings::ToInt(row[0]); + uint32 trap_id = Strings::ToInt(row[1]); LDoNTrapTemplate *trapTemplate = nullptr; auto it = ldon_trap_list.find(trap_id); @@ -2402,7 +2402,7 @@ void Zone::LoadVeteranRewards() int index = 0; for (auto row = results.begin(); row != results.end(); ++row, ++index) { - uint32 claim = atoi(row[0]); + uint32 claim = Strings::ToInt(row[0]); if(claim != current_reward.claim_id) { @@ -2419,8 +2419,8 @@ void Zone::LoadVeteranRewards() } strcpy(current_reward.items[index].item_name, row[1]); - current_reward.items[index].item_id = atoi(row[2]); - current_reward.items[index].charges = atoi(row[3]); + current_reward.items[index].item_id = Strings::ToInt(row[2]); + current_reward.items[index].charges = Strings::ToInt(row[3]); } if(current_reward.claim_id != 0) @@ -2445,8 +2445,8 @@ void Zone::LoadAlternateCurrencies() } for (auto row : results) { - current_currency.id = std::stoul(row[0]); - current_currency.item_id = std::stoul(row[1]); + current_currency.id = Strings::ToUnsignedInt(row[0]); + current_currency.item_id = Strings::ToUnsignedInt(row[1]); AlternateCurrencies.push_back(current_currency); } @@ -2492,7 +2492,7 @@ void Zone::LoadAdventureFlavor() } for (auto row = results.begin(); row != results.end(); ++row) { - uint32 id = atoi(row[0]); + uint32 id = Strings::ToInt(row[0]); adventure_entry_list_flavor[id] = row[1]; } @@ -2575,9 +2575,9 @@ void Zone::LoadNPCEmotes(LinkedList* NPCEmoteList) for (auto row = results.begin(); row != results.end(); ++row) { auto nes = new NPC_Emote_Struct; - nes->emoteid = atoi(row[0]); - nes->event_ = atoi(row[1]); - nes->type = atoi(row[2]); + nes->emoteid = Strings::ToInt(row[0]); + nes->event_ = Strings::ToInt(row[1]); + nes->type = Strings::ToInt(row[2]); strn0cpy(nes->text, row[3], sizeof(nes->text)); NPCEmoteList->Insert(nes); } @@ -2660,16 +2660,16 @@ void Zone::LoadTickItems() for (auto row = results.begin(); row != results.end(); ++row) { - if(atoi(row[0]) == 0) + if(Strings::ToInt(row[0]) == 0) continue; item_tick_struct ti_tmp; - ti_tmp.itemid = atoi(row[0]); - ti_tmp.chance = atoi(row[1]); - ti_tmp.level = atoi(row[2]); - ti_tmp.bagslot = (int16)atoi(row[4]); + ti_tmp.itemid = Strings::ToInt(row[0]); + ti_tmp.chance = Strings::ToInt(row[1]); + ti_tmp.level = Strings::ToInt(row[2]); + ti_tmp.bagslot = (int16)Strings::ToInt(row[4]); ti_tmp.qglobal = std::string(row[3]); - tick_items[atoi(row[0])] = ti_tmp; + tick_items[Strings::ToInt(row[0])] = ti_tmp; } @@ -3015,7 +3015,7 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st break; } - if (std::stoll(player_value) < std::stoll(bucket_value)) { + if (Strings::ToBigInt(player_value) < Strings::ToBigInt(bucket_value)) { break; } @@ -3028,7 +3028,7 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st break; } - if (std::stoll(player_value) > std::stoll(bucket_value)) { + if (Strings::ToBigInt(player_value) > Strings::ToBigInt(bucket_value)) { break; } @@ -3041,7 +3041,7 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st break; } - if (std::stoll(player_value) <= std::stoll(bucket_value)) { + if (Strings::ToBigInt(player_value) <= Strings::ToBigInt(bucket_value)) { break; } @@ -3054,7 +3054,7 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st break; } - if (std::stoll(player_value) >= std::stoll(bucket_value)) { + if (Strings::ToBigInt(player_value) >= Strings::ToBigInt(bucket_value)) { break; } @@ -3115,9 +3115,9 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st if ( !EQ::ValueWithin( - std::stoll(player_value), - std::stoll(bucket_checks[0]), - std::stoll(bucket_checks[1]) + Strings::ToBigInt(player_value), + Strings::ToBigInt(bucket_checks[0]), + Strings::ToBigInt(bucket_checks[1]) ) ) { break; @@ -3143,9 +3143,9 @@ bool Zone::CheckDataBucket(uint8 bucket_comparison, std::string bucket_value, st if ( EQ::ValueWithin( - std::stoll(player_value), - std::stoll(bucket_checks[0]), - std::stoll(bucket_checks[1]) + Strings::ToBigInt(player_value), + Strings::ToBigInt(bucket_checks[0]), + Strings::ToBigInt(bucket_checks[1]) ) ) { break; diff --git a/zone/zonedb.cpp b/zone/zonedb.cpp index 0a52953a4d..b392beb802 100644 --- a/zone/zonedb.cpp +++ b/zone/zonedb.cpp @@ -151,8 +151,8 @@ uint32 ZoneDatabase::GetSpawnTimeLeft(uint32 id, uint16 instance_id) timeval tv; gettimeofday(&tv, nullptr); - uint32 resStart = atoi(row[0]); - uint32 resDuration = atoi(row[1]); + uint32 resStart = Strings::ToInt(row[0]); + uint32 resDuration = Strings::ToInt(row[1]); //compare our values to current time if((resStart + resDuration) <= tv.tv_sec) { @@ -201,16 +201,16 @@ void ZoneDatabase::LoadWorldContainer(uint32 parentid, EQ::ItemInstance* contain } for (auto& row = results.begin(); row != results.end(); ++row) { - uint8 index = (uint8)atoi(row[0]); - uint32 item_id = (uint32)atoi(row[1]); - int8 charges = (int8)atoi(row[2]); + uint8 index = (uint8)Strings::ToInt(row[0]); + uint32 item_id = (uint32)Strings::ToInt(row[1]); + int8 charges = (int8)Strings::ToInt(row[2]); uint32 aug[EQ::invaug::SOCKET_COUNT]; - aug[0] = (uint32)atoi(row[3]); - aug[1] = (uint32)atoi(row[4]); - aug[2] = (uint32)atoi(row[5]); - aug[3] = (uint32)atoi(row[6]); - aug[4] = (uint32)atoi(row[7]); - aug[5] = (uint32)atoi(row[8]); + aug[0] = (uint32)Strings::ToInt(row[3]); + aug[1] = (uint32)Strings::ToInt(row[4]); + aug[2] = (uint32)Strings::ToInt(row[5]); + aug[3] = (uint32)Strings::ToInt(row[6]); + aug[4] = (uint32)Strings::ToInt(row[7]); + aug[5] = (uint32)Strings::ToInt(row[8]); EQ::ItemInstance* inst = database.CreateItem(item_id, charges); if (inst && inst->GetItem()->IsClassCommon()) { @@ -301,13 +301,13 @@ Trader_Struct* ZoneDatabase::LoadTraderItem(uint32 char_id) loadti->Code = BazaarTrader_ShowItems; for (auto& row = results.begin(); row != results.end(); ++row) { - if (atoi(row[5]) >= 80 || atoi(row[4]) < 0) { + if (Strings::ToInt(row[5]) >= 80 || Strings::ToInt(row[4]) < 0) { LogTrading("Bad Slot number when trying to load trader information!\n"); continue; } - loadti->Items[atoi(row[5])] = atoi(row[1]); - loadti->ItemCost[atoi(row[5])] = atoi(row[4]); + loadti->Items[Strings::ToInt(row[5])] = Strings::ToInt(row[1]); + loadti->ItemCost[Strings::ToInt(row[5])] = Strings::ToInt(row[4]); } return loadti; } @@ -325,15 +325,15 @@ TraderCharges_Struct* ZoneDatabase::LoadTraderItemWithCharges(uint32 char_id) } for (auto& row = results.begin(); row != results.end(); ++row) { - if (atoi(row[5]) >= 80 || atoi(row[5]) < 0) { + if (Strings::ToInt(row[5]) >= 80 || Strings::ToInt(row[5]) < 0) { LogTrading("Bad Slot number when trying to load trader information!\n"); continue; } - loadti->ItemID[atoi(row[5])] = atoi(row[1]); - loadti->SerialNumber[atoi(row[5])] = atoi(row[2]); - loadti->Charges[atoi(row[5])] = atoi(row[3]); - loadti->ItemCost[atoi(row[5])] = atoi(row[4]); + loadti->ItemID[Strings::ToInt(row[5])] = Strings::ToInt(row[1]); + loadti->SerialNumber[Strings::ToInt(row[5])] = Strings::ToInt(row[2]); + loadti->Charges[Strings::ToInt(row[5])] = Strings::ToInt(row[3]); + loadti->ItemCost[Strings::ToInt(row[5])] = Strings::ToInt(row[4]); } return loadti; } @@ -352,9 +352,9 @@ EQ::ItemInstance* ZoneDatabase::LoadSingleTraderItem(uint32 CharID, int SerialNu auto& row = results.begin(); - int ItemID = atoi(row[1]); - int Charges = atoi(row[3]); - int Cost = atoi(row[4]); + int ItemID = Strings::ToInt(row[1]); + int Charges = Strings::ToInt(row[3]); + int Cost = Strings::ToInt(row[4]); const EQ::ItemData *item = database.GetItem(ItemID); @@ -630,96 +630,96 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct* for (auto& row = results.begin(); row != results.end(); ++row) { strcpy(pp->name, row[r]); r++; // "`name`, " strcpy(pp->last_name, row[r]); r++; // "last_name, " - pp->gender = atoi(row[r]); r++; // "gender, " - pp->race = atoi(row[r]); r++; // "race, " - pp->class_ = atoi(row[r]); r++; // "class, " - pp->level = atoi(row[r]); r++; // "`level`, " - pp->deity = atoi(row[r]); r++; // "deity, " - pp->birthday = atoi(row[r]); r++; // "birthday, " - pp->lastlogin = atoi(row[r]); r++; // "last_login, " - pp->timePlayedMin = atoi(row[r]); r++; // "time_played, " - pp->pvp = atoi(row[r]); r++; // "pvp_status, " - pp->level2 = atoi(row[r]); r++; // "level2, " - pp->anon = atoi(row[r]); r++; // "anon, " - pp->gm = atoi(row[r]); r++; // "gm, " - pp->intoxication = atoi(row[r]); r++; // "intoxication, " - pp->haircolor = atoi(row[r]); r++; // "hair_color, " - pp->beardcolor = atoi(row[r]); r++; // "beard_color, " - pp->eyecolor1 = atoi(row[r]); r++; // "eye_color_1, " - pp->eyecolor2 = atoi(row[r]); r++; // "eye_color_2, " - pp->hairstyle = atoi(row[r]); r++; // "hair_style, " - pp->beard = atoi(row[r]); r++; // "beard, " - pp->ability_time_seconds = atoi(row[r]); r++; // "ability_time_seconds, " - pp->ability_number = atoi(row[r]); r++; // "ability_number, " - pp->ability_time_minutes = atoi(row[r]); r++; // "ability_time_minutes, " - pp->ability_time_hours = atoi(row[r]); r++; // "ability_time_hours, " + pp->gender = Strings::ToInt(row[r]); r++; // "gender, " + pp->race = Strings::ToInt(row[r]); r++; // "race, " + pp->class_ = Strings::ToInt(row[r]); r++; // "class, " + pp->level = Strings::ToInt(row[r]); r++; // "`level`, " + pp->deity = Strings::ToInt(row[r]); r++; // "deity, " + pp->birthday = Strings::ToInt(row[r]); r++; // "birthday, " + pp->lastlogin = Strings::ToInt(row[r]); r++; // "last_login, " + pp->timePlayedMin = Strings::ToInt(row[r]); r++; // "time_played, " + pp->pvp = Strings::ToInt(row[r]); r++; // "pvp_status, " + pp->level2 = Strings::ToInt(row[r]); r++; // "level2, " + pp->anon = Strings::ToInt(row[r]); r++; // "anon, " + pp->gm = Strings::ToInt(row[r]); r++; // "gm, " + pp->intoxication = Strings::ToInt(row[r]); r++; // "intoxication, " + pp->haircolor = Strings::ToInt(row[r]); r++; // "hair_color, " + pp->beardcolor = Strings::ToInt(row[r]); r++; // "beard_color, " + pp->eyecolor1 = Strings::ToInt(row[r]); r++; // "eye_color_1, " + pp->eyecolor2 = Strings::ToInt(row[r]); r++; // "eye_color_2, " + pp->hairstyle = Strings::ToInt(row[r]); r++; // "hair_style, " + pp->beard = Strings::ToInt(row[r]); r++; // "beard, " + pp->ability_time_seconds = Strings::ToInt(row[r]); r++; // "ability_time_seconds, " + pp->ability_number = Strings::ToInt(row[r]); r++; // "ability_number, " + pp->ability_time_minutes = Strings::ToInt(row[r]); r++; // "ability_time_minutes, " + pp->ability_time_hours = Strings::ToInt(row[r]); r++; // "ability_time_hours, " strcpy(pp->title, row[r]); r++; // "title, " strcpy(pp->suffix, row[r]); r++; // "suffix, " - pp->exp = atoi(row[r]); r++; // "exp, " - pp->points = atoi(row[r]); r++; // "points, " - pp->mana = atoi(row[r]); r++; // "mana, " - pp->cur_hp = atoi(row[r]); r++; // "cur_hp, " - pp->STR = atoi(row[r]); r++; // "str, " - pp->STA = atoi(row[r]); r++; // "sta, " - pp->CHA = atoi(row[r]); r++; // "cha, " - pp->DEX = atoi(row[r]); r++; // "dex, " - pp->INT = atoi(row[r]); r++; // "`int`, " - pp->AGI = atoi(row[r]); r++; // "agi, " - pp->WIS = atoi(row[r]); r++; // "wis, " - pp->face = atoi(row[r]); r++; // "face, " - pp->y = atof(row[r]); r++; // "y, " - pp->x = atof(row[r]); r++; // "x, " - pp->z = atof(row[r]); r++; // "z, " - pp->heading = atof(row[r]); r++; // "heading, " - pp->pvp2 = atoi(row[r]); r++; // "pvp2, " - pp->pvptype = atoi(row[r]); r++; // "pvp_type, " - pp->autosplit = atoi(row[r]); r++; // "autosplit_enabled, " - pp->zone_change_count = atoi(row[r]); r++; // "zone_change_count, " - pp->drakkin_heritage = atoi(row[r]); r++; // "drakkin_heritage, " - pp->drakkin_tattoo = atoi(row[r]); r++; // "drakkin_tattoo, " - pp->drakkin_details = atoi(row[r]); r++; // "drakkin_details, " - pp->toxicity = atoi(row[r]); r++; // "toxicity, " - pp->hunger_level = atoi(row[r]); r++; // "hunger_level, " - pp->thirst_level = atoi(row[r]); r++; // "thirst_level, " - pp->ability_up = atoi(row[r]); r++; // "ability_up, " - pp->zone_id = atoi(row[r]); r++; // "zone_id, " - pp->zoneInstance = atoi(row[r]); r++; // "zone_instance, " - pp->leadAAActive = atoi(row[r]); r++; // "leadership_exp_on, " - pp->ldon_points_guk = atoi(row[r]); r++; // "ldon_points_guk, " - pp->ldon_points_mir = atoi(row[r]); r++; // "ldon_points_mir, " - pp->ldon_points_mmc = atoi(row[r]); r++; // "ldon_points_mmc, " - pp->ldon_points_ruj = atoi(row[r]); r++; // "ldon_points_ruj, " - pp->ldon_points_tak = atoi(row[r]); r++; // "ldon_points_tak, " - pp->ldon_points_available = atoi(row[r]); r++; // "ldon_points_available, " - pp->tribute_time_remaining = atoi(row[r]); r++; // "tribute_time_remaining, " - pp->showhelm = atoi(row[r]); r++; // "show_helm, " - pp->career_tribute_points = atoi(row[r]); r++; // "career_tribute_points, " - pp->tribute_points = atoi(row[r]); r++; // "tribute_points, " - pp->tribute_active = atoi(row[r]); r++; // "tribute_active, " - pp->endurance = atoi(row[r]); r++; // "endurance, " - pp->group_leadership_exp = atoi(row[r]); r++; // "group_leadership_exp, " - pp->raid_leadership_exp = atoi(row[r]); r++; // "raid_leadership_exp, " - pp->group_leadership_points = atoi(row[r]); r++; // "group_leadership_points, " - pp->raid_leadership_points = atoi(row[r]); r++; // "raid_leadership_points, " - pp->air_remaining = atoi(row[r]); r++; // "air_remaining, " - pp->PVPKills = atoi(row[r]); r++; // "pvp_kills, " - pp->PVPDeaths = atoi(row[r]); r++; // "pvp_deaths, " - pp->PVPCurrentPoints = atoi(row[r]); r++; // "pvp_current_points, " - pp->PVPCareerPoints = atoi(row[r]); r++; // "pvp_career_points, " - pp->PVPBestKillStreak = atoi(row[r]); r++; // "pvp_best_kill_streak, " - pp->PVPWorstDeathStreak = atoi(row[r]); r++; // "pvp_worst_death_streak, " - pp->PVPCurrentKillStreak = atoi(row[r]); r++; // "pvp_current_kill_streak, " - pp->aapoints_spent = atoi(row[r]); r++; // "aa_points_spent, " - pp->expAA = atoi(row[r]); r++; // "aa_exp, " - pp->aapoints = atoi(row[r]); r++; // "aa_points, " - pp->groupAutoconsent = atoi(row[r]); r++; // "group_auto_consent, " - pp->raidAutoconsent = atoi(row[r]); r++; // "raid_auto_consent, " - pp->guildAutoconsent = atoi(row[r]); r++; // "guild_auto_consent, " - pp->RestTimer = atoi(row[r]); r++; // "RestTimer, " - m_epp->aa_effects = atoi(row[r]); r++; // "`e_aa_effects`, " - m_epp->perAA = atoi(row[r]); r++; // "`e_percent_to_aa`, " - m_epp->expended_aa = atoi(row[r]); r++; // "`e_expended_aa_spent`, " - m_epp->last_invsnapshot_time = atoul(row[r]); r++; // "`e_last_invsnapshot` " + pp->exp = Strings::ToInt(row[r]); r++; // "exp, " + pp->points = Strings::ToInt(row[r]); r++; // "points, " + pp->mana = Strings::ToInt(row[r]); r++; // "mana, " + pp->cur_hp = Strings::ToInt(row[r]); r++; // "cur_hp, " + pp->STR = Strings::ToInt(row[r]); r++; // "str, " + pp->STA = Strings::ToInt(row[r]); r++; // "sta, " + pp->CHA = Strings::ToInt(row[r]); r++; // "cha, " + pp->DEX = Strings::ToInt(row[r]); r++; // "dex, " + pp->INT = Strings::ToInt(row[r]); r++; // "`int`, " + pp->AGI = Strings::ToInt(row[r]); r++; // "agi, " + pp->WIS = Strings::ToInt(row[r]); r++; // "wis, " + pp->face = Strings::ToInt(row[r]); r++; // "face, " + pp->y = Strings::ToFloat(row[r]); r++; // "y, " + pp->x = Strings::ToFloat(row[r]); r++; // "x, " + pp->z = Strings::ToFloat(row[r]); r++; // "z, " + pp->heading = Strings::ToFloat(row[r]); r++; // "heading, " + pp->pvp2 = Strings::ToInt(row[r]); r++; // "pvp2, " + pp->pvptype = Strings::ToInt(row[r]); r++; // "pvp_type, " + pp->autosplit = Strings::ToInt(row[r]); r++; // "autosplit_enabled, " + pp->zone_change_count = Strings::ToInt(row[r]); r++; // "zone_change_count, " + pp->drakkin_heritage = Strings::ToInt(row[r]); r++; // "drakkin_heritage, " + pp->drakkin_tattoo = Strings::ToInt(row[r]); r++; // "drakkin_tattoo, " + pp->drakkin_details = Strings::ToInt(row[r]); r++; // "drakkin_details, " + pp->toxicity = Strings::ToInt(row[r]); r++; // "toxicity, " + pp->hunger_level = Strings::ToInt(row[r]); r++; // "hunger_level, " + pp->thirst_level = Strings::ToInt(row[r]); r++; // "thirst_level, " + pp->ability_up = Strings::ToInt(row[r]); r++; // "ability_up, " + pp->zone_id = Strings::ToInt(row[r]); r++; // "zone_id, " + pp->zoneInstance = Strings::ToInt(row[r]); r++; // "zone_instance, " + pp->leadAAActive = Strings::ToInt(row[r]); r++; // "leadership_exp_on, " + pp->ldon_points_guk = Strings::ToInt(row[r]); r++; // "ldon_points_guk, " + pp->ldon_points_mir = Strings::ToInt(row[r]); r++; // "ldon_points_mir, " + pp->ldon_points_mmc = Strings::ToInt(row[r]); r++; // "ldon_points_mmc, " + pp->ldon_points_ruj = Strings::ToInt(row[r]); r++; // "ldon_points_ruj, " + pp->ldon_points_tak = Strings::ToInt(row[r]); r++; // "ldon_points_tak, " + pp->ldon_points_available = Strings::ToInt(row[r]); r++; // "ldon_points_available, " + pp->tribute_time_remaining = Strings::ToInt(row[r]); r++; // "tribute_time_remaining, " + pp->showhelm = Strings::ToInt(row[r]); r++; // "show_helm, " + pp->career_tribute_points = Strings::ToInt(row[r]); r++; // "career_tribute_points, " + pp->tribute_points = Strings::ToInt(row[r]); r++; // "tribute_points, " + pp->tribute_active = Strings::ToInt(row[r]); r++; // "tribute_active, " + pp->endurance = Strings::ToInt(row[r]); r++; // "endurance, " + pp->group_leadership_exp = Strings::ToInt(row[r]); r++; // "group_leadership_exp, " + pp->raid_leadership_exp = Strings::ToInt(row[r]); r++; // "raid_leadership_exp, " + pp->group_leadership_points = Strings::ToInt(row[r]); r++; // "group_leadership_points, " + pp->raid_leadership_points = Strings::ToInt(row[r]); r++; // "raid_leadership_points, " + pp->air_remaining = Strings::ToInt(row[r]); r++; // "air_remaining, " + pp->PVPKills = Strings::ToInt(row[r]); r++; // "pvp_kills, " + pp->PVPDeaths = Strings::ToInt(row[r]); r++; // "pvp_deaths, " + pp->PVPCurrentPoints = Strings::ToInt(row[r]); r++; // "pvp_current_points, " + pp->PVPCareerPoints = Strings::ToInt(row[r]); r++; // "pvp_career_points, " + pp->PVPBestKillStreak = Strings::ToInt(row[r]); r++; // "pvp_best_kill_streak, " + pp->PVPWorstDeathStreak = Strings::ToInt(row[r]); r++; // "pvp_worst_death_streak, " + pp->PVPCurrentKillStreak = Strings::ToInt(row[r]); r++; // "pvp_current_kill_streak, " + pp->aapoints_spent = Strings::ToInt(row[r]); r++; // "aa_points_spent, " + pp->expAA = Strings::ToInt(row[r]); r++; // "aa_exp, " + pp->aapoints = Strings::ToInt(row[r]); r++; // "aa_points, " + pp->groupAutoconsent = Strings::ToInt(row[r]); r++; // "group_auto_consent, " + pp->raidAutoconsent = Strings::ToInt(row[r]); r++; // "raid_auto_consent, " + pp->guildAutoconsent = Strings::ToInt(row[r]); r++; // "guild_auto_consent, " + pp->RestTimer = Strings::ToInt(row[r]); r++; // "RestTimer, " + m_epp->aa_effects = Strings::ToInt(row[r]); r++; // "`e_aa_effects`, " + m_epp->perAA = Strings::ToInt(row[r]); r++; // "`e_percent_to_aa`, " + m_epp->expended_aa = Strings::ToInt(row[r]); r++; // "`e_expended_aa_spent`, " + m_epp->last_invsnapshot_time = Strings::ToUnsignedInt(row[r]); r++; // "`e_last_invsnapshot` " m_epp->next_invsnapshot_time = m_epp->last_invsnapshot_time + (RuleI(Character, InvSnapshotMinIntervalM) * 60); pp->fast_heal_threshold = atoi(row[r]); r++; // "`fast_heal_threshold` " pp->heal_threshold = atoi(row[r]); r++; // "`heal_threshold` " @@ -737,7 +737,7 @@ bool ZoneDatabase::LoadCharacterData(uint32 character_id, PlayerProfile_Struct* bool ZoneDatabase::LoadCharacterFactionValues(uint32 character_id, faction_map & val_list) { std::string query = StringFormat("SELECT `faction_id`, `current_value` FROM `faction_values` WHERE `char_id` = %i", character_id); auto results = database.QueryDatabase(query); - for (auto& row = results.begin(); row != results.end(); ++row) { val_list[atoi(row[0])] = atoi(row[1]); } + for (auto& row = results.begin(); row != results.end(); ++row) { val_list[Strings::ToInt(row[0])] = Strings::ToInt(row[1]); } return true; } @@ -756,9 +756,9 @@ bool ZoneDatabase::LoadCharacterMemmedSpells(uint32 character_id, PlayerProfile_ pp->mem_spells[i] = 0xFFFFFFFF; } for (auto& row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); - if (i < EQ::spells::SPELL_GEM_COUNT && atoi(row[1]) <= SPDAT_RECORDS){ - pp->mem_spells[i] = atoi(row[1]); + i = Strings::ToInt(row[0]); + if (i < EQ::spells::SPELL_GEM_COUNT && Strings::ToInt(row[1]) <= SPDAT_RECORDS){ + pp->mem_spells[i] = Strings::ToInt(row[1]); } } return true; @@ -784,8 +784,8 @@ bool ZoneDatabase::LoadCharacterSpellBook(uint32 character_id, PlayerProfile_Str // Load them all so that server actions are valid..but, nix them in translators. for (auto& row = results.begin(); row != results.end(); ++row) { - int idx = atoi(row[0]); - int id = atoi(row[1]); + int idx = Strings::ToInt(row[0]); + int id = Strings::ToInt(row[1]); if (idx < 0 || idx >= EQ::spells::SPELLBOOK_SIZE) continue; @@ -812,9 +812,9 @@ bool ZoneDatabase::LoadCharacterLanguages(uint32 character_id, PlayerProfile_Str pp->languages[i] = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); + i = Strings::ToInt(row[0]); if (i < MAX_PP_LANGUAGE){ - pp->languages[i] = atoi(row[1]); + pp->languages[i] = Strings::ToInt(row[1]); } } @@ -825,8 +825,8 @@ bool ZoneDatabase::LoadCharacterLeadershipAA(uint32 character_id, PlayerProfile_ std::string query = StringFormat("SELECT slot, `rank` FROM character_leadership_abilities WHERE `id` = %u", character_id); auto results = database.QueryDatabase(query); uint32 slot = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - slot = atoi(row[0]); - pp->leader_abilities.ranks[slot] = atoi(row[1]); + slot = Strings::ToInt(row[0]); + pp->leader_abilities.ranks[slot] = Strings::ToInt(row[1]); } return true; } @@ -869,9 +869,9 @@ bool ZoneDatabase::LoadCharacterSkills(uint32 character_id, PlayerProfile_Struct pp->skills[i] = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); + i = Strings::ToInt(row[0]); if (i < MAX_PP_SKILL) - pp->skills[i] = atoi(row[1]); + pp->skills[i] = Strings::ToInt(row[1]); } return true; @@ -901,22 +901,22 @@ bool ZoneDatabase::LoadCharacterCurrency(uint32 character_id, PlayerProfile_Stru "WHERE `id` = %i ", character_id); auto results = database.QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - pp->platinum = atoi(row[0]); - pp->gold = atoi(row[1]); - pp->silver = atoi(row[2]); - pp->copper = atoi(row[3]); - pp->platinum_bank = atoi(row[4]); - pp->gold_bank = atoi(row[5]); - pp->silver_bank = atoi(row[6]); - pp->copper_bank = atoi(row[7]); - pp->platinum_cursor = atoi(row[8]); - pp->gold_cursor = atoi(row[9]); - pp->silver_cursor = atoi(row[10]); - pp->copper_cursor = atoi(row[11]); - pp->currentRadCrystals = atoi(row[12]); - pp->careerRadCrystals = atoi(row[13]); - pp->currentEbonCrystals = atoi(row[14]); - pp->careerEbonCrystals = atoi(row[15]); + pp->platinum = Strings::ToInt(row[0]); + pp->gold = Strings::ToInt(row[1]); + pp->silver = Strings::ToInt(row[2]); + pp->copper = Strings::ToInt(row[3]); + pp->platinum_bank = Strings::ToInt(row[4]); + pp->gold_bank = Strings::ToInt(row[5]); + pp->silver_bank = Strings::ToInt(row[6]); + pp->copper_bank = Strings::ToInt(row[7]); + pp->platinum_cursor = Strings::ToInt(row[8]); + pp->gold_cursor = Strings::ToInt(row[9]); + pp->silver_cursor = Strings::ToInt(row[10]); + pp->copper_cursor = Strings::ToInt(row[11]); + pp->currentRadCrystals = Strings::ToInt(row[12]); + pp->careerRadCrystals = Strings::ToInt(row[13]); + pp->currentEbonCrystals = Strings::ToInt(row[14]); + pp->careerEbonCrystals = Strings::ToInt(row[15]); } return true; } @@ -926,11 +926,11 @@ bool ZoneDatabase::LoadCharacterMaterialColor(uint32 character_id, PlayerProfile auto results = database.QueryDatabase(query); int i = 0; int r = 0; for (auto& row = results.begin(); row != results.end(); ++row) { r = 0; - i = atoi(row[r]); /* Slot */ r++; - pp->item_tint.Slot[i].Blue = atoi(row[r]); r++; - pp->item_tint.Slot[i].Green = atoi(row[r]); r++; - pp->item_tint.Slot[i].Red = atoi(row[r]); r++; - pp->item_tint.Slot[i].UseTint = atoi(row[r]); + i = Strings::ToInt(row[r]); /* Slot */ r++; + pp->item_tint.Slot[i].Blue = Strings::ToInt(row[r]); r++; + pp->item_tint.Slot[i].Green = Strings::ToInt(row[r]); r++; + pp->item_tint.Slot[i].Red = Strings::ToInt(row[r]); r++; + pp->item_tint.Slot[i].UseTint = Strings::ToInt(row[r]); } return true; } @@ -951,13 +951,13 @@ bool ZoneDatabase::LoadCharacterBandolier(uint32 character_id, PlayerProfile_Str for (auto& row = results.begin(); row != results.end(); ++row) { r = 0; - i = atoi(row[r]); /* Bandolier ID */ r++; - si = atoi(row[r]); /* Bandolier Slot */ r++; + i = Strings::ToInt(row[r]); /* Bandolier ID */ r++; + si = Strings::ToInt(row[r]); /* Bandolier Slot */ r++; - const EQ::ItemData* item_data = database.GetItem(atoi(row[r])); + const EQ::ItemData* item_data = database.GetItem(Strings::ToInt(row[r])); if (item_data) { pp->bandoliers[i].Items[si].ID = item_data->ID; r++; - pp->bandoliers[i].Items[si].Icon = atoi(row[r]); r++; // Must use db value in case an Ornamentation is assigned + pp->bandoliers[i].Items[si].Icon = Strings::ToInt(row[r]); r++; // Must use db value in case an Ornamentation is assigned strncpy(pp->bandoliers[i].Items[si].Name, item_data->Name, 64); } else { @@ -982,9 +982,9 @@ bool ZoneDatabase::LoadCharacterTribute(uint32 character_id, PlayerProfile_Struc } i = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - if(atoi(row[1]) != TRIBUTE_NONE){ - pp->tributes[i].tier = atoi(row[0]); - pp->tributes[i].tribute = atoi(row[1]); + if(Strings::ToInt(row[1]) != TRIBUTE_NONE){ + pp->tributes[i].tier = Strings::ToInt(row[0]); + pp->tributes[i].tribute = Strings::ToInt(row[1]); i++; } } @@ -1005,12 +1005,12 @@ bool ZoneDatabase::LoadCharacterPotions(uint32 character_id, PlayerProfile_Struc } for (auto& row = results.begin(); row != results.end(); ++row) { - i = atoi(row[0]); - const EQ::ItemData *item_data = database.GetItem(atoi(row[1])); + i = Strings::ToInt(row[0]); + const EQ::ItemData *item_data = database.GetItem(Strings::ToInt(row[1])); if (!item_data) continue; pp->potionbelt.Items[i].ID = item_data->ID; - pp->potionbelt.Items[i].Icon = atoi(row[2]); + pp->potionbelt.Items[i].Icon = Strings::ToInt(row[2]); strncpy(pp->potionbelt.Items[i].Name, item_data->Name, 64); } @@ -1028,7 +1028,7 @@ bool ZoneDatabase::LoadCharacterBindPoint(uint32 character_id, PlayerProfile_Str return true; for (auto& row = results.begin(); row != results.end(); ++row) { - int index = atoi(row[0]); + int index = Strings::ToInt(row[0]); if (index < 0 || index > 4) continue; @@ -1597,7 +1597,7 @@ bool ZoneDatabase::NoRentExpired(const char* name){ return false; auto& row = results.begin(); - uint32 seconds = atoi(row[0]); + uint32 seconds = Strings::ToInt(row[0]); return (seconds>1800); } @@ -1678,7 +1678,7 @@ int ZoneDatabase::CountCharacterInvSnapshots(uint32 character_id) { auto& row = results.begin(); - int64 count = atoll(row[0]); + int64 count = Strings::ToBigInt(row[0]); if (count > 2147483647) return -2; if (count < 0) @@ -1727,7 +1727,7 @@ void ZoneDatabase::ListCharacterInvSnapshots(uint32 character_id, std::list(atoul(row[0]), atoi(row[1]))); + is_list.push_back(std::pair(Strings::ToUnsignedInt(row[0]), Strings::ToInt(row[1]))); } bool ZoneDatabase::ValidateCharacterInvSnapshotTimestamp(uint32 character_id, uint32 timestamp) { @@ -1777,7 +1777,7 @@ void ZoneDatabase::ParseCharacterInvSnapshot(uint32 character_id, uint32 timesta return; for (auto row : results) - parse_list.push_back(std::pair(atoi(row[0]), atoul(row[1]))); + parse_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id, uint32 timestamp, std::list> &compare_list) { @@ -1821,7 +1821,7 @@ void ZoneDatabase::DivergeCharacterInvSnapshotFromInventory(uint32 character_id, return; for (auto row : results) - compare_list.push_back(std::pair(atoi(row[0]), atoul(row[1]))); + compare_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, uint32 timestamp, std::list> &compare_list) { @@ -1862,7 +1862,7 @@ void ZoneDatabase::DivergeCharacterInventoryFromInvSnapshot(uint32 character_id, return; for (auto row : results) - compare_list.push_back(std::pair(atoi(row[0]), atoul(row[1]))); + compare_list.push_back(std::pair(Strings::ToInt(row[0]), Strings::ToUnsignedInt(row[1]))); } bool ZoneDatabase::RestoreCharacterInvSnapshot(uint32 character_id, uint32 timestamp) { @@ -2096,9 +2096,9 @@ const NPCType *ZoneDatabase::LoadNPCTypesData(uint32 npc_type_id, bool bulk_load auto& armorTint_row = armortint_results.begin(); for (int index = EQ::textures::textureBegin; index <= EQ::textures::LastTexture; index++) { - t->armor_tint.Slot[index].Color = atoi(armorTint_row[index * 3]) << 16; - t->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 1]) << 8; - t->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 2]); + t->armor_tint.Slot[index].Color = Strings::ToInt(armorTint_row[index * 3]) << 16; + t->armor_tint.Slot[index].Color |= Strings::ToInt(armorTint_row[index * 3 + 1]) << 8; + t->armor_tint.Slot[index].Color |= Strings::ToInt(armorTint_row[index * 3 + 2]); t->armor_tint.Slot[index].Color |= (t->armor_tint.Slot[index].Color) ? (0xFF << 24) : 0; } @@ -2276,62 +2276,62 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client tmpNPCType = new NPCType; memset(tmpNPCType, 0, sizeof *tmpNPCType); - tmpNPCType->npc_id = atoi(row[0]); + tmpNPCType->npc_id = Strings::ToInt(row[0]); strn0cpy(tmpNPCType->name, row[1], 50); - tmpNPCType->level = atoi(row[2]); - tmpNPCType->race = atoi(row[3]); - tmpNPCType->class_ = atoi(row[4]); - tmpNPCType->max_hp = atoi(row[5]); + tmpNPCType->level = Strings::ToInt(row[2]); + tmpNPCType->race = Strings::ToInt(row[3]); + tmpNPCType->class_ = Strings::ToInt(row[4]); + tmpNPCType->max_hp = Strings::ToInt(row[5]); tmpNPCType->current_hp = tmpNPCType->max_hp; - tmpNPCType->Mana = atoi(row[6]); - tmpNPCType->gender = atoi(row[7]); - tmpNPCType->texture = atoi(row[8]); - tmpNPCType->helmtexture = atoi(row[9]); - tmpNPCType->attack_delay = atoi(row[10]) * 100; // TODO: fix DB - tmpNPCType->STR = atoi(row[11]); - tmpNPCType->STA = atoi(row[12]); - tmpNPCType->DEX = atoi(row[13]); - tmpNPCType->AGI = atoi(row[14]); - tmpNPCType->INT = atoi(row[15]); - tmpNPCType->WIS = atoi(row[16]); - tmpNPCType->CHA = atoi(row[17]); - tmpNPCType->MR = atoi(row[18]); - tmpNPCType->CR = atoi(row[19]); - tmpNPCType->DR = atoi(row[20]); - tmpNPCType->FR = atoi(row[21]); - tmpNPCType->PR = atoi(row[22]); - tmpNPCType->Corrup = atoi(row[23]); - tmpNPCType->min_dmg = atoi(row[24]); - tmpNPCType->max_dmg = atoi(row[25]); - tmpNPCType->attack_count = atoi(row[26]); + tmpNPCType->Mana = Strings::ToInt(row[6]); + tmpNPCType->gender = Strings::ToInt(row[7]); + tmpNPCType->texture = Strings::ToInt(row[8]); + tmpNPCType->helmtexture = Strings::ToInt(row[9]); + tmpNPCType->attack_delay = Strings::ToInt(row[10]) * 100; // TODO: fix DB + tmpNPCType->STR = Strings::ToInt(row[11]); + tmpNPCType->STA = Strings::ToInt(row[12]); + tmpNPCType->DEX = Strings::ToInt(row[13]); + tmpNPCType->AGI = Strings::ToInt(row[14]); + tmpNPCType->INT = Strings::ToInt(row[15]); + tmpNPCType->WIS = Strings::ToInt(row[16]); + tmpNPCType->CHA = Strings::ToInt(row[17]); + tmpNPCType->MR = Strings::ToInt(row[18]); + tmpNPCType->CR = Strings::ToInt(row[19]); + tmpNPCType->DR = Strings::ToInt(row[20]); + tmpNPCType->FR = Strings::ToInt(row[21]); + tmpNPCType->PR = Strings::ToInt(row[22]); + tmpNPCType->Corrup = Strings::ToInt(row[23]); + tmpNPCType->min_dmg = Strings::ToInt(row[24]); + tmpNPCType->max_dmg = Strings::ToInt(row[25]); + tmpNPCType->attack_count = Strings::ToInt(row[26]); if (row[27] != nullptr) strn0cpy(tmpNPCType->special_abilities, row[27], 512); else tmpNPCType->special_abilities[0] = '\0'; - tmpNPCType->d_melee_texture1 = atoi(row[28]); - tmpNPCType->d_melee_texture2 = atoi(row[29]); - tmpNPCType->prim_melee_type = atoi(row[30]); - tmpNPCType->sec_melee_type = atoi(row[31]); - tmpNPCType->runspeed = atof(row[32]); + tmpNPCType->d_melee_texture1 = Strings::ToInt(row[28]); + tmpNPCType->d_melee_texture2 = Strings::ToInt(row[29]); + tmpNPCType->prim_melee_type = Strings::ToInt(row[30]); + tmpNPCType->sec_melee_type = Strings::ToInt(row[31]); + tmpNPCType->runspeed = Strings::ToFloat(row[32]); - tmpNPCType->hp_regen = atoi(row[33]); - tmpNPCType->mana_regen = atoi(row[34]); + tmpNPCType->hp_regen = Strings::ToInt(row[33]); + tmpNPCType->mana_regen = Strings::ToInt(row[34]); tmpNPCType->aggroradius = RuleI(Mercs, AggroRadius); if (row[35] && strlen(row[35])) - tmpNPCType->bodytype = (uint8)atoi(row[35]); + tmpNPCType->bodytype = (uint8)Strings::ToInt(row[35]); else tmpNPCType->bodytype = 1; - uint32 armor_tint_id = atoi(row[36]); - tmpNPCType->armor_tint.Slot[0].Color = (atoi(row[37]) & 0xFF) << 16; - tmpNPCType->armor_tint.Slot[0].Color |= (atoi(row[38]) & 0xFF) << 8; - tmpNPCType->armor_tint.Slot[0].Color |= (atoi(row[39]) & 0xFF); + uint32 armor_tint_id = Strings::ToInt(row[36]); + tmpNPCType->armor_tint.Slot[0].Color = (Strings::ToInt(row[37]) & 0xFF) << 16; + tmpNPCType->armor_tint.Slot[0].Color |= (Strings::ToInt(row[38]) & 0xFF) << 8; + tmpNPCType->armor_tint.Slot[0].Color |= (Strings::ToInt(row[39]) & 0xFF); tmpNPCType->armor_tint.Slot[0].Color |= (tmpNPCType->armor_tint.Slot[0].Color) ? (0xFF << 24) : 0; if (armor_tint_id == 0) @@ -2356,21 +2356,21 @@ const NPCType* ZoneDatabase::GetMercType(uint32 id, uint16 raceid, uint32 client auto& armorTint_row = results.begin(); for (int index = EQ::textures::textureBegin; index <= EQ::textures::LastTexture; index++) { - tmpNPCType->armor_tint.Slot[index].Color = atoi(armorTint_row[index * 3]) << 16; - tmpNPCType->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 1]) << 8; - tmpNPCType->armor_tint.Slot[index].Color |= atoi(armorTint_row[index * 3 + 2]); + tmpNPCType->armor_tint.Slot[index].Color = Strings::ToInt(armorTint_row[index * 3]) << 16; + tmpNPCType->armor_tint.Slot[index].Color |= Strings::ToInt(armorTint_row[index * 3 + 1]) << 8; + tmpNPCType->armor_tint.Slot[index].Color |= Strings::ToInt(armorTint_row[index * 3 + 2]); tmpNPCType->armor_tint.Slot[index].Color |= (tmpNPCType->armor_tint.Slot[index].Color) ? (0xFF << 24) : 0; } } } else armor_tint_id = 0; - tmpNPCType->AC = atoi(row[40]); - tmpNPCType->ATK = atoi(row[41]); - tmpNPCType->accuracy_rating = atoi(row[42]); - tmpNPCType->scalerate = atoi(row[43]); - tmpNPCType->spellscale = atoi(row[44]); - tmpNPCType->healscale = atoi(row[45]); + tmpNPCType->AC = Strings::ToInt(row[40]); + tmpNPCType->ATK = Strings::ToInt(row[41]); + tmpNPCType->accuracy_rating = Strings::ToInt(row[42]); + tmpNPCType->scalerate = Strings::ToInt(row[43]); + tmpNPCType->spellscale = Strings::ToInt(row[44]); + tmpNPCType->healscale = Strings::ToInt(row[45]); tmpNPCType->skip_global_loot = true; tmpNPCType->skip_auto_scale = true; @@ -2404,35 +2404,35 @@ bool ZoneDatabase::LoadMercInfo(Client *client) { return false; for (auto& row = results.begin(); row != results.end(); ++row) { - uint8 slot = atoi(row[1]); + uint8 slot = Strings::ToInt(row[1]); if(slot >= MAXMERCS) continue; - client->GetMercInfo(slot).mercid = atoi(row[0]); + client->GetMercInfo(slot).mercid = Strings::ToInt(row[0]); client->GetMercInfo(slot).slot = slot; snprintf(client->GetMercInfo(slot).merc_name, 64, "%s", row[2]); - client->GetMercInfo(slot).MercTemplateID = atoi(row[3]); - client->GetMercInfo(slot).SuspendedTime = atoi(row[4]); - client->GetMercInfo(slot).IsSuspended = atoi(row[5]) == 1 ? true : false; - client->GetMercInfo(slot).MercTimerRemaining = atoi(row[6]); - client->GetMercInfo(slot).Gender = atoi(row[7]); - client->GetMercInfo(slot).MercSize = atof(row[8]); + client->GetMercInfo(slot).MercTemplateID = Strings::ToInt(row[3]); + client->GetMercInfo(slot).SuspendedTime = Strings::ToInt(row[4]); + client->GetMercInfo(slot).IsSuspended = Strings::ToInt(row[5]) == 1 ? true : false; + client->GetMercInfo(slot).MercTimerRemaining = Strings::ToInt(row[6]); + client->GetMercInfo(slot).Gender = Strings::ToInt(row[7]); + client->GetMercInfo(slot).MercSize = Strings::ToFloat(row[8]); client->GetMercInfo(slot).State = 5; - client->GetMercInfo(slot).Stance = atoi(row[9]); - client->GetMercInfo(slot).hp = atoi(row[10]); - client->GetMercInfo(slot).mana = atoi(row[11]); - client->GetMercInfo(slot).endurance = atoi(row[12]); - client->GetMercInfo(slot).face = atoi(row[13]); - client->GetMercInfo(slot).luclinHairStyle = atoi(row[14]); - client->GetMercInfo(slot).luclinHairColor = atoi(row[15]); - client->GetMercInfo(slot).luclinEyeColor = atoi(row[16]); - client->GetMercInfo(slot).luclinEyeColor2 = atoi(row[17]); - client->GetMercInfo(slot).luclinBeardColor = atoi(row[18]); - client->GetMercInfo(slot).luclinBeard = atoi(row[19]); - client->GetMercInfo(slot).drakkinHeritage = atoi(row[20]); - client->GetMercInfo(slot).drakkinTattoo = atoi(row[21]); - client->GetMercInfo(slot).drakkinDetails = atoi(row[22]); + client->GetMercInfo(slot).Stance = Strings::ToInt(row[9]); + client->GetMercInfo(slot).hp = Strings::ToInt(row[10]); + client->GetMercInfo(slot).mana = Strings::ToInt(row[11]); + client->GetMercInfo(slot).endurance = Strings::ToInt(row[12]); + client->GetMercInfo(slot).face = Strings::ToInt(row[13]); + client->GetMercInfo(slot).luclinHairStyle = Strings::ToInt(row[14]); + client->GetMercInfo(slot).luclinHairColor = Strings::ToInt(row[15]); + client->GetMercInfo(slot).luclinEyeColor = Strings::ToInt(row[16]); + client->GetMercInfo(slot).luclinEyeColor2 = Strings::ToInt(row[17]); + client->GetMercInfo(slot).luclinBeardColor = Strings::ToInt(row[18]); + client->GetMercInfo(slot).luclinBeard = Strings::ToInt(row[19]); + client->GetMercInfo(slot).drakkinHeritage = Strings::ToInt(row[20]); + client->GetMercInfo(slot).drakkinTattoo = Strings::ToInt(row[21]); + client->GetMercInfo(slot).drakkinDetails = Strings::ToInt(row[22]); } return true; @@ -2462,29 +2462,29 @@ bool ZoneDatabase::LoadCurrentMerc(Client *client) { for (auto& row = results.begin(); row != results.end(); ++row) { - client->GetMercInfo(slot).mercid = atoi(row[0]); + client->GetMercInfo(slot).mercid = Strings::ToInt(row[0]); client->GetMercInfo(slot).slot = slot; snprintf(client->GetMercInfo(slot).merc_name, 64, "%s", row[1]); - client->GetMercInfo(slot).MercTemplateID = atoi(row[2]); - client->GetMercInfo(slot).SuspendedTime = atoi(row[3]); - client->GetMercInfo(slot).IsSuspended = atoi(row[4]) == 1? true: false; - client->GetMercInfo(slot).MercTimerRemaining = atoi(row[5]); - client->GetMercInfo(slot).Gender = atoi(row[6]); - client->GetMercInfo(slot).MercSize = atof(row[7]); - client->GetMercInfo(slot).State = atoi(row[8]); - client->GetMercInfo(slot).hp = atoi(row[9]); - client->GetMercInfo(slot).mana = atoi(row[10]); - client->GetMercInfo(slot).endurance = atoi(row[11]); - client->GetMercInfo(slot).face = atoi(row[12]); - client->GetMercInfo(slot).luclinHairStyle = atoi(row[13]); - client->GetMercInfo(slot).luclinHairColor = atoi(row[14]); - client->GetMercInfo(slot).luclinEyeColor = atoi(row[15]); - client->GetMercInfo(slot).luclinEyeColor2 = atoi(row[16]); - client->GetMercInfo(slot).luclinBeardColor = atoi(row[17]); - client->GetMercInfo(slot).luclinBeard = atoi(row[18]); - client->GetMercInfo(slot).drakkinHeritage = atoi(row[19]); - client->GetMercInfo(slot).drakkinTattoo = atoi(row[20]); - client->GetMercInfo(slot).drakkinDetails = atoi(row[21]); + client->GetMercInfo(slot).MercTemplateID = Strings::ToInt(row[2]); + client->GetMercInfo(slot).SuspendedTime = Strings::ToInt(row[3]); + client->GetMercInfo(slot).IsSuspended = Strings::ToInt(row[4]) == 1? true: false; + client->GetMercInfo(slot).MercTimerRemaining = Strings::ToInt(row[5]); + client->GetMercInfo(slot).Gender = Strings::ToInt(row[6]); + client->GetMercInfo(slot).MercSize = Strings::ToFloat(row[7]); + client->GetMercInfo(slot).State = Strings::ToInt(row[8]); + client->GetMercInfo(slot).hp = Strings::ToInt(row[9]); + client->GetMercInfo(slot).mana = Strings::ToInt(row[10]); + client->GetMercInfo(slot).endurance = Strings::ToInt(row[11]); + client->GetMercInfo(slot).face = Strings::ToInt(row[12]); + client->GetMercInfo(slot).luclinHairStyle = Strings::ToInt(row[13]); + client->GetMercInfo(slot).luclinHairColor = Strings::ToInt(row[14]); + client->GetMercInfo(slot).luclinEyeColor = Strings::ToInt(row[15]); + client->GetMercInfo(slot).luclinEyeColor2 = Strings::ToInt(row[16]); + client->GetMercInfo(slot).luclinBeardColor = Strings::ToInt(row[17]); + client->GetMercInfo(slot).luclinBeard = Strings::ToInt(row[18]); + client->GetMercInfo(slot).drakkinHeritage = Strings::ToInt(row[19]); + client->GetMercInfo(slot).drakkinTattoo = Strings::ToInt(row[20]); + client->GetMercInfo(slot).drakkinDetails = Strings::ToInt(row[21]); } return true; @@ -2632,34 +2632,34 @@ void ZoneDatabase::LoadMercBuffs(Merc *merc) { if(buffCount == BUFF_COUNT) break; - buffs[buffCount].spellid = atoi(row[0]); - buffs[buffCount].casterlevel = atoi(row[1]); - buffs[buffCount].ticsremaining = atoi(row[3]); + buffs[buffCount].spellid = Strings::ToInt(row[0]); + buffs[buffCount].casterlevel = Strings::ToInt(row[1]); + buffs[buffCount].ticsremaining = Strings::ToInt(row[3]); if(CalculatePoisonCounters(buffs[buffCount].spellid) > 0) - buffs[buffCount].counters = atoi(row[4]); + buffs[buffCount].counters = Strings::ToInt(row[4]); if(CalculateDiseaseCounters(buffs[buffCount].spellid) > 0) - buffs[buffCount].counters = atoi(row[5]); + buffs[buffCount].counters = Strings::ToInt(row[5]); if(CalculateCurseCounters(buffs[buffCount].spellid) > 0) - buffs[buffCount].counters = atoi(row[6]); + buffs[buffCount].counters = Strings::ToInt(row[6]); if(CalculateCorruptionCounters(buffs[buffCount].spellid) > 0) - buffs[buffCount].counters = atoi(row[7]); + buffs[buffCount].counters = Strings::ToInt(row[7]); - buffs[buffCount].hit_number = atoi(row[8]); - buffs[buffCount].melee_rune = atoi(row[9]); - buffs[buffCount].magic_rune = atoi(row[10]); - buffs[buffCount].dot_rune = atoi(row[11]); - buffs[buffCount].caston_x = atoi(row[12]); + buffs[buffCount].hit_number = Strings::ToInt(row[8]); + buffs[buffCount].melee_rune = Strings::ToInt(row[9]); + buffs[buffCount].magic_rune = Strings::ToInt(row[10]); + buffs[buffCount].dot_rune = Strings::ToInt(row[11]); + buffs[buffCount].caston_x = Strings::ToInt(row[12]); buffs[buffCount].casterid = 0; - bool IsPersistent = atoi(row[13])? true: false; + bool IsPersistent = Strings::ToInt(row[13])? true: false; - buffs[buffCount].caston_y = atoi(row[13]); - buffs[buffCount].caston_z = atoi(row[14]); - buffs[buffCount].ExtraDIChance = atoi(row[15]); + buffs[buffCount].caston_y = Strings::ToInt(row[13]); + buffs[buffCount].caston_z = Strings::ToInt(row[14]); + buffs[buffCount].ExtraDIChance = Strings::ToInt(row[15]); buffs[buffCount].persistant_buff = IsPersistent; @@ -2718,10 +2718,10 @@ void ZoneDatabase::LoadMercEquipment(Merc *merc) { if (itemCount == EQ::invslot::EQUIPMENT_COUNT) break; - if(atoi(row[0]) == 0) + if(Strings::ToInt(row[0]) == 0) continue; - merc->AddItem(itemCount, atoi(row[0])); + merc->AddItem(itemCount, Strings::ToInt(row[0])); itemCount++; } } @@ -2739,7 +2739,7 @@ uint8 ZoneDatabase::GetGridType(uint32 grid, uint32 zoneid ) { auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } void ZoneDatabase::SaveMerchantTemp(uint32 npcid, uint32 slot, uint32 zone_id, uint32 instance_id, uint32 item, uint32 charges){ @@ -2770,7 +2770,7 @@ uint32 ZoneDatabase::GetZoneTZ(uint32 zoneid, uint32 version) { return 0; auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool ZoneDatabase::SetZoneTZ(uint32 zoneid, uint32 version, uint32 tz) { @@ -2857,7 +2857,7 @@ uint8 ZoneDatabase::GroupCount(uint32 groupid) { auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint8 ZoneDatabase::RaidGroupCount(uint32 raidid, uint32 groupid) { @@ -2875,7 +2875,7 @@ uint8 ZoneDatabase::RaidGroupCount(uint32 raidid, uint32 groupid) { auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } int32 ZoneDatabase::GetBlockedSpellsCount(uint32 zoneid) @@ -2891,7 +2891,7 @@ int32 ZoneDatabase::GetBlockedSpellsCount(uint32 zoneid) auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked* into, uint32 zoneid) @@ -2916,10 +2916,10 @@ bool ZoneDatabase::LoadBlockedSpells(int32 blockedSpellsCount, ZoneSpellsBlocked } memset(&into[index], 0, sizeof(ZoneSpellsBlocked)); - into[index].spellid = atoi(row[1]); - into[index].type = atoi(row[2]); - into[index].m_Location = glm::vec3(atof(row[3]), atof(row[4]), atof(row[5])); - into[index].m_Difference = glm::vec3(atof(row[6]), atof(row[7]), atof(row[8])); + into[index].spellid = Strings::ToInt(row[1]); + into[index].type = Strings::ToInt(row[2]); + into[index].m_Location = glm::vec3(Strings::ToFloat(row[3]), Strings::ToFloat(row[4]), Strings::ToFloat(row[5])); + into[index].m_Difference = glm::vec3(Strings::ToFloat(row[6]), Strings::ToFloat(row[7]), Strings::ToFloat(row[8])); strn0cpy(into[index].message, row[9], 255); } @@ -2941,7 +2941,7 @@ uint32 ZoneDatabase::GetKarma(uint32 acct_id) return 0; for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; @@ -3021,12 +3021,12 @@ void ZoneDatabase::ListAllInstances(Client* client, uint32 character_id) uint32 instance_count = 0; for (auto row : results) { - auto instance_id = std::stoul(row[0]); - auto zone_id = std::stoul(row[1]); - auto version = std::stoul(row[2]); - auto start_time = std::stoul(row[3]); - auto duration = std::stoul(row[4]); - auto never_expires = std::stoi(row[5]) ? true : false; + auto instance_id = Strings::ToUnsignedInt(row[0]); + auto zone_id = Strings::ToUnsignedInt(row[1]); + auto version = Strings::ToUnsignedInt(row[2]); + auto start_time = Strings::ToUnsignedInt(row[3]); + auto duration = Strings::ToUnsignedInt(row[4]); + auto never_expires = Strings::ToInt(row[5]) ? true : false; std::string remaining_time_string = "Never"; timeval time_value; gettimeofday(&time_value, nullptr); @@ -3106,7 +3106,7 @@ void ZoneDatabase::LoadAltCurrencyValues(uint32 char_id, std::map= client->GetMaxBuffSlots()) continue; - uint32 spell_id = atoul(row[0]); + uint32 spell_id = Strings::ToUnsignedInt(row[0]); if (!IsValidSpell(spell_id)) continue; Client *caster = entity_list.GetClientByName(row[3]); - uint32 caster_level = atoi(row[2]); - int32 ticsremaining = atoi(row[4]); - uint32 counters = atoul(row[5]); - uint32 hit_number = atoul(row[6]); - uint32 melee_rune = atoul(row[7]); - uint32 magic_rune = atoul(row[8]); - uint8 persistent = atoul(row[9]); - uint32 dot_rune = atoul(row[10]); - int32 caston_x = atoul(row[11]); - int32 caston_y = atoul(row[12]); - int32 caston_z = atoul(row[13]); - int32 ExtraDIChance = atoul(row[14]); - uint32 instrument_mod = atoul(row[15]); + uint32 caster_level = Strings::ToInt(row[2]); + int32 ticsremaining = Strings::ToInt(row[4]); + uint32 counters = Strings::ToUnsignedInt(row[5]); + uint32 hit_number = Strings::ToUnsignedInt(row[6]); + uint32 melee_rune = Strings::ToUnsignedInt(row[7]); + uint32 magic_rune = Strings::ToUnsignedInt(row[8]); + uint8 persistent = Strings::ToUnsignedInt(row[9]); + uint32 dot_rune = Strings::ToUnsignedInt(row[10]); + int32 caston_x = Strings::ToUnsignedInt(row[11]); + int32 caston_y = Strings::ToUnsignedInt(row[12]); + int32 caston_z = Strings::ToUnsignedInt(row[13]); + int32 ExtraDIChance = Strings::ToUnsignedInt(row[14]); + uint32 instrument_mod = Strings::ToUnsignedInt(row[15]); buffs[slot_id].spellid = spell_id; buffs[slot_id].casterlevel = caster_level; @@ -3271,7 +3271,7 @@ void ZoneDatabase::LoadAuras(Client *c) return; for (auto& row = results.begin(); row != results.end(); ++row) - c->MakeAura(atoi(row[0])); + c->MakeAura(Strings::ToInt(row[0])); } void ZoneDatabase::SavePetInfo(Client *client) @@ -3397,7 +3397,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) PetInfo *pi; for (auto& row = results.begin(); row != results.end(); ++row) { - uint16 pet = atoi(row[0]); + uint16 pet = Strings::ToInt(row[0]); if (pet == 0) pi = petinfo; @@ -3407,12 +3407,12 @@ void ZoneDatabase::LoadPetInfo(Client *client) continue; strncpy(pi->Name, row[1], 64); - pi->petpower = atoi(row[2]); - pi->SpellID = atoi(row[3]); - pi->HP = atoul(row[4]); - pi->Mana = atoul(row[5]); - pi->size = atof(row[6]); - pi->taunting = (bool) atoi(row[7]); + pi->petpower = Strings::ToInt(row[2]); + pi->SpellID = Strings::ToInt(row[3]); + pi->HP = Strings::ToUnsignedInt(row[4]); + pi->Mana = Strings::ToUnsignedInt(row[5]); + pi->size = Strings::ToFloat(row[6]); + pi->taunting = (bool) Strings::ToInt(row[7]); } query = StringFormat("SELECT `pet`, `slot`, `spell_id`, `caster_level`, `castername`, " @@ -3425,7 +3425,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) } for (auto& row = results.begin(); row != results.end(); ++row) { - uint16 pet = atoi(row[0]); + uint16 pet = Strings::ToInt(row[0]); if (pet == 0) pi = petinfo; else if (pet == 1) @@ -3433,20 +3433,20 @@ void ZoneDatabase::LoadPetInfo(Client *client) else continue; - uint32 slot_id = atoul(row[1]); + uint32 slot_id = Strings::ToUnsignedInt(row[1]); if (slot_id >= RuleI(Spells, MaxTotalSlotsPET)) continue; - uint32 spell_id = atoul(row[2]); + uint32 spell_id = Strings::ToUnsignedInt(row[2]); if (!IsValidSpell(spell_id)) continue; - uint32 caster_level = atoi(row[3]); + uint32 caster_level = Strings::ToInt(row[3]); int caster_id = 0; // The castername field is currently unused - int32 ticsremaining = atoi(row[5]); - uint32 counters = atoul(row[6]); - uint8 bard_mod = atoul(row[7]); + int32 ticsremaining = Strings::ToInt(row[5]); + uint32 counters = Strings::ToUnsignedInt(row[6]); + uint8 bard_mod = Strings::ToUnsignedInt(row[7]); pi->Buffs[slot_id].spellid = spell_id; pi->Buffs[slot_id].level = caster_level; @@ -3468,7 +3468,7 @@ void ZoneDatabase::LoadPetInfo(Client *client) } for (auto& row = results.begin(); row != results.end(); ++row) { - uint16 pet = atoi(row[0]); + uint16 pet = Strings::ToInt(row[0]); if (pet == 0) pi = petinfo; else if (pet == 1) @@ -3476,11 +3476,11 @@ void ZoneDatabase::LoadPetInfo(Client *client) else continue; - int slot = atoi(row[1]); + int slot = Strings::ToInt(row[1]); if (slot < EQ::invslot::EQUIPMENT_BEGIN || slot > EQ::invslot::EQUIPMENT_END) continue; - pi->Items[slot] = atoul(row[2]); + pi->Items[slot] = Strings::ToUnsignedInt(row[2]); } } @@ -3639,7 +3639,7 @@ bool ZoneDatabase::LoadFactionData() auto& fmr_row = faction_max_results.begin(); - max_faction = atoul(fmr_row[0]); + max_faction = Strings::ToUnsignedInt(fmr_row[0]); faction_array = new Faction *[max_faction + 1]; memset(faction_array, 0, (sizeof(Faction*) * (max_faction + 1))); @@ -3656,7 +3656,7 @@ bool ZoneDatabase::LoadFactionData() for (auto fr_row : faction_results) { - uint32 index = atoul(fr_row[0]); + uint32 index = Strings::ToUnsignedInt(fr_row[0]); if (index > max_faction) { Log(Logs::General, Logs::Error, "Faction '%u' is out-of-bounds for faction array size!", index); continue; @@ -3670,7 +3670,7 @@ bool ZoneDatabase::LoadFactionData() faction_array[index] = new Faction; strn0cpy(faction_array[index]->name, fr_row[1], 50); - faction_array[index]->base = atoi(fr_row[2]); + faction_array[index]->base = Strings::ToInt(fr_row[2]); faction_array[index]->min = MIN_PERSONAL_FACTION; faction_array[index]->max = MAX_PERSONAL_FACTION; @@ -3689,7 +3689,7 @@ bool ZoneDatabase::LoadFactionData() for (auto br_row : base_results) { - uint32 index = atoul(br_row[0]); + uint32 index = Strings::ToUnsignedInt(br_row[0]); if (index > max_faction) { LogError("Faction [{}] is out-of-bounds for faction array size in Base adjustment!", index); continue; @@ -3700,8 +3700,8 @@ bool ZoneDatabase::LoadFactionData() continue; } - faction_array[index]->min = atoi(br_row[1]); - faction_array[index]->max = atoi(br_row[2]); + faction_array[index]->min = Strings::ToInt(br_row[1]); + faction_array[index]->max = Strings::ToInt(br_row[2]); } LogInfo("Loaded [{}] faction base(s)", Strings::Commify(std::to_string(base_results.RowCount()))); @@ -3718,7 +3718,7 @@ bool ZoneDatabase::LoadFactionData() for (auto mr_row : modifier_results) { - uint32 index = atoul(mr_row[0]); + uint32 index = Strings::ToUnsignedInt(mr_row[0]); if (index > max_faction) { Log(Logs::General, Logs::Error, "Faction '%u' is out-of-bounds for faction array size in Modifier adjustment!", index); continue; @@ -3729,7 +3729,7 @@ bool ZoneDatabase::LoadFactionData() continue; } - faction_array[index]->mods[mr_row[2]] = atoi(mr_row[1]); + faction_array[index]->mods[mr_row[2]] = Strings::ToInt(mr_row[1]); } LogInfo("Loaded [{}] faction modifier(s)", Strings::Commify(std::to_string(modifier_results.RowCount()))); @@ -3818,7 +3818,7 @@ uint32 ZoneDatabase::GetCharacterCorpseDecayTimer(uint32 corpse_db_id){ auto results = QueryDatabase(query); auto& row = results.begin(); if (results.Success() && results.RowsAffected() != 0) - return atoul(row[0]); + return Strings::ToUnsignedInt(row[0]); return 0; } @@ -4009,7 +4009,7 @@ uint32 ZoneDatabase::GetCharacterBuriedCorpseCount(uint32 char_id) { auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4019,7 +4019,7 @@ uint32 ZoneDatabase::GetCharacterCorpseCount(uint32 char_id) { auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4031,7 +4031,7 @@ uint32 ZoneDatabase::GetCharacterCorpseID(uint32 char_id, uint8 corpse) { auto& row = results.begin(); if (row != results.end()) - return atoul(row[0]); + return Strings::ToUnsignedInt(row[0]); else return 0; } @@ -4043,7 +4043,7 @@ uint32 ZoneDatabase::GetCharacterCorpseItemCount(uint32 corpse_id){ auto results = QueryDatabase(query); auto& row = results.begin(); if (results.Success() && results.RowsAffected() != 0){ - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4103,39 +4103,39 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct auto results = QueryDatabase(query); uint16 i = 0; for (auto& row = results.begin(); row != results.end(); ++row) { - pcs->locked = atoi(row[i++]); // is_locked, - pcs->exp = atoul(row[i++]); // exp, - pcs->size = atoi(row[i++]); // size, - pcs->level = atoi(row[i++]); // `level`, - pcs->race = atoi(row[i++]); // race, - pcs->gender = atoi(row[i++]); // gender, - pcs->class_ = atoi(row[i++]); // class, - pcs->deity = atoi(row[i++]); // deity, - pcs->texture = atoi(row[i++]); // texture, - pcs->helmtexture = atoi(row[i++]); // helm_texture, - pcs->copper = atoul(row[i++]); // copper, - pcs->silver = atoul(row[i++]); // silver, - pcs->gold = atoul(row[i++]); // gold, - pcs->plat = atoul(row[i++]); // platinum, - pcs->haircolor = atoi(row[i++]); // hair_color, - pcs->beardcolor = atoi(row[i++]); // beard_color, - pcs->eyecolor1 = atoi(row[i++]); // eye_color_1, - pcs->eyecolor2 = atoi(row[i++]); // eye_color_2, - pcs->hairstyle = atoi(row[i++]); // hair_style, - pcs->face = atoi(row[i++]); // face, - pcs->beard = atoi(row[i++]); // beard, - pcs->drakkin_heritage = atoul(row[i++]); // drakkin_heritage, - pcs->drakkin_tattoo = atoul(row[i++]); // drakkin_tattoo, - pcs->drakkin_details = atoul(row[i++]); // drakkin_details, - pcs->item_tint.Head.Color = atoul(row[i++]); // wc_1, - pcs->item_tint.Chest.Color = atoul(row[i++]); // wc_2, - pcs->item_tint.Arms.Color = atoul(row[i++]); // wc_3, - pcs->item_tint.Wrist.Color = atoul(row[i++]); // wc_4, - pcs->item_tint.Hands.Color = atoul(row[i++]); // wc_5, - pcs->item_tint.Legs.Color = atoul(row[i++]); // wc_6, - pcs->item_tint.Feet.Color = atoul(row[i++]); // wc_7, - pcs->item_tint.Primary.Color = atoul(row[i++]); // wc_8, - pcs->item_tint.Secondary.Color = atoul(row[i++]); // wc_9 + pcs->locked = Strings::ToInt(row[i++]); // is_locked, + pcs->exp = Strings::ToUnsignedInt(row[i++]); // exp, + pcs->size = Strings::ToInt(row[i++]); // size, + pcs->level = Strings::ToInt(row[i++]); // `level`, + pcs->race = Strings::ToInt(row[i++]); // race, + pcs->gender = Strings::ToInt(row[i++]); // gender, + pcs->class_ = Strings::ToInt(row[i++]); // class, + pcs->deity = Strings::ToInt(row[i++]); // deity, + pcs->texture = Strings::ToInt(row[i++]); // texture, + pcs->helmtexture = Strings::ToInt(row[i++]); // helm_texture, + pcs->copper = Strings::ToUnsignedInt(row[i++]); // copper, + pcs->silver = Strings::ToUnsignedInt(row[i++]); // silver, + pcs->gold = Strings::ToUnsignedInt(row[i++]); // gold, + pcs->plat = Strings::ToUnsignedInt(row[i++]); // platinum, + pcs->haircolor = Strings::ToInt(row[i++]); // hair_color, + pcs->beardcolor = Strings::ToInt(row[i++]); // beard_color, + pcs->eyecolor1 = Strings::ToInt(row[i++]); // eye_color_1, + pcs->eyecolor2 = Strings::ToInt(row[i++]); // eye_color_2, + pcs->hairstyle = Strings::ToInt(row[i++]); // hair_style, + pcs->face = Strings::ToInt(row[i++]); // face, + pcs->beard = Strings::ToInt(row[i++]); // beard, + pcs->drakkin_heritage = Strings::ToUnsignedInt(row[i++]); // drakkin_heritage, + pcs->drakkin_tattoo = Strings::ToUnsignedInt(row[i++]); // drakkin_tattoo, + pcs->drakkin_details = Strings::ToUnsignedInt(row[i++]); // drakkin_details, + pcs->item_tint.Head.Color = Strings::ToUnsignedInt(row[i++]); // wc_1, + pcs->item_tint.Chest.Color = Strings::ToUnsignedInt(row[i++]); // wc_2, + pcs->item_tint.Arms.Color = Strings::ToUnsignedInt(row[i++]); // wc_3, + pcs->item_tint.Wrist.Color = Strings::ToUnsignedInt(row[i++]); // wc_4, + pcs->item_tint.Hands.Color = Strings::ToUnsignedInt(row[i++]); // wc_5, + pcs->item_tint.Legs.Color = Strings::ToUnsignedInt(row[i++]); // wc_6, + pcs->item_tint.Feet.Color = Strings::ToUnsignedInt(row[i++]); // wc_7, + pcs->item_tint.Primary.Color = Strings::ToUnsignedInt(row[i++]); // wc_8, + pcs->item_tint.Secondary.Color = Strings::ToUnsignedInt(row[i++]); // wc_9 } query = StringFormat( "SELECT \n" @@ -4162,16 +4162,16 @@ bool ZoneDatabase::LoadCharacterCorpseData(uint32 corpse_id, PlayerCorpse_Struct uint16 r = 0; for (auto& row = results.begin(); row != results.end(); ++row) { memset(&pcs->items[i], 0, sizeof (player_lootitem::ServerLootItem_Struct)); - pcs->items[i].equip_slot = atoi(row[r++]); // equip_slot, - pcs->items[i].item_id = atoul(row[r++]); // item_id, - pcs->items[i].charges = atoi(row[r++]); // charges, - pcs->items[i].aug_1 = atoi(row[r++]); // aug_1, - pcs->items[i].aug_2 = atoi(row[r++]); // aug_2, - pcs->items[i].aug_3 = atoi(row[r++]); // aug_3, - pcs->items[i].aug_4 = atoi(row[r++]); // aug_4, - pcs->items[i].aug_5 = atoi(row[r++]); // aug_5, - pcs->items[i].aug_6 = atoi(row[r++]); // aug_6, - pcs->items[i].attuned = atoi(row[r++]); // attuned, + pcs->items[i].equip_slot = Strings::ToInt(row[r++]); // equip_slot, + pcs->items[i].item_id = Strings::ToUnsignedInt(row[r++]); // item_id, + pcs->items[i].charges = Strings::ToInt(row[r++]); // charges, + pcs->items[i].aug_1 = Strings::ToInt(row[r++]); // aug_1, + pcs->items[i].aug_2 = Strings::ToInt(row[r++]); // aug_2, + pcs->items[i].aug_3 = Strings::ToInt(row[r++]); // aug_3, + pcs->items[i].aug_4 = Strings::ToInt(row[r++]); // aug_4, + pcs->items[i].aug_5 = Strings::ToInt(row[r++]); // aug_5, + pcs->items[i].aug_6 = Strings::ToInt(row[r++]); // aug_6, + pcs->items[i].attuned = Strings::ToInt(row[r++]); // attuned, r = 0; i++; } @@ -4190,14 +4190,14 @@ Corpse* ZoneDatabase::SummonBuriedCharacterCorpses(uint32 char_id, uint32 dest_z for (auto& row = results.begin(); row != results.end(); ++row) { corpse = Corpse::LoadCharacterCorpseEntity( - atoul(row[0]), // uint32 in_dbid + Strings::ToUnsignedInt(row[0]), // uint32 in_dbid char_id, // uint32 in_charid row[1], // char* in_charname position, row[2], // char* time_of_death - atoi(row[3]) == 1, // bool rezzed + Strings::ToInt(row[3]) == 1, // bool rezzed false, // bool was_at_graveyard - atoul(row[4]) // uint32 guild_consent_id + Strings::ToUnsignedInt(row[4]) // uint32 guild_consent_id ); if (!corpse) continue; @@ -4230,14 +4230,14 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id for (auto& row = results.begin(); row != results.end(); ++row) { corpse = Corpse::LoadCharacterCorpseEntity( - atoul(row[0]), + Strings::ToUnsignedInt(row[0]), char_id, row[1], position, row[2], - atoi(row[3]) == 1, + Strings::ToInt(row[3]) == 1, false, - atoul(row[4])); + Strings::ToUnsignedInt(row[4])); if (corpse) { entity_list.AddCorpse(corpse); @@ -4267,7 +4267,7 @@ int ZoneDatabase::CountCharacterCorpses(uint32 char_id) { ); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4289,7 +4289,7 @@ int ZoneDatabase::CountCharacterCorpsesByZoneID(uint32 char_id, uint32 zone_id) ); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4317,16 +4317,16 @@ Corpse* ZoneDatabase::LoadCharacterCorpse(uint32 player_corpse_id) { ); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - auto position = glm::vec4(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6])); + auto position = glm::vec4(Strings::ToFloat(row[3]), Strings::ToFloat(row[4]), Strings::ToFloat(row[5]), Strings::ToFloat(row[6])); NewCorpse = Corpse::LoadCharacterCorpseEntity( - atoul(row[0]), // id uint32 in_dbid - atoul(row[1]), // charid uint32 in_charid + Strings::ToUnsignedInt(row[0]), // id uint32 in_dbid + Strings::ToUnsignedInt(row[1]), // charid uint32 in_charid row[2], // char_name position, row[7], // time_of_death char* time_of_death - atoi(row[8]) == 1, // is_rezzed bool rezzed - atoi(row[9]), // was_at_graveyard bool was_at_graveyard - atoul(row[10]) // guild_consent_id uint32 guild_consent_id + Strings::ToInt(row[8]) == 1, // is_rezzed bool rezzed + Strings::ToInt(row[9]), // was_at_graveyard bool was_at_graveyard + Strings::ToUnsignedInt(row[10]) // guild_consent_id uint32 guild_consent_id ); entity_list.AddCorpse(NewCorpse); } @@ -4344,17 +4344,17 @@ bool ZoneDatabase::LoadCharacterCorpses(uint32 zone_id, uint16 instance_id) { auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - auto position = glm::vec4(atof(row[3]), atof(row[4]), atof(row[5]), atof(row[6])); + auto position = glm::vec4(Strings::ToFloat(row[3]), Strings::ToFloat(row[4]), Strings::ToFloat(row[5]), Strings::ToFloat(row[6])); entity_list.AddCorpse( Corpse::LoadCharacterCorpseEntity( - atoul(row[0]), // id uint32 in_dbid - atoul(row[1]), // charid uint32 in_charid + Strings::ToUnsignedInt(row[0]), // id uint32 in_dbid + Strings::ToUnsignedInt(row[1]), // charid uint32 in_charid row[2], // char_name position, row[7], // time_of_death char* time_of_death - atoi(row[8]) == 1, // is_rezzed bool rezzed - atoi(row[9]), - atoul(row[10])) // guild_consent_id uint32 guild_consent_id + Strings::ToInt(row[8]) == 1, // is_rezzed bool rezzed + Strings::ToInt(row[9]), + Strings::ToUnsignedInt(row[10])) // guild_consent_id uint32 guild_consent_id ); } @@ -4367,7 +4367,7 @@ uint32 ZoneDatabase::GetFirstCorpseID(uint32 char_id) { std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = '%u' AND `is_buried` = 0 ORDER BY `time_of_death` LIMIT 1", char_id); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atoi(row[0]); + return Strings::ToInt(row[0]); } return 0; } @@ -4394,7 +4394,7 @@ bool ZoneDatabase::BuryAllCharacterCorpses(uint32 char_id) { std::string query = StringFormat("SELECT `id` FROM `character_corpses` WHERE `charid` = %u", char_id); auto results = QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - BuryCharacterCorpse(atoi(row[0])); + BuryCharacterCorpse(Strings::ToInt(row[0])); return true; } return false; @@ -4426,7 +4426,7 @@ uint32 ZoneDatabase::LoadSaylinkID(const char* saylink_text, bool auto_insert) } auto& row = results.begin(); - return atoi(row[0]); + return Strings::ToInt(row[0]); } uint32 ZoneDatabase::SaveSaylinkID(const char* saylink_text) @@ -4464,7 +4464,7 @@ double ZoneDatabase::GetAAEXPModifier(uint32 character_id, uint32 zone_id, int16 auto results = database.QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atof(row[0]); + return Strings::ToFloat(row[0]); } return 1.0f; @@ -4492,7 +4492,7 @@ double ZoneDatabase::GetEXPModifier(uint32 character_id, uint32 zone_id, int16 i auto results = database.QueryDatabase(query); for (auto& row = results.begin(); row != results.end(); ++row) { - return atof(row[0]); + return Strings::ToFloat(row[0]); } return 1.0f; diff --git a/zone/zoning.cpp b/zone/zoning.cpp index bdfdc4c860..560e35758e 100644 --- a/zone/zoning.cpp +++ b/zone/zoning.cpp @@ -1018,7 +1018,7 @@ void Client::LoadZoneFlags() { zone_flags.clear(); for (auto row : results) { - zone_flags.insert(std::stoul(row[0])); + zone_flags.insert(Strings::ToUnsignedInt(row[0])); } } @@ -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) && std::stoi(z->flag_needed) == 1) { + if (!z->flag_needed.empty() && Strings::IsNumber(z->flag_needed) && Strings::ToInt(z->flag_needed) == 1) { if (Admin() < minStatusToIgnoreZoneFlags && !HasZoneFlag(z->zoneidnumber)) { LogInfo( "Character [{}] does not have the flag to be in this zone [{}]!",