Revert "Core: more more cleanup" - Build test anyone?

This reverts commit 20cd4c71ee.
This commit is contained in:
leak
2012-03-14 18:51:51 +01:00
parent b02a012b47
commit 2a5caef4a6
27 changed files with 804 additions and 804 deletions
@@ -504,8 +504,8 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
SQLTransaction trans = CharacterDatabase.BeginTransaction();
if (auction && auction->owner == player->GetGUIDLow())
{
Item* item = sAuctionMgr->GetAItem(auction->item_guidlow);
if (item)
Item* pItem = sAuctionMgr->GetAItem(auction->item_guidlow);
if (pItem)
{
if (auction->bidder > 0) // If we have a bidder, we have to send him the money he paid
{
@@ -522,7 +522,7 @@ void WorldSession::HandleAuctionRemoveItem(WorldPacket & recv_data)
// item will deleted or added to received mail list
MailDraft(msgAuctionCanceledOwner.str(), "") // TODO: fix body
.AddItem(item)
.AddItem(pItem)
.SendMailTo(trans, player, auction, MAIL_CHECK_MASK_COPIED);
}
else
+62 -62
View File
@@ -255,14 +255,14 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data)
}
}
Item* item = _player->GetItemByPos(bag, slot);
if (!item)
Item* pItem = _player->GetItemByPos(bag, slot);
if (!pItem)
{
_player->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return;
}
if (item->GetTemplate()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
if (pItem->GetTemplate()->Flags & ITEM_PROTO_FLAG_INDESTRUCTIBLE)
{
_player->SendEquipError(EQUIP_ERR_CANT_DROP_SOULBOUND, NULL, NULL);
return;
@@ -271,7 +271,7 @@ void WorldSession::HandleDestroyItemOpcode(WorldPacket & recv_data)
if (count)
{
uint32 i_count = count;
_player->DestroyItemCount(item, i_count, true);
_player->DestroyItemCount(pItem, i_count, true);
}
else
_player->DestroyItem(bag, slot, true);
@@ -445,13 +445,13 @@ void WorldSession::HandleReadItem(WorldPacket & recv_data)
recv_data >> bag >> slot;
//sLog->outDetail("STORAGE: Read bag = %u, slot = %u", bag, slot);
Item* item = _player->GetItemByPos(bag, slot);
Item* pItem = _player->GetItemByPos(bag, slot);
if (item && item->GetTemplate()->PageText)
if (pItem && pItem->GetTemplate()->PageText)
{
WorldPacket data;
InventoryResult msg = _player->CanUseItem(item);
InventoryResult msg = _player->CanUseItem(pItem);
if (msg == EQUIP_ERR_OK)
{
data.Initialize (SMSG_READ_ITEM_OK, 8);
@@ -461,9 +461,9 @@ void WorldSession::HandleReadItem(WorldPacket & recv_data)
{
data.Initialize(SMSG_READ_ITEM_FAILED, 8);
sLog->outDetail("STORAGE: Unable to read item");
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
}
data << item->GetGUID();
data << pItem->GetGUID();
SendPacket(&data);
}
else
@@ -506,25 +506,25 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data)
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* item = _player->GetItemByGuid(itemguid);
if (item)
Item* pItem = _player->GetItemByGuid(itemguid);
if (pItem)
{
// prevent sell not owner item
if (_player->GetGUID() != item->GetOwnerGUID())
if (_player->GetGUID() != pItem->GetOwnerGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
// prevent sell non empty bag by drag-and-drop at vendor's item list
if (item->IsNotEmptyBag())
if (pItem->IsNotEmptyBag())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
// prevent sell currently looted item
if (_player->GetLootGUID() == item->GetGUID())
if (_player->GetLootGUID() == pItem->GetGUID())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
@@ -533,44 +533,44 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data)
// prevent selling item for sellprice when the item is still refundable
// this probably happens when right clicking a refundable item, the client sends both
// CMSG_SELL_ITEM and CMSG_REFUND_ITEM (unverified)
if (item->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
if (pItem->HasFlag(ITEM_FIELD_FLAGS, ITEM_FLAG_REFUNDABLE))
return; // Therefore, no feedback to client
// special case at auto sell (sell all)
if (count == 0)
{
count = item->GetCount();
count = pItem->GetCount();
}
else
{
// prevent sell more items that exist in stack (possible only not from client)
if (count > item->GetCount())
if (count > pItem->GetCount())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
}
ItemTemplate const* pProto = item->GetTemplate();
ItemTemplate const* pProto = pItem->GetTemplate();
if (pProto)
{
if (pProto->SellPrice > 0)
{
if (count < item->GetCount()) // need split items
if (count < pItem->GetCount()) // need split items
{
Item* pNewItem = item->CloneItem(count, _player);
Item* pNewItem = pItem->CloneItem(count, _player);
if (!pNewItem)
{
sLog->outError("WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", item->GetEntry(), count);
sLog->outError("WORLD: HandleSellItemOpcode - could not create clone of item %u; count = %u", pItem->GetEntry(), count);
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, creature, itemguid, 0);
return;
}
item->SetCount(item->GetCount() - count);
_player->ItemRemovedQuestCheck(item->GetEntry(), count);
pItem->SetCount(pItem->GetCount() - count);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), count);
if (_player->IsInWorld())
item->SendUpdateToPlayer(_player);
item->SetState(ITEM_CHANGED, _player);
pItem->SendUpdateToPlayer(_player);
pItem->SetState(ITEM_CHANGED, _player);
_player->AddItemToBuyBackSlot(pNewItem);
if (_player->IsInWorld())
@@ -578,10 +578,10 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data)
}
else
{
_player->ItemRemovedQuestCheck(item->GetEntry(), item->GetCount());
_player->RemoveItem(item->GetBagSlot(), item->GetSlot(), true);
item->RemoveFromUpdateQueueOf(_player);
_player->AddItemToBuyBackSlot(item);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->RemoveItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
pItem->RemoveFromUpdateQueueOf(_player);
_player->AddItemToBuyBackSlot(pItem);
}
uint32 money = pProto->SellPrice * count;
@@ -617,28 +617,28 @@ void WorldSession::HandleBuybackItem(WorldPacket & recv_data)
if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);
Item* item = _player->GetItemFromBuyBackSlot(slot);
if (item)
Item* pItem = _player->GetItemFromBuyBackSlot(slot);
if (pItem)
{
uint32 price = _player->GetUInt32Value(PLAYER_FIELD_BUYBACK_PRICE_1 + slot - BUYBACK_SLOT_START);
if (!_player->HasEnoughMoney(price))
{
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, item->GetEntry(), 0);
_player->SendBuyError(BUY_ERR_NOT_ENOUGHT_MONEY, creature, pItem->GetEntry(), 0);
return;
}
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, item, false);
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
if (msg == EQUIP_ERR_OK)
{
_player->ModifyMoney(-(int32)price);
_player->RemoveItemFromBuyBackSlot(slot, false);
_player->ItemAddedQuestCheck(item->GetEntry(), item->GetCount());
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, item->GetEntry(), item->GetCount());
_player->StoreItem(dest, item, true);
_player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_RECEIVE_EPIC_ITEM, pItem->GetEntry(), pItem->GetCount());
_player->StoreItem(dest, pItem, true);
}
else
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
else
@@ -815,8 +815,8 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data)
recv_data >> srcbag >> srcslot >> dstbag;
//sLog->outDebug("STORAGE: receive srcbag = %u, srcslot = %u, dstbag = %u", srcbag, srcslot, dstbag);
Item* item = _player->GetItemByPos(srcbag, srcslot);
if (!item)
Item* pItem = _player->GetItemByPos(srcbag, srcslot);
if (!pItem)
return;
if (!_player->IsValidPos(dstbag, NULL_SLOT, false)) // can be autostore pos
@@ -825,7 +825,7 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data)
return;
}
uint16 src = item->GetPos();
uint16 src = pItem->GetPos();
// check unequip potability for equipped items and bank bags
if (_player->IsEquipmentPos (src) || _player->IsBagPos (src))
@@ -833,16 +833,16 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data)
InventoryResult msg = _player->CanUnequipItem(src, !_player->IsBagPos (src));
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
}
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem(dstbag, NULL_SLOT, dest, item, false);
InventoryResult msg = _player->CanStoreItem(dstbag, NULL_SLOT, dest, pItem, false);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
@@ -850,12 +850,12 @@ void WorldSession::HandleAutoStoreBagItemOpcode(WorldPacket & recv_data)
if (dest.size() == 1 && dest[0].pos == src)
{
// just remove grey item state
_player->SendEquipError(EQUIP_ERR_NONE, item, NULL);
_player->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);
return;
}
_player->RemoveItem(srcbag, srcslot, true);
_player->StoreItem(dest, item, true);
_player->StoreItem(dest, pItem, true);
}
void WorldSession::HandleBuyBankSlotOpcode(WorldPacket& recvPacket)
@@ -919,27 +919,27 @@ void WorldSession::HandleAutoBankItemOpcode(WorldPacket& recvPacket)
recvPacket >> srcbag >> srcslot;
sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot);
Item* item = _player->GetItemByPos(srcbag, srcslot);
if (!item)
Item* pItem = _player->GetItemByPos(srcbag, srcslot);
if (!pItem)
return;
ItemPosCountVec dest;
InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, item, false);
InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
if (dest.size() == 1 && dest[0].pos == item->GetPos())
if (dest.size() == 1 && dest[0].pos == pItem->GetPos())
{
_player->SendEquipError(EQUIP_ERR_NONE, item, NULL);
_player->SendEquipError(EQUIP_ERR_NONE, pItem, NULL);
return;
}
_player->RemoveItem(srcbag, srcslot, true);
_player->ItemRemovedQuestCheck(item->GetEntry(), item->GetCount());
_player->BankItem(dest, item, true);
_player->ItemRemovedQuestCheck(pItem->GetEntry(), pItem->GetCount());
_player->BankItem(dest, pItem, true);
}
void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
@@ -950,36 +950,36 @@ void WorldSession::HandleAutoStoreBankItemOpcode(WorldPacket& recvPacket)
recvPacket >> srcbag >> srcslot;
sLog->outDebug(LOG_FILTER_NETWORKIO, "STORAGE: receive srcbag = %u, srcslot = %u", srcbag, srcslot);
Item* item = _player->GetItemByPos(srcbag, srcslot);
if (!item)
Item* pItem = _player->GetItemByPos(srcbag, srcslot);
if (!pItem)
return;
if (_player->IsBankPos(srcbag, srcslot)) // moving from bank to inventory
{
ItemPosCountVec dest;
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, item, false);
InventoryResult msg = _player->CanStoreItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
_player->RemoveItem(srcbag, srcslot, true);
_player->StoreItem(dest, item, true);
_player->ItemAddedQuestCheck(item->GetEntry(), item->GetCount());
_player->StoreItem(dest, pItem, true);
_player->ItemAddedQuestCheck(pItem->GetEntry(), pItem->GetCount());
}
else // moving from inventory to bank
{
ItemPosCountVec dest;
InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, item, false);
InventoryResult msg = _player->CanBankItem(NULL_BAG, NULL_SLOT, dest, pItem, false);
if (msg != EQUIP_ERR_OK)
{
_player->SendEquipError(msg, item, NULL);
_player->SendEquipError(msg, pItem, NULL);
return;
}
_player->RemoveItem(srcbag, srcslot, true);
_player->BankItem(dest, item, true);
_player->BankItem(dest, pItem, true);
}
}
+11 -11
View File
@@ -55,15 +55,15 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket & recv_data)
}
else if (IS_ITEM_GUID(lguid))
{
Item* item = player->GetItemByGuid(lguid);
Item* pItem = player->GetItemByGuid(lguid);
if (!item)
if (!pItem)
{
player->SendLootRelease(lguid);
return;
}
loot = &item->loot;
loot = &pItem->loot;
}
else if (IS_CORPSE_GUID(lguid))
{
@@ -357,29 +357,29 @@ void WorldSession::DoLootRelease(uint64 lguid)
}
else if (IS_ITEM_GUID(lguid))
{
Item* item = player->GetItemByGuid(lguid);
if (!item)
Item* pItem = player->GetItemByGuid(lguid);
if (!pItem)
return;
ItemTemplate const* proto = item->GetTemplate();
ItemTemplate const* proto = pItem->GetTemplate();
// destroy only 5 items from stack in case prospecting and milling
if (proto->Flags & (ITEM_PROTO_FLAG_PROSPECTABLE | ITEM_PROTO_FLAG_MILLABLE))
{
item->m_lootGenerated = false;
item->loot.clear();
pItem->m_lootGenerated = false;
pItem->loot.clear();
uint32 count = item->GetCount();
uint32 count = pItem->GetCount();
// >=5 checked in spell code, but will work for cheating cases also with removing from another stacks.
if (count > 5)
count = 5;
player->DestroyItemCount(item, count, true);
player->DestroyItemCount(pItem, count, true);
}
else
// FIXME: item must not be deleted in case not fully looted state. But this pre-request implement loot saving in DB at item save. Or cheating possible.
player->DestroyItem(item->GetBagSlot(), item->GetSlot(), true);
player->DestroyItem(pItem->GetBagSlot(), pItem->GetSlot(), true);
return; // item can be looted only single player
}
else
+19 -19
View File
@@ -86,53 +86,53 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
return;
}
Item* item = pUser->GetUseableItemByPos(bagIndex, slot);
if (!item)
Item* pItem = pUser->GetUseableItemByPos(bagIndex, slot);
if (!pItem)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return;
}
if (item->GetGUID() != itemGUID)
if (pItem->GetGUID() != itemGUID)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, NULL, NULL);
return;
}
sLog->outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, castCount: %u, spellId: %u, Item: %u, glyphIndex: %u, data length = %i", bagIndex, slot, castCount, spellId, item->GetEntry(), glyphIndex, (uint32)recvPacket.size());
sLog->outDetail("WORLD: CMSG_USE_ITEM packet, bagIndex: %u, slot: %u, castCount: %u, spellId: %u, Item: %u, glyphIndex: %u, data length = %i", bagIndex, slot, castCount, spellId, pItem->GetEntry(), glyphIndex, (uint32)recvPacket.size());
ItemTemplate const* proto = item->GetTemplate();
ItemTemplate const* proto = pItem->GetTemplate();
if (!proto)
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return;
}
// some item classes can be used only in equipped state
if (proto->InventoryType != INVTYPE_NON_EQUIP && !item->IsEquipped())
if (proto->InventoryType != INVTYPE_NON_EQUIP && !pItem->IsEquipped())
{
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, item, NULL);
pUser->SendEquipError(EQUIP_ERR_ITEM_NOT_FOUND, pItem, NULL);
return;
}
InventoryResult msg = pUser->CanUseItem(item);
InventoryResult msg = pUser->CanUseItem(pItem);
if (msg != EQUIP_ERR_OK)
{
pUser->SendEquipError(msg, item, NULL);
pUser->SendEquipError(msg, pItem, NULL);
return;
}
// only allow conjured consumable, bandage, poisons (all should have the 2^21 item flag set in DB)
if (proto->Class == ITEM_CLASS_CONSUMABLE && !(proto->Flags & ITEM_PROTO_FLAG_USEABLE_IN_ARENA) && pUser->InArena())
{
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, item, NULL);
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, pItem, NULL);
return;
}
// don't allow items banned in arena
if (proto->Flags & ITEM_PROTO_FLAG_NOT_USEABLE_IN_ARENA && pUser->InArena())
{
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, item, NULL);
pUser->SendEquipError(EQUIP_ERR_NOT_DURING_ARENA_MATCH, pItem, NULL);
return;
}
@@ -144,7 +144,7 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
{
if (!spellInfo->CanBeUsedInCombat())
{
pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, item, NULL);
pUser->SendEquipError(EQUIP_ERR_NOT_IN_COMBAT, pItem, NULL);
return;
}
}
@@ -152,12 +152,12 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
}
// check also BIND_WHEN_PICKED_UP and BIND_QUEST_ITEM for .additem or .additemset case by GM (not binded at adding to inventory)
if (item->GetTemplate()->Bonding == BIND_WHEN_USE || item->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || item->GetTemplate()->Bonding == BIND_QUEST_ITEM)
if (pItem->GetTemplate()->Bonding == BIND_WHEN_USE || pItem->GetTemplate()->Bonding == BIND_WHEN_PICKED_UP || pItem->GetTemplate()->Bonding == BIND_QUEST_ITEM)
{
if (!item->IsSoulBound())
if (!pItem->IsSoulBound())
{
item->SetState(ITEM_CHANGED, pUser);
item->SetBinding(true);
pItem->SetState(ITEM_CHANGED, pUser);
pItem->SetBinding(true);
}
}
@@ -166,10 +166,10 @@ void WorldSession::HandleUseItemOpcode(WorldPacket& recvPacket)
HandleClientCastFlags(recvPacket, castFlags, targets);
// Note: If script stop casting it must send appropriate data to client to prevent stuck item in gray state.
if (!sScriptMgr->OnItemUse(pUser, item, targets))
if (!sScriptMgr->OnItemUse(pUser, pItem, targets))
{
// no script or script not process request by self
pUser->CastItemUseSpell(item, targets, castCount, glyphIndex);
pUser->CastItemUseSpell(pItem, targets, castCount, glyphIndex);
}
}