aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-05-05 02:09:49 +0200
committerMachiavelli <none@none>2010-05-05 02:09:49 +0200
commitc7ec359495d846a0ae275119a58fc3db6efab41f (patch)
treeaa2b86f5505d6af7920c42aa64d43111e8420c69 /src
parent52893aeae229465a05867f8b1df7b9bb8b83718b (diff)
Save items with itemstate ITEM_CHANGED using DELETE followed by an INSERT query (wrapped in a transaction).
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Player.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index 1e5dcdb343b..847c72af4c4 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -17777,13 +17777,16 @@ void Player::_SaveInventory()
Bag *container = item->GetContainer();
uint32 bag_guid = container ? container->GetGUIDLow() : 0;
- switch(item->GetState())
+ switch (item->GetState())
{
case ITEM_NEW:
CharacterDatabase.PExecute("INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES ('%u', '%u', '%u', '%u', '%u')", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetGUIDLow(), item->GetEntry());
break;
case ITEM_CHANGED:
- CharacterDatabase.PExecute("UPDATE character_inventory SET guid='%u', bag='%u', slot='%u', item_template='%u' WHERE item='%u'", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetEntry(), item->GetGUIDLow());
+ CharacterDatabase.BeginTransaction();
+ CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow());
+ CharacterDatabase.PExecute("INSERT INTO character_inventory (guid,bag,slot,item,item_template) VALUES ('%u', '%u', '%u', '%u', '%u')", GetGUIDLow(), bag_guid, item->GetSlot(), item->GetGUIDLow(), item->GetEntry());
+ CharacterDatabase.CommitTransaction();
break;
case ITEM_REMOVED:
CharacterDatabase.PExecute("DELETE FROM character_inventory WHERE item = '%u'", item->GetGUIDLow());