]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/nodedef.h
Game: Scale damage flash to max HP
[dragonfireclient.git] / src / nodedef.h
index 6fc20518df40acc52f7935fc517e046c0283372b..0de4dbc21578eb4adb4e6fd897a2c08740fa804d 100644 (file)
@@ -44,6 +44,9 @@ class ITextureSource;
 class IShaderSource;
 class IGameDef;
 class NodeResolver;
+#if BUILD_UNITTESTS
+class TestSchematic;
+#endif
 
 enum ContentParamType
 {
@@ -64,7 +67,7 @@ enum ContentParamType2
        CPT2_WALLMOUNTED,
        // Block level like FLOWINGLIQUID
        CPT2_LEVELED,
-       // 2D rotation for things like plants
+       // 2D rotation
        CPT2_DEGROTATE,
        // Mesh options for plants
        CPT2_MESHOPTIONS,
@@ -76,6 +79,8 @@ enum ContentParamType2
        CPT2_COLORED_WALLMOUNTED,
        // Glasslike framed drawtype internal liquid level, param2 values 0 to 63
        CPT2_GLASSLIKE_LIQUID_LEVEL,
+       // 3 bits of palette index, then degrotate
+       CPT2_COLORED_DEGROTATE,
 };
 
 enum LiquidType
@@ -720,7 +725,7 @@ class NodeDefManager {
         * @param i a content ID
         * @param name a node name
         */
-       void addNameIdMapping(content_t i, std::string name);
+       void addNameIdMapping(content_t i, const std::string &name);
 
        /*!
         * Removes a content ID from all groups.
@@ -789,10 +794,13 @@ class NodeDefManager {
 
 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 +812,31 @@ class NodeResolver {
        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;
 };