Freeciv21
Develop your civilization from humble roots to a global empire
settings.cpp File Reference
#include <fc_config.h>
#include "astring.h"
#include "fcintl.h"
#include "game.h"
#include "log.h"
#include "registry.h"
#include "shared.h"
#include "map.h"
#include "nation.h"
#include "gamehand.h"
#include "maphand.h"
#include "meta.h"
#include "notify.h"
#include "plrhand.h"
#include "report.h"
#include "rssanity.h"
#include "settings.h"
#include "srv_main.h"
#include "stdinhand.h"
+ Include dependency graph for settings.cpp:

Go to the source code of this file.

Classes

struct  setting
 

Macros

#define settings_snprintf(_buf, _buf_len, format, ...)
 
#define NAME_CASE(_val, _support, _pretty)
 
#define GEN_BOOL(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
 
#define GEN_INT(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_help, func_validate, func_action, _min, _max, _default)
 
#define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
 
#define GEN_ENUM(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_help, func_validate, func_action, func_name, _default)
 
#define GEN_BITWISE(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, func_name, _default)
 
#define PACKET_COMMON_INIT(packet, pset, pconn)
 

Typedefs

typedef bool(* bool_validate_func_t) (bool value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
 
typedef bool(* int_validate_func_t) (int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
 
typedef bool(* string_validate_func_t) (const char *value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
 
typedef bool(* enum_validate_func_t) (int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
 
typedef bool(* bitwise_validate_func_t) (unsigned value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
 
typedef void(* action_callback_func_t) (const struct setting *pset)
 
typedef const char *(* help_callback_func_t) (const struct setting *pset)
 
typedef const struct sset_val_name *(* val_name_func_t) (int value)
 

Enumerations

enum  sset_class {
  SSET_MAP_SIZE , SSET_MAP_GEN , SSET_MAP_ADD , SSET_PLAYERS ,
  SSET_GAME_INIT , SSET_RULES , SSET_RULES_SCENARIO , SSET_RULES_FLEXIBLE ,
  SSET_META
}
 

Functions

static bool setting_ruleset_one (struct section_file *file, const char *name, const char *path)
 Set one setting from the game.ruleset file. More...
 
static void setting_game_set (struct setting *pset, bool init)
 Save the setting value of the current game. More...
 
static void setting_game_free (struct setting *pset)
 Free the memory used for the settings at game start. More...
 
static void setting_game_restore (struct setting *pset)
 Restore the setting to the value used at the start of the current game. More...
 
static void settings_list_init ()
 Initialise sorted settings. More...
 
static void settings_list_free ()
 Free sorted settings. More...
 
int settings_list_cmp (const struct setting *const *ppset1, const struct setting *const *ppset2)
 Update sorted settings (changed and locked values). More...
 
static bool set_enum_value (struct setting *pset, int val)
 Helper function to write value to enumerator setting. More...
 
static const struct sset_val_namecaravanbonusstyle_name (int caravanbonus)
 Caravan bonus style setting names accessor. More...
 
static const struct sset_val_namemapsize_name (int mapsize)
 Map size definition setting names accessor. More...
 
static const struct sset_val_nametopology_name (int topology_bit)
 Topology setting names accessor. More...
 
static const struct sset_val_nametraderevenuestyle_name (int revenue_style)
 Trade revenue style setting names accessor. More...
 
static const struct sset_val_namegenerator_name (int generator)
 Generator setting names accessor. More...
 
static const struct sset_val_namestartpos_name (int startpos)
 Start position setting names accessor. More...
 
static const struct sset_val_nameteamplacement_name (int team_placement)
 Team placement setting names accessor. More...
 
static const struct sset_val_namepersistentready_name (int persistent_ready)
 Persistentready setting names accessor. More...
 
static const struct sset_val_namevictory_conditions_name (int condition_bit)
 Victory conditions setting names accessor. More...
 
static const struct sset_val_nameautosaves_name (int autosaves_bit)
 Autosaves setting names accessor. More...
 
static const struct sset_val_nameborders_name (int borders)
 Borders setting names accessor. More...
 
static const struct sset_val_nametrait_dist_name (int trait_dist)
 Trait distribution setting names accessor. More...
 
static const struct sset_val_nameplrcol_name (int plrcol)
 Player colors configuration setting names accessor. More...
 
static const struct sset_val_namehappyborders_name (int happyborders)
 Happyborders setting names accessor. More...
 
static const struct sset_val_namediplomacy_name (int diplomacy)
 Diplomacy setting names accessor. More...
 
static const struct sset_val_namecitynames_name (int citynames)
 City names setting names accessor. More...
 
static const struct sset_val_namebarbarians_name (int barbarians)
 Barbarian setting names accessor. More...
 
static const struct sset_val_namerevolentype_name (int revolentype)
 Revolution length type setting names accessor. More...
 
static const struct sset_val_namerevealmap_name (int bit)
 Revealmap setting names accessor. More...
 
static const struct sset_val_nameairliftingstyle_name (int bit)
 Airlifting style setting names accessor. More...
 
static const struct sset_val_namephasemode_name (int phasemode)
 Phase mode names accessor. More...
 
static const struct sset_val_namescoreloglevel_name (enum scoreQtMsgType sl_level)
 Scorelog level names accessor. More...
 
static const struct sset_val_namecompresstype_name (enum compress_type compresstype)
 Savegame compress type names accessor. More...
 
static const struct sset_val_namebool_name (int enable)
 Names accessor for boolean settings (disable/enable). More...
 
static const struct sset_val_nameunitwaittime_name (int bit)
 Unitwaittime style names accessor. More...
 
static const char * phasemode_help (const struct setting *pset)
 Help about phasemode setting. More...
 
static const char * huts_help (const struct setting *pset)
 Help about huts setting. More...
 
static void scorelog_action (const struct setting *pset)
 (De)initialze the score log. More...
 
static void aifill_action (const struct setting *pset)
 Create the selected number of AI's. More...
 
static void nationset_action (const struct setting *pset)
 Restrict to the selected nation set. More...
 
static void plrcol_action (const struct setting *pset)
 Clear any user-set player colors in modes other than PLRCOL_PLR_SET. More...
 
static void autotoggle_action (const struct setting *pset)
 Toggle player AI status. More...
 
static void timeout_action (const struct setting *pset)
 Enact a change in the 'timeout' server setting immediately, if the game is afoot. More...
 
static void first_timeout_action (const struct setting *pset)
 Enact a change in the 'first_timeout' server setting immediately, if the game is afoot. More...
 
static void huts_action (const struct setting *pset)
 Clean out absolute number of huts when relative setting set. More...
 
static void topology_action (const struct setting *pset)
 Topology setting changed. More...
 
static void metamessage_action (const struct setting *pset)
 Update metaserver message string from changed user meta server message string. More...
 
static bool savename_validate (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify the selected savename definition. More...
 
static bool generator_validate (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify the value of the generator option (notably the MAPGEN_SCENARIO case). More...
 
static bool scorefile_validate (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify the name for the score log file. More...
 
static bool demography_callback (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify that a given demography string is valid. More...
 
static bool autosaves_callback (unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Autosaves setting callback. More...
 
static bool allowtake_callback (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify that a given allowtake string is valid. More...
 
static bool startunits_callback (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify that a given startunits string is valid. More...
 
static bool endturn_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify that a given endturn is valid. More...
 
static bool maxplayers_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Verify that a given maxplayers is valid. More...
 
static bool nationset_callback (const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Validate the 'nationset' server setting. More...
 
static bool timeout_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Validate the 'timeout' server setting. More...
 
static bool first_timeout_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Validate the 'first_timeout' server setting. More...
 
static bool unitwaittime_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Check 'timeout' setting if 'unitwaittime' is changed. More...
 
static bool mapsize_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Mapsize setting validation callback. More...
 
static bool xsize_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 xsize setting validation callback. More...
 
static bool ysize_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 ysize setting validation callback. More...
 
static bool topology_callback (unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Topology setting validation callback. More...
 
static bool compresstype_callback (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Warn about deprecated compresstype selection. More...
 
static bool plrcol_validate (int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Validate that the player color mode can be used. More...
 
struct settingsetting_by_number (int id)
 Returns the setting to the given id. More...
 
struct settingsetting_by_name (const char *name)
 Returns the setting to the given name. More...
 
int setting_number (const struct setting *pset)
 Returns the id to the given setting. More...
 
const char * setting_name (const struct setting *pset)
 Access function for the setting name. More...
 
const char * setting_short_help (const struct setting *pset)
 Access function for the short help (not translated yet) of the setting. More...
 
const char * setting_extra_help (const struct setting *pset, bool constant)
 Access function for the long (extra) help of the setting. More...
 
enum sset_type setting_type (const struct setting *pset)
 Access function for the setting type. More...
 
enum sset_level setting_level (const struct setting *pset)
 Access function for the setting level (used by the /show command). More...
 
enum sset_category setting_category (const struct setting *pset)
 Access function for the setting category. More...
 
static bool setting_is_free_to_change (const struct setting *pset, char *reject_msg, size_t reject_msg_len)
 Returns whether the specified server setting (option) can currently be changed without breaking data consistency (map dimension options can't change when map has already been created with certain dimensions) More...
 
bool setting_is_changeable (const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns whether the specified server setting (option) can currently be changed by the caller. More...
 
bool setting_is_visible_at_level (const struct setting *pset, enum cmdlevel plevel)
 Returns whether the specified server setting (option) can be seen by a caller with the specified access level. More...
 
bool setting_is_visible (const struct setting *pset, struct connection *caller)
 Returns whether the specified server setting (option) can be seen by the caller. More...
 
static enum m_pre_result setting_match_prefix_base (const val_name_func_t name_fn, const char *prefix, int *ind_result, QVector< QString > &matches, size_t max_matches, size_t *pnum_matches)
 Convert the string prefix to an integer representation. More...
 
static bool setting_match_prefix (const val_name_func_t name_fn, const char *prefix, int *pvalue, char *reject_msg, size_t reject_msg_len)
 Convert the string prefix to an integer representation. More...
 
static const char * setting_bool_to_str (const struct setting *pset, bool value, bool pretty, char *buf, size_t buf_len)
 Compute the string representation of the value for this boolean setting. More...
 
static bool setting_bool_validate_base (const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
bool setting_bool_set (struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Set the setting to 'val'. More...
 
bool setting_bool_get (struct setting *pset)
 Get value of boolean setting. More...
 
bool setting_bool_validate (const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
static const char * setting_bool_secfile_str (secfile_data_t data, int val)
 Convert the integer to the long support string representation of a boolean setting. More...
 
static const char * setting_int_to_str (const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
 Compute the string representation of the value for this integer setting. More...
 
int setting_int_min (const struct setting *pset)
 Returns the minimal integer value for this setting. More...
 
int setting_int_max (const struct setting *pset)
 Returns the maximal integer value for this setting. More...
 
bool setting_int_set (struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Set the setting to 'val'. More...
 
bool setting_int_validate (const struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
int setting_int_get (struct setting *pset)
 Get value of integer setting. More...
 
static const char * setting_str_to_str (const struct setting *pset, const char *value, bool pretty, char *buf, size_t buf_len)
 Compute the string representation of the value for this string setting. More...
 
bool setting_str_set (struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Set the setting to 'val'. More...
 
bool setting_str_validate (const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
char * setting_str_get (struct setting *pset)
 Get value of string setting. More...
 
const char * setting_enum_secfile_str (secfile_data_t data, int val)
 Convert the integer to the long support string representation of an enumerator. More...
 
const char * setting_enum_val (const struct setting *pset, int val, bool pretty)
 Convert the integer to the string representation of an enumerator. More...
 
static const char * setting_enum_to_str (const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
 Compute the string representation of the value for this enumerator setting. More...
 
static bool setting_enum_validate_base (const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
int read_enum_value (const struct setting *pset)
 Helper function to read value from enumerator setting. More...
 
bool setting_enum_set (struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Set the setting to 'val'. More...
 
bool setting_enum_validate (const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
const char * setting_bitwise_secfile_str (secfile_data_t data, int bit)
 Convert the integer to the long support string representation of an enumerator. More...
 
const char * setting_bitwise_bit (const struct setting *pset, int bit, bool pretty)
 Convert the bit number to its string representation. More...
 
static const char * setting_bitwise_to_str (const struct setting *pset, unsigned value, bool pretty, char *buf, size_t buf_len)
 Compute the string representation of the value for this bitwise setting. More...
 
static bool setting_bitwise_validate_base (const struct setting *pset, const char *val, unsigned *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
bool setting_bitwise_set (struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Set the setting to 'val'. More...
 
bool setting_bitwise_validate (const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
 Returns TRUE if 'val' is a valid value for this setting. More...
 
int setting_bitwise_get (struct setting *pset)
 Get value of bitwise setting. More...
 
const char * setting_value_name (const struct setting *pset, bool pretty, char *buf, size_t buf_len)
 Compute the name of the current value of the setting. More...
 
const char * setting_default_name (const struct setting *pset, bool pretty, char *buf, size_t buf_len)
 Compute the name of the default value of the setting. More...
 
void setting_set_to_default (struct setting *pset)
 Update the setting to the default value. More...
 
void setting_action (const struct setting *pset)
 Execute the action callback if needed. More...
 
bool settings_ruleset (struct section_file *file, const char *section, bool act)
 Load game settings from ruleset file 'game.ruleset'. More...
 
bool setting_non_default (const struct setting *pset)
 Returns whether the setting has non-default value. More...
 
bool setting_locked (const struct setting *pset)
 Returns if the setting is locked by the ruleset. More...
 
void setting_lock_set (struct setting *pset, bool lock)
 Set the value for the lock of a setting. More...
 
void settings_game_start ()
 Save setting values at the start of the game. More...
 
void settings_game_save (struct section_file *file, const char *section)
 Save game settings. More...
 
void settings_game_load (struct section_file *file, const char *section)
 Restore all settings from a savegame. More...
 
bool settings_game_reset ()
 Reset all settings to the values at game start. More...
 
void settings_init (bool act)
 Initialize stuff related to this code module. More...
 
void settings_reset ()
 Reset all settings iff they are changeable. More...
 
void settings_turn ()
 Update stuff every turn that is related to this code module. More...
 
void settings_free ()
 Deinitialize stuff related to this code module. More...
 
int settings_number ()
 Returns the total number of settings. More...
 
void send_server_setting (struct conn_list *dest, const struct setting *pset)
 Tell the client about just one server setting. More...
 
void send_server_settings (struct conn_list *dest)
 Tell the client about all server settings. More...
 
void send_server_access_level_settings (struct conn_list *dest, enum cmdlevel old_level, enum cmdlevel new_level)
 Send the server settings that got a different visibility or changability after a connection access level change. More...
 
void send_server_setting_control (struct connection *pconn)
 Tell the client about all server settings. More...
 
void settings_list_update ()
 Update sorted settings (changed and locked values). More...
 
struct setting_list * settings_list_get (enum sset_level level)
 Get a settings list of a certain level. More...
 
void setting_changed (struct setting *pset)
 Mark setting changed. More...
 
enum setting_default_level setting_get_setdef (const struct setting *pset)
 Is the setting in changed state, or the default. More...
 

Variables

struct {
   bool   init
 
   struct setting_list *   level [OLEVELS_NUM]
 
setting_sorted = {.init = false}
 
static struct setting settings []
 
static const int SETTINGS_NUM = ARRAY_SIZE(settings)
 

Macro Definition Documentation

◆ GEN_BITWISE

#define GEN_BITWISE (   name,
  value,
  sclass,
  scateg,
  slevel,
  al_read,
  al_write,
  short_help,
  extra_help,
  func_validate,
  func_action,
  func_name,
  _default 
)
Value:
{ \
name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
SST_BITWISE, scateg, slevel, \
{.bitwise = {(unsigned *) (void *) &value, _default, func_validate, \
func_name, 0}}, \
func_action, false \
}

Definition at line 1326 of file settings.cpp.

◆ GEN_BOOL

#define GEN_BOOL (   name,
  value,
  sclass,
  scateg,
  slevel,
  al_read,
  al_write,
  short_help,
  extra_help,
  func_validate,
  func_action,
  _default 
)
Value:
{ \
name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
SST_BOOL, scateg, slevel, \
{.boolean = {&value, _default, func_validate, bool_name, false}}, \
func_action, false \
}
static const struct sset_val_name * bool_name(int enable)
Names accessor for boolean settings (disable/enable).
Definition: settings.cpp:557

Definition at line 1283 of file settings.cpp.

◆ GEN_ENUM

#define GEN_ENUM (   name,
  value,
  sclass,
  scateg,
  slevel,
  al_read,
  al_write,
  short_help,
  extra_help,
  func_help,
  func_validate,
  func_action,
  func_name,
  _default 
)
Value:
{ \
name, sclass, al_read, al_write, short_help, extra_help, func_help, \
SST_ENUM, scateg, slevel, \
{.enumerator = {&value, sizeof(value), _default, func_validate, \
(val_name_func_t) func_name, 0}}, \
func_action, false \
}
const struct sset_val_name *(* val_name_func_t)(int value)
Definition: settings.cpp:76

Definition at line 1315 of file settings.cpp.

◆ GEN_INT

#define GEN_INT (   name,
  value,
  sclass,
  scateg,
  slevel,
  al_read,
  al_write,
  short_help,
  extra_help,
  func_help,
  func_validate,
  func_action,
  _min,
  _max,
  _default 
)
Value:
{ \
name, sclass, al_read, al_write, short_help, extra_help, func_help, \
SST_INT, scateg, slevel, \
{.integer = {(int *) &value, _default, _min, _max, func_validate, \
0}}, \
func_action, false \
}

Definition at line 1293 of file settings.cpp.

◆ GEN_STRING

#define GEN_STRING (   name,
  value,
  sclass,
  scateg,
  slevel,
  al_read,
  al_write,
  short_help,
  extra_help,
  func_validate,
  func_action,
  _default 
)
Value:
{ \
name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
SST_STRING, scateg, slevel, \
{.string = {value, _default, sizeof(value), func_validate, \
(char *) ""}}, \
func_action, false \
}

Definition at line 1304 of file settings.cpp.

◆ NAME_CASE

#define NAME_CASE (   _val,
  _support,
  _pretty 
)
Value:
case _val: { \
static const struct sset_val_name name = {_support, _pretty}; \
return &name; \
}
const char * name
Definition: inputfile.cpp:118

Definition at line 199 of file settings.cpp.

◆ PACKET_COMMON_INIT

#define PACKET_COMMON_INIT (   packet,
  pset,
  pconn 
)
Value:
memset(&packet, 0, sizeof(packet)); \
packet.id = setting_number(pset); \
packet.is_visible = setting_is_visible(pset, pconn); \
packet.is_changeable = setting_is_changeable(pset, pconn, nullptr, 0); \
packet.initial_setting = game.info.is_new_game; \
packet.setdef = setting_get_setdef(pset);
struct civ_game game
Definition: game.cpp:47
int setting_number(const struct setting *pset)
Returns the id to the given setting.
Definition: settings.cpp:3056
bool setting_is_visible(const struct setting *pset, struct connection *caller)
Returns whether the specified server setting (option) can be seen by the caller.
Definition: settings.cpp:3227
enum setting_default_level setting_get_setdef(const struct setting *pset)
Is the setting in changed state, or the default.
Definition: settings.cpp:5160
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns whether the specified server setting (option) can currently be changed by the caller.
Definition: settings.cpp:3191
struct packet_game_info info
Definition: game.h:80

◆ settings_snprintf

#define settings_snprintf (   _buf,
  _buf_len,
  format,
  ... 
)
Value:
if (_buf != nullptr) { \
fc_snprintf(_buf, _buf_len, format, ##__VA_ARGS__); \
}

Definition at line 181 of file settings.cpp.

Typedef Documentation

◆ action_callback_func_t

typedef void(* action_callback_func_t) (const struct setting *pset)

Definition at line 74 of file settings.cpp.

◆ bitwise_validate_func_t

typedef bool(* bitwise_validate_func_t) (unsigned value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)

Definition at line 69 of file settings.cpp.

◆ bool_validate_func_t

typedef bool(* bool_validate_func_t) (bool value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)

Definition at line 57 of file settings.cpp.

◆ enum_validate_func_t

typedef bool(* enum_validate_func_t) (int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)

Definition at line 66 of file settings.cpp.

◆ help_callback_func_t

typedef const char*(* help_callback_func_t) (const struct setting *pset)

Definition at line 75 of file settings.cpp.

◆ int_validate_func_t

typedef bool(* int_validate_func_t) (int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)

Definition at line 60 of file settings.cpp.

◆ string_validate_func_t

typedef bool(* string_validate_func_t) (const char *value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)

Definition at line 62 of file settings.cpp.

◆ val_name_func_t

typedef const struct sset_val_name*(* val_name_func_t) (int value)

Definition at line 75 of file settings.cpp.

Enumeration Type Documentation

◆ sset_class

enum sset_class
Enumerator
SSET_MAP_SIZE 
SSET_MAP_GEN 
SSET_MAP_ADD 
SSET_PLAYERS 
SSET_GAME_INIT 
SSET_RULES 
SSET_RULES_SCENARIO 
SSET_RULES_FLEXIBLE 
SSET_META 

Definition at line 45 of file settings.cpp.

Function Documentation

◆ aifill_action()

static void aifill_action ( const struct setting pset)
static

Create the selected number of AI's.

Definition at line 644 of file settings.cpp.

◆ airliftingstyle_name()

static const struct sset_val_name* airliftingstyle_name ( int  bit)
static

Airlifting style setting names accessor.

Definition at line 490 of file settings.cpp.

◆ allowtake_callback()

static bool allowtake_callback ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify that a given allowtake string is valid.

See game.allow_take.

Definition at line 912 of file settings.cpp.

◆ autosaves_callback()

static bool autosaves_callback ( unsigned  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Autosaves setting callback.

Definition at line 888 of file settings.cpp.

◆ autosaves_name()

static const struct sset_val_name* autosaves_name ( int  autosaves_bit)
static

Autosaves setting names accessor.

Definition at line 341 of file settings.cpp.

◆ autotoggle_action()

static void autotoggle_action ( const struct setting pset)
static

Toggle player AI status.

Definition at line 706 of file settings.cpp.

◆ barbarians_name()

static const struct sset_val_name* barbarians_name ( int  barbarians)
static

Barbarian setting names accessor.

Definition at line 447 of file settings.cpp.

◆ bool_name()

static const struct sset_val_name* bool_name ( int  enable)
static

Names accessor for boolean settings (disable/enable).

Definition at line 557 of file settings.cpp.

◆ borders_name()

static const struct sset_val_name* borders_name ( int  borders)
static

Borders setting names accessor.

Definition at line 357 of file settings.cpp.

◆ caravanbonusstyle_name()

static const struct sset_val_name* caravanbonusstyle_name ( int  caravanbonus)
static

Caravan bonus style setting names accessor.

Definition at line 208 of file settings.cpp.

◆ citynames_name()

static const struct sset_val_name* citynames_name ( int  citynames)
static

City names setting names accessor.

Definition at line 433 of file settings.cpp.

◆ compresstype_callback()

static bool compresstype_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Warn about deprecated compresstype selection.

Definition at line 1248 of file settings.cpp.

◆ compresstype_name()

static const struct sset_val_name* compresstype_name ( enum compress_type  compresstype)
static

Savegame compress type names accessor.

Definition at line 536 of file settings.cpp.

◆ demography_callback()

static bool demography_callback ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify that a given demography string is valid.

See game.demography.

Definition at line 869 of file settings.cpp.

◆ diplomacy_name()

static const struct sset_val_name* diplomacy_name ( int  diplomacy)
static

Diplomacy setting names accessor.

Definition at line 414 of file settings.cpp.

◆ endturn_callback()

static bool endturn_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify that a given endturn is valid.

Definition at line 1005 of file settings.cpp.

◆ first_timeout_action()

static void first_timeout_action ( const struct setting pset)
static

Enact a change in the 'first_timeout' server setting immediately, if the game is afoot.

Definition at line 741 of file settings.cpp.

◆ first_timeout_callback()

static bool first_timeout_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Validate the 'first_timeout' server setting.

Definition at line 1106 of file settings.cpp.

◆ generator_name()

static const struct sset_val_name* generator_name ( int  generator)
static

Generator setting names accessor.

Definition at line 262 of file settings.cpp.

◆ generator_validate()

static bool generator_validate ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify the value of the generator option (notably the MAPGEN_SCENARIO case).

Definition at line 828 of file settings.cpp.

◆ happyborders_name()

static const struct sset_val_name* happyborders_name ( int  happyborders)
static

Happyborders setting names accessor.

Definition at line 401 of file settings.cpp.

◆ huts_action()

static void huts_action ( const struct setting pset)
static

Clean out absolute number of huts when relative setting set.

Definition at line 761 of file settings.cpp.

◆ huts_help()

static const char* huts_help ( const struct setting pset)
static

Help about huts setting.

Definition at line 605 of file settings.cpp.

◆ mapsize_callback()

static bool mapsize_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Mapsize setting validation callback.

Definition at line 1151 of file settings.cpp.

◆ mapsize_name()

static const struct sset_val_name* mapsize_name ( int  mapsize)
static

Map size definition setting names accessor.

This setting has an hard-coded depedence in "server/meta.c".

Definition at line 223 of file settings.cpp.

◆ maxplayers_callback()

static bool maxplayers_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify that a given maxplayers is valid.

Definition at line 1020 of file settings.cpp.

◆ metamessage_action()

static void metamessage_action ( const struct setting pset)
static

Update metaserver message string from changed user meta server message string.

Definition at line 786 of file settings.cpp.

◆ nationset_action()

static void nationset_action ( const struct setting pset)
static

Restrict to the selected nation set.

Definition at line 657 of file settings.cpp.

◆ nationset_callback()

static bool nationset_callback ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Validate the 'nationset' server setting.

Definition at line 1047 of file settings.cpp.

◆ persistentready_name()

static const struct sset_val_name* persistentready_name ( int  persistent_ready)
static

Persistentready setting names accessor.

Definition at line 313 of file settings.cpp.

◆ phasemode_help()

static const char* phasemode_help ( const struct setting pset)
static

Help about phasemode setting.

Definition at line 587 of file settings.cpp.

◆ phasemode_name()

static const struct sset_val_name* phasemode_name ( int  phasemode)
static

Phase mode names accessor.

Definition at line 508 of file settings.cpp.

Referenced by phasemode_help().

◆ plrcol_action()

static void plrcol_action ( const struct setting pset)
static

Clear any user-set player colors in modes other than PLRCOL_PLR_SET.

Definition at line 691 of file settings.cpp.

◆ plrcol_name()

static const struct sset_val_name* plrcol_name ( int  plrcol)
static

Player colors configuration setting names accessor.

Definition at line 385 of file settings.cpp.

◆ plrcol_validate()

static bool plrcol_validate ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Validate that the player color mode can be used.

Definition at line 1264 of file settings.cpp.

◆ read_enum_value()

int read_enum_value ( const struct setting pset)

◆ revealmap_name()

static const struct sset_val_name* revealmap_name ( int  bit)
static

Revealmap setting names accessor.

Definition at line 478 of file settings.cpp.

◆ revolentype_name()

static const struct sset_val_name* revolentype_name ( int  revolentype)
static

Revolution length type setting names accessor.

Definition at line 462 of file settings.cpp.

◆ savename_validate()

static bool savename_validate ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify the selected savename definition.

Definition at line 806 of file settings.cpp.

◆ scorefile_validate()

static bool scorefile_validate ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify the name for the score log file.

Definition at line 853 of file settings.cpp.

◆ scorelog_action()

static void scorelog_action ( const struct setting pset)
static

(De)initialze the score log.

Definition at line 632 of file settings.cpp.

◆ scoreloglevel_name()

static const struct sset_val_name* scoreloglevel_name ( enum scoreQtMsgType  sl_level)
static

Scorelog level names accessor.

Definition at line 523 of file settings.cpp.

◆ send_server_access_level_settings()

void send_server_access_level_settings ( struct conn_list *  dest,
enum cmdlevel  old_level,
enum cmdlevel  new_level 
)

Send the server settings that got a different visibility or changability after a connection access level change.

Usually called when the access level of the user changes.

Definition at line 4952 of file settings.cpp.

Referenced by conn_set_access().

◆ send_server_setting()

void send_server_setting ( struct conn_list *  dest,
const struct setting pset 
)

Tell the client about just one server setting.

Call this after a setting is saved.

Definition at line 4822 of file settings.cpp.

Referenced by metamessage_command(), send_server_access_level_settings(), send_server_settings(), and set_command().

◆ send_server_setting_control()

void send_server_setting_control ( struct connection pconn)

Tell the client about all server settings.

Definition at line 4986 of file settings.cpp.

Referenced by establish_new_connection().

◆ send_server_settings()

void send_server_settings ( struct conn_list *  dest)

Tell the client about all server settings.

Definition at line 4941 of file settings.cpp.

Referenced by establish_new_connection(), load_command(), reset_command(), settings_ruleset(), and srv_ready().

◆ set_enum_value()

static bool set_enum_value ( struct setting pset,
int  val 
)
static

Helper function to write value to enumerator setting.

Definition at line 3664 of file settings.cpp.

Referenced by setting_enum_set(), setting_ruleset_one(), setting_set_to_default(), and settings_game_load().

◆ setting_action()

void setting_action ( const struct setting pset)

Execute the action callback if needed.

Definition at line 4048 of file settings.cpp.

Referenced by set_command(), settings_game_load(), settings_init(), settings_reset(), and settings_ruleset().

◆ setting_bitwise_bit()

const char* setting_bitwise_bit ( const struct setting pset,
int  bit,
bool  pretty 
)

Convert the bit number to its string representation.

Return nullptr if 'bit' is not a valid bit.

Definition at line 3775 of file settings.cpp.

Referenced by manual_command(), option_value_accessor(), and show_help_option().

◆ setting_bitwise_get()

int setting_bitwise_get ( struct setting pset)

Get value of bitwise setting.

Definition at line 3936 of file settings.cpp.

Referenced by save_game_ruleset(), and server_ss_val_bitwise_get().

◆ setting_bitwise_secfile_str()

const char* setting_bitwise_secfile_str ( secfile_data_t  data,
int  bit 
)

Convert the integer to the long support string representation of an enumerator.

This function must match the secfile_enum_name_data_fn_t type.

Definition at line 3763 of file settings.cpp.

Referenced by save_game_ruleset(), setting_ruleset_one(), settings_game_load(), and settings_game_save().

◆ setting_bitwise_set()

bool setting_bitwise_set ( struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Set the setting to 'val'.

Returns TRUE on success. If it fails, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3902 of file settings.cpp.

Referenced by set_command(), and setting_game_restore().

◆ setting_bitwise_to_str()

static const char* setting_bitwise_to_str ( const struct setting pset,
unsigned  value,
bool  pretty,
char *  buf,
size_t  buf_len 
)
static

Compute the string representation of the value for this bitwise setting.

Definition at line 3794 of file settings.cpp.

Referenced by setting_default_name(), setting_game_restore(), and setting_value_name().

◆ setting_bitwise_validate()

bool setting_bitwise_validate ( const struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3923 of file settings.cpp.

Referenced by set_command().

◆ setting_bitwise_validate_base()

static bool setting_bitwise_validate_base ( const struct setting pset,
const char *  val,
unsigned *  pint_val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

FIXME: also check the access level of pconn.

Definition at line 3854 of file settings.cpp.

Referenced by setting_bitwise_set(), and setting_bitwise_validate().

◆ setting_bool_get()

bool setting_bool_get ( struct setting pset)

Get value of boolean setting.

Definition at line 3391 of file settings.cpp.

Referenced by save_game_ruleset(), and server_ss_val_bool_get().

◆ setting_bool_secfile_str()

static const char* setting_bool_secfile_str ( secfile_data_t  data,
int  val 
)
static

Convert the integer to the long support string representation of a boolean setting.

This function must match the secfile_enum_name_data_fn_t type.

Definition at line 3417 of file settings.cpp.

Referenced by setting_ruleset_one().

◆ setting_bool_set()

bool setting_bool_set ( struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Set the setting to 'val'.

Returns TRUE on success. If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3372 of file settings.cpp.

Referenced by set_command(), and setting_game_restore().

◆ setting_bool_to_str()

static const char* setting_bool_to_str ( const struct setting pset,
bool  value,
bool  pretty,
char *  buf,
size_t  buf_len 
)
static

Compute the string representation of the value for this boolean setting.

Definition at line 3322 of file settings.cpp.

Referenced by setting_default_name(), setting_game_restore(), and setting_value_name().

◆ setting_bool_validate()

bool setting_bool_validate ( const struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3403 of file settings.cpp.

Referenced by set_command().

◆ setting_bool_validate_base()

static bool setting_bool_validate_base ( const struct setting pset,
const char *  val,
int *  pint_val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

FIXME: also check the access level of pconn.

Definition at line 3343 of file settings.cpp.

Referenced by setting_bool_set(), and setting_bool_validate().

◆ setting_by_name()

struct setting* setting_by_name ( const char *  name)

◆ setting_by_number()

◆ setting_category()

enum sset_category setting_category ( const struct setting pset)

Access function for the setting category.

Definition at line 3080 of file settings.cpp.

Referenced by manual_command(), and sanity_check_setting_is_game_rule().

◆ setting_changed()

void setting_changed ( struct setting pset)

Mark setting changed.

Definition at line 5155 of file settings.cpp.

Referenced by metamessage_command(), and set_command().

◆ setting_default_name()

const char* setting_default_name ( const struct setting pset,
bool  pretty,
char *  buf,
size_t  buf_len 
)

Compute the name of the default value of the setting.

Definition at line 3982 of file settings.cpp.

Referenced by manual_command(), and show_help_option().

◆ setting_enum_secfile_str()

const char* setting_enum_secfile_str ( secfile_data_t  data,
int  val 
)

Convert the integer to the long support string representation of an enumerator.

This function must match the secfile_enum_name_data_fn_t type.

Definition at line 3583 of file settings.cpp.

Referenced by save_game_ruleset(), setting_ruleset_one(), settings_game_load(), and settings_game_save().

◆ setting_enum_set()

bool setting_enum_set ( struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Set the setting to 'val'.

Returns TRUE on success. If it fails, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3720 of file settings.cpp.

Referenced by autolock_settings(), set_command(), setting_game_restore(), and srv_ready().

◆ setting_enum_to_str()

static const char* setting_enum_to_str ( const struct setting pset,
int  value,
bool  pretty,
char *  buf,
size_t  buf_len 
)
static

Compute the string representation of the value for this enumerator setting.

Definition at line 3615 of file settings.cpp.

Referenced by setting_default_name(), setting_game_restore(), and setting_value_name().

◆ setting_enum_val()

const char* setting_enum_val ( const struct setting pset,
int  val,
bool  pretty 
)

Convert the integer to the string representation of an enumerator.

Return nullptr if 'val' is not a valid enumerator.

Definition at line 3595 of file settings.cpp.

Referenced by manual_command(), option_value_accessor(), and show_help_option().

◆ setting_enum_validate()

bool setting_enum_validate ( const struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

Definition at line 3749 of file settings.cpp.

Referenced by set_command().

◆ setting_enum_validate_base()

static bool setting_enum_validate_base ( const struct setting pset,
const char *  val,
int *  pint_val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available in the optionnal parameter 'reject_msg'.

FIXME: also check the access level of pconn.

Definition at line 3637 of file settings.cpp.

Referenced by setting_enum_set(), and setting_enum_validate().

◆ setting_extra_help()

const char* setting_extra_help ( const struct setting pset,
bool  constant 
)

Access function for the long (extra) help of the setting.

If 'constant' is TRUE, static, not-yet-translated string is always returned.

Definition at line 3080 of file settings.cpp.

Referenced by manual_command(), send_server_setting_control(), and show_help_option().

◆ setting_game_free()

static void setting_game_free ( struct setting pset)
static

Free the memory used for the settings at game start.

Definition at line 4332 of file settings.cpp.

Referenced by settings_free().

◆ setting_game_restore()

static void setting_game_restore ( struct setting pset)
static

Restore the setting to the value used at the start of the current game.

Definition at line 4343 of file settings.cpp.

Referenced by settings_game_reset().

◆ setting_game_set()

static void setting_game_set ( struct setting pset,
bool  init 
)
static

Save the setting value of the current game.

Definition at line 4296 of file settings.cpp.

Referenced by settings_game_start(), and settings_init().

◆ setting_get_setdef()

enum setting_default_level setting_get_setdef ( const struct setting pset)

Is the setting in changed state, or the default.

Definition at line 5155 of file settings.cpp.

Referenced by save_game_ruleset(), settings_game_save(), and show_settings_one().

◆ setting_int_get()

int setting_int_get ( struct setting pset)

Get value of integer setting.

Definition at line 3502 of file settings.cpp.

Referenced by save_game_ruleset(), and server_ss_val_int_get().

◆ setting_int_max()

int setting_int_max ( const struct setting pset)

Returns the maximal integer value for this setting.

Definition at line 3447 of file settings.cpp.

Referenced by manual_command(), show_help_option(), and show_settings_one().

◆ setting_int_min()

int setting_int_min ( const struct setting pset)

Returns the minimal integer value for this setting.

Definition at line 3438 of file settings.cpp.

Referenced by manual_command(), show_help_option(), and show_settings_one().

◆ setting_int_set()

bool setting_int_set ( struct setting pset,
int  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Set the setting to 'val'.

Returns TRUE on success. If it fails, the reason of the failure is available by the function setting_error().

Definition at line 3457 of file settings.cpp.

Referenced by set_command(), setting_game_restore(), and setting_ruleset_one().

◆ setting_int_to_str()

static const char* setting_int_to_str ( const struct setting pset,
int  value,
bool  pretty,
char *  buf,
size_t  buf_len 
)
static

Compute the string representation of the value for this integer setting.

Definition at line 3428 of file settings.cpp.

Referenced by setting_default_name(), and setting_value_name().

◆ setting_int_validate()

bool setting_int_validate ( const struct setting pset,
int  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available by the function setting_error().

FIXME: also check the access level of pconn.

Definition at line 3477 of file settings.cpp.

Referenced by set_command(), and setting_int_set().

◆ setting_is_changeable()

bool setting_is_changeable ( const struct setting pset,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns whether the specified server setting (option) can currently be changed by the caller.

If it returns FALSE, the reason of the failure is available by the function setting_error().

Definition at line 3191 of file settings.cpp.

Referenced by default_command(), manual_command(), set_command(), setting_bitwise_set(), setting_bool_set(), setting_enum_set(), setting_game_restore(), setting_int_set(), setting_status(), setting_str_set(), settings_game_load(), settings_reset(), and show_help_option().

◆ setting_is_free_to_change()

static bool setting_is_free_to_change ( const struct setting pset,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Returns whether the specified server setting (option) can currently be changed without breaking data consistency (map dimension options can't change when map has already been created with certain dimensions)

Definition at line 3118 of file settings.cpp.

Referenced by setting_is_changeable(), and settings_game_save().

◆ setting_is_visible()

bool setting_is_visible ( const struct setting pset,
struct connection caller 
)

Returns whether the specified server setting (option) can be seen by the caller.

Definition at line 3227 of file settings.cpp.

Referenced by set_command(), show_help_option(), show_help_option_list(), and show_settings().

◆ setting_is_visible_at_level()

bool setting_is_visible_at_level ( const struct setting pset,
enum cmdlevel  plevel 
)

Returns whether the specified server setting (option) can be seen by a caller with the specified access level.

Definition at line 3217 of file settings.cpp.

Referenced by sanity_check_setting_is_seen(), and setting_is_visible().

◆ setting_level()

enum sset_level setting_level ( const struct setting pset)

Access function for the setting level (used by the /show command).

Definition at line 3080 of file settings.cpp.

Referenced by manual_command(), and settings_list_init().

◆ setting_lock_set()

void setting_lock_set ( struct setting pset,
bool  lock 
)

Set the value for the lock of a setting.

Definition at line 4288 of file settings.cpp.

Referenced by autolock_settings(), setting_ruleset_one(), settings_init(), and settings_ruleset().

◆ setting_locked()

bool setting_locked ( const struct setting pset)

Returns if the setting is locked by the ruleset.

Definition at line 4283 of file settings.cpp.

Referenced by manual_command(), save_game_ruleset(), setting_is_changeable(), setting_status(), and settings_list_update().

◆ setting_match_prefix()

static bool setting_match_prefix ( const val_name_func_t  name_fn,
const char *  prefix,
int *  pvalue,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Convert the string prefix to an integer representation.

NB: This function is used for SST_ENUM and SST_BITWISE.

Definition at line 3285 of file settings.cpp.

Referenced by setting_bitwise_validate_base(), setting_bool_validate_base(), and setting_enum_validate_base().

◆ setting_match_prefix_base()

static enum m_pre_result setting_match_prefix_base ( const val_name_func_t  name_fn,
const char *  prefix,
int *  ind_result,
QVector< QString > &  matches,
size_t  max_matches,
size_t *  pnum_matches 
)
static

Convert the string prefix to an integer representation.

NB: This function is used for SST_ENUM and SST_BITWISE.

FIXME: this mostly duplicate match_prefix_full().

Definition at line 3227 of file settings.cpp.

Referenced by setting_match_prefix().

◆ setting_name()

◆ setting_non_default()

bool setting_non_default ( const struct setting pset)

Returns whether the setting has non-default value.

Definition at line 4257 of file settings.cpp.

Referenced by manual_command(), settings_list_update(), and show_settings_one().

◆ setting_number()

int setting_number ( const struct setting pset)

◆ setting_ruleset_one()

static bool setting_ruleset_one ( struct section_file file,
const char *  name,
const char *  path 
)
static

Set one setting from the game.ruleset file.

Definition at line 4108 of file settings.cpp.

Referenced by settings_ruleset().

◆ setting_set_to_default()

void setting_set_to_default ( struct setting pset)

Update the setting to the default value.

Definition at line 4018 of file settings.cpp.

Referenced by default_command(), settings_init(), settings_reset(), and settings_ruleset().

◆ setting_short_help()

const char* setting_short_help ( const struct setting pset)

Access function for the short help (not translated yet) of the setting.

Definition at line 3070 of file settings.cpp.

Referenced by manual_command(), send_server_setting_control(), and show_help_option().

◆ setting_str_get()

char* setting_str_get ( struct setting pset)

Get value of string setting.

Definition at line 3572 of file settings.cpp.

Referenced by save_game_ruleset().

◆ setting_str_set()

bool setting_str_set ( struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Set the setting to 'val'.

Returns TRUE on success. If it fails, the reason of the failure is available by the function setting_error().

Definition at line 3528 of file settings.cpp.

Referenced by set_command(), setting_game_restore(), setting_ruleset_one(), and settings_game_load().

◆ setting_str_to_str()

static const char* setting_str_to_str ( const struct setting pset,
const char *  value,
bool  pretty,
char *  buf,
size_t  buf_len 
)
static

Compute the string representation of the value for this string setting.

Definition at line 3512 of file settings.cpp.

Referenced by setting_default_name(), and setting_value_name().

◆ setting_str_validate()

bool setting_str_validate ( const struct setting pset,
const char *  val,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)

Returns TRUE if 'val' is a valid value for this setting.

If it's not, the reason of the failure is available by the function setting_error().

FIXME: also check the access level of pconn.

Definition at line 3548 of file settings.cpp.

Referenced by set_command(), and setting_str_set().

◆ setting_type()

◆ setting_value_name()

const char* setting_value_name ( const struct setting pset,
bool  pretty,
char *  buf,
size_t  buf_len 
)

◆ settings_free()

void settings_free ( )

Deinitialize stuff related to this code module.

Definition at line 4805 of file settings.cpp.

Referenced by server_quit().

◆ settings_game_load()

void settings_game_load ( struct section_file file,
const char *  section 
)

Restore all settings from a savegame.

Definition at line 4487 of file settings.cpp.

Referenced by sg_load_settings().

◆ settings_game_reset()

bool settings_game_reset ( )

Reset all settings to the values at game start.

Definition at line 4745 of file settings.cpp.

Referenced by reset_command().

◆ settings_game_save()

void settings_game_save ( struct section_file file,
const char *  section 
)

Save game settings.

Definition at line 4416 of file settings.cpp.

Referenced by sg_save_settings().

◆ settings_game_start()

void settings_game_start ( )

Save setting values at the start of the game.

Definition at line 4404 of file settings.cpp.

Referenced by srv_ready().

◆ settings_init()

void settings_init ( bool  act)

Initialize stuff related to this code module.

Definition at line 4761 of file settings.cpp.

Referenced by main().

◆ settings_list_cmp()

int settings_list_cmp ( const struct setting *const *  pset1,
const struct setting *const *  pset2 
)

Update sorted settings (changed and locked values).

Definition at line 5113 of file settings.cpp.

Referenced by settings_list_init(), and settings_list_update().

◆ settings_list_free()

static void settings_list_free ( )
static

Free sorted settings.

Definition at line 5138 of file settings.cpp.

Referenced by settings_free().

◆ settings_list_get()

struct setting_list* settings_list_get ( enum sset_level  level)

Get a settings list of a certain level.

Call settings_list_update() before if something was changed.

Definition at line 5126 of file settings.cpp.

◆ settings_list_init()

static void settings_list_init ( )
static

Initialise sorted settings.

Definition at line 5024 of file settings.cpp.

Referenced by settings_init().

◆ settings_list_update()

void settings_list_update ( )

Update sorted settings (changed and locked values).

Definition at line 5084 of file settings.cpp.

Referenced by settings_init(), and show_settings().

◆ settings_number()

int settings_number ( )

Returns the total number of settings.

Definition at line 4816 of file settings.cpp.

Referenced by explain_option(), lookup_option(), olevel_generator(), option_generator(), show_help(), and universal_kind_values().

◆ settings_reset()

void settings_reset ( )

Reset all settings iff they are changeable.

Definition at line 4782 of file settings.cpp.

Referenced by reset_command().

◆ settings_ruleset()

bool settings_ruleset ( struct section_file file,
const char *  section,
bool  act 
)

Load game settings from ruleset file 'game.ruleset'.

Definition at line 4058 of file settings.cpp.

Referenced by load_rulesetdir(), and reload_rulesets_settings().

◆ settings_turn()

void settings_turn ( )

Update stuff every turn that is related to this code module.

Run this on turn end.

Definition at line 4798 of file settings.cpp.

Referenced by end_turn().

◆ startpos_name()

static const struct sset_val_name* startpos_name ( int  startpos)
static

Start position setting names accessor.

Definition at line 278 of file settings.cpp.

◆ startunits_callback()

static bool startunits_callback ( const char *  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Verify that a given startunits string is valid.

See game.server.start_units.

Definition at line 955 of file settings.cpp.

◆ teamplacement_name()

static const struct sset_val_name* teamplacement_name ( int  team_placement)
static

Team placement setting names accessor.

Definition at line 296 of file settings.cpp.

◆ timeout_action()

static void timeout_action ( const struct setting pset)
static

Enact a change in the 'timeout' server setting immediately, if the game is afoot.

Definition at line 724 of file settings.cpp.

◆ timeout_callback()

static bool timeout_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Validate the 'timeout' server setting.

Definition at line 1067 of file settings.cpp.

◆ topology_action()

static void topology_action ( const struct setting pset)
static

Topology setting changed.

Definition at line 769 of file settings.cpp.

◆ topology_callback()

static bool topology_callback ( unsigned  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Topology setting validation callback.

Definition at line 1228 of file settings.cpp.

◆ topology_name()

static const struct sset_val_name* topology_name ( int  topology_bit)
static

Topology setting names accessor.

Definition at line 236 of file settings.cpp.

◆ traderevenuestyle_name()

static const struct sset_val_name* traderevenuestyle_name ( int  revenue_style)
static

Trade revenue style setting names accessor.

Definition at line 250 of file settings.cpp.

◆ trait_dist_name()

static const struct sset_val_name* trait_dist_name ( int  trait_dist)
static

Trait distribution setting names accessor.

Definition at line 373 of file settings.cpp.

◆ unitwaittime_callback()

static bool unitwaittime_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

Check 'timeout' setting if 'unitwaittime' is changed.

Definition at line 1124 of file settings.cpp.

◆ unitwaittime_name()

static const struct sset_val_name* unitwaittime_name ( int  bit)
static

Unitwaittime style names accessor.

Definition at line 569 of file settings.cpp.

◆ victory_conditions_name()

static const struct sset_val_name* victory_conditions_name ( int  condition_bit)
static

Victory conditions setting names accessor.

Definition at line 327 of file settings.cpp.

◆ xsize_callback()

static bool xsize_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

xsize setting validation callback.

Definition at line 1170 of file settings.cpp.

◆ ysize_callback()

static bool ysize_callback ( int  value,
struct connection caller,
char *  reject_msg,
size_t  reject_msg_len 
)
static

ysize setting validation callback.

Definition at line 1195 of file settings.cpp.

Variable Documentation

◆ init

bool init

Definition at line 166 of file settings.cpp.

Referenced by setting_game_set().

◆ level

◆ 

struct { ... } setting_sorted

◆ settings

◆ SETTINGS_NUM

const int SETTINGS_NUM = ARRAY_SIZE(settings)
static

Definition at line 3026 of file settings.cpp.

Referenced by send_server_setting_control(), setting_by_number(), and settings_number().