summaryrefslogtreecommitdiff
path: root/src/net
diff options
context:
space:
mode:
authorJared Adams <jaxad0127@gmail.com>2010-03-25 16:03:13 -0600
committerJared Adams <jaxad0127@gmail.com>2010-03-25 16:56:12 -0600
commit8745368108563d7c32820b989c3ea794ccb834f9 (patch)
treea69554b2e5659b25f50797cc6ab4cc95b2b6f84e /src/net
parentac18a72c9972faf6dbd68abf3c883b2d444396c8 (diff)
downloadmana-8745368108563d7c32820b989c3ea794ccb834f9.tar.gz
mana-8745368108563d7c32820b989c3ea794ccb834f9.tar.bz2
mana-8745368108563d7c32820b989c3ea794ccb834f9.tar.xz
mana-8745368108563d7c32820b989c3ea794ccb834f9.zip
Remove the type boolean from InventoryWindow
This moves inventory/storage type into the Inventory class, having size default to a call to the netcode to get the sive for the given type. Reviewed-by: Chuck Miller
Diffstat (limited to 'src/net')
-rw-r--r--src/net/ea/inventoryhandler.cpp26
-rw-r--r--src/net/ea/inventoryhandler.h15
-rw-r--r--src/net/inventoryhandler.h18
-rw-r--r--src/net/manaserv/inventoryhandler.cpp18
-rw-r--r--src/net/manaserv/inventoryhandler.h10
5 files changed, 44 insertions, 43 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp
index 1b191354..36d024f6 100644
--- a/src/net/ea/inventoryhandler.cpp
+++ b/src/net/ea/inventoryhandler.cpp
@@ -296,7 +296,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
int size = msg.readInt16(); // Max size
if (!mStorage)
- mStorage = new Inventory(size);
+ mStorage = new Inventory(Inventory::STORAGE, size);
InventoryItems::iterator it = mInventoryItems.begin();
InventoryItems::iterator it_end = mInventoryItems.end();
@@ -472,26 +472,26 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
// Not implemented for eAthena (possible?)
}
-void InventoryHandler::openStorage(StorageType type)
+void InventoryHandler::openStorage(int type)
{
// Doesn't apply to eAthena, since opening happens through NPCs?
}
-void InventoryHandler::closeStorage(StorageType type)
+void InventoryHandler::closeStorage(int type)
{
MessageOut outMsg(CMSG_CLOSE_STORAGE);
}
-void InventoryHandler::moveItem(StorageType source, int slot, int amount,
- StorageType destination)
+void InventoryHandler::moveItem(int source, int slot, int amount,
+ int destination)
{
- if (source == INVENTORY && destination == STORAGE)
+ if (source == Inventory::INVENTORY && destination == Inventory::STORAGE)
{
MessageOut outMsg(CMSG_MOVE_TO_STORAGE);
outMsg.writeInt16(slot + INVENTORY_OFFSET);
outMsg.writeInt32(amount);
}
- else if (source == STORAGE && destination == INVENTORY)
+ else if (source == Inventory::STORAGE && destination == Inventory::INVENTORY)
{
MessageOut outMsg(CSMG_MOVE_FROM_STORAGE);
outMsg.writeInt16(slot + STORAGE_OFFSET);
@@ -499,16 +499,18 @@ void InventoryHandler::moveItem(StorageType source, int slot, int amount,
}
}
-size_t InventoryHandler::getSize(StorageType type) const
+size_t InventoryHandler::getSize(int type) const
{
switch (type)
{
- case INVENTORY:
+ case Inventory::INVENTORY:
return 100;
- case STORAGE:
- return 0;
+ case Inventory::STORAGE:
+ return 0; // Comes from server after items
+ case Inventory::TRADE:
+ return 12;
case GUILD_STORAGE:
- return 0;
+ 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 d08e4772..cb127af9 100644
--- a/src/net/ea/inventoryhandler.h
+++ b/src/net/ea/inventoryhandler.h
@@ -118,6 +118,11 @@ typedef std::list<InventoryItem> InventoryItems;
class InventoryHandler : public MessageHandler, public Net::InventoryHandler
{
public:
+ enum {
+ GUILD_STORAGE = Inventory::TYPE_END,
+ CART
+ };
+
InventoryHandler();
~InventoryHandler();
@@ -138,14 +143,14 @@ class InventoryHandler : public MessageHandler, public Net::InventoryHandler
void moveItem(int oldIndex, int newIndex);
- void openStorage(StorageType type);
+ void openStorage(int type);
- void closeStorage(StorageType type);
+ void closeStorage(int type);
- void moveItem(StorageType source, int slot, int amount,
- StorageType destination);
+ void moveItem(int source, int slot, int amount,
+ int destination);
- size_t getSize(StorageType type) const;
+ size_t getSize(int type) const;
private:
EquipBackend mEquips;
diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h
index 9d0a5bc8..e48043a7 100644
--- a/src/net/inventoryhandler.h
+++ b/src/net/inventoryhandler.h
@@ -22,6 +22,7 @@
#ifndef INVENTORYHANDLER_H
#define INVENTORYHANDLER_H
+#include "inventory.h"
#include "item.h"
#include <iosfwd>
@@ -45,24 +46,17 @@ class InventoryHandler
virtual void moveItem(int oldIndex, int newIndex) = 0;
- enum StorageType {
- INVENTORY,
- STORAGE,
- GUILD_STORAGE,
- CART
- };
+ virtual void openStorage(int type) = 0;
- virtual void openStorage(StorageType type) = 0;
-
- virtual void closeStorage(StorageType type) = 0;
+ virtual void closeStorage(int type) = 0;
//void changeCart() = 0;
- virtual void moveItem(StorageType source, int slot, int amount,
- StorageType destination) = 0;
+ virtual void moveItem(int source, int slot, int amount,
+ int destination) = 0;
// TODO: fix/remove me
- virtual size_t getSize(StorageType type) const = 0;
+ virtual size_t getSize(int type) const = 0;
virtual ~InventoryHandler() {}
};
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 66f4a2ba..76fca7ae 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -79,7 +79,7 @@ void InventoryHandler::handleMessage(Net::MessageIn &msg)
{
mEquips.setEquipment(slot, id);
}
- else if (slot >= 32 && slot < 32 + getSize(INVENTORY))
+ else if (slot >= 32 && slot < 32 + getSize(Inventory::INVENTORY))
{
int amount = id ? msg.readInt8() : 0;
player_node->setInvItem(slot - 32, id, amount);
@@ -154,30 +154,30 @@ void InventoryHandler::moveItem(int oldIndex, int newIndex)
gameServerConnection->send(msg);
}
-void InventoryHandler::openStorage(StorageType type)
+void InventoryHandler::openStorage(int type)
{
// TODO
}
-void InventoryHandler::closeStorage(StorageType type)
+void InventoryHandler::closeStorage(int type)
{
// TODO
}
-void InventoryHandler::moveItem(StorageType source, int slot, int amount,
- StorageType destination)
+void InventoryHandler::moveItem(int source, int slot, int amount,
+ int destination)
{
// TODO
}
-size_t InventoryHandler::getSize(StorageType type) const
+size_t InventoryHandler::getSize(int type) const
{
switch (type)
{
- case INVENTORY:
+ case Inventory::INVENTORY:
+ case Inventory::TRADE:
return 50;
- case STORAGE:
- case GUILD_STORAGE:
+ case Inventory::STORAGE:
return 300;
default:
return 0;
diff --git a/src/net/manaserv/inventoryhandler.h b/src/net/manaserv/inventoryhandler.h
index 49f013cf..fd08b95e 100644
--- a/src/net/manaserv/inventoryhandler.h
+++ b/src/net/manaserv/inventoryhandler.h
@@ -88,14 +88,14 @@ class InventoryHandler : public MessageHandler, Net::InventoryHandler
void moveItem(int oldIndex, int newIndex);
- void openStorage(StorageType type);
+ void openStorage(int type);
- void closeStorage(StorageType type);
+ void closeStorage(int type);
- void moveItem(StorageType source, int slot, int amount,
- StorageType destination);
+ void moveItem(int source, int slot, int amount,
+ int destination);
- size_t getSize(StorageType type) const;
+ size_t getSize(int type) const;
private:
EquipBackend mEquips;