summaryrefslogtreecommitdiff
path: root/src/inventory.h
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2011-11-27 05:01:38 +0200
committerPerttu Ahola <celeron55@gmail.com>2011-11-29 19:13:54 +0200
commitf42c57d9a885450014cadd56a0eaf7c79eefebf4 (patch)
tree2ad93e18ac16b4b8c362a58ce046cb18be4d3e00 /src/inventory.h
parent82a460ec90b4537926f31603219504bce8817ac2 (diff)
downloadminetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.tar.gz
minetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.tar.bz2
minetest-f42c57d9a885450014cadd56a0eaf7c79eefebf4.zip
Add IDropAction and related stuff
Diffstat (limited to 'src/inventory.h')
-rw-r--r--src/inventory.h45
1 files changed, 41 insertions, 4 deletions
diff --git a/src/inventory.h b/src/inventory.h
index d6049f52f..441b2ca4d 100644
--- a/src/inventory.h
+++ b/src/inventory.h
@@ -62,7 +62,7 @@ public:
// Returns the string used for inventory
virtual std::string getItemString();
// Creates an object from the item, to be placed in the world.
- virtual ServerActiveObject* createSAO(ServerEnvironment *env, u16 id, v3f pos);
+ virtual ServerActiveObject* createSAO(ServerEnvironment *env, v3f pos);
// Gets amount of items that dropping one SAO will decrement
virtual u16 getDropCount() const { return getCount(); }
@@ -252,7 +252,7 @@ public:
return os.str();
}
- ServerActiveObject* createSAO(ServerEnvironment *env, u16 id, v3f pos);
+ ServerActiveObject* createSAO(ServerEnvironment *env, v3f pos);
u16 getDropCount() const;
virtual bool addableTo(const InventoryItem *other) const
@@ -535,6 +535,7 @@ public:
};
#define IACTION_MOVE 0
+#define IACTION_DROP 1
struct InventoryAction
{
@@ -542,7 +543,8 @@ struct InventoryAction
virtual u16 getType() const = 0;
virtual void serialize(std::ostream &os) const = 0;
- virtual void apply(InventoryContext *c, InventoryManager *mgr) = 0;
+ virtual void apply(InventoryContext *c, InventoryManager *mgr,
+ ServerEnvironment *env) = 0;
};
struct IMoveAction : public InventoryAction
@@ -582,7 +584,42 @@ struct IMoveAction : public InventoryAction
os<<to_i;
}
- void apply(InventoryContext *c, InventoryManager *mgr);
+ 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);
};
/*