summaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2011-04-05 02:56:29 +0300
committerPerttu Ahola <celeron55@gmail.com>2011-04-05 02:56:29 +0300
commitd1d57cf5c34c9a4626fd8e3b40db3ea321b40335 (patch)
treee263dcc5268f514f43521d2df86640a96be94e96 /src/inventory.h
parent281f76b6a07393906cb532bed95d5d98f0791c3a (diff)
downloadminetest-d1d57cf5c34c9a4626fd8e3b40db3ea321b40335.tar.gz
minetest-d1d57cf5c34c9a4626fd8e3b40db3ea321b40335.tar.bz2
minetest-d1d57cf5c34c9a4626fd8e3b40db3ea321b40335.zip
initial workings of the furnace
Diffstat (limited to 'src/inventory.h')
-rw-r--r--src/inventory.h52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/inventory.h b/src/inventory.h
index 45bc488c5..0cbd97abc 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -435,6 +435,7 @@ public:
InventoryItem * changeItem(u32 i, InventoryItem *newitem);
// Delete item
void deleteItem(u32 i);
+
// Adds an item to a suitable place. Returns leftover item.
// If all went into the list, returns NULL.
InventoryItem * addItem(InventoryItem *newitem);
@@ -445,6 +446,9 @@ public:
// If can be added fully, NULL is returned.
InventoryItem * addItem(u32 i, InventoryItem *newitem);
+ // Checks whether the item could be added to the given slot
+ bool itemFits(u32 i, InventoryItem *newitem);
+
// Takes some items from a slot.
// If there are not enough, takes as many as it can.
// Returns NULL if couldn't take any.
@@ -522,7 +526,7 @@ public:
*/
virtual Inventory* getInventory(InventoryContext *c, std::string id)
{return NULL;}
- // Used on the server by InventoryAction::apply
+ // Used on the server by InventoryAction::apply and other stuff
virtual void inventoryModified(InventoryContext *c, std::string id)
{}
// Used on the client
@@ -600,5 +604,51 @@ struct IMoveAction : public InventoryAction
void apply(InventoryContext *c, InventoryManager *mgr);
};
+/*
+ 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(InventoryItem *item);
+};
+
+/*
+ items: a pointer to an array of 9 pointers to items
+ specs: a pointer to an array of 9 ItemSpecs
+*/
+bool checkItemCombination(InventoryItem **items, ItemSpec *specs);
+
#endif