aboutsummaryrefslogtreecommitdiff
path: root/src/nodedef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodedef.h')
-rw-r--r--src/nodedef.h40
1 files changed, 39 insertions, 1 deletions
diff --git a/src/nodedef.h b/src/nodedef.h
index 27d67b481..bd29b92b6 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -282,6 +282,40 @@ struct ContentFeatures
}
};
+struct NodeResolveInfo {
+ std::string n_wanted;
+ std::string n_alt;
+ content_t c_fallback;
+ content_t *output;
+};
+
+#define NR_STATUS_FAILURE 0
+#define NR_STATUS_PENDING 1
+#define NR_STATUS_SUCCESS 2
+
+class NodeResolver {
+public:
+ NodeResolver(INodeDefManager *ndef);
+ ~NodeResolver();
+
+ int addNode(std::string n_wanted, std::string n_alt,
+ content_t c_fallback, content_t *content);
+ int addNodeList(const char *nodename, std::vector<content_t> *content_vec);
+
+ bool cancelNode(content_t *content);
+ int cancelNodeList(std::vector<content_t> *content_vec);
+
+ int resolveNodes();
+
+ bool isNodeRegFinished() { return m_is_node_registration_complete; }
+
+private:
+ INodeDefManager *m_ndef;
+ bool m_is_node_registration_complete;
+ std::list<NodeResolveInfo *> m_pending_contents;
+ std::list<std::pair<std::string, std::vector<content_t> *> > m_pending_content_vecs;
+};
+
class INodeDefManager
{
public:
@@ -298,6 +332,8 @@ public:
virtual const ContentFeatures& get(const std::string &name) const=0;
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
+
+ virtual NodeResolver *getResolver()=0;
};
class IWritableNodeDefManager : public INodeDefManager
@@ -338,9 +374,11 @@ public:
virtual void serialize(std::ostream &os, u16 protocol_version)=0;
virtual void deSerialize(std::istream &is)=0;
+
+ virtual NodeResolver *getResolver()=0;
};
-IWritableNodeDefManager* createNodeDefManager();
+IWritableNodeDefManager *createNodeDefManager();
#endif