From 773efc19b1d05e573d5bc811c0175d192f7c12c5 Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 1 Apr 2017 10:18:13 +0200 Subject: [PATCH] mapgen: Fix segfault when selecting invalid mapgen (#5491) --- src/mapgen.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 6f3ea7cb0..b6e8c0fd1 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -1003,8 +1003,11 @@ void MapgenParams::readParams(const Settings *settings) } std::string mg_name; - if (settings->getNoEx("mg_name", mg_name)) - this->mgtype = Mapgen::getMapgenType(mg_name); + if (settings->getNoEx("mg_name", mg_name)) { + mgtype = Mapgen::getMapgenType(mg_name); + if (mgtype == MAPGEN_INVALID) + mgtype = MAPGEN_DEFAULT; + } settings->getS16NoEx("water_level", water_level); settings->getS16NoEx("mapgen_limit", mapgen_limit); -- 2.25.1