summaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-12-06 15:21:56 +0200
committerPerttu Ahola <celeron55@gmail.com>2012-01-02 01:49:38 +0200
commit103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e (patch)
tree416a253ff37aeb5944781dd1288c5afa7483d799 /src/inventory.h
parent70ed371d0cd532da8efc5acbd41a20e9a373b811 (diff)
downloadminetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.tar.gz
minetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.tar.bz2
minetest-103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e.zip
Add InvRef and InvStack (currently untested and unusable)
Diffstat (limited to 'src/inventory.h')
-rw-r--r--src/inventory.h178
1 files changed, 1 insertions, 177 deletions
diff --git a/src/inventory.h b/src/inventory.h
index 795d32d3e..15de3c8e7 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -419,6 +419,7 @@ public:
InventoryList(std::string name, u32 size);
~InventoryList();
void clearItems();
+ void setSize(u32 newsize);
void serialize(std::ostream &os) const;
void deSerialize(std::istream &is, IGameDef *gamedef);
@@ -513,182 +514,5 @@ private:
core::array<InventoryList*> m_lists;
};
-class Player;
-
-struct InventoryContext
-{
- Player *current_player;
-
- InventoryContext():
- current_player(NULL)
- {}
-};
-
-struct InventoryAction;
-
-class InventoryManager
-{
-public:
- InventoryManager(){}
- virtual ~InventoryManager(){}
-
- /*
- Get a pointer to an inventory specified by id.
- id can be:
- - "current_player"
- - "nodemeta:X,Y,Z"
- */
- virtual Inventory* getInventory(InventoryContext *c, std::string id)
- {return NULL;}
- // Used on the server by InventoryAction::apply and other stuff
- virtual void inventoryModified(InventoryContext *c, std::string id)
- {}
- // Used on the client
- virtual void inventoryAction(InventoryAction *a)
- {}
-};
-
-#define IACTION_MOVE 0
-#define IACTION_DROP 1
-
-struct InventoryAction
-{
- static InventoryAction * deSerialize(std::istream &is);
-
- virtual u16 getType() const = 0;
- virtual void serialize(std::ostream &os) const = 0;
- virtual void apply(InventoryContext *c, InventoryManager *mgr,
- ServerEnvironment *env) = 0;
- virtual ~InventoryAction() {};
-};
-
-struct IMoveAction : public InventoryAction
-{
- // count=0 means "everything"
- u16 count;
- std::string from_inv;
- std::string from_list;
- s16 from_i;
- std::string to_inv;
- std::string to_list;
- s16 to_i;
-
- IMoveAction()
- {
- count = 0;
- from_i = -1;
- to_i = -1;
- }
-
- IMoveAction(std::istream &is);
-
- u16 getType() const
- {
- return IACTION_MOVE;
- }
-
- void serialize(std::ostream &os) const
- {
- os<<"Move ";
- os<<count<<" ";
- os<<from_inv<<" ";
- os<<from_list<<" ";
- os<<from_i<<" ";
- os<<to_inv<<" ";
- os<<to_list<<" ";
- os<<to_i;
- }
-
- void apply(InventoryContext *c, InventoryManager *mgr,
- ServerEnvironment *env);
-};
-
-struct IDropAction : public InventoryAction
-{
- // count=0 means "everything"
- u16 count;
- std::string from_inv;
- std::string from_list;
- s16 from_i;
-
- IDropAction()
- {
- count = 0;
- from_i = -1;
- }
-
- IDropAction(std::istream &is);
-
- u16 getType() const
- {
- return IACTION_DROP;
- }
-
- void serialize(std::ostream &os) const
- {
- os<<"Drop ";
- os<<count<<" ";
- os<<from_inv<<" ";
- os<<from_list<<" ";
- os<<from_i;
- }
-
- void apply(InventoryContext *c, InventoryManager *mgr,
- ServerEnvironment *env);
-};
-
-/*
- Craft checking system
-*/
-
-enum ItemSpecType
-{
- ITEM_NONE,
- ITEM_MATERIAL,
- ITEM_CRAFT,
- ITEM_TOOL,
- ITEM_MBO
-};
-
-struct ItemSpec
-{
- enum ItemSpecType type;
- // Only other one of these is used
- std::string name;
- u16 num;
-
- ItemSpec():
- type(ITEM_NONE)
- {
- }
- ItemSpec(enum ItemSpecType a_type, std::string a_name):
- type(a_type),
- name(a_name),
- num(65535)
- {
- }
- ItemSpec(enum ItemSpecType a_type, u16 a_num):
- type(a_type),
- name(""),
- num(a_num)
- {
- }
-
- bool checkItem(const InventoryItem *item) const;
-};
-
-/*
- items: a pointer to an array of 9 pointers to items
- specs: a pointer to an array of 9 ItemSpecs
-*/
-bool checkItemCombination(const InventoryItem * const*items, const ItemSpec *specs);
-
-/*
- items: a pointer to an array of 9 pointers to items
- specs: a pointer to an array of 9 pointers to items
-*/
-bool checkItemCombination(const InventoryItem * const * items,
- const InventoryItem * const * specs);
-
#endif