Modernize client code (#6250)
[oweals/minetest.git] / src / voxel.cpp
index 78efde5bbf3de512ec1da0f9cf1bede13c53718a..981bc58233cb73a2c7686e824e89d12d6e9beda3 100644 (file)
@@ -33,9 +33,7 @@ u64 emerge_load_time = 0;
 u64 clearflag_time = 0;
 
 
-VoxelManipulator::VoxelManipulator():
-       m_data(NULL),
-       m_flags(NULL)
+VoxelManipulator::VoxelManipulator()
 {
 }
 
@@ -49,15 +47,15 @@ void VoxelManipulator::clear()
        // Reset area to volume=0
        m_area = VoxelArea();
        delete[] m_data;
-       m_data = NULL;
+       m_data = nullptr;
        delete[] m_flags;
-       m_flags = NULL;
+       m_flags = nullptr;
 }
 
 void VoxelManipulator::print(std::ostream &o, INodeDefManager *ndef,
                VoxelPrintMode mode)
 {
-       v3s16 em = m_area.getExtent();
+       const v3s16 &em = m_area.getExtent();
        v3s16 of = m_area.MinEdge;
        o<<"size: "<<em.X<<"x"<<em.Y<<"x"<<em.Z
         <<" offset: ("<<of.X<<","<<of.Y<<","<<of.Z<<")"<<std::endl;
@@ -210,7 +208,7 @@ void VoxelManipulator::addArea(const VoxelArea &area)
 }
 
 void VoxelManipulator::copyFrom(MapNode *src, const VoxelArea& src_area,
-               v3s16 from_pos, v3s16 to_pos, v3s16 size)
+               v3s16 from_pos, v3s16 to_pos, const v3s16 &size)
 {
        /* The reason for this optimised code is that we're a member function
         * and the data type/layout of m_data is know to us: it's stored as
@@ -258,7 +256,7 @@ void VoxelManipulator::copyFrom(MapNode *src, const VoxelArea& src_area,
 }
 
 void VoxelManipulator::copyTo(MapNode *dst, const VoxelArea& dst_area,
-               v3s16 dst_pos, v3s16 from_pos, v3s16 size)
+               v3s16 dst_pos, v3s16 from_pos, const v3s16 &size)
 {
        for(s16 z=0; z<size.Z; z++)
        for(s16 y=0; y<size.Y; y++)
@@ -386,37 +384,6 @@ void VoxelManipulator::unspreadLight(enum LightBank bank, v3s16 p, u8 oldlight,
        }
 }
 
-/*
-       Goes recursively through the neighbours of the node.
-
-       Alters only transparent nodes.
-
-       If the lighting of the neighbour is lower than the lighting of
-       the node was (before changing it to 0 at the step before), the
-       lighting of the neighbour is set to 0 and then the same stuff
-       repeats for the neighbour.
-
-       The ending nodes of the routine are stored in light_sources.
-       This is useful when a light is removed. In such case, this
-       routine can be called for the light node and then again for
-       light_sources to re-light the area without the removed light.
-
-       values of from_nodes are lighting values.
-*/
-void VoxelManipulator::unspreadLight(enum LightBank bank,
-               std::map<v3s16, u8> & from_nodes,
-               std::set<v3s16> & light_sources, INodeDefManager *nodemgr)
-{
-       if(from_nodes.empty())
-               return;
-
-       for(std::map<v3s16, u8>::iterator j = from_nodes.begin();
-               j != from_nodes.end(); ++j)
-       {
-               unspreadLight(bank, j->first, j->second, light_sources, nodemgr);
-       }
-}
-
 void VoxelManipulator::spreadLight(enum LightBank bank, v3s16 p,
                INodeDefManager *nodemgr)
 {