diff --git a/server/settings.c b/server/settings.c index 97103a5b8a..423478c8d3 100644 --- a/server/settings.c +++ b/server/settings.c @@ -170,6 +170,8 @@ struct setting { /* ruleset lock for game settings */ bool locked; + bool ruleset_settable; + /* It's not "default", even if value is the same as default */ enum setting_default_level setdef; }; @@ -1294,7 +1296,7 @@ static bool plrcol_validate(int value, struct connection *caller, scateg, slevel, \ INIT_BRACE_BEGIN \ .boolean = {&value, _default, func_validate, bool_name, \ - FALSE} INIT_BRACE_END , func_action, FALSE}, + FALSE} INIT_BRACE_END , func_action, FALSE, TRUE}, #define GEN_INT(name, value, sclass, scateg, slevel, al_read, al_write, \ short_help, extra_help, func_help, \ @@ -1305,7 +1307,7 @@ static bool plrcol_validate(int value, struct connection *caller, INIT_BRACE_BEGIN \ .integer = {(int *) &value, _default, _min, _max, func_validate, \ 0} INIT_BRACE_END, \ - func_action, FALSE}, + func_action, FALSE, TRUE}, #define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, \ short_help, extra_help, func_validate, func_action, \ @@ -1315,7 +1317,17 @@ static bool plrcol_validate(int value, struct connection *caller, INIT_BRACE_BEGIN \ .string = {value, _default, sizeof(value), func_validate, ""} \ INIT_BRACE_END, \ - func_action, FALSE}, + func_action, FALSE, TRUE}, + +#define GEN_STRING_NRS(name, value, sclass, scateg, slevel, al_read, al_write, \ + short_help, extra_help, func_validate, func_action, \ + _default) \ + {name, sclass, al_read, al_write, short_help, extra_help, NULL, \ + SST_STRING, scateg, slevel, \ + INIT_BRACE_BEGIN \ + .string = {value, _default, sizeof(value), func_validate, ""} \ + INIT_BRACE_END, \ + func_action, FALSE, FALSE}, #define GEN_ENUM(name, value, sclass, scateg, slevel, al_read, al_write, \ short_help, extra_help, func_help, func_validate, \ @@ -1326,7 +1338,7 @@ static bool plrcol_validate(int value, struct connection *caller, .enumerator = { &value, sizeof(value), _default, \ func_validate, \ (val_name_func_t) func_name, 0 } INIT_BRACE_END, \ - func_action, FALSE}, + func_action, FALSE, TRUE}, #define GEN_BITWISE(name, value, sclass, scateg, slevel, al_read, al_write, \ short_help, extra_help, func_validate, func_action, \ @@ -1336,7 +1348,7 @@ static bool plrcol_validate(int value, struct connection *caller, INIT_BRACE_BEGIN \ .bitwise = { (unsigned *) (void *) &value, _default, func_validate, \ func_name, 0 } INIT_BRACE_END, \ - func_action, FALSE}, + func_action, FALSE, TRUE}, /* game settings */ static struct setting settings[] = { @@ -3026,15 +3038,15 @@ static struct setting settings[] = { "affect users kicked in the past."), NULL, NULL, NULL, GAME_MIN_KICK_TIME, GAME_MAX_KICK_TIME, GAME_DEFAULT_KICK_TIME) - GEN_STRING("metamessage", game.server.meta_info.user_message, - SSET_META, SSET_INTERNAL, SSET_RARE, ALLOW_CTRL, ALLOW_CTRL, - N_("Metaserver info line"), - N_("User defined metaserver info line. For most of the time " - "a user defined metamessage will be used instead of an " - "automatically generated message. " - "Set to empty (\"\", not \"empty\") to always use an " - "automatically generated meta server message."), - NULL, metamessage_action, GAME_DEFAULT_USER_META_MESSAGE) + GEN_STRING_NRS("metamessage", game.server.meta_info.user_message, + SSET_META, SSET_INTERNAL, SSET_RARE, ALLOW_CTRL, ALLOW_CTRL, + N_("Metaserver info line"), + N_("User defined metaserver info line. For most of the time " + "a user defined metamessage will be used instead of an " + "automatically generated message. " + "Set to empty (\"\", not \"empty\") to always use an " + "automatically generated meta server message."), + NULL, metamessage_action, GAME_DEFAULT_USER_META_MESSAGE) }; #undef GEN_BOOL @@ -4105,7 +4117,9 @@ bool settings_ruleset(struct section_file *file, const char *section, /* Unlock all settings. */ settings_iterate(SSET_ALL, pset) { setting_lock_set(pset, FALSE); - setting_set_to_default(pset); + if (pset->ruleset_settable) { + setting_set_to_default(pset); + } } settings_iterate_end; /* settings */ @@ -4120,7 +4134,8 @@ bool settings_ruleset(struct section_file *file, const char *section, fc_snprintf(path, sizeof(path), "%s.set%d", section, j); if (!setting_ruleset_one(file, name, path)) { - log_error("unknown setting in '%s': %s", secfile_name(file), name); + log_error("Unknown on unsettable setting in '%s': %s", + secfile_name(file), name); } } } @@ -4129,7 +4144,9 @@ bool settings_ruleset(struct section_file *file, const char *section, * default values. */ if (act) { settings_iterate(SSET_ALL, pset) { - setting_action(pset); + if (pset->ruleset_settable) { + setting_action(pset); + } } settings_iterate_end; } @@ -4158,8 +4175,8 @@ static bool setting_ruleset_one(struct section_file *file, } } settings_iterate_end; - if (pset == NULL) { - /* no setting found */ + if (pset == NULL || !pset->ruleset_settable) { + /* No setting found or it's not settable by ruleset */ return FALSE; }