]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/mapnode.h
Fix map deserialization and remove old serialization code
[dragonfireclient.git] / src / mapnode.h
index 32e46b63f26be0a9ef19603ffe29946f84575c75..a95497ef5c3c50e3202838299146d46c28e6e89c 100644 (file)
@@ -22,7 +22,9 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "irrlichttypes.h"
 #include "irr_v3d.h"
+#include "irr_aabb3d.h"
 #include "light.h"
+#include <vector>
 
 class INodeDefManager;
 
@@ -31,10 +33,6 @@ class INodeDefManager;
        - Material = irrlicht's Material class
        - Content = (content_t) content of a node
        - Tile = TileSpec at some side of a node of some content type
-
-       Content ranges:
-         0x000...0x07f: param2 is fully usable
-         0x800...0xfff: param2 lower 4 bits are free
 */
 typedef u16 content_t;
 #define MAX_CONTENT 0xfff
@@ -82,10 +80,8 @@ struct MapNode
 {
        /*
                Main content
-               0x00-0x7f: Short content type
-               0x80-0xff: Long content type (param2>>4 makes up low bytes)
        */
-       u8 param0;
+       u16 param0;
 
        /*
                Misc parameter. Initialized to 0.
@@ -100,7 +96,6 @@ struct MapNode
        /*
                The second parameter. Initialized to 0.
                E.g. direction for torches and flowing water.
-               If param0 >= 0x80, bits 0xf0 of this is extended content type data
        */
        u8 param2;
 
@@ -111,11 +106,9 @@ struct MapNode
        
        MapNode(content_t content=CONTENT_AIR, u8 a_param1=0, u8 a_param2=0)
        {
+               param0 = content;
                param1 = a_param1;
                param2 = a_param2;
-               // Set content (param0 and (param2&0xf0)) after other params
-               // because this needs to override part of param2
-               setContent(content);
        }
        
        // Create directly from a nodename
@@ -133,25 +126,11 @@ struct MapNode
        // To be used everywhere
        content_t getContent() const
        {
-               if(param0 < 0x80)
-                       return param0;
-               else
-                       return (param0<<4) + (param2>>4);
+               return param0;
        }
        void setContent(content_t c)
        {
-               if(c < 0x80)
-               {
-                       if(param0 >= 0x80)
-                               param2 &= ~(0xf0);
-                       param0 = c;
-               }
-               else
-               {
-                       param0 = c>>4;
-                       param2 &= ~(0xf0);
-                       param2 |= (c&0x0f)<<4;
-               }
+               param0 = c;
        }
        u8 getParam1() const
        {
@@ -163,19 +142,11 @@ struct MapNode
        }
        u8 getParam2() const
        {
-               if(param0 < 0x80)
-                       return param2;
-               else
-                       return param2 & 0x0f;
+               return param2;
        }
        void setParam2(u8 p)
        {
-               if(param0 < 0x80)
-                       param2 = p;
-               else{
-                       param2 &= 0xf0;
-                       param2 |= (p&0x0f);
-               }
+               param2 = p;
        }
        
        void setLight(enum LightBank bank, u8 a_light, INodeDefManager *nodemgr);
@@ -196,6 +167,17 @@ struct MapNode
        u8 getWallMounted(INodeDefManager *nodemgr) const;
        v3s16 getWallMountedDir(INodeDefManager *nodemgr) const;
 
+       /*
+               Gets list of node boxes (used for rendering (NDT_NODEBOX)
+               and collision)
+       */
+       std::vector<aabb3f> getNodeBoxes(INodeDefManager *nodemgr) const;
+
+       /*
+               Gets list of selection boxes
+       */
+       std::vector<aabb3f> getSelectionBoxes(INodeDefManager *nodemgr) const;
+
        /*
                Serialization functions
        */
@@ -220,7 +202,6 @@ struct MapNode
 
 private:
        // Deprecated serialization methods
-       void serialize_pre22(u8 *dest, u8 version);
        void deSerialize_pre22(u8 *source, u8 version);
 };