diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/emerge.h | 1 | ||||
-rw-r--r-- | src/mapgen.cpp | 2 | ||||
-rw-r--r-- | src/mapgen_v5.cpp | 8 | ||||
-rw-r--r-- | src/mapgen_v6.cpp | 8 | ||||
-rw-r--r-- | src/mapgen_v6.h | 6 | ||||
-rw-r--r-- | src/mapgen_v7.cpp | 8 | ||||
-rw-r--r-- | src/mg_biome.cpp | 17 | ||||
-rw-r--r-- | src/mg_biome.h | 27 | ||||
-rw-r--r-- | src/mg_ore.cpp | 6 | ||||
-rw-r--r-- | src/mg_ore.h | 1 | ||||
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 16 |
11 files changed, 36 insertions, 64 deletions
diff --git a/src/emerge.h b/src/emerge.h index 712289d30..65b1d6594 100644 --- a/src/emerge.h +++ b/src/emerge.h @@ -42,7 +42,6 @@ with this program; if not, write to the Free Software Foundation, Inc., class EmergeThread; class INodeDefManager; class Settings; -//class ManualMapVoxelManipulator; class BiomeManager; class OreManager; diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 1d3b5869b..60fa842a6 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -348,7 +348,7 @@ GenElement *GenElementManager::getByName(std::string &name) GenElement *GenElementManager::update(u32 id, GenElement *elem) { if (id >= m_elements.size()) - return false; + return NULL; GenElement *old_elem = m_elements[id]; m_elements[id] = elem; diff --git a/src/mapgen_v5.cpp b/src/mapgen_v5.cpp index e98b211af..bb8c703cc 100644 --- a/src/mapgen_v5.cpp +++ b/src/mapgen_v5.cpp @@ -230,12 +230,8 @@ void MapgenV5::makeChunk(BlockMakeData *data) { } // Calculate biomes - BiomeNoiseInput binput; - binput.mapsize = v2s16(csize.X, csize.Z); - binput.heat_map = noise_heat->result; - binput.humidity_map = noise_humidity->result; - binput.height_map = heightmap; - bmgr->calcBiomes(&binput, biomemap); + bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result, + noise_humidity->result, heightmap, biomemap); // Actually place the biome-specific nodes generateBiomes(); diff --git a/src/mapgen_v6.cpp b/src/mapgen_v6.cpp index 30d512783..de0c81688 100644 --- a/src/mapgen_v6.cpp +++ b/src/mapgen_v6.cpp @@ -312,7 +312,7 @@ bool MapgenV6::getHaveBeach(v2s16 p) { } -BiomeType MapgenV6::getBiome(v2s16 p) { +BiomeV6Type MapgenV6::getBiome(v2s16 p) { int index = (p.Y - node_min.Z) * ystride + (p.X - node_min.X); return getBiome(index, p); } @@ -387,7 +387,7 @@ bool MapgenV6::getHaveBeach(int index) } -BiomeType MapgenV6::getBiome(int index, v2s16 p) +BiomeV6Type MapgenV6::getBiome(int index, v2s16 p) { // Just do something very simple as for now /*double d = noise2d_perlin( @@ -608,7 +608,7 @@ int MapgenV6::generateGround() { if (surface_y > stone_surface_max_y) stone_surface_max_y = surface_y; - BiomeType bt = getBiome(index, v2s16(x, z)); + BiomeV6Type bt = getBiome(index, v2s16(x, z)); // Fill ground with stone v3s16 em = vm->m_area.getExtent(); @@ -652,7 +652,7 @@ void MapgenV6::addMud() { if (surface_y == vm->m_area.MinEdge.Y - 1) continue; - BiomeType bt = getBiome(index, v2s16(x, z)); + BiomeV6Type bt = getBiome(index, v2s16(x, z)); addnode = (bt == BT_DESERT) ? n_desert_sand : n_dirt; if (bt == BT_DESERT && surface_y + mud_add_amount <= water_level + 1) { diff --git a/src/mapgen_v6.h b/src/mapgen_v6.h index 1fac37fb6..eecfb1fe6 100644 --- a/src/mapgen_v6.h +++ b/src/mapgen_v6.h @@ -34,7 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc., extern FlagDesc flagdesc_mapgen_v6[]; -enum BiomeType +enum BiomeV6Type { BT_NORMAL, BT_DESERT @@ -132,8 +132,8 @@ public: virtual float getMudAmount(int index); bool getHaveBeach(v2s16 p); bool getHaveBeach(int index); - BiomeType getBiome(v2s16 p); - BiomeType getBiome(int index, v2s16 p); + BiomeV6Type getBiome(v2s16 p); + BiomeV6Type getBiome(int index, v2s16 p); u32 get_blockseed(u64 seed, v3s16 p); diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp index 39f0984a1..8e345164e 100644 --- a/src/mapgen_v7.cpp +++ b/src/mapgen_v7.cpp @@ -233,12 +233,8 @@ void MapgenV7::makeChunk(BlockMakeData *data) { updateHeightmap(node_min, node_max); // Calculate biomes - BiomeNoiseInput binput; - binput.mapsize = v2s16(csize.X, csize.Z); - binput.heat_map = noise_heat->result; - binput.humidity_map = noise_humidity->result; - binput.height_map = heightmap; - bmgr->calcBiomes(&binput, biomemap); + bmgr->calcBiomes(csize.X, csize.Z, noise_heat->result, + noise_humidity->result, heightmap, biomemap); // Actually place the biome-specific nodes and what not generateBiomes(); diff --git a/src/mg_biome.cpp b/src/mg_biome.cpp index 4b9bc0dc1..1746be25d 100644 --- a/src/mg_biome.cpp +++ b/src/mg_biome.cpp @@ -76,14 +76,15 @@ BiomeManager::~BiomeManager() // just a PoC, obviously needs optimization later on (precalculate this) -void BiomeManager::calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map) +void BiomeManager::calcBiomes(s16 sx, s16 sy, float *heat_map, + float *humidity_map, s16 *height_map, u8 *biomeid_map) { int i = 0; - for (int y = 0; y != input->mapsize.Y; y++) { - for (int x = 0; x != input->mapsize.X; x++, i++) { - float heat = (input->heat_map[i] + 1) * 50; - float humidity = (input->humidity_map[i] + 1) * 50; - biomeid_map[i] = getBiome(heat, humidity, input->height_map[i])->id; + for (int y = 0; y != sy; y++) { + for (int x = 0; x != sx; x++, i++) { + float heat = (heat_map[i] + 1) * 50; + float humidity = (humidity_map[i] + 1) * 50; + biomeid_map[i] = getBiome(heat, humidity, height_map[i])->id; } } } @@ -96,10 +97,8 @@ Biome *BiomeManager::getBiome(float heat, float humidity, s16 y) for (size_t i = 1; i < m_elements.size(); i++) { b = (Biome *)m_elements[i]; - if (!b || y > b->height_max || y < b->height_min) { - printf("not good - %p %d %d %d\n", b, y, b->height_max, b->height_min); + if (!b || y > b->height_max || y < b->height_min) continue; - } float d_heat = heat - b->heat_point; float d_humidity = humidity - b->humidity_point; diff --git a/src/mg_biome.h b/src/mg_biome.h index 9c653a768..d6130ee3a 100644 --- a/src/mg_biome.h +++ b/src/mg_biome.h @@ -23,31 +23,19 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "mapgen.h" #include "noise.h" -//#include <string> -//#include "nodedef.h" -//#include "gamedef.h" -//#include "mapnode.h" - -enum BiomeTerrainType +enum BiomeType { - BIOME_TERRAIN_NORMAL, - BIOME_TERRAIN_LIQUID, - BIOME_TERRAIN_NETHER, - BIOME_TERRAIN_AETHER, - BIOME_TERRAIN_FLAT + BIOME_TYPE_NORMAL, + BIOME_TYPE_LIQUID, + BIOME_TYPE_NETHER, + BIOME_TYPE_AETHER, + BIOME_TYPE_FLAT }; extern NoiseParams nparams_biome_def_heat; extern NoiseParams nparams_biome_def_humidity; -struct BiomeNoiseInput { - v2s16 mapsize; - float *heat_map; - float *humidity_map; - s16 *height_map; -}; - class Biome : public GenElement { public: u32 flags; @@ -83,7 +71,8 @@ public: return new Biome; } - void calcBiomes(BiomeNoiseInput *input, u8 *biomeid_map); + void calcBiomes(s16 sx, s16 sy, float *heat_map, float *humidity_map, + s16 *height_map, u8 *biomeid_map); Biome *getBiome(float heat, float humidity, s16 y); }; diff --git a/src/mg_ore.cpp b/src/mg_ore.cpp index 9e2d456ee..edbb224c1 100644 --- a/src/mg_ore.cpp +++ b/src/mg_ore.cpp @@ -70,12 +70,6 @@ Ore::~Ore() } -std::string Ore::getName() -{ - return name; -} - - size_t Ore::placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax) { int in_range = 0; diff --git a/src/mg_ore.h b/src/mg_ore.h index c1124b0f9..4bf415734 100644 --- a/src/mg_ore.h +++ b/src/mg_ore.h @@ -73,7 +73,6 @@ public: size_t placeOre(Mapgen *mg, u32 blockseed, v3s16 nmin, v3s16 nmax); virtual void generate(ManualMapVoxelManipulator *vm, int seed, u32 blockseed, v3s16 nmin, v3s16 nmax) = 0; - virtual std::string getName(); }; class OreScatter : public Ore { diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 71b1f4740..89bf8dadb 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -38,11 +38,11 @@ with this program; if not, write to the Free Software Foundation, Inc., struct EnumString ModApiMapgen::es_BiomeTerrainType[] = { - {BIOME_TERRAIN_NORMAL, "normal"}, - {BIOME_TERRAIN_LIQUID, "liquid"}, - {BIOME_TERRAIN_NETHER, "nether"}, - {BIOME_TERRAIN_AETHER, "aether"}, - {BIOME_TERRAIN_FLAT, "flat"}, + {BIOME_TYPE_NORMAL, "normal"}, + {BIOME_TYPE_LIQUID, "liquid"}, + {BIOME_TYPE_NETHER, "nether"}, + {BIOME_TYPE_AETHER, "aether"}, + {BIOME_TYPE_FLAT, "flat"}, {0, NULL}, }; @@ -312,9 +312,9 @@ int ModApiMapgen::l_register_biome(lua_State *L) NodeResolver *resolver = getServer(L)->getNodeDefManager()->getResolver(); BiomeManager *bmgr = getServer(L)->getEmergeManager()->biomemgr; - enum BiomeTerrainType terrain = (BiomeTerrainType)getenumfield(L, index, - "terrain_type", es_BiomeTerrainType, BIOME_TERRAIN_NORMAL); - Biome *b = bmgr->create(terrain); + enum BiomeType biometype = (BiomeType)getenumfield(L, index, "type", + es_BiomeTerrainType, BIOME_TYPE_NORMAL); + Biome *b = bmgr->create(biometype); b->name = getstringfield_default(L, index, "name", ""); b->depth_top = getintfield_default(L, index, "depth_top", 1); |