summaryrefslogtreecommitdiff
path: root/src/mapgen.cpp
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2015-03-07 03:15:12 +0000
committerparamat <mat.gregory@virginmedia.com>2015-03-08 03:54:03 +0000
commitd463000595ee2b8bce94e5b99e764be6e1fd52f6 (patch)
tree89a488c35ff82936ba40462a5673c86eef5a7e09 /src/mapgen.cpp
parent267c9f4cb4616afcf07a2a33aaca43a903ac895a (diff)
downloadminetest-d463000595ee2b8bce94e5b99e764be6e1fd52f6.tar.gz
minetest-d463000595ee2b8bce94e5b99e764be6e1fd52f6.tar.bz2
minetest-d463000595ee2b8bce94e5b99e764be6e1fd52f6.zip
Heightmaps: Fix uninitialised values in mgv5/mgv6. findGroundLevel: Return -MAP_GENERATION_LIMIT if surface not found
Diffstat (limited to 'src/mapgen.cpp')
-rw-r--r--src/mapgen.cpp19
1 files changed, 2 insertions, 17 deletions
diff --git a/src/mapgen.cpp b/src/mapgen.cpp
index 67cf3d065..137418471 100644
--- a/src/mapgen.cpp
+++ b/src/mapgen.cpp
@@ -41,8 +41,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
const char *GenElementManager::ELEMENT_TITLE = "element";
-static const s16 INVALID_HEIGHT = MAP_GENERATION_LIMIT + 1;
-
FlagDesc flagdesc_mapgen[] = {
{"trees", MG_TREES},
{"caves", MG_CAVES},
@@ -140,6 +138,7 @@ s16 Mapgen::findGroundLevelFull(v2s16 p2d)
}
+// Returns -MAP_GENERATION_LIMIT if not found
s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
{
v3s16 em = vm->m_area.getExtent();
@@ -153,16 +152,10 @@ s16 Mapgen::findGroundLevel(v2s16 p2d, s16 ymin, s16 ymax)
vm->m_area.add_y(em, i, -1);
}
- return y;
+ return (y >= ymin) ? y : -MAP_GENERATION_LIMIT;
}
-void Mapgen::initHeightMap(s16 *dest, size_t len)
-{
- for (size_t i = 0; i < len; i++)
- dest[i] = INVALID_HEIGHT;
-}
-
void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
{
if (!heightmap)
@@ -174,14 +167,6 @@ void Mapgen::updateHeightmap(v3s16 nmin, v3s16 nmax)
for (s16 x = nmin.X; x <= nmax.X; x++, index++) {
s16 y = findGroundLevel(v2s16(x, z), nmin.Y, nmax.Y);
- if (heightmap[index] != INVALID_HEIGHT) {
- // if the values found are out of range, trust the old heightmap
- if (y == nmax.Y && heightmap[index] > nmax.Y)
- continue;
- if (y == nmin.Y - 1 && heightmap[index] < nmin.Y)
- continue;
- }
-
heightmap[index] = y;
}
}