summaryrefslogtreecommitdiff
path: root/src/nodedef.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/nodedef.h')
-rw-r--r--src/nodedef.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/nodedef.h b/src/nodedef.h
index 6fc20518d..3e77624eb 100644
--- a/src/nodedef.h
+++ b/src/nodedef.h
@@ -44,6 +44,9 @@ class ITextureSource;
class IShaderSource;
class IGameDef;
class NodeResolver;
+#if BUILD_UNITTESTS
+class TestSchematic;
+#endif
enum ContentParamType
{
@@ -789,10 +792,13 @@ private:
NodeDefManager *createNodeDefManager();
+// NodeResolver: Queue for node names which are then translated
+// to content_t after the NodeDefManager was initialized
class NodeResolver {
public:
NodeResolver();
virtual ~NodeResolver();
+ // Callback which is run as soon NodeDefManager is ready
virtual void resolveNodeNames() = 0;
// required because this class is used as mixin for ObjDef
@@ -804,12 +810,31 @@ public:
bool getIdsFromNrBacklog(std::vector<content_t> *result_out,
bool all_required = false, content_t c_fallback = CONTENT_IGNORE);
- void nodeResolveInternal();
+ inline bool isResolveDone() const { return m_resolve_done; }
+ void reset(bool resolve_done = false);
- u32 m_nodenames_idx = 0;
- u32 m_nnlistsizes_idx = 0;
+ // Vector containing all node names in the resolve "queue"
std::vector<std::string> m_nodenames;
+ // Specifies the "set size" of node names which are to be processed
+ // this is used for getIdsFromNrBacklog
+ // TODO: replace or remove
std::vector<size_t> m_nnlistsizes;
+
+protected:
+ friend class NodeDefManager; // m_ndef
+
const NodeDefManager *m_ndef = nullptr;
+ // Index of the next "m_nodenames" entry to resolve
+ u32 m_nodenames_idx = 0;
+
+private:
+#if BUILD_UNITTESTS
+ // Unittest requires access to m_resolve_done
+ friend class TestSchematic;
+#endif
+ void nodeResolveInternal();
+
+ // Index of the next "m_nnlistsizes" entry to process
+ u32 m_nnlistsizes_idx = 0;
bool m_resolve_done = false;
};