diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-09-17 10:55:20 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-09-17 10:55:20 +0300 |
commit | fd050698f74b5dc7a9867bc93ba6b7c65ef2462f (patch) | |
tree | 246017e7d1b399e60a5d7b97a7106cd75587b88f | |
parent | 4228763829f71ec4db50ed185483d7707c5e47eb (diff) | |
download | manaverse-fd050698f74b5dc7a9867bc93ba6b7c65ef2462f.tar.gz manaverse-fd050698f74b5dc7a9867bc93ba6b7c65ef2462f.tar.bz2 manaverse-fd050698f74b5dc7a9867bc93ba6b7c65ef2462f.tar.xz manaverse-fd050698f74b5dc7a9867bc93ba6b7c65ef2462f.zip |
Remove getter for inventoryHandler.
-rw-r--r-- | src/being/localplayer.cpp | 2 | ||||
-rw-r--r-- | src/being/playerinfo.cpp | 22 | ||||
-rw-r--r-- | src/beingequipbackend.cpp | 2 | ||||
-rw-r--r-- | src/client.cpp | 4 | ||||
-rw-r--r-- | src/gui/dialogsmanager.cpp | 4 | ||||
-rw-r--r-- | src/gui/popups/popupmenu.cpp | 18 | ||||
-rw-r--r-- | src/gui/widgets/itemcontainer.cpp | 4 | ||||
-rw-r--r-- | src/gui/windows/inventorywindow.cpp | 16 | ||||
-rw-r--r-- | src/gui/windows/itemamountwindow.cpp | 6 | ||||
-rw-r--r-- | src/inventory.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/playerhandler.cpp | 2 | ||||
-rw-r--r-- | src/net/inventoryhandler.h | 2 | ||||
-rw-r--r-- | src/net/net.cpp | 6 | ||||
-rw-r--r-- | src/net/net.h | 2 | ||||
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 2 |
15 files changed, 45 insertions, 49 deletions
diff --git a/src/being/localplayer.cpp b/src/being/localplayer.cpp index aa92cf6d7..f01a3171a 100644 --- a/src/being/localplayer.cpp +++ b/src/being/localplayer.cpp @@ -2925,7 +2925,7 @@ void LocalPlayer::imitateOutfit(const Being *const player, else { // logger->log("have unequip %d", sprite); - const int equipmentSlot = Net::getInventoryHandler() + const int equipmentSlot = inventoryHandler ->convertFromServerSlot(sprite); // logger->log("equipmentSlot: " + toString(equipmentSlot)); if (equipmentSlot == ItemSlot::PROJECTILE_SLOT) diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp index b84fb72a9..3768b6e35 100644 --- a/src/being/playerinfo.cpp +++ b/src/being/playerinfo.cpp @@ -188,7 +188,7 @@ Inventory *getInventory() Inventory *getStorageInventory() { - return Net::getInventoryHandler()->getStorage(); + return inventoryHandler->getStorage(); } void clearInventory() @@ -233,21 +233,21 @@ void equipItem(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); - Net::getInventoryHandler()->equipItem(item); + inventoryHandler->equipItem(item); } void unequipItem(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); - Net::getInventoryHandler()->unequipItem(item); + inventoryHandler->unequipItem(item); } void useItem(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); - Net::getInventoryHandler()->useItem(item); + inventoryHandler->useItem(item); } void useEquipItem(const Item *const item, const bool sfx) @@ -260,20 +260,20 @@ void useEquipItem(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); - Net::getInventoryHandler()->unequipItem(item); + inventoryHandler->unequipItem(item); } else { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); - Net::getInventoryHandler()->equipItem(item); + inventoryHandler->equipItem(item); } } else { if (mProtectedItems.find(item->getId()) == mProtectedItems.end()) { - Net::getInventoryHandler()->useItem(item); + inventoryHandler->useItem(item); if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); } @@ -291,13 +291,13 @@ void useEquipItem2(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::UNEQUIP); - Net::getInventoryHandler()->unequipItem(item); + inventoryHandler->unequipItem(item); } else { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::EQUIP); - Net::getInventoryHandler()->equipItem(item); + inventoryHandler->equipItem(item); } } else @@ -306,7 +306,7 @@ void useEquipItem2(const Item *const item, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::USE); - Net::getInventoryHandler()->useItem(item); + inventoryHandler->useItem(item); } } } @@ -318,7 +318,7 @@ void dropItem(const Item *const item, const int amount, const bool sfx) { if (sfx) ItemSoundManager::playSfx(item, ItemSoundEvent::DROP); - Net::getInventoryHandler()->dropItem(item, amount); + inventoryHandler->dropItem(item, amount); } } diff --git a/src/beingequipbackend.cpp b/src/beingequipbackend.cpp index 5284a4d84..e6b618ade 100644 --- a/src/beingequipbackend.cpp +++ b/src/beingequipbackend.cpp @@ -38,7 +38,7 @@ BeingEquipBackend::BeingEquipBackend(Being *const being) for (size_t f = 0; f < sz; f ++) { - const int idx = Net::getInventoryHandler()-> + const int idx = inventoryHandler-> convertFromServerSlot(static_cast<int>(f)); const int id = being->mSpriteIDs[f]; if (id > 0 && idx >= 0 && idx < EQUIPMENT_SIZE) diff --git a/src/client.cpp b/src/client.cpp index 63f5f1852..473162b93 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -645,8 +645,8 @@ void Client::gameClear() delete2(popupManager); delete2(gui); - if (Net::getInventoryHandler()) - Net::getInventoryHandler()->clear(); + if (inventoryHandler) + inventoryHandler->clear(); if (logger) logger->log1("Quitting3"); diff --git a/src/gui/dialogsmanager.cpp b/src/gui/dialogsmanager.cpp index dd5cfee6e..6af34bef4 100644 --- a/src/gui/dialogsmanager.cpp +++ b/src/gui/dialogsmanager.cpp @@ -55,8 +55,8 @@ void DialogsManager::closeDialogs() BuySellDialog::closeAll(); NpcDialog::closeAll(); SellDialog::closeAll(); - if (Net::getInventoryHandler()) - Net::getInventoryHandler()->closeStorage(); + if (inventoryHandler) + inventoryHandler->closeStorage(); if (deathNotice) { deathNotice->scheduleDelete(); diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp index 8e9939991..1c4722419 100644 --- a/src/gui/popups/popupmenu.cpp +++ b/src/gui/popups/popupmenu.cpp @@ -1191,25 +1191,25 @@ void PopupMenu::handleLink(const std::string &link, int cnt = 10; if (cnt > mItem->getQuantity()) cnt = mItem->getQuantity(); - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, mItem->getInvIndex(), cnt, Inventory::STORAGE); } else if (link == "store half" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, mItem->getInvIndex(), mItem->getQuantity() / 2, Inventory::STORAGE); } else if (link == "store all-1" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, mItem->getInvIndex(), mItem->getQuantity() - 1, Inventory::STORAGE); } else if (link == "store all" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, mItem->getInvIndex(), mItem->getQuantity(), Inventory::STORAGE); } @@ -1259,25 +1259,25 @@ void PopupMenu::handleLink(const std::string &link, int cnt = 10; if (cnt > mItem->getQuantity()) cnt = mItem->getQuantity(); - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, mItem->getInvIndex(), cnt, Inventory::INVENTORY); } else if (link == "retrieve half" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, mItem->getInvIndex(), mItem->getQuantity() / 2, Inventory::INVENTORY); } else if (link == "retrieve all-1" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, mItem->getInvIndex(), mItem->getQuantity() - 1, Inventory::INVENTORY); } else if (link == "retrieve all" && mItem) { - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, mItem->getInvIndex(), mItem->getQuantity(), Inventory::INVENTORY); } @@ -2856,7 +2856,7 @@ void PopupMenu::addUseDrop(const Item *const item, const bool isProtected) } } - if (Net::getInventoryHandler()->canSplit(item)) + if (inventoryHandler->canSplit(item)) { // TRANSLATORS: popup menu item // TRANSLATORS: split items diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp index d3a57a71b..aa8966620 100644 --- a/src/gui/widgets/itemcontainer.cpp +++ b/src/gui/widgets/itemcontainer.cpp @@ -497,7 +497,7 @@ void ItemContainer::mouseReleased(MouseEvent &event) return; if (index == mSelectedIndex || mSelectedIndex == -1) return; - Net::getInventoryHandler()->moveItem(mSelectedIndex, index); + inventoryHandler->moveItem(mSelectedIndex, index); selectNone(); } else if (mInventory) @@ -570,7 +570,7 @@ void ItemContainer::mouseReleased(MouseEvent &event) { if (srcContainer != -1) { // inventory <--> storage - Net::getInventoryHandler()->moveItem2(srcContainer, + inventoryHandler->moveItem2(srcContainer, item->getInvIndex(), item->getQuantity(), dstContainer); } diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp index c1bdafe7b..e44f9e087 100644 --- a/src/gui/windows/inventorywindow.cpp +++ b/src/gui/windows/inventorywindow.cpp @@ -369,7 +369,7 @@ void InventoryWindow::action(const ActionEvent &event) { if (isStorageActive()) { - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, item->getInvIndex(), item->getQuantity(), Inventory::STORAGE); } @@ -474,7 +474,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event) } else { - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, item->getInvIndex(), item->getQuantity(), Inventory::STORAGE); } @@ -488,7 +488,7 @@ void InventoryWindow::mouseClicked(MouseEvent &event) } else { - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, item->getInvIndex(), item->getQuantity(), Inventory::INVENTORY); } @@ -588,7 +588,7 @@ void InventoryWindow::valueChanged(const SelectionEvent &event A_UNUSED) Item *const item = mItems->getSelectedItem(); - if (mSplit && item && Net::getInventoryHandler()-> + if (mSplit && item && inventoryHandler-> canSplit(mItems->getSelectedItem())) { ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit, @@ -642,7 +642,7 @@ void InventoryWindow::updateButtons(const Item *item) if (mSplitButton) { - if (Net::getInventoryHandler()->canSplit(item)) + if (inventoryHandler->canSplit(item)) mSplitButton->setEnabled(true); else mSplitButton->setEnabled(false); @@ -663,10 +663,10 @@ void InventoryWindow::close() } else { - if (Net::getInventoryHandler()) + if (inventoryHandler) { - Net::getInventoryHandler()->closeStorage(Inventory::STORAGE); - Net::getInventoryHandler()->forgotStorage(); + inventoryHandler->closeStorage(Inventory::STORAGE); + inventoryHandler->forgotStorage(); } scheduleDelete(); } diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp index d7760444a..86cfd973c 100644 --- a/src/gui/windows/itemamountwindow.cpp +++ b/src/gui/windows/itemamountwindow.cpp @@ -67,14 +67,14 @@ void ItemAmountWindow::finish(const Item *const item, PlayerInfo::dropItem(item, amount, true); break; case ItemSplit: - Net::getInventoryHandler()->splitItem(item, amount); + inventoryHandler->splitItem(item, amount); break; case StoreAdd: - Net::getInventoryHandler()->moveItem2(Inventory::INVENTORY, + inventoryHandler->moveItem2(Inventory::INVENTORY, item->getInvIndex(), amount, Inventory::STORAGE); break; case StoreRemove: - Net::getInventoryHandler()->moveItem2(Inventory::STORAGE, + inventoryHandler->moveItem2(Inventory::STORAGE, item->getInvIndex(), amount, Inventory::INVENTORY); break; case ShopBuyAdd: diff --git a/src/inventory.cpp b/src/inventory.cpp index 4248a9a73..b4a30d0a8 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -57,7 +57,7 @@ Inventory::Inventory(const int type, const int size1) : mInventoryListeners(), mType(type), mSize(size1 == -1 ? static_cast<unsigned>( - Net::getInventoryHandler()->getSize(type)) + inventoryHandler->getSize(type)) : static_cast<unsigned>(size1)), mItems(new Item*[mSize]), mUsed(0) diff --git a/src/net/eathena/playerhandler.cpp b/src/net/eathena/playerhandler.cpp index d31fd5f0d..fd17105c9 100644 --- a/src/net/eathena/playerhandler.cpp +++ b/src/net/eathena/playerhandler.cpp @@ -176,7 +176,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const MessageOut outMsg(CMSG_ITEM_PICKUP); outMsg.writeInt32(floorItem->getId()); EAthena::InventoryHandler *const handler = - static_cast<EAthena::InventoryHandler*>(Net::getInventoryHandler()); + static_cast<EAthena::InventoryHandler*>(inventoryHandler); if (handler) handler->pushPickup(floorItem->getId()); } diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h index 7caad3994..ce134f90c 100644 --- a/src/net/inventoryhandler.h +++ b/src/net/inventoryhandler.h @@ -86,4 +86,6 @@ class InventoryHandler notfinal } // namespace Net +extern Net::InventoryHandler *inventoryHandler; + #endif // NET_INVENTORYHANDLER_H diff --git a/src/net/net.cpp b/src/net/net.cpp index feed36ea0..ed81a42ec 100644 --- a/src/net/net.cpp +++ b/src/net/net.cpp @@ -50,6 +50,7 @@ namespace Net class GameHandler; class GeneralHandler; class GuildHandler; + class InventoryHandler; } Net::AdminHandler *adminHandler = nullptr; @@ -75,11 +76,6 @@ Net::CashShopHandler *cashShopHandler = nullptr; Net::FamilyHandler *familyHandler = nullptr; Net::BankHandler *bankHandler = nullptr; -Net::InventoryHandler *Net::getInventoryHandler() -{ - return inventoryHandler; -} - Net::LoginHandler *Net::getLoginHandler() { return loginHandler; diff --git a/src/net/net.h b/src/net/net.h index 71cbcc21e..baee5e9b2 100644 --- a/src/net/net.h +++ b/src/net/net.h @@ -36,7 +36,6 @@ namespace Net { -class InventoryHandler; class LoginHandler; class MailHandler; class NpcHandler; @@ -47,7 +46,6 @@ class SkillHandler; class TradeHandler; class ServerFeatures; -InventoryHandler *getInventoryHandler() A_WARN_UNUSED; LoginHandler *getLoginHandler() A_WARN_UNUSED; NpcHandler *getNpcHandler() A_WARN_UNUSED; PartyHandler *getPartyHandler() A_WARN_UNUSED; diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index c2791e0d9..baf8e43a4 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -186,7 +186,7 @@ void PlayerHandler::pickUp(const FloorItem *const floorItem) const MessageOut outMsg(CMSG_ITEM_PICKUP); outMsg.writeInt32(floorItem->getId()); TmwAthena::InventoryHandler *const handler = - static_cast<TmwAthena::InventoryHandler*>(Net::getInventoryHandler()); + static_cast<TmwAthena::InventoryHandler*>(inventoryHandler); if (handler) handler->pushPickup(floorItem->getId()); } |