1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Rework Settings to support arbitrary hierarchies (#11352)

This commit is contained in:
sfan5 2021-06-23 15:22:31 +02:00 committed by GitHub
parent cec0dfcbbd
commit c60a146e22
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 164 additions and 71 deletions

View file

@ -91,6 +91,7 @@ static void list_worlds(bool print_name, bool print_path);
static bool setup_log_params(const Settings &cmd_args);
static bool create_userdata_path();
static bool init_common(const Settings &cmd_args, int argc, char *argv[]);
static void uninit_common();
static void startup_message();
static bool read_config_file(const Settings &cmd_args);
static void init_log_streams(const Settings &cmd_args);
@ -201,6 +202,7 @@ int main(int argc, char *argv[])
errorstream << "Unittest support is not enabled in this binary. "
<< "If you want to enable it, compile project with BUILD_UNITTESTS=1 flag."
<< std::endl;
return 1;
#endif
}
#endif
@ -236,9 +238,6 @@ int main(int argc, char *argv[])
print_modified_quicktune_values();
// Stop httpfetch thread (if started)
httpfetch_cleanup();
END_DEBUG_EXCEPTION_HANDLER
return retval;
@ -486,13 +485,14 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
startup_message();
set_default_settings();
// Initialize sockets
sockets_init();
atexit(sockets_cleanup);
// Initialize g_settings
Settings::createLayer(SL_GLOBAL);
// Set cleanup callback(s) to run at process exit
atexit(uninit_common);
if (!read_config_file(cmd_args))
return false;
@ -511,6 +511,17 @@ static bool init_common(const Settings &cmd_args, int argc, char *argv[])
return true;
}
static void uninit_common()
{
httpfetch_cleanup();
sockets_cleanup();
// It'd actually be okay to leak these but we want to please valgrind...
for (int i = 0; i < (int)SL_TOTAL_COUNT; i++)
delete Settings::getLayer((SettingsLayer)i);
}
static void startup_message()
{
infostream << PROJECT_NAME << " " << _("with")