]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/voxelalgorithms.cpp
Fix mods not being recursively enabled
[dragonfireclient.git] / src / voxelalgorithms.cpp
index cf4cee20555b087eea543fbc6961c95cf2564a5e..ffb70aa719762b92fd4d7b5a5a57d4a3554344fd 100644 (file)
@@ -65,7 +65,7 @@ struct ChangingLight {
 
        ChangingLight() = default;
 
-       ChangingLight(const relative_v3 &rel_pos, const mapblock_v3 &block_pos,
+       ChangingLight(relative_v3 rel_pos, mapblock_v3 block_pos,
                MapBlock *b, direction source_dir) :
                rel_position(rel_pos),
                block_position(block_pos),
@@ -125,8 +125,8 @@ struct LightQueue {
         * The parameters are the same as in ChangingLight's constructor.
         * \param light light level of the ChangingLight
         */
-       inline void push(u8 light, const relative_v3 &rel_pos,
-               const mapblock_v3 &block_pos, MapBlock *block,
+       inline void push(u8 light, relative_v3 rel_pos,
+               mapblock_v3 block_pos, MapBlock *block,
                direction source_dir)
        {
                assert(light <= LIGHT_SUN);
@@ -467,7 +467,7 @@ bool is_sunlight_above(Map *map, v3s16 pos, const NodeDefManager *ndef)
 static const LightBank banks[] = { LIGHTBANK_DAY, LIGHTBANK_NIGHT };
 
 void update_lighting_nodes(Map *map,
-       std::vector<std::pair<v3s16, MapNode> > &oldnodes,
+       const std::vector<std::pair<v3s16, MapNode>> &oldnodes,
        std::map<v3s16, MapBlock*> &modified_blocks)
 {
        const NodeDefManager *ndef = map->getNodeDefManager();
@@ -482,8 +482,7 @@ void update_lighting_nodes(Map *map,
                // won't change, since they didn't get their light from a
                // modified node.
                u8 min_safe_light = 0;
-               for (std::vector<std::pair<v3s16, MapNode> >::iterator it =
-                               oldnodes.begin(); it < oldnodes.end(); ++it) {
+               for (auto it = oldnodes.cbegin(); it < oldnodes.cend(); ++it) {
                        u8 old_light = it->second.getLight(bank, ndef);
                        if (old_light > min_safe_light) {
                                min_safe_light = old_light;
@@ -495,8 +494,7 @@ void update_lighting_nodes(Map *map,
                        min_safe_light++;
                }
                // For each changed node process sunlight and initialize
-               for (std::vector<std::pair<v3s16, MapNode> >::iterator it =
-                               oldnodes.begin(); it < oldnodes.end(); ++it) {
+               for (auto it = oldnodes.cbegin(); it < oldnodes.cend(); ++it) {
                        // Get position and block of the changed node
                        v3s16 p = it->first;
                        relative_v3 rel_pos;
@@ -529,7 +527,7 @@ void update_lighting_nodes(Map *map,
                                        for (const v3s16 &neighbor_dir : neighbor_dirs) {
                                                v3s16 p2 = p + neighbor_dir;
                                                bool is_valid;
-                                               MapNode n2 = map->getNodeNoEx(p2, &is_valid);
+                                               MapNode n2 = map->getNode(p2, &is_valid);
                                                if (is_valid) {
                                                        u8 spread = n2.getLight(bank, ndef);
                                                        // If it is sure that the neighbor won't be
@@ -566,7 +564,7 @@ void update_lighting_nodes(Map *map,
 
                                                MapNode n2;
 
-                                               n2 = map->getNodeNoEx(n2pos, &is_valid_position);
+                                               n2 = map->getNode(n2pos, &is_valid_position);
                                                if (!is_valid_position)
                                                        break;
 
@@ -598,7 +596,7 @@ void update_lighting_nodes(Map *map,
 
                                                MapNode n2;
 
-                                               n2 = map->getNodeNoEx(n2pos, &is_valid_position);
+                                               n2 = map->getNode(n2pos, &is_valid_position);
                                                if (!is_valid_position)
                                                        break;
 
@@ -668,7 +666,7 @@ bool is_light_locally_correct(Map *map, const NodeDefManager *ndef,
        LightBank bank, v3s16 pos)
 {
        bool is_valid_position;
-       MapNode n = map->getNodeNoEx(pos, &is_valid_position);
+       MapNode n = map->getNode(pos, &is_valid_position);
        const ContentFeatures &f = ndef->get(n);
        if (f.param_type != CPT_LIGHT) {
                return true;
@@ -677,7 +675,7 @@ bool is_light_locally_correct(Map *map, const NodeDefManager *ndef,
        assert(f.light_source <= LIGHT_MAX);
        u8 brightest_neighbor = f.light_source + 1;
        for (const v3s16 &neighbor_dir : neighbor_dirs) {
-               MapNode n2 = map->getNodeNoEx(pos + neighbor_dir,
+               MapNode n2 = map->getNode(pos + neighbor_dir,
                        &is_valid_position);
                u8 light2 = n2.getLight(bank, ndef);
                if (brightest_neighbor < light2) {
@@ -1008,7 +1006,7 @@ void finish_bulk_light_update(Map *map, mapblock_v3 minblock,
                for (relpos.X = 0; relpos.X < MAP_BLOCKSIZE; relpos.X++)
                for (relpos.Z = 0; relpos.Z < MAP_BLOCKSIZE; relpos.Z++)
                for (relpos.Y = 0; relpos.Y < MAP_BLOCKSIZE; relpos.Y++) {
-                       MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Y, &is_valid);
+                       MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
                        const ContentFeatures &f = ndef->get(node);
 
                        // For each light bank