aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-02-01 02:05:39 -0500
committerkwolekr <kwolekr@minetest.net>2015-02-01 02:05:39 -0500
commit48fa893abdaa7d7f29f7e909b326146b2f0606b9 (patch)
treef376152d6ef56cad7b14c47abab1a0cef35a56e3
parent285655a8788aefe89df608218774b8336736c1ba (diff)
downloadminetest-48fa893abdaa7d7f29f7e909b326146b2f0606b9.tar.gz
minetest-48fa893abdaa7d7f29f7e909b326146b2f0606b9.tar.bz2
minetest-48fa893abdaa7d7f29f7e909b326146b2f0606b9.zip
Randomly generate seed if field blank for any Settings instance
-rw-r--r--src/emerge.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/emerge.cpp b/src/emerge.cpp
index 2926b0c0b..c485caffa 100644
--- a/src/emerge.cpp
+++ b/src/emerge.cpp
@@ -167,13 +167,6 @@ EmergeManager::~EmergeManager()
void EmergeManager::loadMapgenParams()
{
loadParamsFromSettings(g_settings);
-
- if (g_settings->get("fixed_map_seed").empty()) {
- params.seed = (((u64)(myrand() & 0xffff) << 0)
- | ((u64)(myrand() & 0xffff) << 16)
- | ((u64)(myrand() & 0xffff) << 32)
- | ((u64)(myrand() & 0xffff) << 48));
- }
}
@@ -368,8 +361,15 @@ void EmergeManager::loadParamsFromSettings(Settings *settings)
std::string seed_str;
const char *setname = (settings == g_settings) ? "fixed_map_seed" : "seed";
- if (settings->getNoEx(setname, seed_str))
+ if (settings->getNoEx(setname, seed_str) && !seed_str.empty()) {
params.seed = read_seed(seed_str.c_str());
+ } else {
+ params.seed =
+ ((u64)(myrand() & 0xffff) << 0) |
+ ((u64)(myrand() & 0xffff) << 16) |
+ ((u64)(myrand() & 0xffff) << 32) |
+ ((u64)(myrand() & 0xffff) << 48);
+ }
settings->getNoEx("mg_name", params.mg_name);
settings->getS16NoEx("water_level", params.water_level);