aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorparamat <mat.gregory@virginmedia.com>2017-04-22 05:16:50 +0100
committerparamat <mat.gregory@virginmedia.com>2017-04-22 05:37:33 +0100
commit4c03190ce80457f19f87f9a3a6b4b03fb4f08ee1 (patch)
tree706d58a0fb74ccfdd61284469e214dfeb0c90cac
parentf6d1b682d3c3fa25e11d64d52c93b92760fe2612 (diff)
downloadminetest-4c03190ce80457f19f87f9a3a6b4b03fb4f08ee1.tar.gz
minetest-4c03190ce80457f19f87f9a3a6b4b03fb4f08ee1.tar.bz2
minetest-4c03190ce80457f19f87f9a3a6b4b03fb4f08ee1.zip
Mgflat, Mgv7: Fix noise crash on world exit.
Fix crash caused by destructor 'delete' on noise objects that are not created due to mapgen options. Crash was caused by commit 57eaf62c697cec91890d9cb28d10385d293d2d3f
-rw-r--r--src/mapgen_flat.cpp4
-rw-r--r--src/mapgen_v7.cpp24
2 files changed, 20 insertions, 8 deletions
diff --git a/src/mapgen_flat.cpp b/src/mapgen_flat.cpp
index c51b5e12e..0a44f71a5 100644
--- a/src/mapgen_flat.cpp
+++ b/src/mapgen_flat.cpp
@@ -73,8 +73,10 @@ MapgenFlat::MapgenFlat(int mapgenid, MapgenFlatParams *params, EmergeManager *em
MapgenFlat::~MapgenFlat()
{
- delete noise_terrain;
delete noise_filler_depth;
+
+ if ((spflags & MGFLAT_LAKES) || (spflags & MGFLAT_HILLS))
+ delete noise_terrain;
}
diff --git a/src/mapgen_v7.cpp b/src/mapgen_v7.cpp
index c4583578f..420d77185 100644
--- a/src/mapgen_v7.cpp
+++ b/src/mapgen_v7.cpp
@@ -97,16 +97,26 @@ MapgenV7::MapgenV7(int mapgenid, MapgenV7Params *params, EmergeManager *emerge)
MapgenV7::~MapgenV7()
{
delete noise_terrain_base;
+ delete noise_terrain_alt;
delete noise_terrain_persist;
delete noise_height_select;
- delete noise_terrain_alt;
delete noise_filler_depth;
- delete noise_mount_height;
- delete noise_ridge_uwater;
- delete noise_floatland_base;
- delete noise_float_base_height;
- delete noise_mountain;
- delete noise_ridge;
+
+ if (spflags & MGV7_MOUNTAINS)
+ delete noise_mount_height;
+
+ if (spflags & MGV7_FLOATLANDS) {
+ delete noise_floatland_base;
+ delete noise_float_base_height;
+ }
+
+ if (spflags & MGV7_RIDGES) {
+ delete noise_ridge_uwater;
+ delete noise_ridge;
+ }
+
+ if ((spflags & MGV7_MOUNTAINS) || (spflags & MGV7_FLOATLANDS))
+ delete noise_mountain;
}