summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-11-16 22:17:15 +0300
committerAndrei Karas <akaras@inbox.ru>2015-11-16 22:17:15 +0300
commit5e8e53f6e795a84ab5ca6cfe0d08672878044707 (patch)
tree23f5a196c6a288ef52cea2742b02ddbc52b2db61 /src
parent0c063cf5b45a843485fe3343e5fb79a40141f88c (diff)
downloadmv-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.gz
mv-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.bz2
mv-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.xz
mv-5e8e53f6e795a84ab5ca6cfe0d08672878044707.zip
Convert InventoryType enum into strong typed.
Diffstat (limited to 'src')
-rw-r--r--src/actions/actions.cpp29
-rw-r--r--src/being/playerinfo.cpp4
-rw-r--r--src/enums/inventorytype.h26
-rw-r--r--src/gui/popups/popupmenu.cpp18
-rw-r--r--src/gui/popups/popupmenu.h2
-rw-r--r--src/gui/widgets/itemcontainer.cpp65
-rw-r--r--src/gui/windows/equipmentwindow.cpp2
-rw-r--r--src/gui/windows/inventorywindow.cpp117
-rw-r--r--src/gui/windows/itemamountwindow.cpp16
-rw-r--r--src/gui/windows/maileditwindow.cpp2
-rw-r--r--src/gui/windows/ministatuswindow.cpp2
-rw-r--r--src/gui/windows/npcdialog.cpp2
-rw-r--r--src/gui/windows/tradewindow.cpp4
-rw-r--r--src/inventory.cpp18
-rw-r--r--src/inventory.h8
-rw-r--r--src/net/ea/inventoryhandler.cpp10
-rw-r--r--src/net/ea/inventoryhandler.h3
-rw-r--r--src/net/ea/inventoryrecv.cpp2
-rw-r--r--src/net/eathena/inventoryhandler.cpp24
-rw-r--r--src/net/eathena/inventoryhandler.h6
-rw-r--r--src/net/inventoryhandler.h10
-rw-r--r--src/net/tmwa/inventoryhandler.cpp16
-rw-r--r--src/net/tmwa/inventoryhandler.h6
23 files changed, 203 insertions, 189 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp
index 288c866f0..b76b64108 100644
--- a/src/actions/actions.cpp
+++ b/src/actions/actions.cpp
@@ -236,18 +236,19 @@ static Being *findBeing(const std::string &name, const bool npc)
return being;
}
-static Item *getItemByInvIndex(const InputEvent &event, const int invType)
+static Item *getItemByInvIndex(const InputEvent &event,
+ const InventoryTypeT invType)
{
const int index = atoi(event.args.c_str());
const Inventory *inv = nullptr;
switch (invType)
{
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
inv = PlayerInfo::getStorageInventory();
break;
default:
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
inv = PlayerInfo::getInventory();
break;
}
@@ -258,7 +259,7 @@ static Item *getItemByInvIndex(const InputEvent &event, const int invType)
static int getAmountFromEvent(const InputEvent &event,
Item *&item0,
- const int invType)
+ const InventoryTypeT invType)
{
Item *const item = getItemByInvIndex(event, invType);
item0 = item;
@@ -453,7 +454,7 @@ impHandler(dropItemId)
impHandler(dropItemInv)
{
- Item *const item = getItemByInvIndex(event, InventoryType::INVENTORY);
+ Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
ItemAmountWindow::showWindow(ItemAmountWindow::ItemDrop,
@@ -479,7 +480,7 @@ impHandler(dropItemIdAll)
impHandler(dropItemInvAll)
{
- Item *const item = getItemByInvIndex(event, InventoryType::INVENTORY);
+ Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
if (item && !PlayerInfo::isItemProtected(item->getId()))
PlayerInfo::dropItem(item, item->getQuantity(), Sfx_true);
return true;
@@ -1518,7 +1519,7 @@ impHandler(useItem)
impHandler(useItemInv)
{
- Item *const item = getItemByInvIndex(event, InventoryType::INVENTORY);
+ Item *const item = getItemByInvIndex(event, InventoryType::Inventory);
PlayerInfo::useEquipItem(item, Sfx_true);
return true;
}
@@ -1527,17 +1528,17 @@ impHandler(invToStorage)
{
Item *item = nullptr;
const int amount = getAmountFromEvent(event, item,
- InventoryType::INVENTORY);
+ InventoryType::Inventory);
if (!item)
return true;
if (amount)
{
if (inventoryHandler)
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
+ inventoryHandler->moveItem2(InventoryType::Inventory,
item->getInvIndex(),
amount,
- InventoryType::STORAGE);
+ InventoryType::Storage);
}
}
else
@@ -1552,7 +1553,7 @@ impHandler(tradeAdd)
{
Item *item = nullptr;
const int amount = getAmountFromEvent(event, item,
- InventoryType::INVENTORY);
+ InventoryType::Inventory);
if (!item || PlayerInfo::isItemProtected(item->getId()))
return true;
@@ -1572,15 +1573,15 @@ impHandler(tradeAdd)
impHandler(storageToInv)
{
Item *item = nullptr;
- const int amount = getAmountFromEvent(event, item, InventoryType::STORAGE);
+ const int amount = getAmountFromEvent(event, item, InventoryType::Storage);
if (amount)
{
if (inventoryHandler && item)
{
- inventoryHandler->moveItem2(InventoryType::STORAGE,
+ inventoryHandler->moveItem2(InventoryType::Storage,
item->getInvIndex(),
amount,
- InventoryType::INVENTORY);
+ InventoryType::Inventory);
}
}
else
diff --git a/src/being/playerinfo.cpp b/src/being/playerinfo.cpp
index b3c3f5bb4..a665001ce 100644
--- a/src/being/playerinfo.cpp
+++ b/src/being/playerinfo.cpp
@@ -466,10 +466,10 @@ void stateChange(const State state)
{
if (!mInventory)
{
- mInventory = new Inventory(InventoryType::INVENTORY);
+ mInventory = new Inventory(InventoryType::Inventory);
mEquipment = new Equipment();
#ifdef EATHENA_SUPPORT
- mCartInventory = new Inventory(InventoryType::CART);
+ mCartInventory = new Inventory(InventoryType::Cart);
#endif
}
}
diff --git a/src/enums/inventorytype.h b/src/enums/inventorytype.h
index fe24864d3..cd4ff4732 100644
--- a/src/enums/inventorytype.h
+++ b/src/enums/inventorytype.h
@@ -23,21 +23,21 @@
#ifndef ENUMS_INVENTORYTYPE_H
#define ENUMS_INVENTORYTYPE_H
-namespace InventoryType
+#include "enums/simpletypes/enumdefines.h"
+
+enumStart(InventoryType)
{
- enum Type
- {
- INVENTORY = 0,
- STORAGE,
- TRADE,
- NPC,
+ Inventory = 0,
+ Storage,
+ Trade,
+ Npc,
#ifdef EATHENA_SUPPORT
- CART,
- VENDING,
- MAIL,
+ Cart,
+ Vending,
+ Mail,
#endif
- TYPE_END
- };
-} // namespace InventoryType
+ TypeEnd
+}
+enumEnd(InventoryType);
#endif // ENUMS_INVENTORYTYPE_H
diff --git a/src/gui/popups/popupmenu.cpp b/src/gui/popups/popupmenu.cpp
index e18906052..f55d8cb22 100644
--- a/src/gui/popups/popupmenu.cpp
+++ b/src/gui/popups/popupmenu.cpp
@@ -1625,7 +1625,7 @@ void PopupMenu::handleLink(const std::string &link,
void PopupMenu::showPopup(Window *const parent,
const int x, const int y,
Item *const item,
- const InventoryType::Type type)
+ const InventoryTypeT type)
{
if (!item)
return;
@@ -1644,7 +1644,7 @@ void PopupMenu::showPopup(Window *const parent,
switch (type)
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
if (tradeWindow && tradeWindow->isWindowVisible() && !isProtected)
{
// TRANSLATORS: popup menu item
@@ -1706,7 +1706,7 @@ void PopupMenu::showPopup(Window *const parent,
addUseDrop(item, isProtected);
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
// TRANSLATORS: popup menu item
// TRANSLATORS: get item from storage
mBrowserBox->addRow("/storagetoinv 'INVINDEX'", _("Retrieve"));
@@ -1734,14 +1734,14 @@ void PopupMenu::showPopup(Window *const parent,
}
break;
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Cart:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
break;
}
diff --git a/src/gui/popups/popupmenu.h b/src/gui/popups/popupmenu.h
index e8e0ddeb4..d37a29f56 100644
--- a/src/gui/popups/popupmenu.h
+++ b/src/gui/popups/popupmenu.h
@@ -96,7 +96,7 @@ class PopupMenu final : public Popup, public LinkHandler
void showPopup(Window *const parent,
const int x, const int y,
Item *const item,
- const InventoryType::Type type);
+ const InventoryTypeT type);
void showPopup(const int x, const int y, Button *const button);
diff --git a/src/gui/widgets/itemcontainer.cpp b/src/gui/widgets/itemcontainer.cpp
index ac65a024f..108dc8638 100644
--- a/src/gui/widgets/itemcontainer.cpp
+++ b/src/gui/widgets/itemcontainer.cpp
@@ -578,31 +578,31 @@ void ItemContainer::mousePressed(MouseEvent &event)
DragDropSource src = DragDropSource::Empty;
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
src = DragDropSource::Inventory;
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
src = DragDropSource::Storage;
break;
- case InventoryType::TRADE:
+ case InventoryType::Trade:
src = DragDropSource::Trade;
break;
- case InventoryType::NPC:
+ case InventoryType::Npc:
src = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
src = DragDropSource::Cart;
break;
- case InventoryType::MAIL:
+ case InventoryType::Mail:
src = DragDropSource::Mail;
break;
#endif
default:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
+ case InventoryType::Vending:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
if (mSelectedIndex == index && mClicks != 2)
@@ -685,57 +685,57 @@ void ItemContainer::mouseReleased(MouseEvent &event)
DragDropSource dst = DragDropSource::Empty;
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
dst = DragDropSource::Inventory;
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
dst = DragDropSource::Storage;
break;
- case InventoryType::TRADE:
+ case InventoryType::Trade:
dst = DragDropSource::Trade;
break;
- case InventoryType::NPC:
+ case InventoryType::Npc:
dst = DragDropSource::Npc;
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::MAIL:
+ case InventoryType::Mail:
dst = DragDropSource::Mail;
break;
- case InventoryType::CART:
+ case InventoryType::Cart:
dst = DragDropSource::Cart;
break;
#endif
default:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
+ case InventoryType::Vending:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
- int srcContainer = -1;
- int dstContainer = -1;
+ InventoryTypeT srcContainer = InventoryType::TypeEnd;
+ InventoryTypeT dstContainer = InventoryType::TypeEnd;
bool checkProtection(false);
Inventory *inventory = nullptr;
if (src == DragDropSource::Inventory
&& dst == DragDropSource::Storage)
{
- srcContainer = InventoryType::INVENTORY;
- dstContainer = InventoryType::STORAGE;
+ srcContainer = InventoryType::Inventory;
+ dstContainer = InventoryType::Storage;
inventory = PlayerInfo::getInventory();
}
else if (src == DragDropSource::Storage
&& dst == DragDropSource::Inventory)
{
- srcContainer = InventoryType::STORAGE;
- dstContainer = InventoryType::INVENTORY;
+ srcContainer = InventoryType::Storage;
+ dstContainer = InventoryType::Inventory;
inventory = PlayerInfo::getStorageInventory();
}
#ifdef EATHENA_SUPPORT
if (src == DragDropSource::Inventory
&& dst == DragDropSource::Cart)
{
- srcContainer = InventoryType::INVENTORY;
- dstContainer = InventoryType::CART;
+ srcContainer = InventoryType::Inventory;
+ dstContainer = InventoryType::Cart;
inventory = PlayerInfo::getInventory();
}
if (src == DragDropSource::Inventory
@@ -753,22 +753,22 @@ void ItemContainer::mouseReleased(MouseEvent &event)
else if (src == DragDropSource::Cart
&& dst == DragDropSource::Inventory)
{
- srcContainer = InventoryType::CART;
- dstContainer = InventoryType::INVENTORY;
+ srcContainer = InventoryType::Cart;
+ dstContainer = InventoryType::Inventory;
inventory = PlayerInfo::getCartInventory();
}
else if (src == DragDropSource::Cart
&& dst == DragDropSource::Storage)
{
- srcContainer = InventoryType::CART;
- dstContainer = InventoryType::STORAGE;
+ srcContainer = InventoryType::Cart;
+ dstContainer = InventoryType::Storage;
inventory = PlayerInfo::getCartInventory();
}
else if (src == DragDropSource::Storage
&& dst == DragDropSource::Cart)
{
- srcContainer = InventoryType::STORAGE;
- dstContainer = InventoryType::CART;
+ srcContainer = InventoryType::Storage;
+ dstContainer = InventoryType::Cart;
inventory = PlayerInfo::getStorageInventory();
}
#endif
@@ -865,10 +865,11 @@ void ItemContainer::mouseReleased(MouseEvent &event)
const Item *const item = inventory->getItem(dragDrop.getTag());
if (item)
{
- if (srcContainer != -1)
+ if (srcContainer != InventoryType::TypeEnd)
{ // inventory <--> storage, cart
inventoryHandler->moveItem2(srcContainer,
- item->getInvIndex(), item->getQuantity(),
+ item->getInvIndex(),
+ item->getQuantity(),
dstContainer);
}
else
diff --git a/src/gui/windows/equipmentwindow.cpp b/src/gui/windows/equipmentwindow.cpp
index 4bd285b8f..b3accf9ed 100644
--- a/src/gui/windows/equipmentwindow.cpp
+++ b/src/gui/windows/equipmentwindow.cpp
@@ -489,7 +489,7 @@ void EquipmentWindow::mousePressed(MouseEvent& event)
else
{
popupMenu->showPopup(this, mx, my, item,
- InventoryType::INVENTORY);
+ InventoryType::Inventory);
}
return;
}
diff --git a/src/gui/windows/inventorywindow.cpp b/src/gui/windows/inventorywindow.cpp
index 6f1cac84d..4770ef69a 100644
--- a/src/gui/windows/inventorywindow.cpp
+++ b/src/gui/windows/inventorywindow.cpp
@@ -117,24 +117,24 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
setWindowName(inventory->getName());
switch (inventory->getType())
{
- case InventoryType::INVENTORY:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Inventory:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
mSortDropDown->setSelected(config.getIntValue(
"inventorySortOrder"));
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
mSortDropDown->setSelected(config.getIntValue(
"storageSortOrder"));
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
mSortDropDown->setSelected(config.getIntValue(
"cartSortOrder"));
break;
@@ -151,7 +151,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
if (setupWindow &&
inventory &&
- inventory->getType() != InventoryType::STORAGE)
+ inventory->getType() != InventoryType::Storage)
{
setupWindow->registerWindowForReset(this);
}
@@ -193,7 +193,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
{
// TRANSLATORS: inventory button
const std::string equip = _("Equip");
@@ -257,7 +257,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
break;
}
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
{
// TRANSLATORS: storage button
mStoreButton = new Button(this, _("Store"), "store", this);
@@ -281,7 +281,7 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
}
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
{
// TRANSLATORS: storage button
mStoreButton = new Button(this, _("Store"), "store", this);
@@ -313,13 +313,13 @@ InventoryWindow::InventoryWindow(Inventory *const inventory) :
#endif
default:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
};
@@ -351,7 +351,7 @@ void InventoryWindow::postInit()
mItems->setSortType(mSortDropDown->getSelected());
widgetResized(Event(nullptr));
- if (mInventory && mInventory->getType() == InventoryType::STORAGE)
+ if (mInventory && mInventory->getType() == InventoryType::Storage)
setVisible(Visible_true);
}
@@ -373,24 +373,24 @@ void InventoryWindow::storeSortOrder() const
{
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Inventory:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
config.setValue("inventorySortOrder",
mSortDropDown->getSelected());
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
config.setValue("storageSortOrder",
mSortDropDown->getSelected());
break;
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
config.setValue("cartSortOrder",
mSortDropDown->getSelected());
break;
@@ -480,16 +480,18 @@ void InventoryWindow::action(const ActionEvent &event)
{
if (isStorageActive())
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Storage);
}
#ifdef EATHENA_SUPPORT
else if (cartWindow && cartWindow->isWindowVisible())
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::CART);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Cart);
}
else
#endif
@@ -598,13 +600,15 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
if (event.getButton() == MouseButton::RIGHT)
{
ItemAmountWindow::showWindow(ItemAmountWindow::StoreAdd,
- inventoryWindow, item);
+ inventoryWindow,
+ item);
}
else
{
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Storage);
}
}
else
@@ -616,9 +620,10 @@ void InventoryWindow::mouseClicked(MouseEvent &event)
}
else
{
- inventoryHandler->moveItem2(InventoryType::STORAGE,
- item->getInvIndex(), item->getQuantity(),
- InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Storage,
+ item->getInvIndex(),
+ item->getQuantity(),
+ InventoryType::Inventory);
}
}
}
@@ -793,30 +798,30 @@ void InventoryWindow::close()
switch (mInventory->getType())
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
#endif
setVisible(Visible_false);
break;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
if (inventoryHandler)
{
- inventoryHandler->closeStorage(InventoryType::STORAGE);
+ inventoryHandler->closeStorage();
inventoryHandler->forgotStorage();
}
scheduleDelete();
break;
default:
- case InventoryType::TRADE:
- case InventoryType::NPC:
+ case InventoryType::Trade:
+ case InventoryType::Npc:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
- case InventoryType::MAIL:
+ case InventoryType::Vending:
+ case InventoryType::Mail:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
break;
}
}
@@ -825,17 +830,18 @@ void InventoryWindow::updateWeight()
{
if (!mInventory || !mWeightBar)
return;
- const InventoryType::Type type = mInventory->getType();
+ const InventoryTypeT type = mInventory->getType();
#ifdef EATHENA_SUPPORT
- if (type != InventoryType::INVENTORY && type != InventoryType::CART)
+ if (type != InventoryType::Inventory &&
+ type != InventoryType::Cart)
#else
- if (type != InventoryType::INVENTORY)
+ if (type != InventoryType::Inventory)
#endif
{
return;
}
- const bool isInv = type == InventoryType::INVENTORY;
+ const bool isInv = type == InventoryType::Inventory;
const int total = PlayerInfo::getAttribute(isInv
? Attributes::TOTAL_WEIGHT : Attributes::CART_TOTAL_WEIGHT);
const int max = PlayerInfo::getAttribute(isInv
@@ -948,11 +954,12 @@ void InventoryWindow::widgetResized(const Event &event)
if (!mInventory)
return;
- const InventoryType::Type type = mInventory->getType();
+ const InventoryTypeT type = mInventory->getType();
#ifdef EATHENA_SUPPORT
- if (type != InventoryType::INVENTORY && type != InventoryType::CART)
+ if (type != InventoryType::Inventory &&
+ type != InventoryType::Cart)
#else
- if (type != InventoryType::INVENTORY)
+ if (type != InventoryType::Inventory)
#endif
{
return;
diff --git a/src/gui/windows/itemamountwindow.cpp b/src/gui/windows/itemamountwindow.cpp
index a48a6dab2..fba671675 100644
--- a/src/gui/windows/itemamountwindow.cpp
+++ b/src/gui/windows/itemamountwindow.cpp
@@ -74,12 +74,12 @@ void ItemAmountWindow::finish(const Item *const item,
inventoryHandler->splitItem(item, amount);
break;
case StoreAdd:
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), amount, InventoryType::STORAGE);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(), amount, InventoryType::Storage);
break;
case StoreRemove:
- inventoryHandler->moveItem2(InventoryType::STORAGE,
- item->getInvIndex(), amount, InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Storage,
+ item->getInvIndex(), amount, InventoryType::Inventory);
break;
case ShopBuyAdd:
if (shopWindow)
@@ -91,12 +91,12 @@ void ItemAmountWindow::finish(const Item *const item,
break;
#ifdef EATHENA_SUPPORT
case CartAdd:
- inventoryHandler->moveItem2(InventoryType::INVENTORY,
- item->getInvIndex(), amount, InventoryType::CART);
+ inventoryHandler->moveItem2(InventoryType::Inventory,
+ item->getInvIndex(), amount, InventoryType::Cart);
break;
case CartRemove:
- inventoryHandler->moveItem2(InventoryType::CART,
- item->getInvIndex(), amount, InventoryType::INVENTORY);
+ inventoryHandler->moveItem2(InventoryType::Cart,
+ item->getInvIndex(), amount, InventoryType::Inventory);
break;
case MailAdd:
if (mailEditWindow)
diff --git a/src/gui/windows/maileditwindow.cpp b/src/gui/windows/maileditwindow.cpp
index de403839b..da7210a43 100644
--- a/src/gui/windows/maileditwindow.cpp
+++ b/src/gui/windows/maileditwindow.cpp
@@ -66,7 +66,7 @@ MailEditWindow::MailEditWindow() :
mSubjectField(new TextField(this)),
mMoneyField(new IntTextField(this, 0, 0, 10000000)),
mMessageField(new TextField(this)),
- mInventory(new Inventory(InventoryType::MAIL, 1)),
+ mInventory(new Inventory(InventoryType::Mail, 1)),
mItemContainer(new ItemContainer(this, mInventory)),
mItemScrollArea(new ScrollArea(this, mItemContainer,
getOptionBool("showitemsbackground"), "mailedit_listbackground.xml"))
diff --git a/src/gui/windows/ministatuswindow.cpp b/src/gui/windows/ministatuswindow.cpp
index 37e6bccc9..aa544e128 100644
--- a/src/gui/windows/ministatuswindow.cpp
+++ b/src/gui/windows/ministatuswindow.cpp
@@ -538,7 +538,7 @@ void MiniStatusWindow::slotsChanged(Inventory *const inventory)
if (!inventory)
return;
- if (inventory->getType() == InventoryType::INVENTORY)
+ if (inventory->getType() == InventoryType::Inventory)
StatusWindow::updateInvSlotsBar(mInvSlotsBar);
}
diff --git a/src/gui/windows/npcdialog.cpp b/src/gui/windows/npcdialog.cpp
index f2157585d..4f716f32d 100644
--- a/src/gui/windows/npcdialog.cpp
+++ b/src/gui/windows/npcdialog.cpp
@@ -124,7 +124,7 @@ NpcDialog::NpcDialog(const BeingId npcId) :
mButton3(new Button(this, _("Add"), "add", this)),
// TRANSLATORS: npc dialog button
mResetButton(new Button(this, _("Reset"), "reset", this)),
- mInventory(new Inventory(InventoryType::NPC, 1)),
+ mInventory(new Inventory(InventoryType::Npc, 1)),
mItemContainer(new ItemContainer(this, mInventory,
10000, ShowEmptyRows_true)),
mItemScrollArea(new ScrollArea(this, mItemContainer,
diff --git a/src/gui/windows/tradewindow.cpp b/src/gui/windows/tradewindow.cpp
index edd685f30..69cf87848 100644
--- a/src/gui/windows/tradewindow.cpp
+++ b/src/gui/windows/tradewindow.cpp
@@ -73,8 +73,8 @@ TradeWindow::TradeWindow() :
Window(_("Trade: You"), Modal_false, nullptr, "trade.xml"),
ActionListener(),
SelectionListener(),
- mMyInventory(new Inventory(InventoryType::TRADE)),
- mPartnerInventory(new Inventory(InventoryType::TRADE)),
+ mMyInventory(new Inventory(InventoryType::Trade)),
+ mPartnerInventory(new Inventory(InventoryType::Trade)),
mMyItemContainer(new ItemContainer(this, mMyInventory)),
mPartnerItemContainer(new ItemContainer(this, mPartnerInventory)),
// TRANSLATORS: trade window money label
diff --git a/src/inventory.cpp b/src/inventory.cpp
index 3240f9d8f..500e8c207 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -53,7 +53,7 @@ namespace
};
} // namespace
-Inventory::Inventory(const InventoryType::Type type, const int size1) :
+Inventory::Inventory(const InventoryTypeT type, const int size1) :
mInventoryListeners(),
mVirtualRemove(),
mType(type),
@@ -298,39 +298,39 @@ std::string Inventory::getName() const
{
switch (mType)
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
#ifdef EATHENA_SUPPORT
- case InventoryType::VENDING:
+ case InventoryType::Vending:
#endif
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
default:
{
// TRANSLATORS: inventory type name
return N_("Inventory");
}
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
{
// TRANSLATORS: inventory type name
return N_("Storage");
}
- case InventoryType::NPC:
+ case InventoryType::Npc:
{
// TRANSLATORS: inventory type name
return N_("Npc");
}
#ifdef EATHENA_SUPPORT
- case InventoryType::CART:
+ case InventoryType::Cart:
{
// TRANSLATORS: inventory type name
return N_("Cart");
}
- case InventoryType::MAIL:
+ case InventoryType::Mail:
{
// TRANSLATORS: inventory type name
return N_("Mail");
}
#endif
- case InventoryType::TRADE:
+ case InventoryType::Trade:
{
// TRANSLATORS: inventory type name
return N_("Trade");
diff --git a/src/inventory.h b/src/inventory.h
index 311e6c5f0..9ebb3de12 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -57,7 +57,7 @@ class Inventory final
*
* @param size the number of items that fit in the inventory
*/
- explicit Inventory(const InventoryType::Type type,
+ explicit Inventory(const InventoryTypeT type,
const int size = -1);
/**
@@ -159,11 +159,11 @@ class Inventory final
void removeInventoyListener(InventoryListener *const listener);
- InventoryType::Type getType() const A_WARN_UNUSED
+ InventoryTypeT getType() const A_WARN_UNUSED
{ return mType; }
bool isMainInventory() const A_WARN_UNUSED
- { return mType == InventoryType::INVENTORY; }
+ { return mType == InventoryType::Inventory; }
const Item *findItemBySprite(std::string spritePath,
const GenderT gender,
@@ -194,7 +194,7 @@ class Inventory final
void distributeSlotsChangedEvent();
IntMap mVirtualRemove;
- InventoryType::Type mType;
+ InventoryTypeT mType;
unsigned mSize; /**< The max number of inventory items */
Item **mItems; /**< The holder of items */
int mUsed; /**< THe number of slots in use */
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 8d3ad6c9f..b1aa87020 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -81,18 +81,18 @@ void InventoryHandler::openStorage(const int type A_UNUSED) const
// Doesn't apply to eAthena, since opening happens through NPCs?
}
-size_t InventoryHandler::getSize(const int type) const
+size_t InventoryHandler::getSize(const InventoryTypeT type) const
{
switch (type)
{
- case InventoryType::INVENTORY:
+ case InventoryType::Inventory:
return 100;
- case InventoryType::STORAGE:
+ case InventoryType::Storage:
return 0; // Comes from server after items
- case InventoryType::TRADE:
+ case InventoryType::Trade:
return 12;
// GUILD_STORAGE
- case InventoryType::TYPE_END:
+ case InventoryType::TypeEnd:
return 0; // Comes from server after items
default:
return 0;
diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h
index 313485dd4..5c6f4258e 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -56,7 +56,8 @@ class InventoryHandler notfinal : public Net::InventoryHandler
void openStorage(const int type) const override final;
- size_t getSize(const int type) const override final A_WARN_UNUSED;
+ size_t getSize(const InventoryTypeT type) const override final
+ A_WARN_UNUSED;
void pushPickup(const BeingId floorId);
diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp
index 7a96e86cd..bda53bab3 100644
--- a/src/net/ea/inventoryrecv.cpp
+++ b/src/net/ea/inventoryrecv.cpp
@@ -148,7 +148,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg)
const int size = msg.readInt16("max size");
if (!mStorage)
- mStorage = new Inventory(InventoryType::STORAGE, size);
+ mStorage = new Inventory(InventoryType::Storage, size);
FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems)
{
diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp
index 1b781c3be..05d8c77ca 100644
--- a/src/net/eathena/inventoryhandler.cpp
+++ b/src/net/eathena/inventoryhandler.cpp
@@ -119,38 +119,38 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const
outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
}
-void InventoryHandler::closeStorage(const int type A_UNUSED) const
+void InventoryHandler::closeStorage() const
{
createOutPacket(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem2(const int source,
+void InventoryHandler::moveItem2(const InventoryTypeT source,
const int slot,
const int amount,
- const int destination) const
+ const InventoryTypeT destination) const
{
int packet = 0;
int offset = INVENTORY_OFFSET;
- if (source == InventoryType::INVENTORY)
+ if (source == InventoryType::Inventory)
{
- if (destination == InventoryType::STORAGE)
+ if (destination == InventoryType::Storage)
packet = CMSG_MOVE_TO_STORAGE;
- else if (destination == InventoryType::CART)
+ else if (destination == InventoryType::Cart)
packet = CMSG_MOVE_TO_CART;
}
- else if (source == InventoryType::STORAGE)
+ else if (source == InventoryType::Storage)
{
offset = STORAGE_OFFSET;
- if (destination == InventoryType::INVENTORY)
+ if (destination == InventoryType::Inventory)
packet = CMSG_MOVE_FROM_STORAGE;
- else if (destination == InventoryType::CART)
+ else if (destination == InventoryType::Cart)
packet = CMSG_MOVE_FROM_STORAGE_TO_CART;
}
- else if (source == InventoryType::CART)
+ else if (source == InventoryType::Cart)
{
- if (destination == InventoryType::INVENTORY)
+ if (destination == InventoryType::Inventory)
packet = CMSG_MOVE_FROM_CART;
- else if (destination == InventoryType::STORAGE)
+ else if (destination == InventoryType::Storage)
packet = CMSG_MOVE_FROM_CART_TO_STORAGE;
}
diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h
index 924275757..a398fe2eb 100644
--- a/src/net/eathena/inventoryhandler.h
+++ b/src/net/eathena/inventoryhandler.h
@@ -46,12 +46,12 @@ class InventoryHandler final : public Ea::InventoryHandler
void dropItem(const Item *const item,
const int amount) const override final;
- void closeStorage(const int type) const override final;
+ void closeStorage() const override final;
- void moveItem2(const int source,
+ void moveItem2(const InventoryTypeT source,
const int slot,
const int amount,
- const int destination) const override final;
+ const InventoryTypeT destination) const override final;
void useCard(const Item *const item) override final;
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index a151e39da..c7153ee29 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -55,13 +55,15 @@ class InventoryHandler notfinal
virtual void openStorage(const int type) const = 0;
- virtual void closeStorage(const int type) const = 0;
+ virtual void closeStorage() const = 0;
- virtual void moveItem2(const int source, const int slot,
+ virtual void moveItem2(const InventoryTypeT source,
+ const int slot,
const int amount,
- const int destination) const = 0;
+ const InventoryTypeT destination) const = 0;
- virtual size_t getSize(const int type) const A_WARN_UNUSED = 0;
+ virtual size_t getSize(const InventoryTypeT type) const
+ A_WARN_UNUSED = 0;
virtual Inventory *getStorage() const = 0;
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp
index 3248ec8f6..f4af144ea 100644
--- a/src/net/tmwa/inventoryhandler.cpp
+++ b/src/net/tmwa/inventoryhandler.cpp
@@ -110,24 +110,26 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const
outMsg.writeInt16(static_cast<int16_t>(amount), "amount");
}
-void InventoryHandler::closeStorage(const int type A_UNUSED) const
+void InventoryHandler::closeStorage() const
{
createOutPacket(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem2(const int source, const int slot,
- const int amount, const int destination) const
+void InventoryHandler::moveItem2(const InventoryTypeT source,
+ const int slot,
+ const int amount,
+ const InventoryTypeT destination) const
{
- if (source == InventoryType::INVENTORY
- && destination == InventoryType::STORAGE)
+ if (source == InventoryType::Inventory &&
+ destination == InventoryType::Storage)
{
createOutPacket(CMSG_MOVE_TO_STORAGE);
outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET),
"index");
outMsg.writeInt32(amount, "amount");
}
- else if (source == InventoryType::STORAGE
- && destination == InventoryType::INVENTORY)
+ else if (source == InventoryType::Storage &&
+ destination == InventoryType::Inventory)
{
createOutPacket(CMSG_MOVE_FROM_STORAGE);
outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET),
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h
index d0ccedab5..81e300bd3 100644
--- a/src/net/tmwa/inventoryhandler.h
+++ b/src/net/tmwa/inventoryhandler.h
@@ -46,12 +46,12 @@ class InventoryHandler final : public Ea::InventoryHandler
void dropItem(const Item *const item,
const int amount) const override final;
- void closeStorage(const int type) const override final;
+ void closeStorage() const override final;
- void moveItem2(const int source,
+ void moveItem2(const InventoryTypeT source,
const int slot,
const int amount,
- const int destination) const override final;
+ const InventoryTypeT destination) const override final;
void useCard(const Item *const item) override final;