SendRewards converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-23 23:05:58 -07:00
parent 46980e5260
commit a48138dfd6

View File

@ -5261,32 +5261,22 @@ const bool Client::IsMQExemptedArea(uint32 zoneID, float x, float y, float z) co
void Client::SendRewards() void Client::SendRewards()
{ {
std::vector<ClientReward> rewards; std::vector<ClientReward> rewards;
char errbuf[MYSQL_ERRMSG_SIZE]; std::string query = StringFormat("SELECT reward_id, amount FROM "
char* query = 0; "account_rewards WHERE account_id = %i "
MYSQL_RES *result; "ORDER BY reward_id", AccountID());
MYSQL_ROW row; auto results = database.QueryDatabase(query);
if (!results.Success()) {
if(database.RunQuery(query,MakeAnyLenString(&query,"SELECT reward_id, amount FROM" LogFile->write(EQEMuLog::Error, "Error in Client::SendRewards(): %s (%s)", query.c_str(), results.ErrorMessage().c_str());
" account_rewards WHERE account_id=%i ORDER by reward_id", AccountID()),
errbuf,&result))
{
while((row = mysql_fetch_row(result)))
{
ClientReward cr;
cr.id = atoi(row[0]);
cr.amount = atoi(row[1]);
rewards.push_back(cr);
}
mysql_free_result(result);
safe_delete_array(query);
}
else
{
LogFile->write(EQEMuLog::Error, "Error in Client::SendRewards(): %s (%s)", query, errbuf);
safe_delete_array(query);
return; return;
} }
for (auto row = results.begin(); row != results.end(); ++row) {
ClientReward cr;
cr.id = atoi(row[0]);
cr.amount = atoi(row[1]);
rewards.push_back(cr);
}
if(rewards.size() > 0) if(rewards.size() > 0)
{ {
EQApplicationPacket *vetapp = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(InternalVeteranReward) * rewards.size())); EQApplicationPacket *vetapp = new EQApplicationPacket(OP_VetRewardsAvaliable, (sizeof(InternalVeteranReward) * rewards.size()));