aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMachiavelli <none@none>2010-03-10 16:16:29 +0100
committerMachiavelli <none@none>2010-03-10 16:16:29 +0100
commit35e1a1eda8d5d20c9c6b5049ac8d9bce1bd55d49 (patch)
tree64ae41ebcc647f3f520633c378b7a1ece03363a0 /src
parentd8fdf47c173306bff49517dd1645b30a612840e1 (diff)
Use "REPLACE INTO" instead of "DELETE" + "INSERT INTO" in Item::SaveToDB call to fix a cause of items randomly disappearing (issue 925).
Note: due to the hierarchy of the function calls, it's not possible to use DB transactions in this function. --HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Item.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/src/game/Item.cpp b/src/game/Item.cpp
index b2821ae7b83..f6b50704abd 100644
--- a/src/game/Item.cpp
+++ b/src/game/Item.cpp
@@ -300,17 +300,14 @@ void Item::SaveToDB()
switch (uState)
{
case ITEM_NEW:
- {
- CharacterDatabase.PExecute( "DELETE FROM item_instance WHERE guid = '%u'", guid );
std::ostringstream ss;
- ss << "INSERT INTO item_instance (guid,owner_guid,data) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
+ ss << "REPLACE INTO item_instance (guid,owner_guid,data) VALUES (" << guid << "," << GUID_LOPART(GetOwnerGUID()) << ",'";
for (uint16 i = 0; i < m_valuesCount; ++i )
ss << GetUInt32Value(i) << " ";
ss << "' )";
- CharacterDatabase.Execute( ss.str().c_str() );
- } break;
+ CharacterDatabase.Execute(ss.str().c_str());
+ break;
case ITEM_CHANGED:
- {
std::ostringstream ss;
ss << "UPDATE item_instance SET data = '";
for (uint16 i = 0; i < m_valuesCount; ++i )
@@ -321,9 +318,8 @@ void Item::SaveToDB()
if(HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAGS_WRAPPED))
CharacterDatabase.PExecute("UPDATE character_gifts SET guid = '%u' WHERE item_guid = '%u'", GUID_LOPART(GetOwnerGUID()),GetGUIDLow());
- } break;
+ break;
case ITEM_REMOVED:
- {
if (GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID) > 0 )
CharacterDatabase.PExecute("DELETE FROM item_text WHERE id = '%u'", GetUInt32Value(ITEM_FIELD_ITEM_TEXT_ID));
CharacterDatabase.PExecute("DELETE FROM item_instance WHERE guid = '%u'", guid);
@@ -331,7 +327,6 @@ void Item::SaveToDB()
CharacterDatabase.PExecute("DELETE FROM character_gifts WHERE item_guid = '%u'", GetGUIDLow());
delete this;
return;
- }
case ITEM_UNCHANGED:
break;
}