Core/Cleanup: remove C-style cast to (Bag*):

* add ToBag() methods for Item class;
* add GetBagByPos() method for Player class.
This commit is contained in:
Azazel
2011-03-18 15:58:08 +06:00
parent 90a3fee232
commit e49b5b44d6
9 changed files with 156 additions and 183 deletions
@@ -188,7 +188,7 @@ void WorldSession::HandleAuctionSellItem(WorldPacket & recv_data)
return;
}
if (it->IsBag() && !((Bag*)it)->IsEmpty())
if (!it->IsNotEmptyBag())
{
SendAuctionCommandResult(0, AUCTION_SELL_ITEM, AUCTION_INTERNAL_ERROR);
return;
@@ -516,7 +516,7 @@ void WorldSession::HandleSellItemOpcode(WorldPacket & recv_data)
}
// prevent sell non empty bag by drag-and-drop at vendor's item list
if (pItem->IsBag() && !((Bag*)pItem)->IsEmpty())
if (pItem->IsNotEmptyBag())
{
_player->SendSellError(SELL_ERR_CANT_SELL_ITEM, pCreature, itemguid, 0);
return;
@@ -668,7 +668,7 @@ void WorldSession::HandleBuyItemInSlotOpcode(WorldPacket & recv_data)
{
for (int i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; ++i)
{
if (Bag *pBag = (Bag*)_player->GetItemByPos(INVENTORY_SLOT_BAG_0,i))
if (Bag* pBag = _player->GetBagByPos(i))
{
if (bagguid == pBag->GetGUID())
{
@@ -219,7 +219,7 @@ void WorldSession::HandleSendMail(WorldPacket & recv_data)
return;
}
if (item->IsBag() && !((Bag*)item)->IsEmpty())
if (item->IsNotEmptyBag())
{
pl->SendMailResult(0, MAIL_SEND, MAIL_ERR_EQUIP_ERROR, EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS);
return;