Skip to content
Permalink
Browse files

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 57eaf62
  • Loading branch information...
paramat committed Apr 22, 2017
1 parent f6d1b68 commit 4c03190ce80457f19f87f9a3a6b4b03fb4f08ee1
Showing with 20 additions and 8 deletions.
  1. +3 −1 src/mapgen_flat.cpp
  2. +17 −7 src/mapgen_v7.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;
}


@@ -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;
}


0 comments on commit 4c03190

Please sign in to comment.
You can’t perform that action at this time.