MC Configuration

This commit is contained in:
AffectedArc07
2021-05-03 19:32:16 +01:00
parent 29af4068f2
commit 34e46807e9
12 changed files with 72 additions and 77 deletions
@@ -8,8 +8,8 @@
target = ((input == 1) ? TRUE : FALSE)\
}
/// Wrapper to not overwrite a variable if a list key doesnt exist. Auto casts to int.
#define CONFIG_LOAD_INT(target, input) \
/// Wrapper to not overwrite a variable if a list key doesnt exist. Auto casts to number.
#define CONFIG_LOAD_NUM(target, input) \
if(!isnull(input)) {\
target = text2num(input)\
}
@@ -7,9 +7,14 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new())
/datum/server_configuration
/// Holder for the admin configuration datum
var/datum/configuration_section/admin_configuration/admin
/// Holder for the AFK configuration datum
var/datum/configuration_section/afk_configuration/afk
/// Holder for the custom sprites configuration datum
var/datum/configuration_section/custom_sprites_configuration/custom_sprites
/// Holder for the DB configuration datum
var/datum/configuration_section/database_configuration/database
/// Holder for the MC configuration datum
var/datum/configuration_section/mc_configuration/mc
/datum/server_configuration/Destroy(force)
SHOULD_CALL_PARENT(FALSE)
@@ -27,6 +32,7 @@ GLOBAL_DATUM_INIT(configuration, /datum/server_configuration, new())
afk = new()
custom_sprites = new()
database = new()
mc = new()
// Load our stuff up
var/config_file = "config/config.toml"
@@ -11,7 +11,7 @@
/datum/configuration_section/afk_configuration/load_data(list/data)
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
CONFIG_LOAD_INT(warning_minutes, data["afk_warning_minutes"])
CONFIG_LOAD_INT(auto_cryo_minutes, data["afk_auto_cryo_minutes"])
CONFIG_LOAD_INT(auto_despawn_minutes, data["afk_auto_despawn_minutes"])
CONFIG_LOAD_INT(ssd_auto_cryo_minutes, data["ssd_auto_cryo_minutes"])
CONFIG_LOAD_NUM(warning_minutes, data["afk_warning_minutes"])
CONFIG_LOAD_NUM(auto_cryo_minutes, data["afk_auto_cryo_minutes"])
CONFIG_LOAD_NUM(auto_despawn_minutes, data["afk_auto_despawn_minutes"])
CONFIG_LOAD_NUM(ssd_auto_cryo_minutes, data["ssd_auto_cryo_minutes"])
@@ -29,19 +29,19 @@
enabled = TRUE
table_prefix = ""
// This needs to happen in the CI environment to ensure the example SQL version gets updated.
CONFIG_LOAD_INT(version, data["sql_version"])
CONFIG_LOAD_NUM(version, data["sql_version"])
#else
// Load the normal config. Were not in CI mode
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
CONFIG_LOAD_BOOL(enabled, data["sql_enabled"])
CONFIG_LOAD_INT(version, data["sql_version"])
CONFIG_LOAD_NUM(version, data["sql_version"])
CONFIG_LOAD_STR(address, data["sql_address"])
CONFIG_LOAD_INT(port, data["sql_port"])
CONFIG_LOAD_NUM(port, data["sql_port"])
CONFIG_LOAD_STR(username, data["sql_username"])
CONFIG_LOAD_STR(password, data["sql_password"])
CONFIG_LOAD_STR(db, data["sql_database"])
CONFIG_LOAD_STR(table_prefix, data["sql_table_prefix"])
CONFIG_LOAD_INT(async_query_timeout, data["async_query_timeout"])
CONFIG_LOAD_INT(async_thread_limit, data["async_thread_limit"])
CONFIG_LOAD_NUM(async_query_timeout, data["async_query_timeout"])
CONFIG_LOAD_NUM(async_thread_limit, data["async_thread_limit"])
#endif
@@ -0,0 +1,23 @@
/// Config holder for all things regarding the MC
/datum/configuration_section/mc_configuration
/// Server ticklag
var/ticklag = 0.5
/// Tick limit % during world Init
var/world_init_tick_limit = TICK_LIMIT_MC_INIT_DEFAULT
/// Base MC tick rate
var/mc_base_tickrate = 1
/// Highpop MC tickrate
var/mc_highpop_tickrate = 1.1
/// MC Highpop enable threshold
var/mc_highpop_enable_threshold = 65
/// MC Highpop disable threshold
var/mc_highpop_disable_threshold = 60
/datum/configuration_section/mc_configuration/load_data(list/data)
// Use the load wrappers here. That way the default isnt made 'null' if you comment out the config line
CONFIG_LOAD_NUM(ticklag, data["ticklag"])
CONFIG_LOAD_NUM(world_init_tick_limit, data["world_init_mc_tick_limit"])
CONFIG_LOAD_NUM(mc_base_tickrate, data["base_mc_tick_rate"])
CONFIG_LOAD_NUM(mc_highpop_tickrate, data["highpop_mc_tick_rate"])
CONFIG_LOAD_NUM(mc_highpop_enable_threshold, data["mc_highpop_threshold_enable"])
CONFIG_LOAD_NUM(mc_highpop_disable_threshold, data["mc_highpop_threshold_disable"])