From e49b5b44d6588b04ba7176f2814f4515006ba5ef Mon Sep 17 00:00:00 2001 From: Azazel Date: Fri, 18 Mar 2011 15:58:08 +0600 Subject: Core/Cleanup: remove C-style cast to (Bag*): * add ToBag() methods for Item class; * add GetBagByPos() method for Player class. --- src/server/scripts/Commands/cs_debug.cpp | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/server/scripts') diff --git a/src/server/scripts/Commands/cs_debug.cpp b/src/server/scripts/Commands/cs_debug.cpp index 7fdd242f561..c6936727885 100644 --- a/src/server/scripts/Commands/cs_debug.cpp +++ b/src/server/scripts/Commands/cs_debug.cpp @@ -516,22 +516,17 @@ public: if (i >= BUYBACK_SLOT_START && i < BUYBACK_SLOT_END) continue; - Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i); - if (!item) continue; - if (!item->IsBag()) - { - if (item->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); - } - else + if (Item *item = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { - Bag *bag = (Bag*)item; - for (uint8 j = 0; j < bag->GetBagSize(); ++j) + if (Bag* bag = item->ToBag()) { - Item* item2 = bag->GetItemByPos(j); - if (item2 && item2->GetState() == state) - handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); + for (uint8 j = 0; j < bag->GetBagSize(); ++j) + if (Item* item2 = bag->GetItemByPos(j)) + if (item2->GetState() == state) + handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item2->GetSlot(), item2->GetGUIDLow(), GUID_LOPART(item2->GetOwnerGUID())); } + else if (item->GetState() == state) + handler->PSendSysMessage("bag: 255 slot: %d guid: %d owner: %d", item->GetSlot(), item->GetGUIDLow(), GUID_LOPART(item->GetOwnerGUID())); } } } @@ -619,9 +614,8 @@ public: error = true; continue; } - if (item->IsBag()) + if (Bag* bag = item->ToBag()) { - Bag *bag = (Bag*)item; for (uint8 j = 0; j < bag->GetBagSize(); ++j) { Item* item2 = bag->GetItemByPos(j); -- cgit v1.2.3