From d661e07790c984e623e83de7db9f93a03d7ac5d2 Mon Sep 17 00:00:00 2001 From: paramat Date: Mon, 11 Jan 2016 00:30:03 +0000 Subject: [PATCH] Mapgen: Various fixes and improvements Lua_api.txt: Document 'minetest.registered_biomes' Cavegen: Add fallback node for 'mapgen_ice' Dungeongen: Add fallback node for 'mapgen_river_water_source' Mgv5: Remove unnecessary '#include util/directiontables.h' Add missing 'this->'s in makeChunk() Mgv6: Edit empty line formatting Remove leading spaces in makeChunk() Add missing spaces after 'for' and 'if' Mgv7: Edit empty line formatting --- doc/lua_api.txt | 2 ++ src/cavegen.cpp | 3 +++ src/dungeongen.cpp | 2 ++ src/mapgen_v5.cpp | 7 +++---- src/mapgen_v6.cpp | 20 +++++++++++--------- src/mapgen_v7.cpp | 1 + 6 files changed, 22 insertions(+), 13 deletions(-) diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 0746de61..28db0dc6 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -2464,6 +2464,8 @@ These functions return the leftover itemstack. * Map of Lua entities, indexed by active object id * `minetest.registered_ores` * List of registered ore definitions. +* `minetest.registered_biomes` + * List of registered biome definitions. * `minetest.registered_decorations` * List of registered decoration definitions. diff --git a/src/cavegen.cpp b/src/cavegen.cpp index 191dfa57..4ec241e9 100644 --- a/src/cavegen.cpp +++ b/src/cavegen.cpp @@ -46,6 +46,9 @@ CaveV5::CaveV5(Mapgen *mg, PseudoRandom *ps) c_ice = ndef->getId("mapgen_ice"); this->np_caveliquids = &nparams_caveliquids; this->ystride = mg->csize.X; + + if (c_ice == CONTENT_IGNORE) + c_ice = CONTENT_AIR; dswitchint = ps->range(1, 14); flooded = ps->range(1, 2) == 2; diff --git a/src/dungeongen.cpp b/src/dungeongen.cpp index c9b8f58f..4fe3cada 100644 --- a/src/dungeongen.cpp +++ b/src/dungeongen.cpp @@ -71,6 +71,8 @@ DungeonGen::DungeonGen(Mapgen *mapgen, DungeonParams *dparams) // For mapgens using river water dp.c_river_water = mg->ndef->getId("mapgen_river_water_source"); + if (dp.c_river_water == CONTENT_IGNORE) + dp.c_river_water = mg->ndef->getId("mapgen_water_source"); } diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index c2aa7305..c123315c 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -41,7 +41,6 @@ along with this program. If not, see . #include "mg_ore.h" #include "mg_decoration.h" #include "mapgen_v5.h" -#include "util/directiontables.h" FlagDesc flagdesc_mapgen_v5[] = { @@ -219,9 +218,9 @@ void MapgenV5::makeChunk(BlockMakeData *data) data->blockpos_requested.Y <= data->blockpos_max.Y && data->blockpos_requested.Z <= data->blockpos_max.Z); - generating = true; - vm = data->vmanip; - ndef = data->nodedef; + this->generating = true; + this->vm = data->vmanip; + this->ndef = data->nodedef; //TimeTaker t("makeChunk"); v3s16 blockpos_min = data->blockpos_min; diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index 68fef657..1b6f0029 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -20,6 +20,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . */ + #include "mapgen.h" #include "voxel.h" #include "noise.h" @@ -40,6 +41,7 @@ along with this program. If not, see . #include "mg_decoration.h" #include "mapgen_v6.h" + FlagDesc flagdesc_mapgen_v6[] = { {"jungles", MGV6_JUNGLES}, {"biomeblend", MGV6_BIOMEBLEND}, @@ -50,7 +52,8 @@ FlagDesc flagdesc_mapgen_v6[] = { {NULL, 0} }; -/////////////////////////////////////////////////////////////////////////////// + +///////////////////////////////////////////////////////////////////////////// MapgenV6::MapgenV6(int mapgenid, MapgenParams *params, EmergeManager *emerge) @@ -200,7 +203,6 @@ void MapgenV6Params::writeParams(Settings *settings) const //////////////////////// Some helper functions for the map generator - // Returns Y one under area minimum if not found s16 MapgenV6::find_stone_level(v2s16 p2d) { @@ -471,11 +473,11 @@ void MapgenV6::makeChunk(BlockMakeData *data) assert(data->vmanip); assert(data->nodedef); assert(data->blockpos_requested.X >= data->blockpos_min.X && - data->blockpos_requested.Y >= data->blockpos_min.Y && - data->blockpos_requested.Z >= data->blockpos_min.Z); + data->blockpos_requested.Y >= data->blockpos_min.Y && + data->blockpos_requested.Z >= data->blockpos_min.Z); assert(data->blockpos_requested.X <= data->blockpos_max.X && - data->blockpos_requested.Y <= data->blockpos_max.Y && - data->blockpos_requested.Z <= data->blockpos_max.Z); + data->blockpos_requested.Y <= data->blockpos_max.Y && + data->blockpos_requested.Z <= data->blockpos_max.Z); this->generating = true; this->vm = data->vmanip; @@ -811,7 +813,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos) continue; // Drop mud on side - for(u32 di = 0; di < 4; di++) { + for (u32 di = 0; di < 4; di++) { v3s16 dirp = dirs4[di]; u32 i2 = i; // Move to side @@ -836,7 +838,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos) vm->m_area.add_y(em, i2, -1); n2 = &vm->m_data[i2]; // if out of known area - if(vm->m_area.contains(i2) == false || + if (vm->m_area.contains(i2) == false || n2->getContent() == CONTENT_IGNORE) { dropped_to_unknown = true; break; @@ -851,7 +853,7 @@ void MapgenV6::flowMud(s16 &mudflow_minpos, s16 &mudflow_maxpos) if (!dropped_to_unknown) { *n2 = *n; // Set old place to be air (or water) - if(old_is_water) + if (old_is_water) *n = MapNode(c_water_source); else *n = MapNode(CONTENT_AIR); diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 812e19cc..b503b2b2 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -49,6 +49,7 @@ FlagDesc flagdesc_mapgen_v7[] = { {NULL, 0} }; + ///////////////////////////////////////////////////////////////////////////////