LoadLeaderboardInfo converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-18 15:44:55 -07:00
parent 8b05eff179
commit 042613d234

View File

@ -1067,18 +1067,20 @@ void AdventureManager::LoadLeaderboardInfo()
leaderboard_info_percentage_ruj.clear(); leaderboard_info_percentage_ruj.clear();
leaderboard_info_wins_tak.clear(); leaderboard_info_wins_tak.clear();
leaderboard_info_percentage_tak.clear(); leaderboard_info_percentage_tak.clear();
char errbuf[MYSQL_ERRMSG_SIZE];
char* query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
if(database.RunQuery(query,MakeAnyLenString(&query,"select ch.name, ch.id, adv_stats.* from adventure_stats " std::string query = "SELECT ch.name, ch.id, adv_stats.* FROM adventure_stats "
"AS adv_stats ""left join character_ AS ch on adv_stats.player_id = ch.id;"), errbuf, &result)) "AS adv_stats LEFT JOIN character_ AS ch ON adv_stats.player_id = ch.id;";
{ auto results = database.QueryDatabase(query);
while((row = mysql_fetch_row(result))) if(!results.Success()) {
{ LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query.c_str(), results.ErrorMessage().c_str());
if(row[0]) return;
}
for (auto row = results.begin(); row != results.end(); ++row)
{ {
if(!row[0])
continue;
LeaderboardInfo lbi; LeaderboardInfo lbi;
lbi.name = row[0]; lbi.name = row[0];
lbi.wins = atoi(row[3]); lbi.wins = atoi(row[3]);
@ -1128,18 +1130,6 @@ void AdventureManager::LoadLeaderboardInfo()
leaderboard_sorted_wins_tak = false; leaderboard_sorted_wins_tak = false;
leaderboard_sorted_percentage_tak = false; leaderboard_sorted_percentage_tak = false;
} }
}
mysql_free_result(result);
safe_delete_array(query);
return;
}
else
{
LogFile->write(EQEMuLog::Error, "Error in AdventureManager:::GetLeaderboardInfo: %s (%s)", query, errbuf);
safe_delete_array(query);
return;
}
return;
}; };
void AdventureManager::DoLeaderboardRequest(const char* player, uint8 type) void AdventureManager::DoLeaderboardRequest(const char* player, uint8 type)