KeyRingAdd converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-08-23 22:49:27 -07:00
parent 2a4a5b1beb
commit 97f59282cf

View File

@ -4013,27 +4013,23 @@ void Client::KeyRingLoad()
void Client::KeyRingAdd(uint32 item_id) void Client::KeyRingAdd(uint32 item_id)
{ {
if(0==item_id)return; if(0==item_id)
char errbuf[MYSQL_ERRMSG_SIZE]; return;
char *query = 0;
uint32 affected_rows = 0; bool found = KeyRingCheck(item_id);
query = new char[256]; if (found)
bool bFound = KeyRingCheck(item_id); return;
if(!bFound){
sprintf(query, "INSERT INTO keyring(char_id,item_id) VALUES(%i,%i)",character_id,item_id); std::string query = StringFormat("INSERT INTO keyring(char_id, item_id) VALUES(%i, %i)", character_id, item_id);
if(database.RunQuery(query, strlen(query), errbuf, 0, &affected_rows)) auto results = database.QueryDatabase(query);
{ if (!results.Success()) {
Message(4,"Added to keyring."); std::cerr << "Error in Doors::HandleClick query '" << query << "' " << results.ErrorMessage() << std::endl;
safe_delete_array(query); return;
} }
else
{ Message(4,"Added to keyring.");
std::cerr << "Error in Doors::HandleClick query '" << query << "' " << errbuf << std::endl;
safe_delete_array(query); keyring.push_back(item_id);
return;
}
keyring.push_back(item_id);
}
} }
bool Client::KeyRingCheck(uint32 item_id) bool Client::KeyRingCheck(uint32 item_id)