Improve glass
[oweals/minetest.git] / src / mapnode.h
index a93589c41fb75fbaa3dbbb48d49482e15d3fe9a1..12dbf45c52fe18b1b47e8a6b22cf86b71939fb76 100644 (file)
@@ -20,15 +20,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef MAPNODE_HEADER
 #define MAPNODE_HEADER
 
-#include <iostream>
-#include "common_irrlicht.h"
+#include "irrlichttypes.h"
 #include "light.h"
-#include "exceptions.h"
-#include "serialization.h"
-#include "materials.h"
-#ifndef SERVER
-#include "tile.h"
-#endif
+
+class INodeDefManager;
 
 /*
        Naming scheme:
@@ -61,6 +56,7 @@ typedef u16 content_t;
 */
 #define CONTENT_AIR 126
 
+#ifndef SERVER
 /*
        Nodes make a face if contents differ and solidness differs.
        Return value:
@@ -69,7 +65,9 @@ typedef u16 content_t;
                2: Face uses m2's content
        equivalent: Whether the blocks share the same face (eg. water and glass)
 */
-u8 face_contents(content_t m1, content_t m2, bool *equivalent);
+u8 face_contents(content_t m1, content_t m2, bool *equivalent,
+               INodeDefManager *nodemgr);
+#endif
 
 /*
        Packs directions like (1,0,0), (1,-1,0) in six bits.
@@ -158,7 +156,7 @@ struct MapNode
        }
        
        // To be used everywhere
-       content_t getContent()
+       content_t getContent() const
        {
                if(param0 < 0x80)
                        return param0;
@@ -181,27 +179,19 @@ struct MapNode
                }
        }
        
-       /*
-               These four are DEPRECATED I guess. -c55
-       */
-       bool light_propagates();
-       bool sunlight_propagates();
-       u8 solidness();
-       u8 light_source();
-
-       void setLight(enum LightBank bank, u8 a_light);
-       u8 getLight(enum LightBank bank);
-       u8 getLightBanksWithSource();
+       void setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr);
+       u8 getLight(enum LightBank bank, INodeDefManager *nodemgr) const;
+       u8 getLightBanksWithSource(INodeDefManager *nodemgr) const;
        
        // 0 <= daylight_factor <= 1000
        // 0 <= return value <= LIGHT_SUN
-       u8 getLightBlend(u32 daylight_factor)
+       u8 getLightBlend(u32 daylight_factor, INodeDefManager *nodemgr) const
        {
-               u8 l = ((daylight_factor * getLight(LIGHTBANK_DAY)
-                       + (1000-daylight_factor) * getLight(LIGHTBANK_NIGHT))
+               u8 l = ((daylight_factor * getLight(LIGHTBANK_DAY, nodemgr)
+                       + (1000-daylight_factor) * getLight(LIGHTBANK_NIGHT, nodemgr))
                        )/1000;
                u8 max = LIGHT_MAX;
-               if(getLight(LIGHTBANK_DAY) == LIGHT_SUN)
+               if(getLight(LIGHTBANK_DAY, nodemgr) == LIGHT_SUN)
                        max = LIGHT_SUN;
                if(l > max)
                        l = max;
@@ -209,32 +199,21 @@ struct MapNode
        }
        /*// 0 <= daylight_factor <= 1000
        // 0 <= return value <= 255
-       u8 getLightBlend(u32 daylight_factor)
+       u8 getLightBlend(u32 daylight_factor, INodeDefManager *nodemgr)
        {
-               u8 daylight = decode_light(getLight(LIGHTBANK_DAY));
-               u8 nightlight = decode_light(getLight(LIGHTBANK_NIGHT));
+               u8 daylight = decode_light(getLight(LIGHTBANK_DAY, nodemgr));
+               u8 nightlight = decode_light(getLight(LIGHTBANK_NIGHT, nodemgr));
                u8 mix = ((daylight_factor * daylight
                        + (1000-daylight_factor) * nightlight)
                        )/1000;
                return mix;
        }*/
 
-       // In mapnode.cpp
-#ifndef SERVER
-       /*
-               Get tile of a face of the node.
-               dir: direction of face
-               Returns: TileSpec. Can contain miscellaneous texture coordinates,
-                        which must be obeyed so that the texture atlas can be used.
-       */
-       TileSpec getTile(v3s16 dir);
-#endif
-       
        /*
                Gets mineral content of node, if there is any.
                MINERAL_NONE if doesn't contain or isn't able to contain mineral.
        */
-       u8 getMineral();
+       u8 getMineral(INodeDefManager *nodemgr) const;
        
        /*
                Serialization functions
@@ -242,7 +221,7 @@ struct MapNode
 
        static u32 serializedLength(u8 version);
        void serialize(u8 *dest, u8 version);
-       void deSerialize(u8 *source, u8 version);
+       void deSerialize(u8 *source, u8 version, INodeDefManager *nodemgr);
        
 };
 
@@ -263,7 +242,7 @@ struct MapNode
        returns encoded light value.
 */
 u8 getFaceLight(u32 daynight_ratio, MapNode n, MapNode n2,
-               v3s16 face_dir);
+               v3s16 face_dir, INodeDefManager *nodemgr);
 
 #endif