All pastes #750378 Raw Edit

Unbenannt

public text v1 · immutable
#750378 ·published 2007-10-26 13:41 UTC
rendered paste body
Index: src/game/Mail.cpp
===================================================================
--- src/game/Mail.cpp	(revision 4645)
+++ src/game/Mail.cpp	(working copy)
@@ -165,10 +165,8 @@
 
         sDatabase.BeginTransaction();
         pItem->DeleteFromInventoryDB();                     //deletes item from character's inventory
-        pItem->SaveToDB();                                  // recursive and not have transaction guard into self
-        sDatabase.CommitTransaction();
 
-        //item reminds in item_instance table already, used it in mail now
+        //item remains still in item_instance table, but is used in mail from now
         pl->RemoveItem( (item_pos >> 8), (item_pos & 255), true );
         pItem->RemoveFromUpdateQueueOf( pl );
         if(pItem->IsInWorld())
@@ -176,6 +174,9 @@
             pItem->RemoveFromWorld();
             pItem->DestroyForPlayer( pl );
         }
+        //save item only after non existent item is already removed
+        pItem->SaveToDB();                                  // recursive and not have transaction guard into self
+        sDatabase.CommitTransaction();
 
         // owner in `data` will set at mail receive and item extracting
         sDatabase.PExecute("UPDATE `item_instance` SET `owner_guid` = '%u' WHERE `guid`='%u'",GUID_LOPART(rc),pItem->GetGUIDLow());