]> git.lizzy.rs Git - minetest.git/blobdiff - src/biome.cpp
Fix crash when no world is selected and configure button is pressed.
[minetest.git] / src / biome.cpp
index 07dad1f23f35a70b0e9ed6ba98a8a86173a9f3ef..180a9c4a5b414ea2bb4ea1c9b963b600ce5efacb 100644 (file)
@@ -78,7 +78,7 @@ BiomeDefManager::BiomeDefManager(IGameDef *gamedef) {
 
 
 BiomeDefManager::~BiomeDefManager() {
-       for (int i = 0; i != bgroups.size(); i++)
+       for (unsigned int i = 0; i != bgroups.size(); i++)
                delete bgroups[i];
 }
 
@@ -96,6 +96,7 @@ Biome *BiomeDefManager::createBiome(BiomeTerrainType btt) {
                case BIOME_TERRAIN_FLAT:
                        return new BiomeSuperflat;
        }
+       return NULL;
 }
 
 
@@ -116,7 +117,7 @@ void BiomeDefManager::addBiomeGroup(float freq) {
 void BiomeDefManager::addBiome(Biome *b) {
        std::vector<Biome *> *bgroup;
 
-       if (b->groupid >= bgroups.size()) {
+       if ((unsigned int)b->groupid >= bgroups.size()) {
                errorstream << "BiomeDefManager: attempted to add biome '" << b->name
                 << "' to nonexistent biome group " << b->groupid << std::endl;
                return;
@@ -131,7 +132,6 @@ void BiomeDefManager::addBiome(Biome *b) {
 
 
 void BiomeDefManager::addDefaultBiomes() {
-       std::vector<Biome *> *bgroup;
        Biome *b;
 
        b = new Biome;
@@ -181,53 +181,16 @@ int Biome::getSurfaceHeight(float noise_terrain) {
 }
 
 
-void Biome::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
-       int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
-       int surfaceh = np->offset + np->scale * mg->map_terrain[i];
-
-       /*///experimental
-       if (groupid > 0) {
-               float prevfreq = mg->biomedef->bgroup_freqs[groupid - 1];
-               float range    = mg->biomedef->bgroup_freqs[groupid] - prevfreq;
-               float factor   = (mg->map_bgroup[i] - prevfreq) / range;
-
-               std::vector<Biome *> *bg = mg->biomedef->bgroups[groupid - 1];
-               Biome *b = (*bg)[0];
-               int h1 = b->np->offset + b->np->scale * mg->map_terrain[i];
-               surfaceh += (int)round((surfaceh - h1) * factor);
-               //printf("h1: %d, surfaceh: %d, factor %f\n", h1, surfaceh, factor);
-       }*/
+void Biome::genColumn(Mapgen *mapgen, int x, int z, int y1, int y2) {
 
-
-       int y = y1;
-
-       i = mg->vmanip->m_area.index(x, y, z);
-       for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_filler;
-       for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_top;
-       for (; y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = mg->n_air;
 }
 
 
 ///////////////////////////// [ Ocean biome ] /////////////////////////////////
 
 
-void BiomeLiquid::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
-       int i = (z - mg->node_min.Z) * mg->csize.Z + (x - mg->node_min.X);
-       int surfaceh = np->offset + np->scale * mg->map_terrain[i];
-       int y = y1;
-
-       i = mg->vmanip->m_area.index(x, y, z);
-       for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_filler;
-       for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_top;
-       for (; y <= mg->water_level && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = mg->n_water;
-       for (; y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = mg->n_air;
+void BiomeLiquid::genColumn(Mapgen *mapgen, int x, int z, int y1, int y2) {
+
 }
 
 
@@ -239,7 +202,7 @@ int BiomeHell::getSurfaceHeight(float noise_terrain) {
 }
 
 
-void BiomeHell::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
+void BiomeHell::genColumn(Mapgen *mapgen, int x, int z, int y1, int y2) {
 
 }
 
@@ -252,7 +215,7 @@ int BiomeAether::getSurfaceHeight(float noise_terrain) {
 }
 
 
-void BiomeAether::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
+void BiomeAether::genColumn(Mapgen *mapgen, int x, int z, int y1, int y2) {
 
 }
 
@@ -265,15 +228,6 @@ int BiomeSuperflat::getSurfaceHeight(float noise_terrain) {
 }
 
 
-void BiomeSuperflat::genColumn(MapgenV7 *mg, int x, int z, int y1, int y2) {
-       int surfaceh = ntopnodes;
-       int y = y1;
+void BiomeSuperflat::genColumn(Mapgen *mapgen, int x, int z, int y1, int y2) {
 
-       int i = mg->vmanip->m_area.index(x, y, z);
-       for (; y <= surfaceh - ntopnodes && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_filler;
-       for (; y <= surfaceh && y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = n_top;
-       for (; y <= y2; y++, i += mg->ystride)
-               mg->vmanip->m_data[i] = mg->n_air;
 }