Core/Auction House: Delete item_instance entries correctly, prevent invalid entries
This commit is contained in:
@@ -241,6 +241,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
|||||||
else
|
else
|
||||||
AH->auctioneer = GUID_LOPART(auctioneer);
|
AH->auctioneer = GUID_LOPART(auctioneer);
|
||||||
|
|
||||||
|
// Required stack size of auction matches to current item stack size, just move item to auctionhouse
|
||||||
if (itemsCount == 1 && item->GetCount() == count[i])
|
if (itemsCount == 1 && item->GetCount() == count[i])
|
||||||
{
|
{
|
||||||
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
|
if (GetSecurity() > SEC_PLAYER && sWorld->getBoolConfig(CONFIG_GM_LOG_TRADE))
|
||||||
@@ -278,7 +279,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
|||||||
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
|
GetPlayer()->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_CREATE_AUCTION, 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else // Required stack size of auction does not match to current item stack size, clone item and set correct stack size
|
||||||
{
|
{
|
||||||
Item* newItem = item->CloneItem(finalCount, _player);
|
Item* newItem = item->CloneItem(finalCount, _player);
|
||||||
if (!newItem)
|
if (!newItem)
|
||||||
@@ -313,16 +314,17 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
|
|||||||
{
|
{
|
||||||
Item* item2 = items[j];
|
Item* item2 = items[j];
|
||||||
|
|
||||||
|
// Item stack count equals required count, ready to delete item - cloned item will be used for auction
|
||||||
if (item2->GetCount() == count[j])
|
if (item2->GetCount() == count[j])
|
||||||
{
|
{
|
||||||
_player->MoveItemFromInventory(item2->GetBagSlot(), item2->GetSlot(), true);
|
_player->MoveItemFromInventory(item2->GetBagSlot(), item2->GetSlot(), true);
|
||||||
|
|
||||||
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
SQLTransaction trans = CharacterDatabase.BeginTransaction();
|
||||||
item2->DeleteFromInventoryDB(trans);
|
item2->DeleteFromInventoryDB(trans);
|
||||||
item2->SaveToDB(trans);
|
item2->DeleteFromDB(trans);
|
||||||
CharacterDatabase.CommitTransaction(trans);
|
CharacterDatabase.CommitTransaction(trans);
|
||||||
}
|
}
|
||||||
else
|
else // Item stack count is bigger than required count, update item stack count and save to database - cloned item will be used for auction
|
||||||
{
|
{
|
||||||
item2->SetCount(item2->GetCount() - count[j]);
|
item2->SetCount(item2->GetCount() - count[j]);
|
||||||
item2->SetState(ITEM_CHANGED, _player);
|
item2->SetState(ITEM_CHANGED, _player);
|
||||||
|
|||||||
Reference in New Issue
Block a user