]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/nodedef.h
Fix key change menu a bit
[dragonfireclient.git] / src / nodedef.h
index b7cca52d04ff8b6920a278e437c78b17501385be..fdf2f8c45b6e1d1525b4f8f81e88e2aa250d0e13 100644 (file)
@@ -32,28 +32,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 class ITextureSource;
 class IGameDef;
 
-/*
-       TODO: Rename to nodedef.h
-*/
-
-#if 0
-
-/*
-       Content feature list
-       
-       Used for determining properties of MapNodes by content type without
-       storing such properties in the nodes itself.
-*/
-
-/*
-       Initialize content feature table.
-
-       Must be called before accessing the table.
-*/
-void init_contentfeatures(ITextureSource *tsrc);
-
-#endif
-
 enum ContentParamType
 {
        CPT_NONE,
@@ -98,7 +76,7 @@ struct NodeBox
                wall_side(-BS/2, -BS/2, -BS/2, -BS/2+BS/16., BS/2, BS/2)
        {}
 
-       void serialize(std::ostream &os);
+       void serialize(std::ostream &os) const;
        void deSerialize(std::istream &is);
 };
 
@@ -115,7 +93,7 @@ struct MaterialSpec
                backface_culling(backface_culling_)
        {}
 
-       void serialize(std::ostream &os);
+       void serialize(std::ostream &os) const;
        void deSerialize(std::istream &is);
 };
 
@@ -156,24 +134,22 @@ struct ContentFeatures
        bool backface_culling;
 #endif
        
-       // List of all block textures that have been used (value is dummy)
-       // Used for texture atlas making.
-       // Exists on server too for cleaner code in content_mapnode.cpp.
+       // List of textures that are used and are wanted to be included in
+       // the texture atlas
        std::set<std::string> used_texturenames;
        
-       // True if this actually contains non-default data
-       bool modified;
-
        /*
                Actual data
        */
 
+       std::string name; // "" = undefined node
+
        // Visual definition
        enum NodeDrawType drawtype;
        float visual_scale; // Misc. scale parameter
        std::string tname_tiles[6];
        std::string tname_inventory;
-       MaterialSpec mspec_special[CF_SPECIAL_COUNT];
+       MaterialSpec mspec_special[CF_SPECIAL_COUNT]; // Use setter methods
        u8 alpha;
 
        // Post effect color, drawn when the camera is inside the node.
@@ -198,9 +174,6 @@ struct ContentFeatures
        // If true, param2 is set to direction when placed. Used for torches.
        // NOTE: the direction format is quite inefficient and should be changed
        bool wall_mounted;
-       // If true, node is equivalent to air. Torches are, air is. Water is not.
-       // Is used for example to check whether a mud block can have grass on.
-       bool air_equivalent;
        // Whether this content type often contains mineral.
        // Used for texture atlas creation.
        // Currently only enabled for CONTENT_STONE.
@@ -210,15 +183,16 @@ struct ContentFeatures
        std::string dug_item;
        // Extra dug item and its rarity
        std::string extra_dug_item;
+       // Usual get interval for extra dug item
        s32 extra_dug_item_rarity;
-       // Initial metadata is cloned from this
-       NodeMetadata *initial_metadata;
+       // Metadata name of node (eg. "furnace")
+       std::string metadata_name;
        // Whether the node is non-liquid, source liquid or flowing liquid
        enum LiquidType liquid_type;
        // If the content is liquid, this is the flowing version of the liquid.
-       content_t liquid_alternative_flowing;
+       std::string liquid_alternative_flowing;
        // If the content is liquid, this is the source version of the liquid.
-       content_t liquid_alternative_source;
+       std::string liquid_alternative_source;
        // Viscosity for fluid flow, ranging from 1 to 7, with
        // 1 giving almost instantaneous propagation and 7 being
        // the slowest possible
@@ -228,6 +202,9 @@ struct ContentFeatures
        u32 damage_per_second;
        NodeBox selection_box;
        MaterialProperties material;
+       std::string cookresult_item;
+       float furnace_cooktime;
+       float furnace_burntime;
 
        /*
                Methods
@@ -240,24 +217,19 @@ struct ContentFeatures
        void deSerialize(std::istream &is, IGameDef *gamedef);
 
        /*
-               Quickhands for simple materials
+               Texture setters.
+               
        */
        
+       // Texture setters. They also add stuff to used_texturenames.
        void setTexture(u16 i, std::string name);
-
-       void setAllTextures(std::string name, u8 alpha_=255)
-       {
-               for(u16 i=0; i<6; i++)
-                       setTexture(i, name);
-               alpha = alpha_;
-               // Force inventory texture too
-               setInventoryTexture(name);
-       }
+       void setAllTextures(std::string name);
+       void setSpecialMaterial(u16 i, const MaterialSpec &mspec);
 
        void setInventoryTexture(std::string imgname);
        void setInventoryTextureCube(std::string top,
                        std::string left, std::string right);
-
+       
        /*
                Some handy methods
        */
@@ -278,6 +250,10 @@ class INodeDefManager
        // Get node definition
        virtual const ContentFeatures& get(content_t c) const=0;
        virtual const ContentFeatures& get(const MapNode &n) const=0;
+       virtual bool getId(const std::string &name, content_t &result) const=0;
+       virtual content_t getId(const std::string &name) const=0;
+       virtual const ContentFeatures& get(const std::string &name) const=0;
+       virtual std::string getAlias(const std::string &name) const =0;
        
        virtual void serialize(std::ostream &os)=0;
 };
@@ -291,10 +267,25 @@ class IWritableNodeDefManager : public INodeDefManager
        // Get node definition
        virtual const ContentFeatures& get(content_t c) const=0;
        virtual const ContentFeatures& get(const MapNode &n) const=0;
+       virtual bool getId(const std::string &name, content_t &result) const=0;
+       virtual content_t getId(const std::string &name) const=0;
+       // If not found, returns the features of CONTENT_IGNORE
+       virtual const ContentFeatures& get(const std::string &name) const=0;
+       virtual std::string getAlias(const std::string &name) const =0;
                
        // Register node definition
        virtual void set(content_t c, const ContentFeatures &def)=0;
-       virtual ContentFeatures* getModifiable(content_t c)=0;
+       // Register node definition by name (allocate an id)
+       // If returns CONTENT_IGNORE, could not allocate id
+       virtual content_t set(const std::string &name,
+                       const ContentFeatures &def)=0;
+       // If returns CONTENT_IGNORE, could not allocate id
+       virtual content_t allocateDummy(const std::string &name)=0;
+       // Set an alias so that nodes named <name> will load as <convert_to>.
+       // Alias is not set if <name> has already been defined.
+       // Alias will be removed if <name> is defined at a later point of time.
+       virtual void setAlias(const std::string &name,
+                       const std::string &convert_to)=0;
 
        /*
                Update tile textures to latest return values of TextueSource.