Fix crash in Player::_saveInventory().

Fixes issue #1175

--HG--
branch : trunk
This commit is contained in:
Machiavelli
2010-03-19 13:36:54 +01:00
parent 34d7e1fed9
commit 1146c59f66
3 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -247,6 +247,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account); GetPlayerName(), GetAccountId(), item->GetProto()->Name1, item->GetEntry(), item->GetCount(), receiver.c_str(), rc_account);
} }
item->SetNotRefundable(GetPlayer()); // makes the item no longer refundable
pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true); pl->MoveItemFromInventory(items[i]->GetBagSlot(), item->GetSlot(), true);
CharacterDatabase.BeginTransaction(); CharacterDatabase.BeginTransaction();
item->DeleteFromInventoryDB(); // deletes item from character's inventory item->DeleteFromInventoryDB(); // deletes item from character's inventory
@@ -254,7 +255,6 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data )
// owner in data will set at mail receive and item extracting // owner in data will set at mail receive and item extracting
CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", GUID_LOPART(rc), item->GetGUIDLow()); CharacterDatabase.PExecute("UPDATE item_instance SET owner_guid = '%u' WHERE guid='%u'", GUID_LOPART(rc), item->GetGUIDLow());
CharacterDatabase.CommitTransaction(); CharacterDatabase.CommitTransaction();
draft.AddItem(item); draft.AddItem(item);
} }
+1 -1
View File
@@ -17494,7 +17494,7 @@ void Player::_SaveInventory()
// Item could be deleted, or traded. // Item could be deleted, or traded.
// In the first case, DeleteRefundDataFromDB() was already called in Item::SaveToDB() // In the first case, DeleteRefundDataFromDB() was already called in Item::SaveToDB()
Item* iPtr = (*itr); Item* iPtr = (*itr);
if (!iPtr || iPtr->GetOwner() != this) if (!iPtr)
m_refundableItems.erase(itr++); m_refundableItems.erase(itr++);
else else
{ {
+5
View File
@@ -202,6 +202,9 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
_player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId()); _player->pTrader->GetName(),_player->pTrader->GetSession()->GetAccountId());
} }
// make not refundable
myItems[i]->SetNotRefundable(_player);
// store // store
_player->pTrader->MoveItemToInventory( traderDst, myItems[i], true, true); _player->pTrader->MoveItemToInventory( traderDst, myItems[i], true, true);
} }
@@ -217,6 +220,8 @@ void WorldSession::moveItems(Item* myItems[], Item* hisItems[])
_player->GetName(),_player->GetSession()->GetAccountId()); _player->GetName(),_player->GetSession()->GetAccountId());
} }
// make not refundable
hisItems[i]->SetNotRefundable(_player->pTrader);
// store // store
_player->MoveItemToInventory( playerDst, hisItems[i], true, true); _player->MoveItemToInventory( playerDst, hisItems[i], true, true);
} }