From 103173fc9b4fcb4c0fded2a93d5cbb8f0bea896e Mon Sep 17 00:00:00 2001 From: Perttu Ahola Date: Tue, 6 Dec 2011 15:21:56 +0200 Subject: Add InvRef and InvStack (currently untested and unusable) --- src/inventory.h | 178 +------------------------------------------------------- 1 file changed, 1 insertion(+), 177 deletions(-) (limited to 'src/inventory.h') 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 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<