diff options
| author | Azazel <azazel.kon@gmail.com> | 2011-03-18 15:58:08 +0600 |
|---|---|---|
| committer | Azazel <azazel.kon@gmail.com> | 2011-03-18 15:58:08 +0600 |
| commit | e49b5b44d6588b04ba7176f2814f4515006ba5ef (patch) | |
| tree | 29cc1c0a1ece7b596d909a94ae8ce8b015af3fc1 /src/server/scripts | |
| parent | 90a3fee2329571863e907315fc6b5bfc7d1c96f5 (diff) | |
Core/Cleanup: remove C-style cast to (Bag*):
* add ToBag() methods for Item class;
* add GetBagByPos() method for Player class.
Diffstat (limited to 'src/server/scripts')
| -rw-r--r-- | src/server/scripts/Commands/cs_debug.cpp | 24 |
1 files changed, 9 insertions, 15 deletions
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); |
