- typedef NodeMetadata* (*Factory)(std::istream&);
-
- NodeMetadata();
- virtual ~NodeMetadata();
-
- static NodeMetadata* deSerialize(std::istream &is);
- void serialize(std::ostream &os);
-
- // This usually is the CONTENT_ value
- virtual u16 typeId() const = 0;
- virtual NodeMetadata* clone() = 0;
- virtual void serializeBody(std::ostream &os) = 0;
- virtual std::string infoText() {return "";}
- virtual Inventory* getInventory() {return NULL;}
- // This is called always after the inventory is modified, before
- // the changes are copied elsewhere
- virtual void inventoryModified(){}
- // A step in time. Returns true if metadata changed.
- virtual bool step(float dtime) {return false;}
- virtual bool nodeRemovalDisabled(){return false;}
- // Used to make custom inventory menus.
- // See format in guiInventoryMenu.cpp.
- virtual std::string getInventoryDrawSpecString(){return "";}
- // primarily used for locking chests, but others can play too
- virtual std::string getOwner(){ return std::string(""); }
- virtual void setOwner(std::string t){ }
-
-protected:
- static void registerType(u16 id, Factory f);
+ NodeMetadata(IItemDefManager *item_def_mgr);
+ ~NodeMetadata();
+
+ void serialize(std::ostream &os, u8 version, bool disk=true) const;
+ void deSerialize(std::istream &is, u8 version);
+
+ void clear();
+ bool empty() const;
+
+ // The inventory
+ Inventory *getInventory()
+ {
+ return m_inventory;
+ }
+
+ inline bool isPrivate(const std::string &name) const
+ {
+ return m_privatevars.count(name) != 0;
+ }
+ void markPrivate(const std::string &name, bool set);
+