Fix warnings and other misc. minor changes
authorkwolekr <kwolekr@minetest.net>
Fri, 14 Nov 2014 07:58:56 +0000 (02:58 -0500)
committerkwolekr <kwolekr@minetest.net>
Fri, 14 Nov 2014 08:07:12 +0000 (03:07 -0500)
src/emerge.h
src/mapgen.cpp
src/mapgen_v5.cpp
src/mapgen_v6.cpp
src/mapgen_v6.h
src/mapgen_v7.cpp
src/mg_biome.cpp
src/mg_biome.h
src/mg_ore.cpp
src/mg_ore.h
src/script/lua_api/l_mapgen.cpp

index 712289d30f7883c5527330d32fed455f96cd4950..65b1d6594ebe9e33544e436c8c88d5597ed26fe5 100644 (file)
@@ -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;
index 1d3b5869bb9d11b82edd353785c3971846d71d04..60fa842a6635b3e6bb8c9e4ae77324cfc775054f 100644 (file)
@@ -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;
index e98b211af9c2b3357e42e7816ca50a4fa3e81350..bb8c703cceb73607e1116108154b7c0c44a37360 100644 (file)
@@ -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();
index 30d51278325aa9ceb598f188c3af7ba0058008aa..de0c8168821f0589980aaa88ed910198f4574d31 100644 (file)
@@ -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) {
index 1fac37fb677645f89387f19d8bdba73bfb8cc7c4..eecfb1fe6d91bd477f49a59004478ebd29b4abf1 100644 (file)
@@ -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);
        
index 39f0984a16ba186392693d14926c3746eae726c5..8e345164e465781d449eafa3265450a9926bc8ae 100644 (file)
@@ -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();
index 4b9bc0dc190728e366d73f0770b2bc094cbb2ce4..1746be25da118681829618509fbc54922329cb0b 100644 (file)
@@ -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;
index 9c653a7687e677b45febfc5bbf54508245ab5b7a..d6130ee3a2a601d6a7ab500b014cd3f08bef2db6 100644 (file)
@@ -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);
 };
 
index 9e2d456eef470792a10b93ae3ee5b3d0b62a7322..edbb224c147005e352489f97621914a126939997 100644 (file)
@@ -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;
index c1124b0f9c93d41bd6370bbe2a9f7c822e036be6..4bf415734af3f0c40c315dc28c38f46333833d10 100644 (file)
@@ -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 {
index 71b1f474015f81873c04669958b330df6ed2e7e3..89bf8dadb17e9b7f80fe40f4df7c1964bec10112 100644 (file)
@@ -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);