RemoveBotItemBySlot converted to QueryDatabase

This commit is contained in:
Arthur Ice 2014-09-03 16:43:59 -07:00
parent cf0c773002
commit 53572b4d13

View File

@ -4183,16 +4183,18 @@ void Bot::SetBotItemInSlot(uint32 slotID, uint32 itemID, const ItemInst* inst, s
// Deletes the inventory record for the specified item from the database for this bot. // Deletes the inventory record for the specified item from the database for this bot.
void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) { void Bot::RemoveBotItemBySlot(uint32 slotID, std::string *errorMessage) {
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
if(this->GetBotID() > 0 && slotID >= 0) { if(this->GetBotID() == 0)
if(!database.RunQuery(query, MakeAnyLenString(&query, "DELETE FROM botinventory WHERE botid=%i AND slotid=%i", this->GetBotID(), slotID), errbuf)){ return;
*errorMessage = std::string(errbuf);
} std::string query = StringFormat("DELETE FROM botinventory "
safe_delete_array(query); "WHERE botid = %i AND slotid = %i",
m_inv.DeleteItem(slotID); this->GetBotID(), slotID);
} auto results = database.QueryDatabase(query);
if(!results.Success())
*errorMessage = std::string(results.ErrorMessage());
m_inv.DeleteItem(slotID);
} }
// Retrieves all the inventory records from the database for this bot. // Retrieves all the inventory records from the database for this bot.