mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 18:13:46 +01:00
Randomly generate seed if field blank for any Settings instance
This commit is contained in:
parent
285655a878
commit
48fa893abd
@ -167,13 +167,6 @@ EmergeManager::~EmergeManager()
|
|||||||
void EmergeManager::loadMapgenParams()
|
void EmergeManager::loadMapgenParams()
|
||||||
{
|
{
|
||||||
loadParamsFromSettings(g_settings);
|
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;
|
std::string seed_str;
|
||||||
const char *setname = (settings == g_settings) ? "fixed_map_seed" : "seed";
|
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());
|
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->getNoEx("mg_name", params.mg_name);
|
||||||
settings->getS16NoEx("water_level", params.water_level);
|
settings->getS16NoEx("water_level", params.water_level);
|
||||||
|
Loading…
Reference in New Issue
Block a user