Skip to content

Commit

Permalink
Mgflat, Mgv7: Fix noise crash on world exit.
Browse files Browse the repository at this point in the history
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 4c03190
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
4 changes: 3 additions & 1 deletion src/mapgen_flat.cpp
Expand Up @@ -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;
}


Expand Down
24 changes: 17 additions & 7 deletions src/mapgen_v7.cpp
Expand Up @@ -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;
}


Expand Down

0 comments on commit 4c03190

Please sign in to comment.