LoadAAs converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-20 12:21:46 -07:00
parent e33e8b713e
commit 3bc582885b

View File

@ -1779,41 +1779,36 @@ uint32 ZoneDatabase::GetSizeAA(){
void ZoneDatabase::LoadAAs(SendAA_Struct **load){ void ZoneDatabase::LoadAAs(SendAA_Struct **load){
if(!load) if(!load)
return; return;
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0; std::string query = "SELECT skill_id FROM altadv_vars ORDER BY skill_id";
MYSQL_RES *result; auto results = QueryDatabase(query);
MYSQL_ROW row; if (results.Success()) {
if (RunQuery(query, MakeAnyLenString(&query, "SELECT skill_id from altadv_vars order by skill_id"), errbuf, &result)) { int skill = 0, index = 0;
int skill=0,ndx=0; for (auto row = results.begin(); row != results.end(); ++row, ++index) {
while((row = mysql_fetch_row(result))!=nullptr) {
skill = atoi(row[0]); skill = atoi(row[0]);
load[ndx] = GetAASkillVars(skill); load[index] = GetAASkillVars(skill);
load[ndx]->seq = ndx+1; load[index]->seq = index+1;
ndx++;
} }
mysql_free_result(result);
} else { } else {
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query, errbuf); LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
} }
safe_delete_array(query);
AARequiredLevelAndCost.clear(); AARequiredLevelAndCost.clear();
query = "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id";
results = QueryDatabase(query);
if (!results.Success()) {
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query.c_str(), results.ErrorMessage().c_str());
return;
}
if (RunQuery(query, MakeAnyLenString(&query, "SELECT skill_id, level, cost from aa_required_level_cost order by skill_id"), errbuf, &result))
{
AALevelCost_Struct aalcs; AALevelCost_Struct aalcs;
while((row = mysql_fetch_row(result))!=nullptr) for (auto row = results.begin(); row != results.end(); ++row)
{ {
aalcs.Level = atoi(row[1]); aalcs.Level = atoi(row[1]);
aalcs.Cost = atoi(row[2]); aalcs.Cost = atoi(row[2]);
AARequiredLevelAndCost[atoi(row[0])] = aalcs; AARequiredLevelAndCost[atoi(row[0])] = aalcs;
} }
mysql_free_result(result);
}
else
LogFile->write(EQEMuLog::Error, "Error in ZoneDatabase::LoadAAs query '%s': %s", query, errbuf);
safe_delete_array(query);
} }
SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id) SendAA_Struct* ZoneDatabase::GetAASkillVars(uint32 skill_id)