mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Strings] Add more number formatters (#2873)
* [Strings] Add more number formatters # Notes - Adds `Strings::ToUnsignedInt` for `uint32` support. - Adds `Strings::ToBigInt` for `int64` support. - Adds `Strings::ToUnsignedBigInt` for `uint64` support. - Adds `Strings::ToFloat` for `float` support. - Replaces all `std::stoi` references with `Strings::ToInt`. - Replaces all `atoi` references with `Strings::ToInt`. - Replaces all `std::stoul` references with `Strings::ToUnsignedInt`. - Replaces all `atoul` references with `Strings::ToUnsignedInt`. - Replaces all `std::stoll` references with `Strings::ToBigInt`. - Replaces all `atoll` references with `Strings::ToBigInt`. - Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`. - Replaces all `atoull` references with `Strings::ToUnsignedBigInt`. - Replaces all `std::stof` references with `Strings::ToFloat`. * [Strings] Add more number formatters - Adds `Strings::ToUnsignedInt` for `uint32` support. - Adds `Strings::ToBigInt` for `int64` support. - Adds `Strings::ToUnsignedBigInt` for `uint64` support. - Adds `Strings::ToFloat` for `float` support. - Replaces all `std::stoi` references with `Strings::ToInt`. - Replaces all `atoi` references with `Strings::ToInt`. - Replaces all `std::stoul` references with `Strings::ToUnsignedInt`. - Replaces all `atoul` references with `Strings::ToUnsignedInt`. - Replaces all `std::stoll` references with `Strings::ToBigInt`. - Replaces all `atoll` references with `Strings::ToBigInt`. - Replaces all `std::stoull` references with `Strings::ToUnsignedBigInt`. - Replaces all `atoull` references with `Strings::ToUnsignedBigInt`. - Replaces all `std::stof` references with `Strings::ToFloat`. * Rebase cleanup * Changes/benchmarks/tests --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user