LoadAccountFlags converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-10-04 15:21:05 -07:00
parent 037df28b7c
commit 81a641c96c

View File

@ -7722,28 +7722,19 @@ void Client::SendFactionMessage(int32 tmpvalue, int32 faction_id, int32 totalval
void Client::LoadAccountFlags() void Client::LoadAccountFlags()
{ {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
MYSQL_RES *result;
MYSQL_ROW row;
accountflags.clear(); accountflags.clear();
MakeAnyLenString(&query, "SELECT p_flag, p_value FROM account_flags WHERE p_accid = '%d'", account_id); std::string query = StringFormat("SELECT p_flag, p_value "
if(database.RunQuery(query, strlen(query), errbuf, &result)) "FROM account_flags WHERE p_accid = '%d'",
{ account_id);
while(row = mysql_fetch_row(result)) auto results = database.QueryDatabase(query);
{ if (!results.Success()) {
std::string fname(row[0]); std::cerr << "Error in LoadAccountFlags query '" << query << "' " << results.ErrorMessage() << std::endl;
std::string fval(row[1]); return;
accountflags[fname] = fval; }
}
mysql_free_result(result); for (auto row = results.begin(); row != results.end(); ++row)
} accountflags[row[0]] = row[1];
else
{
std::cerr << "Error in LoadAccountFlags query '" << query << "' " << errbuf << std::endl;
}
safe_delete_array(query);
} }
void Client::SetAccountFlag(std::string flag, std::string val) void Client::SetAccountFlag(std::string flag, std::string val)