1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Settings: Add get_flags API for mapgen flags (mg_flags, mgv6_spflags, ...) (#9284)

Unified flags handling in C++ and Lua Settings API
     -> Reading only, for now. Writing can be implemented later, if needed.
API function to read the currently active flags
     -> was impossible from Lua

Co-authored-by: Wuzzy <wuzzy2@mail.ru>
This commit is contained in:
SmallJoker 2020-01-25 16:56:54 +01:00 committed by GitHub
parent 9cb3219f34
commit cde2a7f6f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 222 additions and 39 deletions

View file

@ -215,6 +215,17 @@ void Mapgen::getMapgenNames(std::vector<const char *> *mgnames, bool include_hid
}
}
void Mapgen::setDefaultSettings(Settings *settings)
{
settings->setDefault("mg_flags", flagdesc_mapgen,
MG_CAVES | MG_DUNGEONS | MG_LIGHT | MG_DECORATIONS | MG_BIOMES);
for (int i = 0; i < (int)MAPGEN_INVALID; ++i) {
MapgenParams *params = createMapgenParams((MapgenType)i);
params->setDefaultSettings(settings);
delete params;
}
}
u32 Mapgen::getBlockSeed(v3s16 p, s32 seed)
{
@ -1068,7 +1079,7 @@ void MapgenParams::writeParams(Settings *settings) const
settings->setS16("water_level", water_level);
settings->setS16("mapgen_limit", mapgen_limit);
settings->setS16("chunksize", chunksize);
settings->setFlagStr("mg_flags", flags, flagdesc_mapgen, U32_MAX);
settings->setFlagStr("mg_flags", flags, flagdesc_mapgen);
if (bparams)
bparams->writeParams(settings);