]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/voxel.h
Don't ignore server disconnects in client code
[dragonfireclient.git] / src / voxel.h
index 88e2edcc76b4e6e04eadaaa04187a19452651cb0..16540e5951b817849901770c1cec6476046f7992 100644 (file)
@@ -17,20 +17,19 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */
 
-#ifndef VOXEL_HEADER
-#define VOXEL_HEADER
+#pragma once
 
 #include "irrlichttypes.h"
 #include "irr_v3d.h"
 #include <iostream>
-#include "debug.h"
+#include <cassert>
 #include "exceptions.h"
 #include "mapnode.h"
 #include <set>
 #include <list>
 #include "util/basic_macros.h"
 
-class INodeDefManager;
+class NodeDefManager;
 
 // For VC++
 #undef min
@@ -60,7 +59,7 @@ class VoxelArea
 {
 public:
        // Starts as zero sized
-       VoxelArea() {}
+       VoxelArea() = default;
 
        VoxelArea(const v3s16 &min_edge, const v3s16 &max_edge):
                MinEdge(min_edge),
@@ -176,12 +175,12 @@ class VoxelArea
 
        VoxelArea operator+(const v3s16 &off) const
        {
-               return VoxelArea(MinEdge+off, MaxEdge+off);
+               return {MinEdge+off, MaxEdge+off};
        }
 
        VoxelArea operator-(const v3s16 &off) const
        {
-               return VoxelArea(MinEdge-off, MaxEdge-off);
+               return {MinEdge-off, MaxEdge-off};
        }
 
        /*
@@ -278,25 +277,36 @@ class VoxelArea
                return index(p.X, p.Y, p.Z);
        }
 
-       // Translate index in the X coordinate
-       void add_x(const v3s16 &extent, u32 &i, s16 a)
+       /**
+        * Translate index in the X coordinate
+        */
+       static void add_x(const v3s16 &extent, u32 &i, s16 a)
        {
                i += a;
        }
-       // Translate index in the Y coordinate
-       void add_y(const v3s16 &extent, u32 &i, s16 a)
+
+       /**
+        * Translate index in the Y coordinate
+        */
+       static void add_y(const v3s16 &extent, u32 &i, s16 a)
        {
                i += a * extent.X;
        }
-       // Translate index in the Z coordinate
-       void add_z(const v3s16 &extent, u32 &i, s16 a)
+
+       /**
+        * Translate index in the Z coordinate
+        */
+       static void add_z(const v3s16 &extent, u32 &i, s16 a)
        {
-               i += a * extent.X*extent.Y;
+               i += a * extent.X * extent.Y;
        }
-       // Translate index in space
-       void add_p(const v3s16 &extent, u32 &i, v3s16 a)
+
+       /**
+        * Translate index in space
+        */
+       static void add_p(const v3s16 &extent, u32 &i, v3s16 a)
        {
-               i += a.Z*extent.X*extent.Y + a.Y*extent.X + a.X;
+               i += a.Z * extent.X * extent.Y + a.Y * extent.X + a.X;
        }
 
        /*
@@ -345,7 +355,7 @@ enum VoxelPrintMode
 class VoxelManipulator
 {
 public:
-       VoxelManipulator();
+       VoxelManipulator() = default;
        virtual ~VoxelManipulator();
 
        /*
@@ -375,7 +385,7 @@ class VoxelManipulator
                addArea(voxel_area);
 
                if (m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA) {
-                       return MapNode(CONTENT_IGNORE);
+                       return {CONTENT_IGNORE};
                }
 
                return m_data[m_area.index(p)];
@@ -383,9 +393,9 @@ class VoxelManipulator
        MapNode getNodeNoExNoEmerge(const v3s16 &p)
        {
                if (!m_area.contains(p))
-                       return MapNode(CONTENT_IGNORE);
+                       return {CONTENT_IGNORE};
                if (m_flags[m_area.index(p)] & VOXELFLAG_NO_DATA)
-                       return MapNode(CONTENT_IGNORE);
+                       return {CONTENT_IGNORE};
                return m_data[m_area.index(p)];
        }
        // Stuff explodes if non-emerged area is touched with this.
@@ -450,7 +460,7 @@ class VoxelManipulator
 
        virtual void clear();
 
-       void print(std::ostream &o, INodeDefManager *nodemgr,
+       void print(std::ostream &o, const NodeDefManager *nodemgr,
                        VoxelPrintMode mode=VOXELPRINT_MATERIAL);
 
        void addArea(const VoxelArea &area);
@@ -472,15 +482,6 @@ class VoxelManipulator
 
        void clearFlag(u8 flag);
 
-       // TODO: Move to voxelalgorithms.h
-
-       void unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
-                       std::set<v3s16> & light_sources, INodeDefManager *nodemgr);
-
-       void spreadLight(enum LightBank bank, v3s16 p, INodeDefManager *nodemgr);
-       void spreadLight(enum LightBank bank,
-                       std::set<v3s16> & from_nodes, INodeDefManager *nodemgr);
-
        /*
                Member variables
        */
@@ -505,6 +506,3 @@ class VoxelManipulator
 
        static const MapNode ContentIgnoreNode;
 };
-
-#endif
-