[Strings] Add more number formatters (#2873)

* [Strings] Add more number formatters

# Notes
- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* [Strings] Add more number formatters

- Adds `Strings::ToUnsignedInt` for `uint32` support.
- Adds `Strings::ToBigInt` for `int64` support.
- Adds `Strings::ToUnsignedBigInt` for `uint64` support.
- Adds `Strings::ToFloat` for `float` support.
- Replaces all `std::stoi` references with `Strings::ToInt`.
- Replaces all `atoi` references with `Strings::ToInt`.
- Replaces all `std::stoul` references with `Strings::ToUnsignedInt`.
- Replaces all `atoul` references with `Strings::ToUnsignedInt`.
- Replaces all `std::stoll` references with `Strings::ToBigInt`.
- Replaces all `atoll` references with `Strings::ToBigInt`.
- Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `atoull` references with `Strings::ToUnsignedBigInt`.
- Replaces all `std::stof` references with `Strings::ToFloat`.

* Rebase cleanup

* Changes/benchmarks/tests

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Alex King 2023-03-04 18:01:19 -05:00 committed by GitHub
parent be567af70d
commit 2a6cf8c8e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
261 changed files with 3178 additions and 3012 deletions

View File

@ -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)

View File

@ -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]);

View File

@ -313,7 +313,7 @@ namespace cron
{
try
{
return static_cast<cron_int>(std::stoul(text.data()));
return static_cast<cron_int>(Strings::ToUnsignedInt(text.data()));
}
catch (std::exception const & ex)
{

View File

@ -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;
}
@ -387,7 +387,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) {
@ -787,7 +787,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;
}
@ -812,10 +812,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;
}
@ -832,7 +832,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) {
@ -852,14 +852,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<int16>(std::stoi(row[1]));
*status = static_cast<int16>(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;
@ -880,7 +880,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]);
}
}
@ -968,7 +968,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
@ -1052,15 +1052,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;
}
@ -1168,13 +1168,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]);
}
}
@ -1198,7 +1198,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(){
@ -1244,7 +1244,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)
@ -1296,7 +1296,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)
@ -1312,12 +1312,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);
@ -1362,10 +1362,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;
}
@ -1488,7 +1488,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) {
@ -1502,7 +1502,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) {
@ -1591,7 +1591,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));
@ -1638,7 +1638,7 @@ uint8 Database::GetAgreementFlag(uint32 acctid) {
auto row = results.begin();
return atoi(row[0]);
return Strings::ToInt(row[0]);
}
void Database::SetAgreementFlag(uint32 acctid) {
@ -1724,7 +1724,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;
}
@ -1807,7 +1807,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));
@ -1980,16 +1980,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;
@ -2008,7 +2008,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)
@ -2030,7 +2030,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) {
@ -2044,7 +2044,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;
}
@ -2058,7 +2058,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)
@ -2094,12 +2094,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;
@ -2126,7 +2126,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) {
@ -2140,7 +2140,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(
@ -2166,7 +2166,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;

View File

@ -34,8 +34,6 @@
#include <vector>
#include <map>
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
class MySQLRequestResult;
class Client;

View File

@ -530,7 +530,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);
}
@ -929,19 +929,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 */
@ -1567,7 +1567,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);
@ -1599,7 +1599,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"
@ -1670,7 +1670,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); }
@ -1682,7 +1682,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,
@ -1698,7 +1698,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,
@ -1778,7 +1778,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); }
@ -1791,7 +1791,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,
@ -1807,7 +1807,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,

View File

@ -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<uint16>(std::stoul(row[0]));
return static_cast<uint16>(Strings::ToUnsignedInt(row[0]));
}
std::vector<uint16> Database::GetInstanceIDs(uint32 zone_id, uint32 character_id)
@ -328,7 +328,7 @@ std::vector<uint16> Database::GetInstanceIDs(uint32 zone_id, uint32 character_id
}
for (auto row : results) {
l.push_back(static_cast<uint16>(std::stoul(row[0])));
l.push_back(static_cast<uint16>(Strings::ToUnsignedInt(row[0])));
}
return l;

View File

@ -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);

View File

@ -19,6 +19,7 @@
#include "../common/global_define.h"
#include "eqemu_config.h"
#include "misc_functions.h"
#include "strings.h"
#include <iostream>
#include <sstream>
@ -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

View File

@ -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;
}

View File

@ -272,6 +272,8 @@ inline const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *asn1) {
#include <brotli/encode.h>
#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<ssize_t>(std::stoll(cm.str(1)));
first = static_cast<ssize_t>(Strings::ToBigInt(cm.str(1)));
}
ssize_t last = -1;
if (!cm.str(2).empty()) {
last = static_cast<ssize_t>(std::stoll(cm.str(2)));
last = static_cast<ssize_t>(Strings::ToBigInt(cm.str(2)));
}
if (first != -1 && last != -1 && first > last) {

View File

@ -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
{

View File

@ -18,6 +18,7 @@
#include "misc.h"
#include "types.h"
#include <cstring>
#include "strings.h"
std::map<int,std::string> 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++) {

View File

@ -21,6 +21,7 @@
#include "misc_functions.h"
#include <string.h>
#include <time.h>
#include "strings.h"
#ifndef WIN32
#include <netinet/in.h>
@ -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;

View File

@ -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]);
}
}

View File

@ -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');

View File

@ -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:

File diff suppressed because it is too large Load Diff

View File

@ -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<std::string> &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;

View File

@ -86,7 +86,11 @@ class Strings {
public:
static bool Contains(std::vector<std::string> 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);

View File

@ -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;

View File

@ -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) {

View File

@ -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];

View File

@ -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}",

View File

@ -33,8 +33,6 @@
#include <vector>
#include <map>
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
class QSDatabase : public Database {
public:

View File

@ -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);
}

View File

@ -46,8 +46,7 @@ int main()
auto ConfigLoadResult = EQEmuConfig::LoadConfig();
Config = EQEmuConfig::get();
try {
std::ofstream outfile("test_output.txt");
std::unique_ptr<Test::Output> output(new Test::TextOutput(Test::TextOutput::Verbose, outfile));
std::unique_ptr<Test::Output> 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;

View File

@ -31,6 +31,8 @@ public:
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 @@ public:
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

View File

@ -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);

View File

@ -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());

View File

@ -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<std::string
for (auto row = results.begin(); row != results.end(); ++row) {
std::string name = row[1];
if (atoi(row[0]) == 0) {
if (Strings::ToInt(row[0]) == 0) {
ignorees.push_back(name);
LogInfo("Added Ignoree from DB [{}]", name.c_str());
continue;

View File

@ -35,8 +35,6 @@
#include <vector>
#include <map>
//atoi is not uint32 or uint32 safe!!!!
#define atoul(str) strtoul(str, nullptr, 10)
class UCSDatabase : public Database {
public:

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -19,8 +19,8 @@ Fear Pathing generation utility.
bool load_paths_from_db(MYSQL *m, Map *map, const char *zone, list<PathGraph*> &db_paths, list<PathNode*> &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<PathGraph*> &
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<PathGraph*> &
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<PathGraph*> &
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<PathGraph*> &
#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<PathGraph*> &
}
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<PathGraph*> &
bool load_spawns_from_db(MYSQL *m, const char *zone, list<PathNode*> &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<PathNode*> &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<PathNode*> &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<PathNode*> &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<PathNode*> &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);
}

View File

@ -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))

View File

@ -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

View File

@ -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);

View File

@ -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<FactionValueRecord> 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<InventoryEntry> 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<InventoryEntry> 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<QuestGlobalEntry> 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<FactionValueRecord>::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<InventoryEntry>::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<QuestGlobalEntry>::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);
}

View File

@ -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);
}

View File

@ -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));
}
}

View File

@ -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);

View File

@ -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<char *> 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<char *>::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.
*/

View File

@ -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<char *> 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<char *>::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);

View File

@ -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);
}

View File

@ -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) {

View File

@ -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);

View File

@ -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())
);
}

View File

@ -0,0 +1,114 @@
#include <cereal/archives/json.hpp>
#include <cereal/types/vector.hpp>
#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<Benchmark> 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();
}
}

View File

@ -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.");

View File

@ -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;
}
}

View File

@ -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);

View File

@ -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) {

View File

@ -194,7 +194,7 @@ void EQEmuApiWorldDataService::reload(Json::Value &r, const std::vector<std::str
uint8 global_repop = ReloadWorld::NoRepop;
if (Strings::IsNumber(args[2])) {
global_repop = static_cast<uint8>(std::stoul(args[2]));
global_repop = static_cast<uint8>(Strings::ToUnsignedInt(args[2]));
if (global_repop > ReloadWorld::ForceRepop) {
global_repop = ReloadWorld::ForceRepop;

View File

@ -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;
}

View File

@ -131,7 +131,7 @@ std::vector<std::string> EQW::ListBootedZones() {
std::map<std::string,std::string> EQW::GetZoneDetails(Const_char *zone_ref) {
std::map<std::string,std::string> 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<std::string> EQW::ListBugs(uint32 offset) {

View File

@ -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) {

View File

@ -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"

View File

@ -19,6 +19,7 @@ public:
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);
};

View File

@ -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]);
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)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]);
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)

View File

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

View File

@ -1979,10 +1979,10 @@ bool Client::Death(Mob* killerMob, int64 damage, uint16 spell, EQ::skills::Skill
database.GetVariable("ServerType", tmp);
if (tmp[0] == '1' && tmp[1] == '\0' && killerMob && killerMob->IsClient()) {
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);

View File

@ -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;
}

View File

@ -4139,7 +4139,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);
}
@ -4150,7 +4150,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);
}

View File

@ -5041,7 +5041,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)
@ -5078,7 +5078,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)
@ -5358,7 +5358,7 @@ void bot_command_view_combos(Client *c, const Seperator *sep)
return;
}
const uint16 bot_race = static_cast<uint16>(std::stoul(sep->arg[1]));
const uint16 bot_race = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
const std::string race_name = GetRaceIDName(bot_race);
if (!Mob::IsPlayerRace(bot_race)) {
@ -5562,14 +5562,14 @@ void bot_subcommand_bot_create(Client *c, const Seperator *sep)
return;
}
auto bot_class = static_cast<uint8>(std::stoul(sep->arg[2]));
auto bot_class = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
if (arguments < 3 || !sep->IsNumber(3)) {
c->Message(Chat::White, "Invalid race!");
return;
}
auto bot_race = static_cast<uint16>(std::stoul(sep->arg[3]));
auto bot_race = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[3]));
if (arguments < 4) {
c->Message(Chat::White, "Invalid gender!");
@ -5579,7 +5579,7 @@ void bot_subcommand_bot_create(Client *c, const Seperator *sep)
auto bot_gender = MALE;
if (sep->IsNumber(4)) {
bot_gender = static_cast<uint8>(std::stoul(sep->arg[4]));
bot_gender = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[4]));
if (bot_gender == NEUTER) {
bot_gender = MALE;
}
@ -5647,7 +5647,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)
@ -5700,7 +5700,7 @@ void bot_subcommand_bot_dye_armor(Client *c, const Seperator *sep)
bool dye_all = (sep->arg[1][0] == '*');
if (!dye_all) {
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) {
@ -5715,7 +5715,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;
}
@ -5725,7 +5725,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;
}
@ -5735,7 +5735,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;
}
@ -5815,7 +5815,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];
@ -5869,7 +5869,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)) {
@ -5909,7 +5909,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)
@ -5975,7 +5975,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))
@ -6010,7 +6010,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))
@ -6047,7 +6047,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)
@ -6184,13 +6184,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;
}
@ -6751,7 +6751,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;
}
@ -6810,7 +6810,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();
@ -6916,7 +6916,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)
@ -7160,7 +7160,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) {
@ -8228,7 +8228,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);
@ -8257,7 +8257,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("-"))
@ -8294,7 +8294,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);
@ -8323,7 +8323,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("-"))
@ -8437,7 +8437,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();
@ -8585,14 +8585,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)
@ -9315,7 +9315,7 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
return;
}
auto slot_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto slot_id = static_cast<uint16>(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;
@ -10307,7 +10307,7 @@ void bot_command_spell_list(Client* c, const Seperator *sep)
uint8 min_level = 0;
if (sep->IsNumber(1)) {
min_level = static_cast<uint8>(std::stoul(sep->arg[1]));
min_level = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
}
my_bot->ListBotSpells(min_level);
@ -10354,7 +10354,7 @@ void bot_command_spell_settings_add(Client *c, const Seperator *sep)
return;
}
auto spell_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto spell_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
if (!IsValidSpell(spell_id)) {
c->Message(
@ -10381,9 +10381,9 @@ void bot_command_spell_settings_add(Client *c, const Seperator *sep)
return;
}
auto priority = static_cast<int16>(std::stoi(sep->arg[2]));
auto min_hp = static_cast<int8>(EQ::Clamp(std::stoi(sep->arg[3]), -1, 99));
auto max_hp = static_cast<int8>(EQ::Clamp(std::stoi(sep->arg[4]), -1, 100));
auto priority = static_cast<int16>(Strings::ToInt(sep->arg[2]));
auto min_hp = static_cast<int8>(EQ::Clamp(Strings::ToInt(sep->arg[3]), -1, 99));
auto max_hp = static_cast<int8>(EQ::Clamp(Strings::ToInt(sep->arg[4]), -1, 100));
BotSpellSetting bs;
@ -10469,7 +10469,7 @@ void bot_command_spell_settings_delete(Client *c, const Seperator *sep)
return;
}
auto spell_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto spell_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
if (!IsValidSpell(spell_id)) {
c->Message(
@ -10577,7 +10577,7 @@ void bot_command_spell_settings_toggle(Client *c, const Seperator *sep)
return;
}
auto spell_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto spell_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
if (!IsValidSpell(spell_id)) {
c->Message(
Chat::White,
@ -10591,7 +10591,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])
);
@ -10682,7 +10682,7 @@ void bot_command_spell_settings_update(Client *c, const Seperator *sep)
return;
}
auto spell_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto spell_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
if (!IsValidSpell(spell_id)) {
c->Message(
@ -10695,9 +10695,9 @@ void bot_command_spell_settings_update(Client *c, const Seperator *sep)
return;
}
auto priority = static_cast<int16>(std::stoi(sep->arg[2]));
auto min_hp = static_cast<int8>(EQ::Clamp(std::stoi(sep->arg[3]), -1, 99));
auto max_hp = static_cast<int8>(EQ::Clamp(std::stoi(sep->arg[4]), -1, 100));
auto priority = static_cast<int16>(Strings::ToInt(sep->arg[2]));
auto min_hp = static_cast<int8>(EQ::Clamp(Strings::ToInt(sep->arg[3]), -1, 99));
auto max_hp = static_cast<int8>(EQ::Clamp(Strings::ToInt(sep->arg[4]), -1, 100));
BotSpellSetting bs;
@ -10772,7 +10772,7 @@ void bot_spell_info_dialogue_window(Client* c, const Seperator *sep)
return;
}
auto spell_id = static_cast<uint16>(std::stoul(sep->arg[1]));
auto spell_id = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
auto min_level = spells[spell_id].classes;
auto class_level = min_level[my_bot->GetBotClass() - 1];

View File

@ -43,7 +43,7 @@ bool BotDatabase::LoadBotCommandSettings(std::map<std::string, std::pair<uint8,
return false;
for (auto row = results.begin(); row != results.end(); ++row) {
bot_command_settings[row[0]].first = atoi(row[1]);
bot_command_settings[row[0]].first = Strings::ToInt(row[1]);
if (row[2][0] == 0)
continue;
@ -138,19 +138,19 @@ bool BotDatabase::LoadBotSpellCastingChances()
return false;
for (auto row = results.begin(); row != results.end(); ++row) {
uint8 spell_type_index = atoi(row[0]);
uint8 spell_type_index = Strings::ToInt(row[0]);
if (spell_type_index >= 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;
@ -269,7 +269,7 @@ bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list<BotsAvailableLis
for (auto row = results.begin(); row != results.end(); ++row) {
BotsAvailableList bot_entry;
bot_entry.ID = atoi(row[0]);
bot_entry.ID = Strings::ToInt(row[0]);
memset(&bot_entry.Name, 0, sizeof(bot_entry.Name));
std::string bot_name = row[1];
@ -283,11 +283,11 @@ bool BotDatabase::LoadBotsList(const uint32 owner_id, std::list<BotsAvailableLis
bot_owner = bot_owner.substr(0, 63);
if (!bot_owner.empty())
strcpy(bot_entry.Owner, bot_owner.c_str());
bot_entry.Class = atoi(row[2]);
bot_entry.Level = atoi(row[3]);
bot_entry.Race = atoi(row[4]);
bot_entry.Gender = atoi(row[5]);
bot_entry.Owner_ID = atoi(row[7]);
bot_entry.Class = Strings::ToInt(row[2]);
bot_entry.Level = Strings::ToInt(row[3]);
bot_entry.Race = Strings::ToInt(row[4]);
bot_entry.Gender = Strings::ToInt(row[5]);
bot_entry.Owner_ID = Strings::ToInt(row[7]);
bots_list.push_back(bot_entry);
}
@ -307,7 +307,7 @@ bool BotDatabase::LoadOwnerID(const std::string& bot_name, uint32& owner_id)
return true;
auto row = results.begin();
owner_id = atoi(row[0]);
owner_id = Strings::ToInt(row[0]);
return true;
}
@ -325,7 +325,7 @@ bool BotDatabase::LoadOwnerID(const uint32 bot_id, uint32& owner_id)
return true;
auto row = results.begin();
owner_id = atoi(row[0]);
owner_id = Strings::ToInt(row[0]);
return true;
}
@ -366,7 +366,7 @@ bool BotDatabase::LoadBotID(const uint32 owner_id, const std::string& bot_name,
}
auto row = results.begin();
bot_id = std::stoul(row[0]);
bot_id = Strings::ToUnsignedInt(row[0]);
return true;
}
@ -393,8 +393,8 @@ bool BotDatabase::LoadBotID(const uint32 owner_id, const std::string& bot_name,
}
auto row = results.begin();
bot_id = std::stoul(row[0]);
bot_class_id = static_cast<uint8>(std::stoul(row[1]));
bot_id = Strings::ToUnsignedInt(row[0]);
bot_class_id = static_cast<uint8>(Strings::ToUnsignedInt(row[1]));
return true;
}
@ -693,32 +693,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;
}
@ -839,7 +839,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;
}
@ -859,7 +859,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;
@ -952,9 +952,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;
@ -1020,7 +1020,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;
}
@ -1059,22 +1059,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);
@ -1088,12 +1088,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);
@ -1125,9 +1125,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);
@ -1174,7 +1174,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;
}
@ -1315,7 +1315,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;
}
@ -1366,7 +1366,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;
}
@ -1384,7 +1384,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;
}
@ -1408,10 +1408,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;
}
@ -1497,9 +1497,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)
@ -1605,7 +1605,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;
}
@ -2145,7 +2145,7 @@ bool BotDatabase::LoadOwnerOptions(Client *owner)
for (auto row : results) {
owner->SetBotOption(static_cast<Client::BotOwnerOption>(atoul(row[0])), (atoul(row[1]) != 0));
owner->SetBotOption(static_cast<Client::BotOwnerOption>(Strings::ToUnsignedInt(row[0])), (Strings::ToUnsignedInt(row[1]) != 0));
}
return true;
@ -2267,7 +2267,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;
}
@ -2293,7 +2293,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;
}
@ -2319,7 +2319,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;
}
@ -2345,7 +2345,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;
}
@ -2371,7 +2371,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;
}
@ -2593,7 +2593,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;
}
}
@ -2631,7 +2631,7 @@ bool BotDatabase::LoadBotGroup(const std::string& group_name, std::map<uint32, s
}
for (auto row : results) {
member_list[botgroup_id].push_back(std::stoul(row[0]));
member_list[botgroup_id].push_back(Strings::ToUnsignedInt(row[0]));
}
return true;
@ -2663,7 +2663,7 @@ bool BotDatabase::LoadBotGroupsListByOwnerID(const uint32 owner_id, std::list<st
}
for (auto row : results) {
botgroups_list.push_back(std::pair<std::string, uint32>(row[0], atoul(row[1])));
botgroups_list.push_back(std::pair<std::string, uint32>(row[0], Strings::ToUnsignedInt(row[1])));
}
return true;
@ -2735,7 +2735,7 @@ bool BotDatabase::LoadAutoSpawnBotGroupsByOwnerID(const uint32 owner_id, std::li
for (auto row : results) {
group_list.push_back(
std::pair<uint32,std::string>(std::stoul(row[0]), row[1])
std::pair<uint32,std::string>(Strings::ToUnsignedInt(row[0]), row[1])
);
}
@ -2767,7 +2767,7 @@ bool BotDatabase::LoadGroupedBotsByGroupID(const uint32 owner_id, const uint32 g
}
for (auto row : results) {
group_list.push_back(std::stoul(row[0]));
group_list.push_back(Strings::ToUnsignedInt(row[0]));
}
return true;
@ -2788,7 +2788,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;
}
@ -2835,20 +2835,20 @@ bool BotDatabase::LoadHealRotation(Bot* hr_member, std::list<uint32>& 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;
@ -2875,7 +2875,7 @@ bool BotDatabase::LoadHealRotationMembers(const uint32 hr_index, std::list<uint3
for (auto row : results) {
if (row[0])
member_list.push_back(atoi(row[0]));
member_list.push_back(Strings::ToInt(row[0]));
}
return true;
@ -3045,7 +3045,7 @@ bool BotDatabase::DeleteAllHealRotations(const uint32 owner_id)
if (!row[0])
continue;
DeleteHealRotation(atoi(row[0]));
DeleteHealRotation(Strings::ToInt(row[0]));
}
return true;
@ -3077,7 +3077,7 @@ uint16 BotDatabase::GetRaceClassBitmask(uint16 bot_race)
uint16 classes = 0;
if (results.RowCount() == 1) {
auto row = results.begin();
classes = atoi(row[0]);
classes = Strings::ToInt(row[0]);
}
return classes;
}

View File

@ -4012,7 +4012,7 @@ void Client::KeyRingLoad()
}
for (auto row = results.begin(); row != results.end(); ++row)
keyring.push_back(atoi(row[0]));
keyring.push_back(Strings::ToInt(row[0]));
}
@ -5221,8 +5221,8 @@ void Client::SendRewards()
for (auto row = results.begin(); row != results.end(); ++row) {
ClientReward cr;
cr.id = atoi(row[0]);
cr.amount = atoi(row[1]);
cr.id = Strings::ToInt(row[0]);
cr.amount = Strings::ToInt(row[1]);
rewards.push_back(cr);
}
@ -5290,7 +5290,7 @@ bool Client::TryReward(uint32 claim_id)
auto row = results.begin();
uint32 amt = atoi(row[0]);
uint32 amt = Strings::ToInt(row[0]);
if (amt == 0)
return false;
@ -8483,7 +8483,7 @@ void Client::ExpeditionSay(const char *str, int ExpID) {
).c_str()
);
}
// ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, atoi(row[3]));
// ChannelList->CreateChannel(ChannelName, ChannelOwner, ChannelPassword, true, Strings::ToInt(row[3]));
}
@ -9324,8 +9324,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) {
@ -10456,7 +10456,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.");

View File

@ -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;
@ -81,7 +81,7 @@ int Client::GetBotSpawnLimit(uint8 class_id)
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;
}
@ -98,7 +98,7 @@ int Client::GetBotSpawnLimit(uint8 class_id)
}
auto row = results.begin();
bot_spawn_limit = std::stoi(row[0]);
bot_spawn_limit = Strings::ToInt(row[0]);
}
return bot_spawn_limit;

View File

@ -1238,17 +1238,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))
@ -6747,15 +6747,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("<tr><td>%s</td><td>%s</td><td>%8.0f</td><td>%8.0f</td><td>%8.0f</td><td>%s</td><td>%s</td><td>%s</td></tr>",
charName, StaticGetZoneName(ZoneID), CorpseX, CorpseY, CorpseZ, time_of_death,
@ -11436,8 +11436,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;
@ -13158,19 +13158,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) {
@ -13203,10 +13203,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());

View File

@ -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]);
}
/**

View File

@ -1,6 +1,7 @@
#include <regex>
#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(
"<c \"#F07F00\">Click [{}] to continue...</c>",

View File

@ -276,7 +276,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 [{}]!",
@ -727,7 +727,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<DoorsRepository::Doors> ZoneDatabase::LoadDoors(const std::string &zone_name, int16 version)

View File

@ -1952,7 +1952,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<Mob*>(extra_pointers->at(0)));
}
@ -1960,7 +1960,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<Corpse*>(extra_pointers->at(0)));
}
@ -1968,7 +1968,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;
}

View File

@ -3261,7 +3261,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;
}
}
}
@ -5906,7 +5906,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();
}

View File

@ -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<uint8>(std::stoul(global.value));
return static_cast<uint8>(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<uint8>(std::stoul(bucket_value));
return static_cast<uint8>(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<uint8>(std::stoul(bucket_value));
return static_cast<uint8>(Strings::ToUnsignedInt(bucket_value));
}
}

View File

@ -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;

View File

@ -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 = {}",

View File

@ -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);
}

View File

@ -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);

View File

@ -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",

View File

@ -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,

View File

@ -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) {

View File

@ -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;

View File

@ -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) {

View File

@ -11,7 +11,7 @@ void command_chat(Client *c, const Seperator *sep)
return;
}
auto channel_id = static_cast<uint8>(std::stoul(sep->arg[1]));
auto channel_id = static_cast<uint8>(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.");

View File

@ -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
) :

View File

@ -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,

View File

@ -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);
}

View File

@ -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)
"<td>Value</td>"
"</tr>";
for (auto row = results.begin(); row != results.end(); ++row) {
auto id = static_cast<uint32>(atoi(row[0]));
auto id = static_cast<uint32>(Strings::ToInt(row[0]));
std::string key = row[1];
std::string value = row[2];
std::string expires = row[3];

View File

@ -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<uint16>(std::stoul(sep->arg[1]));
auto month = static_cast<uint8>(std::stoul(sep->arg[2]));
auto day = static_cast<uint8>(std::stoul(sep->arg[3]));
auto year = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[1]));
auto month = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
auto day = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[3]));
auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast<uint8>(std::stoul(sep->arg[4]) + 1);
auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast<uint8>(std::stoul(sep->arg[5]));
auto hour = !sep->IsNumber(4) ? eq_time.hour : static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[4]) + 1);
auto minute = !sep->IsNumber(5) ? eq_time.minute : static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[5]));
c->Message(
Chat::White,

View File

@ -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<uint16>(std::stoul(sep->arg[4])) : static_cast<uint16>(0);
auto condition_minimum = sep->IsNumber(5) ? static_cast<int16>(std::stoul(sep->arg[5])) : static_cast<int16>(0);
auto condition_id = sep->IsNumber(4) ? static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[4])) : static_cast<uint16>(0);
auto condition_minimum = sep->IsNumber(5) ? static_cast<int16>(Strings::ToUnsignedInt(sep->arg[5])) : static_cast<int16>(0);
if (!database.CreateSpawn2(
c,

View File

@ -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(

View File

@ -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]));
}

View File

@ -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(

View File

@ -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);

View File

@ -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;
}

View File

@ -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 = (

View File

@ -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()));
}
}

Some files were not shown because too many files have changed in this diff Show More