diff options
author | Loic Blot <loic.blot@unix-experience.fr> | 2018-03-09 08:49:00 +0100 |
---|---|---|
committer | Loïc Blot <nerzhul@users.noreply.github.com> | 2018-03-09 23:27:26 +0100 |
commit | 12d1e4ff0486f86ae20051daa1135dc7db366023 (patch) | |
tree | 20505a9d8b05540cbdcb8faf2da9e4542126e9fe /src | |
parent | 3b27cf30d99a5b4e82677c253bee269574edbaa0 (diff) | |
download | minetest-12d1e4ff0486f86ae20051daa1135dc7db366023.tar.gz minetest-12d1e4ff0486f86ae20051daa1135dc7db366023.tar.bz2 minetest-12d1e4ff0486f86ae20051daa1135dc7db366023.zip |
VoxelArea: add_{x,y,z,p} must be static
Fix some documentations issues
Use getNodeNoCheck(v3s16, ...) in some cases instead of getNodeNoCheck(x, y, z, ...)
Diffstat (limited to 'src')
-rw-r--r-- | src/mapgen/cavegen.cpp | 4 | ||||
-rw-r--r-- | src/mapgen/mapgen.cpp | 32 | ||||
-rw-r--r-- | src/mapgen/mapgen_flat.cpp | 2 | ||||
-rw-r--r-- | src/mapgen/mapgen_v6.cpp | 36 | ||||
-rw-r--r-- | src/mapgen/mapgen_v7.cpp | 2 | ||||
-rw-r--r-- | src/mapgen/mapgen_valleys.cpp | 6 | ||||
-rw-r--r-- | src/mapgen/mg_decoration.cpp | 8 | ||||
-rw-r--r-- | src/serverenvironment.cpp | 4 | ||||
-rw-r--r-- | src/serverenvironment.h | 4 | ||||
-rw-r--r-- | src/voxel.h | 31 | ||||
-rw-r--r-- | src/voxelalgorithms.cpp | 4 |
11 files changed, 72 insertions, 61 deletions
diff --git a/src/mapgen/cavegen.cpp b/src/mapgen/cavegen.cpp index cfaaab9df..d4cb5733b 100644 --- a/src/mapgen/cavegen.cpp +++ b/src/mapgen/cavegen.cpp @@ -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]) * diff --git a/src/mapgen/mapgen.cpp b/src/mapgen/mapgen.cpp index a39e29004..078d6c486 100644 --- a/src/mapgen/mapgen.cpp +++ b/src/mapgen/mapgen.cpp @@ -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); } } diff --git a/src/mapgen/mapgen_flat.cpp b/src/mapgen/mapgen_flat.cpp index 1de87df87..57d358e86 100644 --- a/src/mapgen/mapgen_flat.cpp +++ b/src/mapgen/mapgen_flat.cpp @@ -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); } } diff --git a/src/mapgen/mapgen_v6.cpp b/src/mapgen/mapgen_v6.cpp index 43c6f3665..ae6c2ad9b 100644 --- a/src/mapgen/mapgen_v6.cpp +++ b/src/mapgen/mapgen_v6.cpp @@ -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) { diff --git a/src/mapgen/mapgen_v7.cpp b/src/mapgen/mapgen_v7.cpp index 252469457..2c50be96c 100644 --- a/src/mapgen/mapgen_v7.cpp +++ b/src/mapgen/mapgen_v7.cpp @@ -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; } } diff --git a/src/mapgen/mapgen_valleys.cpp b/src/mapgen/mapgen_valleys.cpp index 0c606f3e8..5fd3455a6 100644 --- a/src/mapgen/mapgen_valleys.cpp +++ b/src/mapgen/mapgen_valleys.cpp @@ -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 diff --git a/src/mapgen/mg_decoration.cpp b/src/mapgen/mg_decoration.cpp index 2491ef2fd..dd621db11 100644 --- a/src/mapgen/mg_decoration.cpp +++ b/src/mapgen/mg_decoration.cpp @@ -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; diff --git a/src/serverenvironment.cpp b/src/serverenvironment.cpp index 8a26c0272..4ca76eead 100644 --- a/src/serverenvironment.cpp +++ b/src/serverenvironment.cpp @@ -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() { diff --git a/src/serverenvironment.h b/src/serverenvironment.h index ee5e8d857..f4996cdc6 100644 --- a/src/serverenvironment.h +++ b/src/serverenvironment.h @@ -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(); diff --git a/src/voxel.h b/src/voxel.h index 687336923..16540e595 100644 --- a/src/voxel.h +++ b/src/voxel.h @@ -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; } /* diff --git a/src/voxelalgorithms.cpp b/src/voxelalgorithms.cpp index f22faef71..cf4cee205 100644 --- a/src/voxelalgorithms.cpp +++ b/src/voxelalgorithms.cpp @@ -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++) { |