mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user