VoxelArea: add_{x,y,z,p} must be static
authorLoic Blot <loic.blot@unix-experience.fr>
Fri, 9 Mar 2018 07:49:00 +0000 (08:49 +0100)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Fri, 9 Mar 2018 22:27:26 +0000 (23:27 +0100)
Fix some documentations issues
Use getNodeNoCheck(v3s16, ...) in some cases instead of getNodeNoCheck(x, y, z, ...)

src/mapgen/cavegen.cpp
src/mapgen/mapgen.cpp
src/mapgen/mapgen_flat.cpp
src/mapgen/mapgen_v6.cpp
src/mapgen/mapgen_v7.cpp
src/mapgen/mapgen_valleys.cpp
src/mapgen/mg_decoration.cpp
src/serverenvironment.cpp
src/serverenvironment.h
src/voxel.h
src/voxelalgorithms.cpp

index cfaaab9dff61d64c4bf935866601087c9e55ae3b..d4cb5733b81aaf953021ec40a725edf651b3a177 100644 (file)
@@ -100,7 +100,7 @@ void CavesNoiseIntersection::generateCaves(MMVManip *vm,
                // This 'roof' is removed when the mapchunk above is generated.
                for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
                                index3d -= m_ystride,
-                               vm->m_area.add_y(em, vi, -1)) {
+                               VoxelArea::add_y(em, vi, -1)) {
                        content_t c = vm->m_data[vi].getContent();
 
                        if (c == CONTENT_AIR || c == biome->c_water_top ||
@@ -245,7 +245,7 @@ bool CavernsNoise::generateCaverns(MMVManip *vm, v3s16 nmin, v3s16 nmax)
                // This 'roof' is excavated when the mapchunk above is generated.
                for (s16 y = nmax.Y; y >= nmin.Y - 1; y--,
                                index3d -= m_ystride,
-                               vm->m_area.add_y(em, vi, -1),
+                               VoxelArea::add_y(em, vi, -1),
                                cavern_amp_index++) {
                        content_t c = vm->m_data[vi].getContent();
                        float n_absamp_cavern = fabs(noise_cavern->result[index3d]) *
index a39e290043dc06f1731071a2793dbe37d81fe381..078d6c486df4a1f9b1280de87e96af2c8e67774b 100644 (file)
@@ -238,7 +238,7 @@ s16 Mapgen::findGroundLevelFull(v2s16 p2d)
                if (ndef->get(n).walkable)
                        break;
 
-               vm->m_area.add_y(em, i, -1);
+               VoxelArea::add_y(em, i, -1);
        }
        return (y >= y_nodes_min) ? y : y_nodes_min - 1;
 }
@@ -256,7 +256,7 @@ s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
                if (ndef->get(n).walkable)
                        break;
 
-               vm->m_area.add_y(em, i, -1);
+               VoxelArea::add_y(em, i, -1);
        }
        return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
 }
@@ -277,7 +277,7 @@ s16 Mapgen::findLiquidSurface(v2s16 p2d, s16 ymin, s16 ymax)
                if (ndef->get(n).isLiquid())
                        break;
 
-               vm->m_area.add_y(em, i, -1);
+               VoxelArea::add_y(em, i, -1);
        }
        return (y >= ymin) ? y : -MAX_MAP_GENERATION_LIMIT;
 }
@@ -309,7 +309,7 @@ void Mapgen::getSurfaces(v2s16 p2d, s16 ymin, s16 ymax,
        u32 vi = vm->m_area.index(p2d.X, ymax, p2d.Y);
        MapNode mn_max = vm->m_data[vi];
        bool walkable_above = ndef->get(mn_max).walkable;
-       vm->m_area.add_y(em, vi, -1);
+       VoxelArea::add_y(em, vi, -1);
 
        for (s16 y = ymax - 1; y >= ymin; y--) {
                MapNode mn = vm->m_data[vi];
@@ -321,7 +321,7 @@ void Mapgen::getSurfaces(v2s16 p2d, s16 ymin, s16 ymax,
                        ceilings.push_back(y + 1);
                }
 
-               vm->m_area.add_y(em, vi, -1);
+               VoxelArea::add_y(em, vi, -1);
                walkable_above = is_walkable;
        }
 }
@@ -330,28 +330,28 @@ void Mapgen::getSurfaces(v2s16 p2d, s16 ymin, s16 ymax,
 inline bool Mapgen::isLiquidHorizontallyFlowable(u32 vi, v3s16 em)
 {
        u32 vi_neg_x = vi;
-       vm->m_area.add_x(em, vi_neg_x, -1);
+       VoxelArea::add_x(em, vi_neg_x, -1);
        if (vm->m_data[vi_neg_x].getContent() != CONTENT_IGNORE) {
                const ContentFeatures &c_nx = ndef->get(vm->m_data[vi_neg_x]);
                if (c_nx.floodable && !c_nx.isLiquid())
                        return true;
        }
        u32 vi_pos_x = vi;
-       vm->m_area.add_x(em, vi_pos_x, +1);
+       VoxelArea::add_x(em, vi_pos_x, +1);
        if (vm->m_data[vi_pos_x].getContent() != CONTENT_IGNORE) {
                const ContentFeatures &c_px = ndef->get(vm->m_data[vi_pos_x]);
                if (c_px.floodable && !c_px.isLiquid())
                        return true;
        }
        u32 vi_neg_z = vi;
-       vm->m_area.add_z(em, vi_neg_z, -1);
+       VoxelArea::add_z(em, vi_neg_z, -1);
        if (vm->m_data[vi_neg_z].getContent() != CONTENT_IGNORE) {
                const ContentFeatures &c_nz = ndef->get(vm->m_data[vi_neg_z]);
                if (c_nz.floodable && !c_nz.isLiquid())
                        return true;
        }
        u32 vi_pos_z = vi;
-       vm->m_area.add_z(em, vi_pos_z, +1);
+       VoxelArea::add_z(em, vi_pos_z, +1);
        if (vm->m_data[vi_pos_z].getContent() != CONTENT_IGNORE) {
                const ContentFeatures &c_pz = ndef->get(vm->m_data[vi_pos_z]);
                if (c_pz.floodable && !c_pz.isLiquid())
@@ -395,7 +395,7 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
                        } else {
                                // This is the topmost node below a liquid column
                                u32 vi_above = vi;
-                               vm->m_area.add_y(em, vi_above, 1);
+                               VoxelArea::add_y(em, vi_above, 1);
                                if (!waspushed && (ndef->get(vm->m_data[vi]).floodable ||
                                                (!waschecked && isLiquidHorizontallyFlowable(vi_above, em)))) {
                                        // Push back the lowest node in the column which is one
@@ -406,7 +406,7 @@ void Mapgen::updateLiquid(UniqueQueue<v3s16> *trans_liquid, v3s16 nmin, v3s16 nm
 
                        wasliquid = isliquid;
                        wasignored = isignored;
-                       vm->m_area.add_y(em, vi, -1);
+                       VoxelArea::add_y(em, vi, -1);
                }
        }
 }
@@ -502,14 +502,14 @@ void Mapgen::propagateSunlight(v3s16 nmin, v3s16 nmax, bool propagate_shadow)
                                        propagate_shadow) {
                                continue;
                        }
-                       vm->m_area.add_y(em, i, -1);
+                       VoxelArea::add_y(em, i, -1);
 
                        for (int y = a.MaxEdge.Y; y >= a.MinEdge.Y; y--) {
                                MapNode &n = vm->m_data[i];
                                if (!ndef->get(n).sunlight_propagates)
                                        break;
                                n.param1 = LIGHT_SUN;
-                               vm->m_area.add_y(em, i, -1);
+                               VoxelArea::add_y(em, i, -1);
                        }
                }
        }
@@ -773,7 +773,7 @@ void MapgenBasic::generateBiomes(MgStoneType *mgstone_type,
                                water_above = false;
                        }
 
-                       vm->m_area.add_y(em, vi, -1);
+                       VoxelArea::add_y(em, vi, -1);
                }
        }
 
@@ -820,7 +820,7 @@ void MapgenBasic::dustTopNodes()
                        if (vm->m_data[vi].getContent() != CONTENT_AIR)
                                break;
 
-                       vm->m_area.add_y(em, vi, -1);
+                       VoxelArea::add_y(em, vi, -1);
                }
 
                content_t c = vm->m_data[vi].getContent();
@@ -834,7 +834,7 @@ void MapgenBasic::dustTopNodes()
                                dtype == NDT_GLASSLIKE_FRAMED ||
                                dtype == NDT_ALLFACES) &&
                                ndef->get(c).walkable && c != biome->c_dust) {
-                       vm->m_area.add_y(em, vi, 1);
+                       VoxelArea::add_y(em, vi, 1);
                        vm->m_data[vi] = MapNode(biome->c_dust);
                }
        }
index 1de87df8723bce6fdac1de7f0a9bdfe3a6969c6d..57d358e86bf7ee7038cbf64e5eac8a877a86e160 100644 (file)
@@ -273,7 +273,7 @@ s16 MapgenFlat::generateTerrain()
                                        vm->m_data[vi] = n_air;
                                }
                        }
-                       vm->m_area.add_y(em, vi, 1);
+                       VoxelArea::add_y(em, vi, 1);
                }
        }
 
index 43c6f36654f3ed7eec3003aa784f915a1c5ef1f3..ae6c2ad9b41278409eab5e024de866089b72a78b 100644 (file)
@@ -223,7 +223,7 @@ s16 MapgenV6::find_stone_level(v2s16 p2d)
                if (c != CONTENT_IGNORE && (c == c_stone || c == c_desert_stone))
                        break;
 
-               vm->m_area.add_y(em, i, -1);
+               VoxelArea::add_y(em, i, -1);
        }
        return (y >= y_nodes_min) ? y : y_nodes_min - 1;
 }
@@ -696,7 +696,7 @@ int MapgenV6::generateGround()
                                        vm->m_data[i] = n_air;
                                }
                        }
-                       vm->m_area.add_y(em, i, 1);
+                       VoxelArea::add_y(em, i, 1);
                }
        }
 
@@ -759,7 +759,7 @@ void MapgenV6::addMud()
                        vm->m_data[i] = addnode;
                        mudcount++;
 
-                       vm->m_area.add_y(em, i, 1);
+                       VoxelArea::add_y(em, i, 1);
                }
        }
 }
@@ -799,7 +799,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                                        n->getContent() == c_gravel)
                                                break;
 
-                                       vm->m_area.add_y(em, i, -1);
+                                       VoxelArea::add_y(em, i, -1);
                                }
 
                                // Stop if out of area
@@ -815,7 +815,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                        // Don't flow it if the stuff under it is not mud
                                        {
                                                u32 i2 = i;
-                                               vm->m_area.add_y(em, i2, -1);
+                                               VoxelArea::add_y(em, i2, -1);
                                                // Cancel if out of area
                                                if (!vm->m_area.contains(i2))
                                                        continue;
@@ -826,7 +826,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                        }
                                }
 
-                               v3s16 dirs4[4] = {
+                               static const v3s16 dirs4[4] = {
                                        v3s16(0, 0, 1), // back
                                        v3s16(1, 0, 0), // right
                                        v3s16(0, 0, -1), // front
@@ -836,7 +836,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                // Check that upper is walkable. Cancel
                                // dropping if upper keeps it in place.
                                u32 i3 = i;
-                               vm->m_area.add_y(em, i3, 1);
+                               VoxelArea::add_y(em, i3, 1);
                                MapNode *n3 = NULL;
 
                                if (vm->m_area.contains(i3)) {
@@ -849,7 +849,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                for (const v3s16 &dirp : dirs4) {
                                        u32 i2 = i;
                                        // Move to side
-                                       vm->m_area.add_p(em, i2, dirp);
+                                       VoxelArea::add_p(em, i2, dirp);
                                        // Fail if out of area
                                        if (!vm->m_area.contains(i2))
                                                continue;
@@ -858,7 +858,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                        if (ndef->get(*n2).walkable)
                                                continue;
                                        // Check that under side is air
-                                       vm->m_area.add_y(em, i2, -1);
+                                       VoxelArea::add_y(em, i2, -1);
                                        if (!vm->m_area.contains(i2))
                                                continue;
                                        n2 = &vm->m_data[i2];
@@ -867,7 +867,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                        // Loop further down until not air
                                        bool dropped_to_unknown = false;
                                        do {
-                                               vm->m_area.add_y(em, i2, -1);
+                                               VoxelArea::add_y(em, i2, -1);
                                                n2 = &vm->m_data[i2];
                                                // if out of known area
                                                if (!vm->m_area.contains(i2) ||
@@ -877,7 +877,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos)
                                                }
                                        } while (!ndef->get(*n2).walkable);
                                        // Loop one up so that we're in air
-                                       vm->m_area.add_y(em, i2, 1);
+                                       VoxelArea::add_y(em, i2, 1);
 
                                        // Move mud to new place. Outside mapchunk remove
                                        // any decorations above removed or placed mud.
@@ -917,17 +917,17 @@ void MapgenV6::moveMud(u32 remove_index, u32 place_index,
                                vm->m_data[above_remove_index].getContent() != c_water_source &&
                                vm->m_data[above_remove_index].getContent() != CONTENT_IGNORE) {
                        vm->m_data[above_remove_index] = n_air;
-                       vm->m_area.add_y(em, above_remove_index, 1);
+                       VoxelArea::add_y(em, above_remove_index, 1);
                }
                // Mud placed may have partially-buried a stacked decoration, search
                // above and remove.
-               vm->m_area.add_y(em, place_index, 1);
+               VoxelArea::add_y(em, place_index, 1);
                while (vm->m_area.contains(place_index) &&
                                vm->m_data[place_index].getContent() != CONTENT_AIR &&
                                vm->m_data[place_index].getContent() != c_water_source &&
                                vm->m_data[place_index].getContent() != CONTENT_IGNORE) {
                        vm->m_data[place_index] = n_air;
-                       vm->m_area.add_y(em, place_index, 1);
+                       VoxelArea::add_y(em, place_index, 1);
                }
        }
 }
@@ -1001,7 +1001,7 @@ void MapgenV6::placeTreesAndJungleGrass()
                                u32 vi = vm->m_area.index(x, y, z);
                                // place on dirt_with_grass, since we know it is exposed to sunlight
                                if (vm->m_data[vi].getContent() == c_dirt_with_grass) {
-                                       vm->m_area.add_y(em, vi, 1);
+                                       VoxelArea::add_y(em, vi, 1);
                                        vm->m_data[vi] = n_junglegrass;
                                }
                        }
@@ -1071,7 +1071,7 @@ void MapgenV6::growGrass() // Add surface nodes
                                                ndef->get(n).liquid_type != LIQUID_NONE ||
                                                n.getContent() == c_ice)
                                        break;
-                               vm->m_area.add_y(em, i, -1);
+                               VoxelArea::add_y(em, i, -1);
                        }
                        surface_y = (y >= full_node_min.Y) ? y : full_node_min.Y;
                }
@@ -1085,10 +1085,10 @@ void MapgenV6::growGrass() // Add surface nodes
                        } else if (bt == BT_TUNDRA) {
                                if (c == c_dirt) {
                                        vm->m_data[i] = n_snowblock;
-                                       vm->m_area.add_y(em, i, -1);
+                                       VoxelArea::add_y(em, i, -1);
                                        vm->m_data[i] = n_dirt_with_snow;
                                } else if (c == c_stone && surface_y < node_max.Y) {
-                                       vm->m_area.add_y(em, i, 1);
+                                       VoxelArea::add_y(em, i, 1);
                                        vm->m_data[i] = n_snowblock;
                                }
                        } else if (c == c_dirt) {
index 252469457a124b783a8c0221c1ff5aa48d65f6fc..2c50be96cf621f6a826e387d3f925d34f919f563 100644 (file)
@@ -539,7 +539,7 @@ int MapgenV7::generateTerrain()
                                        vm->m_data[vi] = n_air;
                                }
                        }
-                       vm->m_area.add_y(em, vi, 1);
+                       VoxelArea::add_y(em, vi, 1);
                        index3d += ystride;
                }
        }
index 0c606f3e870e5bd9c2e50a78ef49006d8c2a6d2f..5fd3455a64398a737934e41a6548ab14d5137e3d 100644 (file)
@@ -540,7 +540,7 @@ int MapgenValleys::generateTerrain()
                                }
                        }
 
-                       vm->m_area.add_y(em, index_data, 1);
+                       VoxelArea::add_y(em, index_data, 1);
                        index_3d += ystride;
                }
 
@@ -668,7 +668,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth)
                // This 'roof' is removed when the mapchunk above is generated.
                for (s16 y = node_max.Y; y >= node_min.Y - 1; y--,
                                index_3d -= ystride,
-                               vm->m_area.add_y(em, index_data, -1)) {
+                               VoxelArea::add_y(em, index_data, -1)) {
 
                        float terrain = noise_terrain_height->result[index_2d];
 
@@ -705,7 +705,7 @@ void MapgenValleys::generateCaves(s16 max_stone_y, s16 large_cave_depth)
                                        // at the tunnel floor
                                        s16 sr = ps.range(0, 39);
                                        u32 j = index_data;
-                                       vm->m_area.add_y(em, j, 1);
+                                       VoxelArea::add_y(em, j, 1);
 
                                        if (sr > terrain - y) {
                                                // Put biome nodes in tunnels near the surface
index 2491ef2fda5578b06d85ed33453a4198fc7e4fab..dd621db111e04e779fb7a49ff1ef5f90c67b0325 100644 (file)
@@ -301,10 +301,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling)
        if (ceiling) {
                // Ceiling decorations
                // 'place offset y' is inverted
-               vm->m_area.add_y(em, vi, -place_offset_y);
+               VoxelArea::add_y(em, vi, -place_offset_y);
 
                for (int i = 0; i < height; i++) {
-                       vm->m_area.add_y(em, vi, -1);
+                       VoxelArea::add_y(em, vi, -1);
                        content_t c = vm->m_data[vi].getContent();
                        if (c != CONTENT_AIR && c != CONTENT_IGNORE && !force_placement)
                                break;
@@ -312,10 +312,10 @@ size_t DecoSimple::generate(MMVManip *vm, PcgRandom *pr, v3s16 p, bool ceiling)
                        vm->m_data[vi] = MapNode(c_place, 0, param2);
                }
        } else { // Heightmap and floor decorations
-               vm->m_area.add_y(em, vi, place_offset_y);
+               VoxelArea::add_y(em, vi, place_offset_y);
 
                for (int i = 0; i < height; i++) {
-                       vm->m_area.add_y(em, vi, 1);
+                       VoxelArea::add_y(em, vi, 1);
                        content_t c = vm->m_data[vi].getContent();
                        if (c != CONTENT_AIR && c != CONTENT_IGNORE && !force_placement)
                                break;
index 8a26c027288b9529fc878d640571ccd53efadd25..4ca76eead2a954844fe031335cc957f3f5187a41 100644 (file)
@@ -1430,8 +1430,8 @@ bool ServerEnvironment::isFreeServerActiveObjectId(u16 id) const
 }
 
 /**
- * Retrieve the next free activeobject ID
- * @return free activeobject ID or zero if not free ID found
+ * Retrieve the first free ActiveObject ID
+ * @return free activeobject ID or 0 if none was found
  */
 u16 ServerEnvironment::getFreeServerActiveObjectId()
 {
index ee5e8d8577a9ac41cab1edd3fe662292bac5ddc1..f4996cdc61a552d77f61fa7f22d93c84847a9887 100644 (file)
@@ -265,8 +265,8 @@ public:
        bool isFreeServerActiveObjectId(u16 id) const;
 
        /**
-        * Retrieve the next free activeobject ID
-        * @return free activeobject ID or zero if not free ID found
+        * Retrieve the first free ActiveObject ID
+        * @return free activeobject ID or 0 if none was found
         */
        u16 getFreeServerActiveObjectId();
 
index 687336923044e53175c914120ebad6f67f08f93f..16540e5951b817849901770c1cec6476046f7992 100644 (file)
@@ -277,25 +277,36 @@ public:
                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;
        }
 
        /*
index f22faef7143cf7970a010446cf522c9363436ed0..cf4cee20555b087eea543fbc6961c95cf2564a5e 100644 (file)
@@ -1111,7 +1111,7 @@ void blit_back_with_light(ServerMap *map, MMVManip *vm,
                        for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
 
                                // Get old and new node
-                               MapNode oldnode = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
+                               MapNode oldnode = block->getNodeNoCheck(relpos, &is_valid);
                                const ContentFeatures &oldf = ndef->get(oldnode);
                                MapNode newnode = vm->getNodeNoExNoEmerge(relpos + offset);
                                const ContentFeatures &newf = oldnode == newnode ? oldf :
@@ -1240,7 +1240,7 @@ void repair_block_light(ServerMap *map, MapBlock *block,
                for (relpos.Y = a.MinEdge.Y; relpos.Y <= a.MaxEdge.Y; relpos.Y++) {
 
                        // Get node
-                       MapNode node = block->getNodeNoCheck(relpos.X, relpos.Y, relpos.Z, &is_valid);
+                       MapNode node = block->getNodeNoCheck(relpos, &is_valid);
                        const ContentFeatures &f = ndef->get(node);
                        // For each light bank
                        for (size_t b = 0; b < 2; b++) {