]> git.lizzy.rs Git - minetest.git/blobdiff - src/nodemetadata.h
Remove un-needed header inclusion
[minetest.git] / src / nodemetadata.h
index 8e84e5af30a15cf9bed380de3b0a3969ab5e9b36..40f6dec657bc9c5316af28b1622d62a2d4c0b036 100644 (file)
@@ -17,13 +17,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef NODEMETADATA_HEADER
-#define NODEMETADATA_HEADER
+#pragma once
 
-#include "irr_v3d.h"
-#include <iostream>
-#include <vector>
-#include "util/string.h"
+#include <unordered_set>
+#include "metadata.h"
 
 /*
        NodeMetadata stores arbitary amounts of data for special blocks.
@@ -35,28 +32,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 */
 
 class Inventory;
-class IGameDef;
+class IItemDefManager;
 
-class NodeMetadata
+class NodeMetadata : public Metadata
 {
 public:
-       NodeMetadata(IGameDef *gamedef);
+       NodeMetadata(IItemDefManager *item_def_mgr);
        ~NodeMetadata();
 
-       void serialize(std::ostream &os) const;
-       void deSerialize(std::istream &is);
+       void serialize(std::ostream &os, u8 version, bool disk=true) const;
+       void deSerialize(std::istream &is, u8 version);
 
        void clear();
-
-       // Generic key/value store
-       std::string getString(const std::string &name, unsigned short recursion = 0) const;
-       void setString(const std::string &name, const std::string &var);
-       // Support variable names in values
-       std::string resolveString(const std::string &str, unsigned short recursion = 0) const;
-       StringMap getStrings() const
-       {
-               return m_stringvars;
-       }
+       bool empty() const;
 
        // The inventory
        Inventory *getInventory()
@@ -64,9 +52,17 @@ class NodeMetadata
                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);
+
 private:
-       StringMap m_stringvars;
+       int countNonPrivate() const;
+
        Inventory *m_inventory;
+       std::unordered_set<std::string> m_privatevars;
 };
 
 
@@ -79,8 +75,8 @@ class NodeMetadataList
 public:
        ~NodeMetadataList();
 
-       void serialize(std::ostream &os) const;
-       void deSerialize(std::istream &is, IGameDef *gamedef);
+       void serialize(std::ostream &os, u8 blockver, bool disk=true) const;
+       void deSerialize(std::istream &is, IItemDefManager *item_def_mgr);
 
        // Add all keys in this list to the vector keys
        std::vector<v3s16> getAllKeys();
@@ -94,8 +90,7 @@ class NodeMetadataList
        void clear();
 
 private:
+       int countNonEmpty() const;
+
        std::map<v3s16, NodeMetadata *> m_data;
 };
-
-#endif
-