1 /**********************************************************************
2 Freeciv - Copyright (C) 1996-2004 - The Freeciv Project
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
15 #include <fc_config.h>
26 #include "string_vector.h"
33 #include "ggzserver.h"
40 #include "stdinhand.h"
42 /* The following classes determine what can be changed when.
43 * Actually, some of them have the same "changeability", but
44 * different types are separated here in case they have
46 * Also, SSET_GAME_INIT/SSET_RULES separate the two sections
47 * of server settings sent to the client.
48 * See the settings[] array and setting_is_changeable() for what
49 * these correspond to and explanations.
62 typedef bool (*bool_validate_func_t
) (bool value
, struct connection
*pconn
,
64 size_t reject_msg_len
);
65 typedef bool (*int_validate_func_t
) (int value
, struct connection
*pconn
,
67 size_t reject_msg_len
);
68 typedef bool (*string_validate_func_t
) (const char * value
,
69 struct connection
*pconn
,
71 size_t reject_msg_len
);
72 typedef bool (*enum_validate_func_t
) (int value
, struct connection
*pconn
,
74 size_t reject_msg_len
);
75 typedef bool (*bitwise_validate_func_t
) (unsigned value
,
76 struct connection
*pconn
,
78 size_t reject_msg_len
);
80 typedef void (*action_callback_func_t
) (const struct setting
*pset
);
81 typedef const struct sset_val_name
* (*val_name_func_t
) (int value
);
85 enum sset_class sclass
;
89 * Sould be less than 42 chars (?), or shorter if the values may
90 * have more than about 4 digits. Don't put "." on the end.
92 const char *short_help
;
95 * May be empty string, if short_help is sufficient. Need not
96 * include embedded newlines (but may, for formatting); lines will
97 * be wrapped (and indented) automatically. Should have punctuation
98 * etc, and should end with a "."
100 const char *extra_help
;
101 enum sset_type stype
;
102 enum sset_category scategory
;
103 enum sset_level slevel
;
106 * About the *_validate functions: If the function is non-NULL, it
107 * is called with the new value, and returns whether the change is
108 * legal. The char * is an error message in the case of reject.
115 const bool default_value
;
116 const bool_validate_func_t validate
;
117 const val_name_func_t name
;
123 const int default_value
;
126 const int_validate_func_t validate
;
129 /*** string part ***/
132 const char *const default_value
;
133 const size_t value_size
;
134 const string_validate_func_t validate
;
137 /*** enumerator part ***/
140 const int store_size
;
141 const int default_value
;
142 const enum_validate_func_t validate
;
143 const val_name_func_t name
;
146 /*** bitwise part ***/
148 unsigned *const pvalue
;
149 const unsigned default_value
;
150 const bitwise_validate_func_t validate
;
151 const val_name_func_t name
;
156 /* action function */
157 const action_callback_func_t action
;
159 /* ruleset lock for game settings */
165 struct setting_list
*level
[OLEVELS_NUM
];
166 } setting_sorted
= { .init
= FALSE
};
168 static void setting_set_to_default(struct setting
*pset
);
169 static bool setting_ruleset_one(struct section_file
*file
,
170 const char *name
, const char *path
);
171 static void setting_game_set(struct setting
*pset
, bool init
);
172 static void setting_game_free(struct setting
*pset
);
173 static void setting_game_restore(struct setting
*pset
);
175 static void settings_list_init(void);
176 static void settings_list_free(void);
177 int settings_list_cmp(const struct setting
*const *pset1
,
178 const struct setting
*const *pset2
);
180 #define settings_snprintf(_buf, _buf_len, format, ...) \
181 if (_buf != NULL) { \
182 fc_snprintf(_buf, _buf_len, format, ## __VA_ARGS__); \
185 static bool set_enum_value(struct setting
*pset
, int val
);
186 static int read_enum_value(const struct setting
*pset
);
188 /****************************************************************************
189 Enumerator name accessors.
191 Important note about compatibility:
192 1) you cannot modify the support name of an existant value. However, in a
193 developpement, you can modify it if it wasn't included in any stable
195 2) Take care of modifiying the pretty name of an existant value: make sure
196 to modify the help texts which are using it.
197 ****************************************************************************/
199 #define NAME_CASE(_val, _support, _pretty) \
202 static const struct sset_val_name name = { _support, _pretty }; \
206 /****************************************************************************
207 Map size definition setting names accessor. This setting has an
208 hard-coded depedence in "server/meta.c".
209 ****************************************************************************/
210 static const struct sset_val_name
*mapsize_name(int mapsize
)
213 NAME_CASE(MAPSIZE_FULLSIZE
, "FULLSIZE", N_("Number of tiles"));
214 NAME_CASE(MAPSIZE_PLAYER
, "PLAYER", N_("Tiles per player"));
215 NAME_CASE(MAPSIZE_XYSIZE
, "XYSIZE", N_("Width and height"));
220 /****************************************************************************
221 Topology setting names accessor.
222 ****************************************************************************/
223 static const struct sset_val_name
*topology_name(int topology_bit
)
225 switch (1 << topology_bit
) {
226 NAME_CASE(TF_WRAPX
, "WRAPX", N_("Wrap East-West"));
227 NAME_CASE(TF_WRAPY
, "WRAPY", N_("Wrap North-South"));
228 NAME_CASE(TF_ISO
, "ISO", N_("Isometric"));
229 NAME_CASE(TF_HEX
, "HEX", N_("Hexagonal"));
234 /****************************************************************************
235 Generator setting names accessor.
236 ****************************************************************************/
237 static const struct sset_val_name
*generator_name(int generator
)
240 NAME_CASE(MAPGEN_SCENARIO
, "SCENARIO", N_("Scenario map"));
241 NAME_CASE(MAPGEN_RANDOM
, "RANDOM", N_("Fully random height"));
242 NAME_CASE(MAPGEN_FRACTAL
, "FRACTAL", N_("Pseudo-fractal height"));
243 NAME_CASE(MAPGEN_ISLAND
, "ISLAND", N_("Island-based"));
244 NAME_CASE(MAPGEN_FAIR
, "FAIR", N_("Fair islands"));
249 /****************************************************************************
250 Start position setting names accessor.
251 ****************************************************************************/
252 static const struct sset_val_name
*startpos_name(int startpos
)
255 NAME_CASE(MAPSTARTPOS_DEFAULT
, "DEFAULT",
256 N_("Generator's choice"));
257 NAME_CASE(MAPSTARTPOS_SINGLE
, "SINGLE",
258 N_("One player per continent"));
259 NAME_CASE(MAPSTARTPOS_2or3
, "2or3",
260 N_("Two or three players per continent"));
261 NAME_CASE(MAPSTARTPOS_ALL
, "ALL",
262 N_("All players on a single continent"));
263 NAME_CASE(MAPSTARTPOS_VARIABLE
, "VARIABLE",
264 N_("Depending on size of continents"));
269 /****************************************************************************
270 Team placement setting names accessor.
271 ****************************************************************************/
272 static const struct sset_val_name
*teamplacement_name(int team_placement
)
274 switch (team_placement
) {
275 NAME_CASE(TEAM_PLACEMENT_DISABLED
, "DISABLED",
277 NAME_CASE(TEAM_PLACEMENT_CLOSEST
, "CLOSEST",
278 N_("As close as possible"));
279 NAME_CASE(TEAM_PLACEMENT_CONTINENT
, "CONTINENT",
280 N_("On the same continent"));
281 NAME_CASE(TEAM_PLACEMENT_HORIZONTAL
, "HORIZONTAL",
282 N_("Horizontal placement"));
283 NAME_CASE(TEAM_PLACEMENT_VERTICAL
, "VERTICAL",
284 N_("Vertical placement"));
289 /****************************************************************************
290 Autosaves setting names accessor.
291 ****************************************************************************/
292 static const struct sset_val_name
*autosaves_name(int autosaves_bit
)
294 switch (autosaves_bit
) {
295 NAME_CASE(AS_TURN
, "TURN", N_("New turn"));
296 NAME_CASE(AS_GAME_OVER
, "GAMEOVER", N_("Game over"));
297 NAME_CASE(AS_QUITIDLE
, "QUITIDLE", N_("No player connections"));
298 NAME_CASE(AS_INTERRUPT
, "INTERRUPT", N_("Server interrupted"));
304 /****************************************************************************
305 Borders setting names accessor.
306 ****************************************************************************/
307 static const struct sset_val_name
*borders_name(int borders
)
310 NAME_CASE(BORDERS_DISABLED
, "DISABLED", N_("Disabled"));
311 NAME_CASE(BORDERS_ENABLED
, "ENABLED", N_("Enabled"));
312 NAME_CASE(BORDERS_SEE_INSIDE
, "SEE_INSIDE",
313 N_("See everything inside borders"));
314 NAME_CASE(BORDERS_EXPAND
, "EXPAND",
315 N_("Borders expand to unknown, revealing tiles"));
320 /****************************************************************************
321 Player colors configuration setting names accessor.
322 ****************************************************************************/
323 static const struct sset_val_name
*plrcol_name(int plrcol
)
326 NAME_CASE(PLRCOL_PLR_ORDER
, "PLR_ORDER", N_("Per-player, in order"));
327 NAME_CASE(PLRCOL_PLR_RANDOM
, "PLR_RANDOM", N_("Per-player, random"));
328 NAME_CASE(PLRCOL_PLR_SET
, "PLR_SET", N_("Set manually"));
329 NAME_CASE(PLRCOL_TEAM_ORDER
, "TEAM_ORDER", N_("Per-team, in order"));
330 NAME_CASE(PLRCOL_NATION_ORDER
, "NATION_ORDER", N_("Per-nation, in order"));
335 /****************************************************************************
336 Diplomacy setting names accessor.
337 ****************************************************************************/
338 static const struct sset_val_name
*diplomacy_name(int diplomacy
)
341 NAME_CASE(DIPLO_FOR_ALL
, "ALL", N_("Enabled for everyone"));
342 NAME_CASE(DIPLO_FOR_HUMANS
, "HUMAN",
343 N_("Only allowed between human players"));
344 NAME_CASE(DIPLO_FOR_AIS
, "AI", N_("Only allowed between AI players"));
345 NAME_CASE(DIPLO_NO_AIS
, "NOAI", N_("Only allowed when human involved"));
346 NAME_CASE(DIPLO_NO_MIXED
, "NOMIXED", N_("Only allowed between two humans, or two AI players"));
347 NAME_CASE(DIPLO_FOR_TEAMS
, "TEAM", N_("Restricted to teams"));
348 NAME_CASE(DIPLO_DISABLED
, "DISABLED", N_("Disabled for everyone"));
353 /****************************************************************************
354 City names setting names accessor.
355 ****************************************************************************/
356 static const struct sset_val_name
*citynames_name(int citynames
)
359 NAME_CASE(CNM_NO_RESTRICTIONS
, "NO_RESTRICTIONS", N_("No restrictions"));
360 NAME_CASE(CNM_PLAYER_UNIQUE
, "PLAYER_UNIQUE", N_("Unique to a player"));
361 NAME_CASE(CNM_GLOBAL_UNIQUE
, "GLOBAL_UNIQUE", N_("Globally unique"));
362 NAME_CASE(CNM_NO_STEALING
, "NO_STEALING", N_("No city name stealing"));
367 /****************************************************************************
368 Barbarian setting names accessor.
369 ****************************************************************************/
370 static const struct sset_val_name
*barbarians_name(int barbarians
)
372 switch (barbarians
) {
373 NAME_CASE(BARBS_DISABLED
, "DISABLED", N_("No barbarians"));
374 NAME_CASE(BARBS_HUTS_ONLY
, "HUTS_ONLY", N_("Only in huts"));
375 NAME_CASE(BARBS_NORMAL
, "NORMAL", N_("Normal rate of appearance"));
376 NAME_CASE(BARBS_FREQUENT
, "FREQUENT", N_("Frequent barbarian uprising"));
377 NAME_CASE(BARBS_HORDES
, "HORDES", N_("Raging hordes"));
382 /****************************************************************************
383 Revealmap setting names accessor.
384 ****************************************************************************/
385 static const struct sset_val_name
*revealmap_name(int bit
)
388 NAME_CASE(REVEAL_MAP_START
, "START", N_("Reveal map at game start"));
389 NAME_CASE(REVEAL_MAP_DEAD
, "DEAD", N_("Unfog map for dead players"));
394 /****************************************************************************
395 Airlifting style setting names accessor.
396 ****************************************************************************/
397 static const struct sset_val_name
*airliftingstyle_name(int bit
)
400 NAME_CASE(AIRLIFTING_ALLIED_SRC
, "FROM_ALLIES",
401 N_("Allows units to be airlifted from allied cities"));
402 NAME_CASE(AIRLIFTING_ALLIED_DEST
, "TO_ALLIES",
403 N_("Allows units to be airlifted to allied cities"));
404 NAME_CASE(AIRLIFTING_UNLIMITED_SRC
, "SRC_UNLIMITED",
405 N_("Unlimited units from source city"));
406 NAME_CASE(AIRLIFTING_UNLIMITED_DEST
, "DEST_UNLIMITED",
407 N_("Unlimited units to destination city"));
412 /****************************************************************************
413 Phase mode names accessor.
414 ****************************************************************************/
415 static const struct sset_val_name
*phasemode_name(int phasemode
)
418 NAME_CASE(PMT_CONCURRENT
, "ALL", N_("All players move concurrently"));
419 NAME_CASE(PMT_PLAYERS_ALTERNATE
,
420 "PLAYER", N_("All players alternate movement"));
421 NAME_CASE(PMT_TEAMS_ALTERNATE
, "TEAM", N_("Team alternate movement"));
426 /****************************************************************************
427 Savegame compress type names accessor.
428 ****************************************************************************/
429 static const struct sset_val_name
*
430 compresstype_name(enum fz_method compresstype
)
432 switch (compresstype
) {
433 NAME_CASE(FZ_PLAIN
, "PLAIN", N_("No compression"));
435 NAME_CASE(FZ_ZLIB
, "LIBZ", N_("Using zlib (gzip format)"));
438 NAME_CASE(FZ_BZIP2
, "BZIP2", N_("Using bzip2"));
441 NAME_CASE(FZ_XZ
, "XZ", N_("Using xz"));
447 /****************************************************************************
448 Names accessor for boolean settings (disable/enable).
449 ****************************************************************************/
450 static const struct sset_val_name
*bool_name(int enable
)
453 NAME_CASE(FALSE
, "DISABLED", N_("disabled"));
454 NAME_CASE(TRUE
, "ENABLED", N_("enabled"));
462 /*************************************************************************
463 Action callback functions.
464 *************************************************************************/
466 /*************************************************************************
467 (De)initialze the score log.
468 *************************************************************************/
469 static void scorelog_action(const struct setting
*pset
)
471 if (*pset
->boolean
.pvalue
) {
472 log_civ_score_init();
474 log_civ_score_free();
478 /*************************************************************************
479 Create the selected number of AI's.
480 *************************************************************************/
481 static void aifill_action(const struct setting
*pset
)
483 aifill(*pset
->integer
.pvalue
);
486 /*************************************************************************
487 Restrict to the selected nation set.
488 *************************************************************************/
489 static void nationset_action(const struct setting
*pset
)
491 /* If any player's existing selection is invalid, abort it */
492 players_iterate(pplayer
) {
493 if (pplayer
->nation
!= NULL
) {
494 if (!nation_is_in_current_set(pplayer
->nation
)) {
495 (void) player_set_nation(pplayer
, NO_NATION_SELECTED
);
496 send_player_info_c(pplayer
, game
.est_connections
);
499 } players_iterate_end
;
500 count_playable_nations();
501 aifill(game
.info
.aifill
);
503 /* There might now be too many players for the available nations.
504 * Rather than getting rid of some players arbitrarily, we let the
505 * situation persist for all already-connected players; the server
506 * will simply refuse to start until someone reduces the number of
507 * players. This policy also avoids annoyance if nationset is
508 * accidentally and transiently set to an unintended value.
509 * (However, new connections will start out detached.) */
510 if (normal_player_count() > server
.playable_nations
) {
511 notify_conn(NULL
, NULL
, E_SETTING
, ftc_server
, "%s",
512 _("Warning: not enough nations for all current players."));
515 send_nation_availability(game
.est_connections
, TRUE
);
518 /*************************************************************************
519 Clear any user-set player colors in modes other than PLRCOL_PLR_SET.
520 *************************************************************************/
521 static void plrcol_action(const struct setting
*pset
)
523 if (!game_was_started()) {
524 if (read_enum_value(pset
) != PLRCOL_PLR_SET
) {
525 players_iterate(pplayer
) {
526 server_player_set_color(pplayer
, NULL
);
527 } players_iterate_end
;
529 /* Update clients with new color scheme. */
530 send_player_info_c(NULL
, NULL
);
534 /*************************************************************************
535 Toggle player AI status.
536 *************************************************************************/
537 static void autotoggle_action(const struct setting
*pset
)
539 if (*pset
->boolean
.pvalue
) {
540 players_iterate(pplayer
) {
541 if (!pplayer
->ai_controlled
&& !pplayer
->is_connected
) {
542 toggle_ai_player_direct(NULL
, pplayer
);
543 send_player_info_c(pplayer
, game
.est_connections
);
545 } players_iterate_end
;
549 /*************************************************************************
550 Enact a change in the 'timeout' server setting immediately, if the game
552 *************************************************************************/
553 static void timeout_action(const struct setting
*pset
)
555 if (S_S_RUNNING
== server_state()) {
556 int timeout
= *pset
->integer
.pvalue
;
557 /* This may cause the current turn to end immediately. */
558 game
.info
.seconds_to_phasedone
= timeout
;
559 send_game_info(NULL
);
563 /*************************************************************************
564 Validation callback functions.
565 *************************************************************************/
567 /****************************************************************************
568 Verify the selected savename definition.
569 ****************************************************************************/
570 static bool savename_validate(const char *value
, struct connection
*caller
,
571 char *reject_msg
, size_t reject_msg_len
)
573 char buf
[MAX_LEN_PATH
];
575 generate_save_name(value
, buf
, sizeof(buf
), NULL
);
577 if (!is_safe_filename(buf
)) {
578 settings_snprintf(reject_msg
, reject_msg_len
,
579 _("Invalid save name definition: '%s' "
580 "(resolves to '%s')."), value
, buf
);
587 /****************************************************************************
588 Verify the value of the generator option (notably the MAPGEN_SCENARIO
590 ****************************************************************************/
591 static bool generator_validate(int value
, struct connection
*caller
,
592 char *reject_msg
, size_t reject_msg_len
)
594 if (map_is_empty()) {
595 if (MAPGEN_SCENARIO
== value
596 && (NULL
!= caller
|| !game
.scenario
.is_scenario
)) {
597 settings_snprintf(reject_msg
, reject_msg_len
,
598 _("You cannot disable the map generator."));
603 if (MAPGEN_SCENARIO
!= value
) {
604 settings_snprintf(reject_msg
, reject_msg_len
,
605 _("You cannot require a map generator "
606 "when a map is loaded."));
613 /****************************************************************************
614 Verify the name for the score log file.
615 ****************************************************************************/
616 static bool scorefile_validate(const char *value
, struct connection
*caller
,
617 char *reject_msg
, size_t reject_msg_len
)
619 if (!is_safe_filename(value
)) {
620 settings_snprintf(reject_msg
, reject_msg_len
,
621 _("Invalid score name definition: '%s'."), value
);
628 /*************************************************************************
629 Verify that a given demography string is valid. See
631 *************************************************************************/
632 static bool demography_callback(const char *value
,
633 struct connection
*caller
,
635 size_t reject_msg_len
)
639 if (is_valid_demography(value
, &error
)) {
642 settings_snprintf(reject_msg
, reject_msg_len
,
643 _("Demography string validation failed at character: "
644 "'%c'. Try \"help demography\"."), value
[error
]);
649 /*************************************************************************
650 Verify that a given allowtake string is valid. See
652 *************************************************************************/
653 static bool allowtake_callback(const char *value
,
654 struct connection
*caller
,
656 size_t reject_msg_len
)
658 int len
= strlen(value
), i
;
659 bool havecharacter_state
= FALSE
;
661 /* We check each character individually to see if it's valid. This
662 * does not check for duplicate entries.
664 * We also track the state of the machine. havecharacter_state is
665 * true if the preceeding character was a primary label, e.g.
666 * NHhAadb. It is false if the preceeding character was a modifier
667 * or if this is the first character. */
669 for (i
= 0; i
< len
; i
++) {
670 /* Check to see if the character is a primary label. */
671 if (strchr("HhAadbOo", value
[i
])) {
672 havecharacter_state
= TRUE
;
676 /* If we've already passed a primary label, check to see if the
677 * character is a modifier. */
678 if (havecharacter_state
&& strchr("1234", value
[i
])) {
679 havecharacter_state
= FALSE
;
683 /* Looks like the character was invalid. */
684 settings_snprintf(reject_msg
, reject_msg_len
,
685 _("Allowed take string validation failed at "
686 "character: '%c'. Try \"help allowtake\"."),
691 /* All characters were valid. */
695 /*************************************************************************
696 Verify that a given startunits string is valid. See
697 game.server.start_units.
698 *************************************************************************/
699 static bool startunits_callback(const char *value
,
700 struct connection
*caller
,
702 size_t reject_msg_len
)
704 int len
= strlen(value
), i
;
706 /* We check each character individually to see if it's valid, and
707 * also make sure there is at least one city founder. */
709 for (i
= 0; i
< len
; i
++) {
710 /* TODO: add 'f' back in here when we can support ferry units */
711 if (strchr("cwxksdDaA", value
[i
])) {
715 /* Looks like the character was invalid. */
716 settings_snprintf(reject_msg
, reject_msg_len
,
717 _("Starting units string validation failed at "
718 "character '%c'. Try \"help startunits\"."),
723 /* All characters were valid. */
727 /*************************************************************************
728 Verify that a given endturn is valid.
729 *************************************************************************/
730 static bool endturn_callback(int value
, struct connection
*caller
,
731 char *reject_msg
, size_t reject_msg_len
)
733 if (value
< game
.info
.turn
) {
734 /* Tried to set endturn earlier than current turn */
735 settings_snprintf(reject_msg
, reject_msg_len
,
736 _("Cannot set endturn earlier than current turn."));
742 /*************************************************************************
743 Verify that a given maxplayers string is valid.
744 *************************************************************************/
745 static bool maxplayers_callback(int value
, struct connection
*caller
,
746 char *reject_msg
, size_t reject_msg_len
)
750 /* In GGZ mode the maxplayers is the number of actual players - set
751 * when the game is lauched and not changed thereafter. This may be
752 * changed in future. */
753 settings_snprintf(reject_msg
, reject_msg_len
,
754 _("Cannot change maxplayers in GGZ mode."));
757 #endif /* GGZ_SERVER */
758 if (value
< player_count()) {
759 settings_snprintf(reject_msg
, reject_msg_len
,
760 _("Number of players (%d) is higher than requested "
761 "value (%d). Keeping old value."), player_count(),
765 /* If any start positions are defined by a scenario, we can only
766 * accommodate as many players as we have start positions. */
767 if (0 < map_startpos_count() && value
> map_startpos_count()) {
768 settings_snprintf(reject_msg
, reject_msg_len
,
769 _("Requested value (%d) is greater than number of "
770 "available start positions (%d). Keeping old value."),
771 value
, map_startpos_count());
778 /*************************************************************************
779 Validate the 'nationset' server setting.
780 *************************************************************************/
781 static bool nationset_callback(const char *value
,
782 struct connection
*caller
,
784 size_t reject_msg_len
)
786 if (strlen(value
) == 0) {
788 } else if (nation_set_by_rule_name(value
)) {
791 settings_snprintf(reject_msg
, reject_msg_len
,
792 /* TRANS: do not translate 'list nationsets' */
793 _("Unknown nation set \"%s\". See '%slist nationsets' "
794 "for possible values."), value
, caller
? "/" : "");
799 /*************************************************************************
800 Validate the 'timeout' server setting.
801 *************************************************************************/
802 static bool timeout_callback(int value
, struct connection
*caller
,
803 char *reject_msg
, size_t reject_msg_len
)
805 /* Disallow low timeout values for non-hack connections. */
806 if (caller
&& caller
->access_level
< ALLOW_HACK
&& value
< 30) {
807 settings_snprintf(reject_msg
, reject_msg_len
,
808 _("You are not allowed to set timeout values less "
809 "than 30 seconds."));
813 if (value
== -1 && game
.server
.unitwaittime
!= 0) {
814 /* autogame only with 'unitwaittime' = 0 */
815 settings_snprintf(reject_msg
, reject_msg_len
,
816 /* TRANS: Do not translate setting names in ''. */
817 _("For autogames ('timeout' = -1) 'unitwaittime' "
818 "should be deactivated (= 0)."));
822 if (value
> 0 && value
< game
.server
.unitwaittime
* 3 / 2) {
823 /* for normal games 'timeout' should be at least 3/2 times the value
824 * of 'unitwaittime' */
825 settings_snprintf(reject_msg
, reject_msg_len
,
826 /* TRANS: Do not translate setting names in ''. */
827 _("'timeout' can not be lower than 3/2 of the "
828 "'unitwaittime' setting (= %d). Please change "
829 "'unitwaittime' first."), game
.server
.unitwaittime
);
836 /*************************************************************************
837 Check 'timeout' setting if 'unitwaittime' is changed.
838 *************************************************************************/
839 static bool unitwaittime_callback(int value
, struct connection
*caller
,
840 char *reject_msg
, size_t reject_msg_len
)
842 if (game
.info
.timeout
== -1 && value
!= 0) {
843 settings_snprintf(reject_msg
, reject_msg_len
,
844 /* TRANS: Do not translate setting names in ''. */
845 _("For autogames ('timeout' = -1) 'unitwaittime' "
846 "should be deactivated (= 0)."));
850 if (game
.info
.timeout
> 0 && value
> game
.info
.timeout
* 2 / 3) {
851 settings_snprintf(reject_msg
, reject_msg_len
,
852 /* TRANS: Do not translate setting names in ''. */
853 _("'unitwaittime' has to be lower than 2/3 of the "
854 "'timeout' setting (= %d). Please change 'timeout' "
855 "first."), game
.info
.timeout
);
862 /*************************************************************************
863 Topology setting validation callback.
864 *************************************************************************/
865 static bool mapsize_callback(int value
, struct connection
*caller
,
866 char *reject_msg
, size_t reject_msg_len
)
868 if (value
== MAPSIZE_XYSIZE
&& MAP_IS_ISOMETRIC
&&
869 map
.ysize
% 2 != 0) {
870 /* An isometric map needs a even ysize. Is is calculated automatically
871 * for all settings but mapsize=XYSIZE. */
872 settings_snprintf(reject_msg
, reject_msg_len
,
873 _("For an isometric or hexagonal map the ysize must be "
881 /*************************************************************************
882 xsize setting validation callback.
883 *************************************************************************/
884 static bool xsize_callback(int value
, struct connection
*caller
,
885 char *reject_msg
, size_t reject_msg_len
)
887 int size
= value
* map
.ysize
;
889 if (size
< MAP_MIN_SIZE
* 1000) {
890 settings_snprintf(reject_msg
, reject_msg_len
,
891 _("The map size (%d * %d = %d) must be larger than "
892 "%d tiles."), value
, map
.ysize
, size
,
893 MAP_MIN_SIZE
* 1000);
895 } else if (size
> MAP_MAX_SIZE
* 1000) {
896 settings_snprintf(reject_msg
, reject_msg_len
,
897 _("The map size (%d * %d = %d) must be lower than "
898 "%d tiles."), value
, map
.ysize
, size
,
899 MAP_MAX_SIZE
* 1000);
906 /*************************************************************************
907 ysize setting validation callback.
908 *************************************************************************/
909 static bool ysize_callback(int value
, struct connection
*caller
,
910 char *reject_msg
, size_t reject_msg_len
)
912 int size
= map
.xsize
* value
;
914 if (size
< MAP_MIN_SIZE
* 1000) {
915 settings_snprintf(reject_msg
, reject_msg_len
,
916 _("The map size (%d * %d = %d) must be larger than "
917 "%d tiles."), map
.xsize
, value
, size
,
918 MAP_MIN_SIZE
* 1000);
920 } else if (size
> MAP_MAX_SIZE
* 1000) {
921 settings_snprintf(reject_msg
, reject_msg_len
,
922 _("The map size (%d * %d = %d) must be lower than "
923 "%d tiles."), map
.xsize
, value
, size
,
924 MAP_MAX_SIZE
* 1000);
926 } else if (map
.server
.mapsize
== MAPSIZE_XYSIZE
&& MAP_IS_ISOMETRIC
&&
928 /* An isometric map needs a even ysize. Is is calculated automatically
929 * for all settings but mapsize=XYSIZE. */
930 settings_snprintf(reject_msg
, reject_msg_len
,
931 _("For an isometric or hexagonal map the ysize must be "
939 /*************************************************************************
940 Topology setting validation callback.
941 *************************************************************************/
942 static bool topology_callback(unsigned value
, struct connection
*caller
,
943 char *reject_msg
, size_t reject_msg_len
)
945 if (map
.server
.mapsize
== MAPSIZE_XYSIZE
&&
946 ((value
& (TF_ISO
)) != 0 || (value
& (TF_HEX
)) != 0) &&
947 map
.ysize
% 2 != 0) {
948 /* An isometric map needs a even ysize. Is is calculated automatically
949 * for all settings but mapsize=XYSIZE. */
950 settings_snprintf(reject_msg
, reject_msg_len
,
951 _("For an isometric or hexagonal map the ysize must be "
959 /*************************************************************************
960 Validate that the player color mode can be used.
961 *************************************************************************/
962 static bool plrcol_validate(int value
, struct connection
*caller
,
963 char *reject_msg
, size_t reject_msg_len
)
965 enum plrcolor_mode mode
= value
;
966 if (mode
== PLRCOL_NATION_ORDER
) {
967 nations_iterate(pnation
) {
968 if (nation_color(pnation
)) {
969 /* At least one nation has a color. Allow this mode. */
972 } nations_iterate_end
;
973 settings_snprintf(reject_msg
, reject_msg_len
,
974 _("No nations in the currently loaded ruleset have "
975 "associated colors."));
981 #define GEN_BOOL(name, value, sclass, scateg, slevel, to_client, \
982 short_help, extra_help, func_validate, func_action, \
984 {name, sclass, to_client, short_help, extra_help, SSET_BOOL, \
986 {.boolean = {&value, _default, func_validate, bool_name, \
987 FALSE}}, func_action, FALSE},
989 #define GEN_INT(name, value, sclass, scateg, slevel, to_client, \
990 short_help, extra_help, func_validate, func_action, \
991 _min, _max, _default) \
992 {name, sclass, to_client, short_help, extra_help, SSET_INT, \
994 {.integer = {(int *) &value, _default, _min, _max, func_validate, \
998 #define GEN_STRING(name, value, sclass, scateg, slevel, to_client, \
999 short_help, extra_help, func_validate, func_action, \
1001 {name, sclass, to_client, short_help, extra_help, SSET_STRING, \
1003 {.string = {value, _default, sizeof(value), func_validate, ""}}, \
1004 func_action, FALSE},
1006 #define GEN_ENUM(name, value, sclass, scateg, slevel, to_client, \
1007 short_help, extra_help, func_validate, func_action, \
1008 func_name, _default) \
1009 { name, sclass, to_client, short_help, extra_help, SSET_ENUM, \
1011 { .enumerator = { &value, sizeof(value), _default, \
1013 (val_name_func_t) func_name, 0 }}, func_action, FALSE},
1015 #define GEN_BITWISE(name, value, sclass, scateg, slevel, to_client, \
1016 short_help, extra_help, func_validate, func_action, \
1017 func_name, _default) \
1018 { name, sclass, to_client, short_help, extra_help, SSET_BITWISE, \
1020 { .bitwise = { (unsigned *) (void *) &value, _default, func_validate, \
1021 func_name, 0 }}, func_action, FALSE},
1024 static struct setting settings
[] = {
1026 /* These should be grouped by sclass */
1028 /* Map size parameters: adjustable if we don't yet have a map */
1029 GEN_ENUM("mapsize", map
.server
.mapsize
, SSET_MAP_SIZE
,
1030 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1031 N_("Map size definition"),
1032 /* TRANS: The strings between double quotes are also translated
1033 * separately (they must match!). The strings between single
1034 * quotes are setting names and shouldn't be translated. The
1035 * strings between parentheses and in uppercase must stay as
1037 N_("Chooses the method used to define the map size. Other options "
1038 "specify the parameters for each method.\n"
1039 "- \"Number of tiles\" (FULLSIZE): Map area (option 'size').\n"
1040 "- \"Tiles per player\" (PLAYER): Number of (land) tiles per "
1041 "player (option 'tilesperplayer').\n"
1042 "- \"Width and height\" (XYSIZE): Map width and height in "
1043 "tiles (options 'xsize' and 'ysize')."),
1044 mapsize_callback
, NULL
, mapsize_name
, MAP_DEFAULT_MAPSIZE
)
1046 GEN_INT("size", map
.server
.size
, SSET_MAP_SIZE
,
1047 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1048 N_("Map area (in thousands of tiles)"),
1049 /* TRANS: The strings between double quotes are also translated
1050 * separately (they must match!). The strings between single
1051 * quotes are setting names and shouldn't be translated. The
1052 * strings between parentheses and in uppercase must stay as
1054 N_("This value is used to determine the map area.\n"
1055 " size = 4 is a normal map of 4,000 tiles (default)\n"
1056 " size = 20 is a huge map of 20,000 tiles\n"
1057 "For this option to take effect, the \"Map size definition\" "
1058 "option ('mapsize') must be set to \"Number of tiles\" "
1059 "(FULLSIZE)."), NULL
, NULL
,
1060 MAP_MIN_SIZE
, MAP_MAX_SIZE
, MAP_DEFAULT_SIZE
)
1062 GEN_INT("tilesperplayer", map
.server
.tilesperplayer
, SSET_MAP_SIZE
,
1063 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1064 N_("Number of (land) tiles per player"),
1065 /* TRANS: The strings between double quotes are also translated
1066 * separately (they must match!). The strings between single
1067 * quotes are setting names and shouldn't be translated. The
1068 * strings between parentheses and in uppercase must stay as
1070 N_("This value is used to determine the map dimensions. It "
1071 "calculates the map size at game start based on the number "
1072 "of players and the value of the setting 'landmass'.\n"
1073 "For this option to take effect, the \"Map size definition\" "
1074 "option ('mapsize') must be set to \"Tiles per player\" "
1076 NULL
, NULL
, MAP_MIN_TILESPERPLAYER
,
1077 MAP_MAX_TILESPERPLAYER
, MAP_DEFAULT_TILESPERPLAYER
)
1079 GEN_INT("xsize", map
.xsize
, SSET_MAP_SIZE
,
1080 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1081 N_("Map width in tiles"),
1082 /* TRANS: The strings between double quotes are also translated
1083 * separately (they must match!). The strings between single
1084 * quotes are setting names and shouldn't be translated. The
1085 * strings between parentheses and in uppercase must stay as
1087 N_("Defines the map width.\n"
1088 "For this option to take effect, the \"Map size definition\" "
1089 "option ('mapsize') must be set to \"Width and height\" "
1091 xsize_callback
, NULL
,
1092 MAP_MIN_LINEAR_SIZE
, MAP_MAX_LINEAR_SIZE
, MAP_DEFAULT_LINEAR_SIZE
)
1093 GEN_INT("ysize", map
.ysize
, SSET_MAP_SIZE
,
1094 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1095 N_("Map height in tiles"),
1096 /* TRANS: The strings between double quotes are also translated
1097 * separately (they must match!). The strings between single
1098 * quotes are setting names and shouldn't be translated. The
1099 * strings between parentheses and in uppercase must stay as
1101 N_("Defines the map height.\n"
1102 "For this option to take effect, the \"Map size definition\" "
1103 "option ('mapsize') must be set to \"Width and height\" "
1105 ysize_callback
, NULL
,
1106 MAP_MIN_LINEAR_SIZE
, MAP_MAX_LINEAR_SIZE
, MAP_DEFAULT_LINEAR_SIZE
)
1108 GEN_BITWISE("topology", map
.topology_id
, SSET_MAP_SIZE
,
1109 SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1110 N_("Map topology index"),
1111 /* TRANS: do not edit the ugly ASCII art */
1112 N_("Freeciv maps are always two-dimensional. They may wrap at "
1113 "the north-south and east-west directions to form a flat "
1114 "map, a cylinder, or a torus (donut). Individual tiles may "
1115 "be rectangular or hexagonal, with either a classic or "
1116 "isometric alignment - this should be set based on the "
1117 "tileset being used.\n"
1118 "Classic rectangular: Isometric rectangular:\n"
1119 " _________ /\\/\\/\\/\\/\\\n"
1120 " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1121 " |_|_|_|_|_| \\/\\/\\/\\/\\/\\\n"
1122 " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1123 " \\/\\/\\/\\/\\/\n"
1124 "Hex tiles: Iso-hex:\n"
1125 " /\\/\\/\\/\\/\\/\\ _ _ _ _ _\n"
1126 " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1127 " \\/\\/\\/\\/\\/\\/\\"
1128 " \\_/ \\_/ \\_/ \\_/ \\_/\n"
1129 " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1130 " \\/\\/\\/\\/\\/\\/"
1131 " \\_/ \\_/ \\_/ \\_/ \\_/\n"),
1132 topology_callback
, NULL
, topology_name
, MAP_DEFAULT_TOPO
)
1134 GEN_ENUM("generator", map
.server
.generator
,
1135 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1136 N_("Method used to generate map"),
1137 /* TRANS: The strings between double quotes are also translated
1138 * separately (they must match!). The strings between single
1139 * quotes (except 'fair') are setting names and shouldn't be
1140 * translated. The strings between parentheses and in uppercase
1141 * must stay as untranslated. */
1142 N_("Specifies the algorithm used to generate the map. If the "
1143 "default value of the 'startpos' option is used, then the "
1144 "chosen generator chooses an appropriate 'startpos' setting; "
1145 "otherwise, the generated map tries to accommodate the "
1146 "chosen 'startpos' setting.\n"
1147 "- \"Scenario map\" (SCENARIO): indicates a pre-generated map. "
1148 "By default, if the scenario does not specify start positions, "
1149 "they will be allocated depending on the size of continents.\n"
1150 "- \"Fully random height\" (RANDOM): generates maps with a "
1151 "number of equally spaced, relatively small islands. By default, "
1152 "start positions are allocated depending on continent size.\n"
1153 "- \"Pseudo-fractal height\" (FRACTAL): generates Earthlike "
1154 "worlds with one or more large continents and a scattering of "
1155 "smaller islands. By default, players are all placed on a "
1156 "single continent.\n"
1157 "- \"Island-based\" (ISLAND): generates 'fair' maps with a "
1158 "number of similarly-sized and -shaped islands, each with "
1159 "approximately the same ratios of terrain types. By default, "
1160 "each player gets their own island.\n"
1161 "- \"Fair islands\" (FAIR): generates the exact copy of the "
1162 "same island for every player or every team.\n"
1163 "If the requested generator is incompatible with other server "
1164 "settings, the server may fall back to another generator."),
1165 generator_validate
, NULL
, generator_name
, MAP_DEFAULT_GENERATOR
)
1167 GEN_ENUM("startpos", map
.server
.startpos
,
1168 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1169 N_("Method used to choose start positions"),
1170 /* TRANS: The strings between double quotes are also translated
1171 * separately (they must match!). The strings between single
1172 * quotes (except 'best') are setting names and shouldn't be
1173 * translated. The strings between parentheses and in uppercase
1174 * must stay as untranslated. */
1175 N_("The method used to choose where each player's initial units "
1176 "start on the map. (For scenarios which include pre-set "
1177 "start positions, this setting is ignored.)\n"
1178 "- \"Generator's choice\" (DEFAULT): the start position "
1179 "placement will depend on the map generator chosen. See the "
1180 "'generator' setting.\n"
1181 "- \"One player per continent\" (SINGLE): one player is "
1182 "placed on each of a set of continents of approximately "
1183 "equivalent value (if possible).\n"
1184 "- \"Two or three players per continent\" (2or3): similar "
1185 "to SINGLE except that two players will be placed on each "
1186 "continent, with three on the 'best' continent if there is an "
1187 "odd number of players.\n"
1188 "- \"All players on a single continent\" (ALL): all players "
1189 "will start on the 'best' available continent.\n"
1190 "- \"Depending on size of continents\" (VARIABLE): players "
1191 "will be placed on the 'best' available continents such that, "
1192 "as far as possible, the number of players on each continent "
1193 "is proportional to its value.\n"
1194 "If the server cannot satisfy the requested setting due to "
1195 "there being too many players for continents, it may fall "
1196 "back to one of the others. (However, map generators try to "
1197 "create the right number of continents for the choice of this "
1198 "'startpos' setting and the number of players, so this is "
1199 "unlikely to occur.)"),
1200 NULL
, NULL
, startpos_name
, MAP_DEFAULT_STARTPOS
)
1202 GEN_ENUM("teamplacement", map
.server
.team_placement
,
1203 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1204 N_("Method used for placement of team mates"),
1205 /* TRANS: The strings between double quotes are also translated
1206 * separately (they must match!). The strings between single
1207 * quotes are setting names and shouldn't be translated. The
1208 * strings between parentheses and in uppercase must stay as
1210 N_("After start positions have been generated thanks to the "
1211 "'startpos' setting, this setting controls how the start "
1212 "positions will be assigned to the different players of the "
1214 "- \"Disabled\" (DISABLED): the start positions will be "
1215 "randomly assigned to players, regardless of teams.\n"
1216 "- \"As close as possible\" (CLOSEST): players will be "
1217 "placed as close as possible, regardless of continents.\n"
1218 "- \"On the same continent\" (CONTINENT): if possible, place "
1219 "all players of the same team onto the same "
1220 "island/continent.\n"
1221 "- \"Horizontal placement\" (HORIZONTAL): players of the same "
1222 "team will be placed horizontally.\n"
1223 "- \"Vertical placement\" (VERTICAL): players of the same "
1224 "team will be placed vertically."),
1225 NULL
, NULL
, teamplacement_name
, MAP_DEFAULT_TEAM_PLACEMENT
)
1227 GEN_BOOL("tinyisles", map
.server
.tinyisles
,
1228 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1229 N_("Presence of 1x1 islands"),
1230 N_("This setting controls whether the map generator is allowed "
1231 "to make islands of one only tile size."), NULL
, NULL
,
1232 MAP_DEFAULT_TINYISLES
)
1234 GEN_BOOL("separatepoles", map
.server
.separatepoles
,
1235 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1236 N_("Whether the poles are separate continents"),
1237 N_("If this setting is disabled, the continents may attach to "
1238 "poles."), NULL
, NULL
, MAP_DEFAULT_SEPARATE_POLES
)
1240 GEN_BOOL("alltemperate", map
.server
.alltemperate
,
1241 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1242 N_("All the map is temperate"),
1243 N_("If this setting is enabled, the temperature will be "
1244 "equivalent everywhere on the map. As a result, the "
1245 "poles won't be generated."),
1246 NULL
, NULL
, MAP_DEFAULT_ALLTEMPERATE
)
1248 GEN_INT("temperature", map
.server
.temperature
,
1249 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1250 N_("Average temperature of the planet"),
1251 N_("Small values will give a cold map, while larger values will "
1252 "give a hotter map.\n"
1254 "100 means a very dry and hot planet with no polar arctic "
1255 "zones, only tropical and dry zones.\n"
1256 " 70 means a hot planet with little polar ice.\n"
1257 " 50 means a temperate planet with normal polar, cold, "
1258 "temperate, and tropical zones; a desert zone overlaps "
1259 "tropical and temperate zones.\n"
1260 " 30 means a cold planet with small tropical zones.\n"
1261 " 0 means a very cold planet with large polar zones and no "
1264 MAP_MIN_TEMPERATURE
, MAP_MAX_TEMPERATURE
, MAP_DEFAULT_TEMPERATURE
)
1266 GEN_INT("landmass", map
.server
.landpercent
,
1267 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1268 N_("Percentage of the map that is land"),
1269 N_("This setting gives the approximate percentage of the map "
1270 "that will be made into land."), NULL
, NULL
,
1271 MAP_MIN_LANDMASS
, MAP_MAX_LANDMASS
, MAP_DEFAULT_LANDMASS
)
1273 GEN_INT("steepness", map
.server
.steepness
,
1274 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1275 N_("Amount of hills/mountains"),
1276 N_("Small values give flat maps, while higher values give a "
1277 "steeper map with more hills and mountains."), NULL
, NULL
,
1278 MAP_MIN_STEEPNESS
, MAP_MAX_STEEPNESS
, MAP_DEFAULT_STEEPNESS
)
1280 GEN_INT("wetness", map
.server
.wetness
,
1281 SSET_MAP_GEN
, SSET_GEOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1282 N_("Amount of water on landmasses"),
1283 N_("Small values mean lots of dry, desert-like land; "
1284 "higher values give a wetter map with more swamps, "
1285 "jungles, and rivers."), NULL
, NULL
,
1286 MAP_MIN_WETNESS
, MAP_MAX_WETNESS
, MAP_DEFAULT_WETNESS
)
1288 GEN_BOOL("globalwarming", game
.info
.global_warming
,
1289 SSET_RULES
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1290 N_("Global warming"),
1291 N_("If turned off, global warming will not occur "
1292 "as a result of pollution. This setting does not "
1293 "affect pollution."), NULL
, NULL
,
1294 GAME_DEFAULT_GLOBAL_WARMING
)
1296 GEN_BOOL("nuclearwinter", game
.info
.nuclear_winter
,
1297 SSET_RULES
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1298 N_("Nuclear winter"),
1299 N_("If turned off, nuclear winter will not occur "
1300 "as a result of nuclear war."), NULL
, NULL
,
1301 GAME_DEFAULT_NUCLEAR_WINTER
)
1303 GEN_INT("mapseed", map
.server
.seed
,
1304 SSET_MAP_GEN
, SSET_INTERNAL
, SSET_RARE
, SSET_SERVER_ONLY
,
1305 N_("Map generation random seed"),
1306 N_("The same seed will always produce the same map; "
1307 "for zero (the default) a seed will be chosen based on "
1308 "the time to give a random map. This setting is usually "
1309 "only of interest while debugging the game."), NULL
, NULL
,
1310 MAP_MIN_SEED
, MAP_MAX_SEED
, MAP_DEFAULT_SEED
)
1312 /* Map additional stuff: huts and specials. gameseed also goes here
1313 * because huts and specials are the first time the gameseed gets used (?)
1314 * These are done when the game starts, so these are historical and
1315 * fixed after the game has started.
1317 GEN_INT("gameseed", game
.server
.seed
,
1318 SSET_MAP_ADD
, SSET_INTERNAL
, SSET_RARE
, SSET_SERVER_ONLY
,
1319 N_("Game random seed"),
1320 N_("For zero (the default) a seed will be chosen based "
1321 "on the current time. This setting is usually "
1322 "only of interest while debugging the game."), NULL
, NULL
,
1323 GAME_MIN_SEED
, GAME_MAX_SEED
, GAME_DEFAULT_SEED
)
1325 GEN_INT("specials", map
.server
.riches
,
1326 SSET_MAP_ADD
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1327 N_("Amount of \"special\" resource tiles"),
1328 N_("Special resources improve the basic terrain type they "
1329 "are on. The server variable's scale is parts per "
1330 "thousand."), NULL
, NULL
,
1331 MAP_MIN_RICHES
, MAP_MAX_RICHES
, MAP_DEFAULT_RICHES
)
1333 GEN_INT("huts", map
.server
.huts
,
1334 SSET_MAP_ADD
, SSET_GEOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1335 N_("Amount of huts (minor tribe villages)"),
1336 N_("This setting gives the exact number of huts that will be "
1337 "placed on the entire map. Huts are small tribal villages "
1338 "that may be investigated by units."), NULL
, NULL
,
1339 MAP_MIN_HUTS
, MAP_MAX_HUTS
, MAP_DEFAULT_HUTS
)
1341 /* Options affecting numbers of players and AI players. These only
1342 * affect the start of the game and can not be adjusted after that.
1344 GEN_INT("minplayers", game
.server
.min_players
,
1345 SSET_PLAYERS
, SSET_INTERNAL
, SSET_VITAL
,
1347 N_("Minimum number of players"),
1348 N_("There must be at least this many players (connected "
1349 "human players) before the game can start."),
1351 GAME_MIN_MIN_PLAYERS
, GAME_MAX_MIN_PLAYERS
, GAME_DEFAULT_MIN_PLAYERS
)
1353 GEN_INT("maxplayers", game
.server
.max_players
,
1354 SSET_PLAYERS
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
1355 N_("Maximum number of players"),
1356 N_("The maximal number of human and AI players who can be in "
1357 "the game. When this number of players are connected in "
1358 "the pregame state, any new players who try to connect "
1359 "will be rejected.\n"
1360 "When playing a scenario which defines player start positions, "
1361 "this setting cannot be set to greater than the number of "
1362 "defined start positions."),
1363 maxplayers_callback
, NULL
,
1364 GAME_MIN_MAX_PLAYERS
, GAME_MAX_MAX_PLAYERS
, GAME_DEFAULT_MAX_PLAYERS
)
1366 GEN_INT("aifill", game
.info
.aifill
,
1367 SSET_PLAYERS
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
1368 N_("Limited number of AI players"),
1369 N_("If set to a positive value, then AI players will be "
1370 "automatically created or removed to keep the total "
1371 "number of players at this amount. As more players join, "
1372 "these AI players will be replaced. When set to zero, "
1373 "all AI players will be removed."), NULL
,
1374 aifill_action
, GAME_MIN_AIFILL
, GAME_MAX_AIFILL
,
1375 GAME_DEFAULT_AIFILL
)
1377 GEN_STRING("nationset", game
.server
.nationset
,
1378 SSET_PLAYERS
, SSET_INTERNAL
, SSET_RARE
, SSET_TO_CLIENT
,
1379 N_("Set of nations to choose from"),
1380 /* TRANS: do not translate '/list nationsets' */
1381 N_("Controls the set of nations allowed in the game. The "
1382 "choices are defined by the ruleset.\n"
1383 "Only nations in the set selected here will be allowed in "
1384 "any circumstances, including new players and civil war; "
1385 "small sets may thus limit the number of players in a game.\n"
1386 "If this is left blank, the ruleset's default nation set is "
1388 "See '/list nationsets' for possible choices for the "
1389 "currently loaded ruleset."),
1390 nationset_callback
, nationset_action
, GAME_DEFAULT_NATIONSET
)
1392 GEN_INT("ec_turns", game
.server
.event_cache
.turns
,
1393 SSET_RULES_FLEXIBLE
, SSET_INTERNAL
, SSET_SITUATIONAL
,
1395 N_("Event cache for this number of turns"),
1396 N_("Event messages are saved for this number of turns. A value of "
1397 "0 deactivates the event cache."),
1398 NULL
, NULL
, GAME_MIN_EVENT_CACHE_TURNS
, GAME_MAX_EVENT_CACHE_TURNS
,
1399 GAME_DEFAULT_EVENT_CACHE_TURNS
)
1401 GEN_INT("ec_max_size", game
.server
.event_cache
.max_size
,
1402 SSET_RULES_FLEXIBLE
, SSET_INTERNAL
, SSET_SITUATIONAL
,
1404 N_("Size of the event cache"),
1405 N_("This defines the maximal number of events in the event cache."),
1406 NULL
, NULL
, GAME_MIN_EVENT_CACHE_MAX_SIZE
,
1407 GAME_MAX_EVENT_CACHE_MAX_SIZE
, GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
)
1409 GEN_BOOL("ec_chat", game
.server
.event_cache
.chat
,
1410 SSET_RULES_FLEXIBLE
, SSET_INTERNAL
, SSET_SITUATIONAL
,
1412 N_("Save chat messages in the event cache"),
1413 N_("If turned on, chat messages will be saved in the event "
1414 "cache."), NULL
, NULL
, GAME_DEFAULT_EVENT_CACHE_CHAT
)
1416 GEN_BOOL("ec_info", game
.server
.event_cache
.info
,
1417 SSET_RULES_FLEXIBLE
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1418 N_("Print turn and time for each cached event"),
1419 /* TRANS: Don't translate the text between single quotes. */
1420 N_("If turned on, all cached events will be marked by the turn "
1421 "and time of the event like '(T2 - 15:29:52)'."),
1422 NULL
, NULL
, GAME_DEFAULT_EVENT_CACHE_INFO
)
1424 /* Game initialization parameters (only affect the first start of the game,
1425 * and not reloads). Can not be changed after first start of game.
1427 /* TODO: Add this line back when we can support Ferry units */
1428 /* " f = Ferryboat (eg., Trireme)\n" */
1429 GEN_STRING("startunits", game
.server
.start_units
,
1430 SSET_GAME_INIT
, SSET_SOCIOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1431 N_("List of players' initial units"),
1432 N_("This should be a string of characters, each of which "
1433 "specifies a unit role. There must be at least one city "
1434 "founder in the string. The characters and their "
1436 " c = City founder (eg., Settlers)\n"
1437 " w = Terrain worker (eg., Engineers)\n"
1438 " x = Explorer (eg., Explorer)\n"
1439 " k = Gameloss (eg., King)\n"
1440 " s = Diplomat (eg., Diplomat)\n"
1441 " d = Ok defense unit (eg., Warriors)\n"
1442 " D = Good defense unit (eg., Phalanx)\n"
1443 " a = Fast attack unit (eg., Horsemen)\n"
1444 " A = Strong attack unit (eg., Catapult)\n"),
1445 startunits_callback
, NULL
, GAME_DEFAULT_START_UNITS
)
1447 GEN_BOOL("startcity", game
.server
.start_city
,
1448 SSET_GAME_INIT
, SSET_SOCIOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1449 N_("Whether player starts with a city"),
1450 N_("If this is set, game will start with player's first "
1451 "city already founded to starting location."),
1452 NULL
, NULL
, GAME_DEFAULT_START_CITY
)
1454 GEN_INT("dispersion", game
.server
.dispersion
,
1455 SSET_GAME_INIT
, SSET_SOCIOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1456 N_("Area where initial units are located"),
1457 N_("This is the radius within "
1458 "which the initial units are dispersed."), NULL
, NULL
,
1459 GAME_MIN_DISPERSION
, GAME_MAX_DISPERSION
, GAME_DEFAULT_DISPERSION
)
1461 GEN_INT("gold", game
.info
.gold
,
1462 SSET_GAME_INIT
, SSET_ECONOMICS
, SSET_VITAL
, SSET_TO_CLIENT
,
1463 N_("Starting gold per player"),
1464 N_("At the beginning of the game, each player is given this "
1465 "much gold."), NULL
, NULL
,
1466 GAME_MIN_GOLD
, GAME_MAX_GOLD
, GAME_DEFAULT_GOLD
)
1468 GEN_INT("techlevel", game
.info
.tech
,
1469 SSET_GAME_INIT
, SSET_SCIENCE
, SSET_VITAL
, SSET_TO_CLIENT
,
1470 N_("Number of initial techs per player"),
1471 /* TRANS: The string between single quotes is a setting name and
1472 * should not be translated. */
1473 N_("At the beginning of the game, each player is given this "
1474 "many technologies. The technologies chosen are random for "
1475 "each player. Depending on the value of tech_cost_style in "
1476 "the ruleset, a big value for 'techlevel' can make the next "
1477 "techs really expensive."), NULL
, NULL
,
1478 GAME_MIN_TECHLEVEL
, GAME_MAX_TECHLEVEL
, GAME_DEFAULT_TECHLEVEL
)
1480 GEN_INT("sciencebox", game
.info
.sciencebox
,
1481 SSET_RULES
, SSET_SCIENCE
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1482 N_("Technology cost multiplier percentage"),
1483 N_("This affects how quickly players can research new "
1484 "technology. All tech costs are multiplied by this amount "
1485 "(as a percentage). The base tech costs are determined by "
1486 "the ruleset or other game settings."),
1487 NULL
, NULL
, GAME_MIN_SCIENCEBOX
, GAME_MAX_SCIENCEBOX
,
1488 GAME_DEFAULT_SCIENCEBOX
)
1490 GEN_INT("techpenalty", game
.server
.techpenalty
,
1491 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1492 N_("Percentage penalty when changing tech"),
1493 N_("If you change your current research technology, and you have "
1494 "positive research points, you lose this percentage of those "
1495 "research points. This does not apply when you have just gained "
1496 "a technology this turn."), NULL
, NULL
,
1497 GAME_MIN_TECHPENALTY
, GAME_MAX_TECHPENALTY
,
1498 GAME_DEFAULT_TECHPENALTY
)
1500 GEN_INT("techlost_recv", game
.server
.techlost_recv
,
1501 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1502 N_("Chance to lose an invention while receiving it"),
1503 N_("If you receive an invention via a treaty, this setting "
1504 "defines the chance that the invention is lost during the "
1506 NULL
, NULL
, GAME_MIN_TECHLOST_RECV
, GAME_MAX_TECHLOST_RECV
,
1507 GAME_DEFAULT_TECHLOST_RECV
)
1509 GEN_INT("techlost_donor", game
.server
.techlost_donor
,
1510 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1511 N_("Chance to lose an invention while giving it"),
1512 N_("If you give an invention via a treaty, this setting "
1513 "defines the chance that the invention is lost for your "
1514 "civilization during the transfer."),
1515 NULL
, NULL
, GAME_MIN_TECHLOST_DONOR
, GAME_MAX_TECHLOST_DONOR
,
1516 GAME_DEFAULT_TECHLOST_DONOR
)
1518 GEN_BOOL("team_pooled_research", game
.info
.team_pooled_research
,
1519 SSET_RULES
, SSET_SCIENCE
, SSET_VITAL
, SSET_TO_CLIENT
,
1520 N_("Team pooled research"),
1521 N_("If this setting is turned on, then the team mates will share "
1522 "the science research. Else, every player of the team will "
1523 "have to make its own."),
1524 NULL
, NULL
, GAME_DEFAULT_TEAM_POOLED_RESEARCH
)
1526 GEN_INT("diplcost", game
.server
.diplcost
,
1527 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1528 N_("Penalty when getting tech or gold from treaty"),
1529 N_("For each technology you gain from a diplomatic treaty, you "
1530 "lose research points equal to this percentage of the cost to "
1531 "research a new technology. If this is non-zero, you can end up "
1532 "with negative research points. Also applies to gold "
1533 "transfers in diplomatic treaties."),
1535 GAME_MIN_DIPLCOST
, GAME_MAX_DIPLCOST
, GAME_DEFAULT_DIPLCOST
)
1537 GEN_INT("conquercost", game
.server
.conquercost
,
1538 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1539 N_("Penalty when getting tech from conquering"),
1540 N_("For each technology you gain by conquering an enemy city, you "
1541 "lose research points equal to this percentage of the cost to "
1542 "research a new technology. If this is non-zero, you can end up "
1543 "with negative research points."),
1545 GAME_MIN_CONQUERCOST
, GAME_MAX_CONQUERCOST
,
1546 GAME_DEFAULT_CONQUERCOST
)
1548 GEN_INT("freecost", game
.server
.freecost
,
1549 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1550 N_("Penalty when getting a free tech"),
1551 /* TRANS: The strings between single quotes are setting names and
1552 * shouldn't be translated. */
1553 N_("For each technology you gain \"for free\" (other than "
1554 "covered by 'diplcost' or 'conquercost': for instance, from huts "
1555 "or from Great Library effects), you lose research points "
1556 "equal to this percentage of the cost to research a new "
1557 "technology. If this is non-zero, you can end up "
1558 "with negative research points."),
1560 GAME_MIN_FREECOST
, GAME_MAX_FREECOST
, GAME_DEFAULT_FREECOST
)
1562 GEN_INT("techlossforgiveness", game
.server
.techloss_forgiveness
,
1563 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1564 N_("Research point debt threshold for losing tech"),
1565 N_("When you have negative research points, and your shortfall is "
1566 "greater than this percentage of the cost of your current "
1567 "research, you forget a technology you already knew.\n"
1568 "The special value -1 prevents loss of technology regardless of "
1569 "research points."),
1571 GAME_MIN_TECHLOSSFG
, GAME_MAX_TECHLOSSFG
,
1572 GAME_DEFAULT_TECHLOSSFG
)
1574 GEN_INT("techlossrestore", game
.server
.techloss_restore
,
1575 SSET_RULES
, SSET_SCIENCE
, SSET_RARE
, SSET_TO_CLIENT
,
1576 N_("Research points restored after losing a tech"),
1577 N_("When you lose a technology due to a negative research balance "
1578 "(see 'techlossforgiveness'), this percentage of its research "
1579 "cost is credited to your research balance (this may not be "
1580 "sufficient to make it positive).\n"
1581 "The special value -1 means that your research balance is always "
1582 "restored to zero, regardless of your previous shortfall."),
1584 GAME_MIN_TECHLOSSREST
, GAME_MAX_TECHLOSSREST
,
1585 GAME_DEFAULT_TECHLOSSREST
)
1587 GEN_INT("foodbox", game
.info
.foodbox
,
1588 SSET_RULES
, SSET_ECONOMICS
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1589 N_("Food required for a city to grow"),
1590 N_("This is the base amount of food required to grow a city. "
1591 "This value is multiplied by another factor that comes from "
1592 "the ruleset and is dependent on the size of the city."),
1594 GAME_MIN_FOODBOX
, GAME_MAX_FOODBOX
, GAME_DEFAULT_FOODBOX
)
1596 GEN_INT("aqueductloss", game
.server
.aqueductloss
,
1597 SSET_RULES
, SSET_ECONOMICS
, SSET_RARE
, SSET_TO_CLIENT
,
1598 N_("Percentage food lost when city can't grow"),
1599 N_("If a city would expand, but it can't because it lacks some "
1600 "prerequisite (traditionally an Aqueduct or Sewer System), "
1601 "this is the base percentage of its foodbox that is lost "
1602 "each turn; the penalty may be reduced by buildings or other "
1603 "circumstances, depending on the ruleset."), NULL
, NULL
,
1604 GAME_MIN_AQUEDUCTLOSS
, GAME_MAX_AQUEDUCTLOSS
,
1605 GAME_DEFAULT_AQUEDUCTLOSS
)
1607 GEN_INT("shieldbox", game
.info
.shieldbox
,
1608 SSET_RULES
, SSET_ECONOMICS
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1609 N_("Multiplier percentage for production costs"),
1610 N_("This affects how quickly units and buildings can be "
1611 "produced. The base costs are multiplied by this value (as "
1613 NULL
, NULL
, GAME_MIN_SHIELDBOX
, GAME_MAX_SHIELDBOX
,
1614 GAME_DEFAULT_SHIELDBOX
)
1616 /* Notradesize and fulltradesize used to have callbacks to prevent them
1617 * from being set illegally (notradesize > fulltradesize). However this
1618 * provided a problem when setting them both through the client's settings
1619 * dialog, since they cannot both be set atomically. So the callbacks were
1620 * removed and instead the game now knows how to deal with invalid
1622 GEN_INT("fulltradesize", game
.info
.fulltradesize
,
1623 SSET_RULES
, SSET_ECONOMICS
, SSET_RARE
, SSET_TO_CLIENT
,
1624 N_("Minimum city size to get full trade"),
1625 /* TRANS: The strings between single quotes are setting names and
1626 * shouldn't be translated. */
1627 N_("There is a trade penalty in all cities smaller than this. "
1628 "The penalty is 100% (no trade at all) for sizes up to "
1629 "'notradesize', and decreases gradually to 0% (no penalty "
1630 "except the normal corruption) for size='fulltradesize'. "
1631 "See also 'notradesize'."), NULL
, NULL
,
1632 GAME_MIN_FULLTRADESIZE
, GAME_MAX_FULLTRADESIZE
,
1633 GAME_DEFAULT_FULLTRADESIZE
)
1635 GEN_INT("notradesize", game
.info
.notradesize
,
1636 SSET_RULES
, SSET_ECONOMICS
, SSET_RARE
, SSET_TO_CLIENT
,
1637 N_("Maximum size of a city without trade"),
1638 /* TRANS: The strings between single quotes are setting names and
1639 * shouldn't be translated. */
1640 N_("Cities do not produce any trade at all unless their size "
1641 "is larger than this amount. The produced trade increases "
1642 "gradually for cities larger than 'notradesize' and smaller "
1643 "than 'fulltradesize'. See also 'fulltradesize'."), NULL
, NULL
,
1644 GAME_MIN_NOTRADESIZE
, GAME_MAX_NOTRADESIZE
,
1645 GAME_DEFAULT_NOTRADESIZE
)
1647 GEN_INT("citymindist", game
.info
.citymindist
,
1648 SSET_RULES
, SSET_SOCIOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1649 N_("Minimum distance between cities"),
1650 N_("When a player attempts to found a new city, it is prevented "
1651 "if the distance from any existing city is less than this "
1652 "setting. For example, when this setting is 3, there must be "
1653 "at least two clear tiles in any direction between all existing "
1654 "cities and the new city site. A value of 1 removes any such "
1655 "restriction on city placement."),
1657 GAME_MIN_CITYMINDIST
, GAME_MAX_CITYMINDIST
,
1658 GAME_DEFAULT_CITYMINDIST
)
1660 GEN_BOOL("trading_tech", game
.info
.trading_tech
,
1661 SSET_RULES
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1662 N_("Technology trading"),
1663 N_("If turned off, trading technologies in the diplomacy dialog "
1664 "is not allowed."), NULL
, NULL
,
1665 GAME_DEFAULT_TRADING_TECH
)
1667 GEN_BOOL("trading_gold", game
.info
.trading_gold
,
1668 SSET_RULES
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1670 N_("If turned off, trading gold in the diplomacy dialog "
1671 "is not allowed."), NULL
, NULL
,
1672 GAME_DEFAULT_TRADING_GOLD
)
1674 GEN_BOOL("trading_city", game
.info
.trading_city
,
1675 SSET_RULES
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1677 N_("If turned off, trading cities in the diplomacy dialog "
1678 "is not allowed."), NULL
, NULL
,
1679 GAME_DEFAULT_TRADING_CITY
)
1681 GEN_INT("trademindist", game
.info
.trademindist
,
1682 SSET_RULES
, SSET_ECONOMICS
, SSET_RARE
, SSET_TO_CLIENT
,
1683 N_("Minimum distance for trade routes"),
1684 N_("In order for two cities in the same civilization to establish "
1685 "a trade route, they must be at least this far apart on the "
1686 "map. For square grids, the distance is calculated as "
1687 "\"Manhattan distance\", that is, the sum of the displacements "
1688 "along the x and y directions."), NULL
, NULL
,
1689 GAME_MIN_TRADEMINDIST
, GAME_MAX_TRADEMINDIST
,
1690 GAME_DEFAULT_TRADEMINDIST
)
1692 GEN_INT("rapturedelay", game
.info
.rapturedelay
,
1693 SSET_RULES
, SSET_SOCIOLOGY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1694 N_("Number of turns between rapture effect"),
1695 N_("Sets the number of turns between rapture growth of a city. "
1696 "If set to n a city will grow after celebrating for n+1 "
1699 GAME_MIN_RAPTUREDELAY
, GAME_MAX_RAPTUREDELAY
,
1700 GAME_DEFAULT_RAPTUREDELAY
)
1702 GEN_INT("disasters", game
.info
.disasters
,
1703 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
1704 N_("Frequency of disasters"),
1705 N_("Affects how often random disasters happen to cities, "
1706 "if any are defined by the ruleset. The relative frequency "
1707 "of disaster types is set by the ruleset. Zero prevents "
1708 "any random disasters from occurring."),
1710 GAME_MIN_DISASTERS
, GAME_MAX_DISASTERS
,
1711 GAME_DEFAULT_DISASTERS
)
1713 GEN_INT("razechance", game
.server
.razechance
,
1714 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1715 N_("Chance for conquered building destruction"),
1716 N_("When a player conquers a city, each city improvement has this "
1717 "percentage chance to be destroyed."), NULL
, NULL
,
1718 GAME_MIN_RAZECHANCE
, GAME_MAX_RAZECHANCE
, GAME_DEFAULT_RAZECHANCE
)
1720 GEN_INT("occupychance", game
.server
.occupychance
,
1721 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1722 N_("Chance of moving into tile after attack"),
1723 N_("If set to 0, combat is Civ1/2-style (when you attack, "
1724 "you remain in place). If set to 100, attacking units "
1725 "will always move into the tile they attacked when they win "
1726 "the combat (and no enemy units remain in the tile). If "
1727 "set to a value between 0 and 100, this will be used as "
1728 "the percent chance of \"occupying\" territory."), NULL
, NULL
,
1729 GAME_MIN_OCCUPYCHANCE
, GAME_MAX_OCCUPYCHANCE
,
1730 GAME_DEFAULT_OCCUPYCHANCE
)
1732 GEN_BOOL("autoattack", game
.server
.autoattack
, SSET_RULES_FLEXIBLE
, SSET_MILITARY
,
1733 SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1734 N_("Turn on/off server-side autoattack"),
1735 N_("If set to on, units with moves left will automatically "
1736 "consider attacking enemy units that move adjacent to them."),
1737 NULL
, NULL
, GAME_DEFAULT_AUTOATTACK
)
1739 GEN_BOOL("killstack", game
.info
.killstack
, SSET_RULES
, SSET_MILITARY
,
1740 SSET_RARE
, SSET_TO_CLIENT
,
1741 N_("Do all units in tile die with defender"),
1742 N_("If this is enabled, each time a defender unit loses in combat, "
1743 "and is not inside a city or suitable base, all units in the same "
1744 "tile are destroyed along with the defender. If this is disabled, "
1745 "only the defender unit is destroyed."),
1746 NULL
, NULL
, GAME_DEFAULT_KILLSTACK
)
1748 GEN_BOOL("killcitizen", game
.info
.killcitizen
,
1749 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1750 N_("Reduce city population after attack"),
1751 N_("This flag indicates whether a city's population is reduced "
1752 "after a successful attack by an enemy unit. If this is "
1753 "disabled, population is never reduced. Even when this is "
1754 "enabled, only some units may kill citizens."),
1755 NULL
, NULL
, GAME_DEFAULT_KILLCITIZEN
)
1757 GEN_INT("killunhomed", game
.server
.killunhomed
,
1758 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1759 N_("Slowly kill units without home cities (e.g., starting units)"),
1760 N_("If greater than 0, then every unit without a homecity will "
1761 "lose hitpoints each turn. The number of hitpoints lost is "
1762 "given by 'killunhomed' percent of the hitpoints of the unit "
1763 "type. At least one hitpoint is lost every turn until the "
1764 "death of the unit."),
1765 NULL
, NULL
, GAME_MIN_KILLUNHOMED
, GAME_MAX_KILLUNHOMED
,
1766 GAME_DEFAULT_KILLUNHOMED
)
1768 GEN_ENUM("borders", game
.info
.borders
,
1769 SSET_RULES
, SSET_MILITARY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1770 N_("National borders"),
1771 N_("If this is not disabled, then any land tiles around a "
1772 "fortress or city will be owned by that nation."),
1773 NULL
, NULL
, borders_name
, GAME_DEFAULT_BORDERS
)
1775 GEN_BOOL("happyborders", game
.info
.happyborders
,
1776 SSET_RULES
, SSET_MILITARY
, SSET_SITUATIONAL
,
1778 N_("Units inside borders cause no unhappiness"),
1779 N_("If this is set, units will not cause unhappiness when "
1780 "inside your own borders."), NULL
, NULL
,
1781 GAME_DEFAULT_HAPPYBORDERS
)
1783 GEN_ENUM("diplomacy", game
.info
.diplomacy
,
1784 SSET_RULES
, SSET_MILITARY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
1785 N_("Ability to do diplomacy with other players"),
1786 N_("This setting controls the ability to do diplomacy with "
1788 NULL
, NULL
, diplomacy_name
, GAME_DEFAULT_DIPLOMACY
)
1790 GEN_ENUM("citynames", game
.server
.allowed_city_names
,
1791 SSET_RULES
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1792 N_("Allowed city names"),
1793 /* TRANS: The strings between double quotes are also translated
1794 * separately (they must match!). The strings between parentheses
1795 * and in uppercase must not be translated. */
1796 N_("- \"No restrictions\" (NO_RESTRICTIONS): players can have "
1797 "multiple cities with the same names.\n"
1798 "- \"Unique to a player\" (PLAYER_UNIQUE): one player can't "
1799 "have multiple cities with the same name.\n"
1800 "- \"Globally unique\" (GLOBAL_UNIQUE): all cities in a game "
1801 "have to have different names.\n"
1802 "- \"No city name stealing\" (NO_STEALING): like "
1803 "\"Globally unique\", but a player isn't allowed to use a "
1804 "default city name of another nation unless it is a default "
1805 "for their nation also."),
1806 NULL
, NULL
, citynames_name
, GAME_DEFAULT_ALLOWED_CITY_NAMES
)
1808 GEN_ENUM("plrcolormode", game
.server
.plrcolormode
,
1809 SSET_RULES
, SSET_INTERNAL
, SSET_RARE
, SSET_TO_CLIENT
,
1810 N_("How to pick player colors"),
1811 /* TRANS: The strings between double quotes are also translated
1812 * separately (they must match!). The strings between single quotes
1813 * are setting names and shouldn't be translated. The strings
1814 * between parentheses and in uppercase must not be translated. */
1815 N_("This setting determines how player colors are chosen. Player "
1816 "colors are used in the Nations report, for national borders on "
1817 "the map, and so on.\n"
1818 "- \"Per-player, in order\" (PLR_ORDER): colors are assigned to "
1819 "individual players in order from a list defined by the "
1821 "- \"Per-player, random\" (PLR_RANDOM): colors are assigned "
1822 "to invididual players randomly from the set defined by the "
1824 "- \"Set manually\" (PLR_SET): colors can be set with the "
1825 "'playercolor' command before the game starts; these are not "
1826 "restricted to the ruleset colors. Any players for which no "
1827 "color is set when the game starts get a random color from the "
1829 "- \"Per-team, in order\" (TEAM_ORDER): colors are assigned to "
1830 "teams from the list in the ruleset. Every player on the same "
1831 "team gets the same color.\n"
1832 "- \"Per-nation, in order\" (NATION_ORDER): if the ruleset "
1833 "defines a color for a player's nation, the player takes that "
1834 "color. Any players whose nations don't have associated colors "
1835 "get a random color from the list in the ruleset.\n"
1836 "Regardless of this setting, individual player colors can be "
1837 "changed after the game starts with the 'playercolor' command."),
1838 plrcol_validate
, plrcol_action
, plrcol_name
,
1839 GAME_DEFAULT_PLRCOLORMODE
)
1841 /* Flexible rules: these can be changed after the game has started.
1843 * The distinction between "rules" and "flexible rules" is not always
1844 * clearcut, and some existing cases may be largely historical or
1845 * accidental. However some generalizations can be made:
1847 * -- Low-level game mechanics should not be flexible (eg, rulesets).
1848 * -- Options which would affect the game "state" (city production etc)
1849 * should not be flexible (eg, foodbox).
1850 * -- Options which are explicitly sent to the client (eg, in
1851 * packet_game_info) should probably not be flexible, or at
1852 * least need extra care to be flexible.
1854 GEN_ENUM("barbarians", game
.server
.barbarianrate
,
1855 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_VITAL
, SSET_TO_CLIENT
,
1856 N_("Barbarian appearance frequency"),
1857 /* TRANS: The string between single quotes is a setting name and
1858 * should not be translated. */
1859 N_("This setting controls how frequently the barbarians appear "
1860 "in the game. See also the 'onsetbarbs' setting."),
1861 NULL
, NULL
, barbarians_name
, GAME_DEFAULT_BARBARIANRATE
)
1863 GEN_INT("onsetbarbs", game
.server
.onsetbarbarian
,
1864 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_VITAL
, SSET_TO_CLIENT
,
1865 N_("Barbarian onset turn"),
1866 N_("Barbarians will not appear before this turn."), NULL
, NULL
,
1867 GAME_MIN_ONSETBARBARIAN
, GAME_MAX_ONSETBARBARIAN
,
1868 GAME_DEFAULT_ONSETBARBARIAN
)
1870 GEN_INT("revolen", game
.server
.revolution_length
,
1871 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1872 N_("Length in turns of revolution"),
1873 N_("When changing governments, a period of anarchy lasting this "
1874 "many turns will occur. "
1875 "Setting this value to 0 will give a random "
1876 "length of 1-5 turns."), NULL
, NULL
,
1877 GAME_MIN_REVOLUTION_LENGTH
, GAME_MAX_REVOLUTION_LENGTH
,
1878 GAME_DEFAULT_REVOLUTION_LENGTH
)
1880 GEN_BOOL("fogofwar", game
.info
.fogofwar
,
1881 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1882 N_("Whether to enable fog of war"),
1883 N_("If this is enabled, only those units and cities within "
1884 "the vision range of your own units and cities will be "
1885 "revealed to you. You will not see new cities or terrain "
1886 "changes in tiles not observed."),
1887 NULL
, NULL
, GAME_DEFAULT_FOGOFWAR
)
1889 GEN_BOOL("foggedborders", game
.server
.foggedborders
,
1890 SSET_RULES
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1891 N_("Whether fog of war applies to border changes"),
1892 N_("If this setting is enabled, players will not be able "
1893 "to see changes in tile ownership if they do not have "
1894 "direct sight of the affected tiles. Otherwise, players "
1895 "can see any or all changes to borders as long as they "
1896 "have previously seen the tiles."),
1897 NULL
, NULL
, GAME_DEFAULT_FOGGEDBORDERS
)
1899 GEN_BITWISE("airliftingstyle", game
.info
.airlifting_style
,
1900 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_SITUATIONAL
,
1901 SSET_TO_CLIENT
, N_("Airlifting style"),
1902 /* TRANS: The strings between double quotes are also
1903 * translated separately (they must match!). The strings
1904 * between parenthesis and in uppercase must not be
1906 N_("This setting affects airlifting units between cities. It "
1907 "can be a set of the following values:\n"
1908 "- \"Allows units to be airlifted from allied cities\" "
1910 "- \"Allows units to be airlifted to allied cities\" "
1912 "- \"Unlimited units from source city\" (SRC_UNLIMITED): "
1913 "note that airlifting from a city doesn't reduce the "
1914 "airlifted counter, but still needs at least 1.\n"
1915 "- \"Unlimited units to destination city\" "
1916 "(DEST_UNLIMITED): note that airlifting to a city doesn't "
1917 "reduce the airlifted counter, and doesn't need any."),
1918 NULL
, NULL
, airliftingstyle_name
, GAME_DEFAULT_AIRLIFTINGSTYLE
)
1920 GEN_INT("diplchance", game
.server
.diplchance
,
1921 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_SITUATIONAL
,
1923 N_("Base chance for diplomats and spies to succeed"),
1924 N_("The base chance of a spy returning from a successful mission and "
1925 "the base chance of success for diplomats and spies."),
1927 GAME_MIN_DIPLCHANCE
, GAME_MAX_DIPLCHANCE
, GAME_DEFAULT_DIPLCHANCE
)
1929 GEN_BOOL("spacerace", game
.info
.spacerace
,
1930 SSET_RULES_FLEXIBLE
, SSET_SCIENCE
, SSET_VITAL
, SSET_TO_CLIENT
,
1931 N_("Whether to allow space race"),
1932 N_("If this option is enabled, players can build spaceships."),
1933 NULL
, NULL
, GAME_DEFAULT_SPACERACE
)
1935 GEN_BOOL("endspaceship", game
.server
.endspaceship
, SSET_RULES_FLEXIBLE
,
1936 SSET_SCIENCE
, SSET_VITAL
, SSET_TO_CLIENT
,
1937 N_("Should the game end if the spaceship arrives?"),
1938 N_("If this option is turned on, the game will end with the "
1939 "arrival of a spaceship at Alpha Centauri."),
1940 NULL
, NULL
, GAME_DEFAULT_END_SPACESHIP
)
1942 GEN_INT("civilwarsize", game
.server
.civilwarsize
,
1943 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
1944 N_("Minimum number of cities for civil war"),
1945 N_("A civil war is triggered when a player has at least this "
1946 "many cities and the player's capital is captured. If "
1947 "this option is set to the maximum value, civil wars are "
1948 "turned off altogether."), NULL
, NULL
,
1949 GAME_MIN_CIVILWARSIZE
, GAME_MAX_CIVILWARSIZE
,
1950 GAME_DEFAULT_CIVILWARSIZE
)
1952 GEN_BOOL("restrictinfra", game
.info
.restrictinfra
,
1953 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1954 N_("Restrict the use of the infrastructure for enemy units"),
1955 N_("If this option is enabled, the use of roads and rails "
1956 "will be restricted for enemy units."), NULL
, NULL
,
1957 GAME_DEFAULT_RESTRICTINFRA
)
1959 GEN_BOOL("unreachableprotects", game
.info
.unreachable_protects
,
1960 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1961 N_("Does unreachable unit protect reachable ones"),
1962 N_("This option controls whether tiles with both unreachable "
1963 "and reachable units can be attacked. If disabled, any "
1964 "tile with reachable units can be attacked. If enabled, "
1965 "tiles with an unreachable unit in them cannot be attacked."),
1966 NULL
, NULL
, GAME_DEFAULT_UNRPROTECTS
)
1968 GEN_INT("contactturns", game
.server
.contactturns
,
1969 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1970 N_("Turns until player contact is lost"),
1971 N_("Players may meet for diplomacy this number of turns "
1972 "after their units have last met, even when they do not have "
1973 "an embassy. If set to zero, then players cannot meet unless "
1974 "they have an embassy."),
1976 GAME_MIN_CONTACTTURNS
, GAME_MAX_CONTACTTURNS
,
1977 GAME_DEFAULT_CONTACTTURNS
)
1979 GEN_BOOL("savepalace", game
.server
.savepalace
,
1980 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1981 N_("Rebuild palace whenever capital is conquered"),
1982 N_("If this is turned on, when the capital is conquered the "
1983 "palace is automatically rebuilt for free in another randomly "
1984 "chosen city. This is significant because the technology "
1985 "requirement for building a palace will be ignored. (In "
1986 "some rulesets, buildings other than the palace are affected "
1987 "by this setting.)"),
1988 NULL
, NULL
, GAME_DEFAULT_SAVEPALACE
)
1990 GEN_BOOL("homecaughtunits", game
.server
.homecaughtunits
,
1991 SSET_RULES_FLEXIBLE
, SSET_MILITARY
, SSET_RARE
, SSET_TO_CLIENT
,
1992 N_("Give caught units a homecity"),
1993 /* TRANS: The string between single quotes is a setting name and
1994 * should not be translated. */
1995 N_("If unset, caught units will have no homecity and will be "
1996 "subject to the 'killunhomed' option."),
1997 NULL
, NULL
, GAME_DEFAULT_HOMECAUGHTUNITS
)
1999 GEN_BOOL("alliedvictory", game
.server
.allied_victory
,
2000 SSET_RULES_FLEXIBLE
, SSET_MILITARY
,
2001 SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2002 N_("Whether allied players can win together"),
2003 N_("If this option is turned on and a point is reached where "
2004 "all the players still able to win the game are allies, and "
2005 "at least one defeated player is not part of this alliance, "
2006 "then the game will end in an immediate shared victory for "
2007 "the allied players."),
2008 NULL
, NULL
, GAME_DEFAULT_ALLIED_VICTORY
)
2010 GEN_BOOL("naturalcitynames", game
.server
.natural_city_names
,
2011 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2012 N_("Whether to use natural city names"),
2013 N_("If enabled, the default city names will be determined based "
2014 "on the surrounding terrain."),
2015 NULL
, NULL
, GAME_DEFAULT_NATURALCITYNAMES
)
2017 GEN_BOOL("migration", game
.server
.migration
,
2018 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2019 N_("Whether to enable citizen migration"),
2020 /* TRANS: The strings between single quotes are setting names
2021 * and should not be translated. */
2022 N_("This is the master setting that controls whether citizen "
2023 "migration is active in the game. If enabled, citizens may "
2024 "automatically move from less desirable cities to more "
2025 "desirable ones. The \"desirability\" of a given city is "
2026 "calculated from a number of factors. In general larger "
2027 "cities with more income and improvements will be preferred. "
2028 "Citizens will never migrate out of the capital, or cause "
2029 "a wonder to be lost by disbanding a city. A number of other "
2030 "settings control how migration behaves:\n"
2031 " 'mgr_turninterval' - How often citizens try to migrate.\n"
2032 " 'mgr_foodneeded' - Whether destination food is checked.\n"
2033 " 'mgr_distance' - How far citizens will migrate.\n"
2034 " 'mgr_worldchance' - Chance for inter-nation migration.\n"
2035 " 'mgr_nationchance' - Chance for intra-nation migration."),
2036 NULL
, NULL
, GAME_DEFAULT_MIGRATION
)
2038 GEN_INT("mgr_turninterval", game
.server
.mgr_turninterval
,
2039 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2040 N_("Number of turns between migrations from a city"),
2041 /* TRANS: Do not translate 'migration' setting name. */
2042 N_("This setting controls the number of turns between migration "
2043 "checks for a given city. The interval is calculated from "
2044 "the founding turn of the city. So for example if this "
2045 "setting is 5, citizens will look for a suitable migration "
2046 "destination every five turns from the founding of their "
2047 "current city. Migration will never occur the same turn "
2048 "that a city is built. This setting has no effect unless "
2049 "migration is enabled by the 'migration' setting."), NULL
,
2050 NULL
, GAME_MIN_MGR_TURNINTERVAL
, GAME_MAX_MGR_TURNINTERVAL
,
2051 GAME_DEFAULT_MGR_TURNINTERVAL
)
2053 GEN_BOOL("mgr_foodneeded", game
.server
.mgr_foodneeded
,
2054 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2055 N_("Whether migration is limited by food"),
2056 /* TRANS: Do not translate 'migration' setting name. */
2057 N_("If this setting is enabled, citizens will not migrate to "
2058 "cities which would not have enough food to support them. "
2059 "This setting has no effect unless migration is enabled by "
2060 "the 'migration' setting."), NULL
, NULL
,
2061 GAME_DEFAULT_MGR_FOODNEEDED
)
2063 GEN_INT("mgr_distance", game
.server
.mgr_distance
,
2064 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2065 N_("Maximum distance citizens may migrate"),
2066 /* TRANS: Do not translate 'migration' setting name. */
2067 N_("This setting controls how far citizens may look for a "
2068 "suitable migration destination when deciding which city "
2069 "to migrate to. The value is added to the current city radius "
2070 "and compared to the distance between the two cities. If "
2071 "the distance is lower or equal, migration is possible. This "
2072 "setting has no effect unless migration is activated by the "
2073 "'migration' setting."),
2074 NULL
, NULL
, GAME_MIN_MGR_DISTANCE
, GAME_MAX_MGR_DISTANCE
,
2075 GAME_DEFAULT_MGR_DISTANCE
)
2077 GEN_INT("mgr_nationchance", game
.server
.mgr_nationchance
,
2078 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2079 N_("Percent probability for migration within the same nation"),
2080 /* TRANS: Do not translate 'migration' setting name. */
2081 N_("This setting controls how likely it is for citizens to "
2082 "migrate between cities owned by the same player. Zero "
2083 "indicates migration will never occur, 100 means that "
2084 "migration will always occur if the citizens find a suitable "
2085 "destination. This setting has no effect unless migration "
2086 "is activated by the 'migration' setting."), NULL
, NULL
,
2087 GAME_MIN_MGR_NATIONCHANCE
, GAME_MAX_MGR_NATIONCHANCE
,
2088 GAME_DEFAULT_MGR_NATIONCHANCE
)
2090 GEN_INT("mgr_worldchance", game
.server
.mgr_worldchance
,
2091 SSET_RULES_FLEXIBLE
, SSET_SOCIOLOGY
, SSET_RARE
, SSET_TO_CLIENT
,
2092 N_("Percent probability for migration between foreign cities"),
2093 /* TRANS: Do not translate 'migration' setting name. */
2094 N_("This setting controls how likely it is for migration "
2095 "to occur between cities owned by different players. "
2096 "Zero indicates migration will never occur, 100 means "
2097 "that citizens will always migrate if they find a suitable "
2098 "destination. This setting has no effect if migration is "
2099 "not enabled by the 'migration' setting."), NULL
, NULL
,
2100 GAME_MIN_MGR_WORLDCHANCE
, GAME_MAX_MGR_WORLDCHANCE
,
2101 GAME_DEFAULT_MGR_WORLDCHANCE
)
2103 /* Meta options: these don't affect the internal rules of the game, but
2104 * do affect players. Also options which only produce extra server
2105 * "output" and don't affect the actual game.
2106 * ("endturn" is here, and not RULES_FLEXIBLE, because it doesn't
2107 * affect what happens in the game, it just determines when the
2108 * players stop playing and look at the score.)
2110 GEN_STRING("allowtake", game
.server
.allow_take
,
2111 SSET_META
, SSET_NETWORK
, SSET_RARE
, SSET_TO_CLIENT
,
2112 N_("Players that users are allowed to take"),
2113 /* TRANS: the strings in double quotes are server command names
2114 * and should not be translated. */
2115 N_("This should be a string of characters, each of which "
2116 "specifies a type or status of a civilization (player).\n"
2117 "Clients will only be permitted to take or observe those "
2118 "players which match one of the specified letters. This "
2119 "only affects future uses of the \"take\" or \"observe\" "
2120 "commands; it is not retroactive. The characters and their "
2122 " o,O = Global observer\n"
2123 " b = Barbarian players\n"
2124 " d = Dead players\n"
2125 " a,A = AI players\n"
2126 " h,H = Human players\n"
2127 "The first description on this list which matches a "
2128 "player is the one which applies. Thus 'd' does not "
2129 "include dead barbarians, 'a' does not include dead AI "
2130 "players, and so on. Upper case letters apply before "
2131 "the game has started, lower case letters afterwards.\n"
2132 "Each character above may be followed by one of the "
2133 "following numbers to allow or restrict the manner "
2135 "(none) = Controller allowed, observers allowed, "
2136 "can displace connections. (Displacing a connection means "
2137 "that you may take over a player, even when another user "
2138 "already controls that player.)\n"
2139 " 1 = Controller allowed, observers allowed, "
2140 "can't displace connections;\n"
2141 " 2 = Controller allowed, no observers allowed, "
2142 "can displace connections;\n"
2143 " 3 = Controller allowed, no observers allowed, "
2144 "can't displace connections;\n"
2145 " 4 = No controller allowed, observers allowed"),
2146 allowtake_callback
, NULL
, GAME_DEFAULT_ALLOW_TAKE
)
2148 GEN_BOOL("autotoggle", game
.server
.auto_ai_toggle
,
2149 SSET_META
, SSET_NETWORK
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2150 N_("Whether AI-status toggles with connection"),
2151 N_("If enabled, AI status is turned off when a player "
2152 "connects, and on when a player disconnects."),
2153 NULL
, autotoggle_action
, GAME_DEFAULT_AUTO_AI_TOGGLE
)
2155 GEN_INT("endturn", game
.server
.end_turn
,
2156 SSET_META
, SSET_SOCIOLOGY
, SSET_VITAL
, SSET_TO_CLIENT
,
2157 N_("Turn the game ends"),
2158 N_("The game will end at the end of the given turn."),
2159 endturn_callback
, NULL
,
2160 GAME_MIN_END_TURN
, GAME_MAX_END_TURN
, GAME_DEFAULT_END_TURN
)
2162 GEN_BITWISE("revealmap", game
.server
.revealmap
, SSET_GAME_INIT
,
2163 SSET_MILITARY
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2164 N_("Reveal the map"),
2165 /* TRANS: The strings between double quotes are also translated
2166 * separately (they must match!). The strings between single
2167 * quotes are setting names and shouldn't be translated. The
2168 * strings between parentheses and in uppercase must not be
2170 N_("If \"Reveal map at game start\" (START) is set, the "
2171 "initial state of the entire map will be known to all "
2172 "players from the start of the game, although it may "
2173 "still be fogged (depending on the 'fogofwar' setting). "
2174 "If \"Unfog map for dead players\" (DEAD) is set, dead "
2175 "players can see the entire map, if they are alone in "
2177 NULL
, NULL
, revealmap_name
, GAME_DEFAULT_REVEALMAP
)
2179 GEN_INT("timeout", game
.info
.timeout
,
2180 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
2181 N_("Maximum seconds per turn"),
2182 /* TRANS: \"Turn Done\" refers to the client button; it is also
2183 * translated separately, the translation should be the same.
2184 * \"timeoutincrease\" is a command name and must not to be
2186 N_("If all players have not hit \"Turn Done\" before this "
2187 "time is up, then the turn ends automatically. Zero "
2188 "means there is no timeout. In servers compiled with "
2189 "debugging, a timeout of -1 sets the autogame test mode. "
2190 "Only connections with hack level access may set the "
2191 "timeout to lower than 30 seconds. Use this with the "
2192 "command \"timeoutincrease\" to have a dynamic timer. "
2193 "The first turn is treated as a special case and is controlled "
2194 "by the 'first_timeout' setting."),
2195 timeout_callback
, timeout_action
,
2196 GAME_MIN_TIMEOUT
, GAME_MAX_TIMEOUT
, GAME_DEFAULT_TIMEOUT
)
2198 GEN_INT("first_timeout", game
.server
.first_timeout
,
2199 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
2200 N_("First turn timeout"),
2201 /* TRANS: The strings between single quotes are setting names and
2202 * should not be translated. */
2203 N_("If greater than 0, T0 will last for 'first_timeout' seconds.\n"
2204 "If set to 0, T0 will not have a timeout.\n"
2205 "If set to -1, the special treatment of T0 will be disabled.\n"
2206 "See also 'timeout'."),
2207 NULL
, NULL
, GAME_MIN_FIRST_TIMEOUT
, GAME_MAX_FIRST_TIMEOUT
,
2208 GAME_DEFAULT_FIRST_TIMEOUT
)
2210 GEN_INT("timeaddenemymove", game
.server
.timeoutaddenemymove
,
2211 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
2212 N_("Timeout at least n seconds when enemy moved"),
2213 N_("Any time a unit moves while in sight of an enemy player, "
2214 "the remaining timeout is increased to this value."),
2215 NULL
, NULL
, 0, GAME_MAX_TIMEOUT
, GAME_DEFAULT_TIMEOUTADDEMOVE
)
2217 GEN_INT("unitwaittime", game
.server
.unitwaittime
,
2218 SSET_RULES_FLEXIBLE
, SSET_INTERNAL
, SSET_VITAL
, SSET_TO_CLIENT
,
2219 N_("Minimum time between unit actions over turn change"),
2220 /* TRANS: The string between single quotes is a setting name and
2221 * should not be translated. */
2222 N_("This setting gives the minimum amount of time in seconds "
2223 "between unit moves and other significant actions (such as "
2224 "building cities) after a turn change occurs. For example, "
2225 "if this setting is set to 20 and a unit moves 5 seconds "
2226 "before the turn change, it will not be able to move or act "
2227 "in the next turn for at least 15 seconds. This value is "
2228 "limited to a maximum value of 2/3 'timeout'."),
2229 unitwaittime_callback
, NULL
, GAME_MIN_UNITWAITTIME
,
2230 GAME_MAX_UNITWAITTIME
, GAME_DEFAULT_UNITWAITTIME
)
2232 /* This setting points to the "stored" value; changing it won't have
2233 * an effect until the next synchronization point (i.e., the start of
2234 * the next turn). */
2235 GEN_ENUM("phasemode", game
.server
.phase_mode_stored
,
2236 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2237 N_("Control of simultaneous player/team phases"),
2238 N_("This setting controls whether players may make "
2239 "moves at the same time during a turn. Change "
2240 "in setting takes effect next turn."),
2241 NULL
, NULL
, phasemode_name
, GAME_DEFAULT_PHASE_MODE
)
2243 GEN_INT("nettimeout", game
.server
.tcptimeout
,
2244 SSET_META
, SSET_NETWORK
, SSET_RARE
, SSET_TO_CLIENT
,
2245 N_("Seconds to let a client's network connection block"),
2246 N_("If a network connection is blocking for a time greater than "
2247 "this value, then the connection is closed. Zero "
2248 "means there is no timeout (although connections will be "
2249 "automatically disconnected eventually)."),
2251 GAME_MIN_TCPTIMEOUT
, GAME_MAX_TCPTIMEOUT
, GAME_DEFAULT_TCPTIMEOUT
)
2253 GEN_INT("netwait", game
.server
.netwait
,
2254 SSET_META
, SSET_NETWORK
, SSET_RARE
, SSET_TO_CLIENT
,
2255 N_("Max seconds for network buffers to drain"),
2256 N_("The server will wait for up to the value of this "
2257 "parameter in seconds, for all client connection network "
2258 "buffers to unblock. Zero means the server will not "
2259 "wait at all."), NULL
, NULL
,
2260 GAME_MIN_NETWAIT
, GAME_MAX_NETWAIT
, GAME_DEFAULT_NETWAIT
)
2262 GEN_INT("pingtime", game
.server
.pingtime
,
2263 SSET_META
, SSET_NETWORK
, SSET_RARE
, SSET_TO_CLIENT
,
2264 N_("Seconds between PINGs"),
2265 N_("The server will poll the clients with a PING request "
2266 "each time this period elapses."), NULL
, NULL
,
2267 GAME_MIN_PINGTIME
, GAME_MAX_PINGTIME
, GAME_DEFAULT_PINGTIME
)
2269 GEN_INT("pingtimeout", game
.server
.pingtimeout
,
2270 SSET_META
, SSET_NETWORK
, SSET_RARE
,
2272 N_("Time to cut a client"),
2273 N_("If a client doesn't reply to a PING in this time the "
2274 "client is disconnected."), NULL
, NULL
,
2275 GAME_MIN_PINGTIMEOUT
, GAME_MAX_PINGTIMEOUT
, GAME_DEFAULT_PINGTIMEOUT
)
2277 GEN_BOOL("turnblock", game
.server
.turnblock
,
2278 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2279 N_("Turn-blocking game play mode"),
2280 N_("If this is turned on, the game turn is not advanced "
2281 "until all players have finished their turn, including "
2282 "disconnected players."),
2283 NULL
, NULL
, GAME_DEFAULT_TURNBLOCK
)
2285 GEN_BOOL("fixedlength", game
.server
.fixedlength
,
2286 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2287 N_("Fixed-length turns play mode"),
2288 /* TRANS: \"Turn Done\" refers to the client button; it is also
2289 * translated separately, the translation should be the same. */
2290 N_("If this is turned on the game turn will not advance "
2291 "until the timeout has expired, even after all players "
2292 "have clicked on \"Turn Done\"."),
2295 GEN_STRING("demography", game
.server
.demography
,
2296 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_TO_CLIENT
,
2297 N_("What is in the Demographics report"),
2298 /* TRANS: The strings between double quotes should be
2300 N_("This should be a string of characters, each of which "
2301 "specifies the inclusion of a line of information "
2302 "in the Demographics report.\n"
2303 "The characters and their meanings are:\n"
2304 " N = include Population\n"
2305 " P = include Production\n"
2306 " A = include Land Area\n"
2307 " L = include Literacy\n"
2308 " R = include Research Speed\n"
2309 " S = include Settled Area\n"
2310 " E = include Economics\n"
2311 " M = include Military Service\n"
2312 " O = include Pollution\n"
2313 "Additionally, the following characters control whether "
2314 "or not certain columns are displayed in the report:\n"
2315 " q = display \"quantity\" column\n"
2316 " r = display \"rank\" column\n"
2317 " b = display \"best nation\" column\n"
2318 "The order of characters is not significant, but "
2319 "their capitalization is."),
2320 demography_callback
, NULL
, GAME_DEFAULT_DEMOGRAPHY
)
2322 GEN_INT("saveturns", game
.server
.save_nturns
,
2323 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_SERVER_ONLY
,
2324 N_("Turns per auto-save"),
2325 /* TRANS: The string between double quotes is also translated
2326 * separately (it must match!). The string between single
2327 * quotes is a setting name and shouldn't be translated. */
2328 N_("How many turns elapse between automatic game saves. This "
2329 "setting only has an effect when the 'autosaves' setting "
2330 "includes \"New turn\"."), NULL
, NULL
,
2331 GAME_MIN_SAVETURNS
, GAME_MAX_SAVETURNS
, GAME_DEFAULT_SAVETURNS
)
2333 GEN_BITWISE("autosaves", game
.server
.autosaves
,
2334 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_SERVER_ONLY
,
2335 N_("Which savegames are generated automatically"),
2336 /* TRANS: The strings between double quotes are also translated
2337 * separately (they must match!). The strings between single
2338 * quotes are setting names and shouldn't be translated. The
2339 * strings between parentheses and in uppercase must stay as
2341 N_("This setting controls which autosave types get generated:\n"
2342 "- \"New turn\" (TURN): Save when turn begins, once every "
2343 "'saveturns' turns.\n"
2344 "- \"Game over\" (GAMEOVER): Final save when game ends.\n"
2345 "- \"No player connections\" (QUITIDLE): "
2346 "Save before server restarts due to lack of players.\n"
2347 "- \"Server interrupted\" (INTERRUPT): Save when server "
2348 "quits due to interrupt."),
2349 NULL
, NULL
, autosaves_name
, GAME_DEFAULT_AUTOSAVES
)
2351 GEN_INT("compress", game
.server
.save_compress_level
,
2352 SSET_META
, SSET_INTERNAL
, SSET_RARE
, SSET_SERVER_ONLY
,
2353 N_("Savegame compression level"),
2354 /* TRANS: 'compresstype' setting name should not be translated. */
2355 N_("If non-zero, saved games will be compressed depending on the "
2356 "'compresstype' setting. Larger values will give better "
2357 "compression but take longer."),
2358 NULL
, NULL
, GAME_MIN_COMPRESS_LEVEL
, GAME_MAX_COMPRESS_LEVEL
,
2359 GAME_DEFAULT_COMPRESS_LEVEL
)
2361 GEN_ENUM("compresstype", game
.server
.save_compress_type
,
2362 SSET_META
, SSET_INTERNAL
, SSET_RARE
, SSET_SERVER_ONLY
,
2363 N_("Savegame compression algorithm"),
2364 N_("Compression library to use for savegames."),
2365 NULL
, NULL
, compresstype_name
, GAME_DEFAULT_COMPRESS_TYPE
)
2367 GEN_STRING("savename", game
.server
.save_name
,
2368 SSET_META
, SSET_INTERNAL
, SSET_VITAL
, SSET_SERVER_ONLY
,
2369 N_("Definition of the save file name"),
2370 /* TRANS: %R, %S, %T and %Y must not be translated. The
2371 * strings (examples and setting names) between single quotes
2372 * neither. The strings between <> should be translated.
2373 * xgettext:no-c-format */
2374 N_("Within the string the following custom formats are "
2378 " %T = <turn-number>\n"
2379 " %Y = <game-year>\n"
2381 "Example: 'freeciv-T%04T-Y%+05Y-%R' => "
2382 "'freeciv-T0100-Y00001-manual'\n"
2384 "Be careful to use at least one of %T and %Y, else newer "
2385 "savegames will overwrite old ones. If none of the formats "
2386 "is used '-T%04T-Y%05Y-%R' is appended to the value of "
2388 savename_validate
, NULL
, GAME_DEFAULT_SAVE_NAME
)
2390 GEN_BOOL("scorelog", game
.server
.scorelog
,
2391 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_SERVER_ONLY
,
2392 N_("Whether to log player statistics"),
2393 /* TRANS: The string between single quotes is a setting name and
2394 * should not be translated. */
2395 N_("If this is turned on, player statistics are appended to "
2396 "the file defined by the option 'scorefile' every turn. "
2397 "These statistics can be used to create power graphs after "
2398 "the game."), NULL
, scorelog_action
, GAME_DEFAULT_SCORELOG
)
2400 GEN_STRING("scorefile", game
.server
.scorefile
,
2401 SSET_META
, SSET_INTERNAL
, SSET_SITUATIONAL
, SSET_SERVER_ONLY
,
2402 N_("Name for the score log file"),
2403 /* TRANS: Don't translate the string in single quotes. */
2404 N_("The default name for the score log file is "
2405 "'freeciv-score.log'."),
2406 scorefile_validate
, NULL
, GAME_DEFAULT_SCOREFILE
)
2408 GEN_INT("maxconnectionsperhost", game
.server
.maxconnectionsperhost
,
2409 SSET_RULES_FLEXIBLE
, SSET_NETWORK
, SSET_RARE
, SSET_TO_CLIENT
,
2410 N_("Maximum number of connections to the server per host"),
2411 N_("New connections from a given host will be rejected if "
2412 "the total number of connections from the very same host "
2413 "equals or exceeds this value. A value of 0 means that "
2414 "there is no limit, at least up to the maximum number of "
2415 "connections supported by the server."), NULL
, NULL
,
2416 GAME_MIN_MAXCONNECTIONSPERHOST
, GAME_MAX_MAXCONNECTIONSPERHOST
,
2417 GAME_DEFAULT_MAXCONNECTIONSPERHOST
)
2419 GEN_INT("kicktime", game
.server
.kick_time
,
2420 SSET_RULES_FLEXIBLE
, SSET_NETWORK
, SSET_RARE
, SSET_SERVER_ONLY
,
2421 N_("Time before a kicked user can reconnect"),
2422 /* TRANS: the string in double quotes is a server command name and
2423 * should not be translated */
2424 N_("Gives the time in seconds before a user kicked using the "
2425 "\"kick\" command may reconnect. Changing this setting will "
2426 "affect users kicked in the past."), NULL
, NULL
,
2427 GAME_MIN_KICK_TIME
, GAME_MAX_KICK_TIME
, GAME_DEFAULT_KICK_TIME
)
2436 /* The number of settings, not including the END. */
2437 static const int SETTINGS_NUM
= ARRAY_SIZE(settings
);
2439 /****************************************************************************
2440 Returns the setting to the given id.
2441 ****************************************************************************/
2442 struct setting
*setting_by_number(int id
)
2444 return (0 <= id
&& id
< SETTINGS_NUM
? settings
+ id
: NULL
);
2447 /****************************************************************************
2448 Returns the setting to the given name.
2449 ****************************************************************************/
2450 struct setting
*setting_by_name(const char *name
)
2452 fc_assert_ret_val(name
, NULL
);
2454 settings_iterate(SSET_ALL
, pset
) {
2455 if (0 == strcmp(name
, pset
->name
)) {
2458 } settings_iterate_end
;
2462 /****************************************************************************
2463 Returns the id to the given setting.
2464 ****************************************************************************/
2465 int setting_number(const struct setting
*pset
)
2467 fc_assert_ret_val(pset
!= NULL
, -1);
2468 return pset
- settings
;
2471 /****************************************************************************
2472 Access function for the setting name.
2473 ****************************************************************************/
2474 const char *setting_name(const struct setting
*pset
)
2479 /****************************************************************************
2480 Access function for the short help (not translated yet) of the setting.
2481 ****************************************************************************/
2482 const char *setting_short_help(const struct setting
*pset
)
2484 return pset
->short_help
;
2487 /****************************************************************************
2488 Access function for the long (extra) help (not translated yet) of
2490 ****************************************************************************/
2491 const char *setting_extra_help(const struct setting
*pset
)
2493 return pset
->extra_help
;
2496 /****************************************************************************
2497 Access function for the setting type.
2498 ****************************************************************************/
2499 enum sset_type
setting_type(const struct setting
*pset
)
2504 /****************************************************************************
2505 Access function for the setting level (used by the /show command).
2506 ****************************************************************************/
2507 enum sset_level
setting_level(const struct setting
*pset
)
2509 return pset
->slevel
;
2512 /****************************************************************************
2513 Access function for the setting category.
2514 ****************************************************************************/
2515 enum sset_category
setting_category(const struct setting
*pset
)
2517 return pset
->scategory
;
2520 /****************************************************************************
2521 Returns whether the specified server setting (option) can currently
2522 be changed by the caller. If it returns FALSE, the reason of the failure
2523 is available by the function setting_error().
2524 ****************************************************************************/
2525 bool setting_is_changeable(const struct setting
*pset
,
2526 struct connection
*caller
, char *reject_msg
,
2527 size_t reject_msg_len
)
2530 && (caller
->access_level
< ALLOW_BASIC
2531 || (caller
->access_level
< ALLOW_HACK
&& !pset
->to_client
))) {
2532 settings_snprintf(reject_msg
, reject_msg_len
,
2533 _("You are not allowed to change the setting '%s'."),
2534 setting_name(pset
));
2538 if (setting_locked(pset
)) {
2539 /* setting is locked by the ruleset */
2540 settings_snprintf(reject_msg
, reject_msg_len
,
2541 _("The setting '%s' is locked by the ruleset."),
2542 setting_name(pset
));
2546 switch (pset
->sclass
) {
2549 /* Only change map options if we don't yet have a map: */
2550 if (map_is_empty()) {
2554 settings_snprintf(reject_msg
, reject_msg_len
,
2555 _("The setting '%s' can't be modified after the map "
2556 "is fixed."), setting_name(pset
));
2561 case SSET_GAME_INIT
:
2563 /* Only change start params and most rules if we don't yet have a map,
2564 * or if we do have a map but its a scenario one (ie, the game has
2565 * never actually been started).
2567 if (map_is_empty() || game
.info
.is_new_game
) {
2571 settings_snprintf(reject_msg
, reject_msg_len
,
2572 _("The setting '%s' can't be modified after the game "
2573 "has started."), setting_name(pset
));
2576 case SSET_RULES_FLEXIBLE
:
2578 /* These can always be changed: */
2582 log_error("Wrong class variant for setting %s (%d): %d.",
2583 setting_name(pset
), setting_number(pset
), pset
->sclass
);
2584 settings_snprintf(reject_msg
, reject_msg_len
, _("Internal error."));
2589 /****************************************************************************
2590 Returns whether the specified server setting (option) can be seen by the
2592 ****************************************************************************/
2593 bool setting_is_visible(const struct setting
*pset
,
2594 struct connection
*caller
)
2598 || caller
->access_level
>= ALLOW_HACK
);
2601 /****************************************************************************
2602 Convert the string prefix to an integer representation.
2603 NB: This function is used for SSET_ENUM *and* SSET_BITWISE.
2605 FIXME: this mostly duplicate match_prefix_full().
2606 ****************************************************************************/
2607 static enum m_pre_result
2608 setting_match_prefix_base(const val_name_func_t name_fn
,
2609 const char *prefix
, int *ind_result
,
2610 const char **matches
, size_t max_matches
,
2611 size_t *pnum_matches
)
2613 const struct sset_val_name
*name
;
2614 size_t len
= strlen(prefix
);
2624 for (i
= 0, num_matches
= 0; (name
= name_fn(i
)); i
++) {
2625 if (0 == fc_strncasecmp(name
->support
, prefix
, len
)) {
2626 if (strlen(name
->support
) == len
) {
2630 if (num_matches
< max_matches
) {
2631 matches
[num_matches
] = name
->support
;
2634 if (0 == num_matches
++) {
2640 if (1 == num_matches
) {
2642 } else if (1 < num_matches
) {
2643 return M_PRE_AMBIGUOUS
;
2649 /****************************************************************************
2650 Convert the string prefix to an integer representation.
2651 NB: This function is used for SSET_ENUM *and* SSET_BITWISE.
2652 ****************************************************************************/
2653 static bool setting_match_prefix(const val_name_func_t name_fn
,
2654 const char *prefix
, int *pvalue
,
2656 size_t reject_msg_len
)
2658 const char *matches
[16];
2661 switch (setting_match_prefix_base(name_fn
, prefix
, pvalue
, matches
,
2662 ARRAY_SIZE(matches
), &num_matches
)) {
2665 return TRUE
; /* Ok. */
2666 case M_PRE_AMBIGUOUS
:
2668 struct astring astr
= ASTRING_INIT
;
2670 fc_assert(2 <= num_matches
);
2671 settings_snprintf(reject_msg
, reject_msg_len
,
2672 _("\"%s\" prefix is ambiguous. Candidates are: %s."),
2674 astr_build_and_list(&astr
, matches
, num_matches
));
2679 settings_snprintf(reject_msg
, reject_msg_len
, _("Missing value."));
2687 settings_snprintf(reject_msg
, reject_msg_len
,
2688 _("No match for \"%s\"."), prefix
);
2692 /****************************************************************************
2693 Compute the string representation of the value for this boolean setting.
2694 ****************************************************************************/
2695 static const char *setting_bool_to_str(const struct setting
*pset
,
2696 bool value
, bool pretty
,
2697 char *buf
, size_t buf_len
)
2699 const struct sset_val_name
*name
= pset
->boolean
.name(value
);
2702 fc_snprintf(buf
, buf_len
, "%s", Q_(name
->pretty
));
2704 fc_strlcpy(buf
, name
->support
, buf_len
);
2709 /****************************************************************************
2710 Returns TRUE if 'val' is a valid value for this setting. If it's not,
2711 the reason of the failure is available in the optionnal parameter
2714 FIXME: also check the access level of pconn.
2715 ****************************************************************************/
2716 static bool setting_bool_validate_base(const struct setting
*pset
,
2717 const char *val
, int *pint_val
,
2718 struct connection
*caller
,
2720 size_t reject_msg_len
)
2724 if (SSET_BOOL
!= pset
->stype
) {
2725 settings_snprintf(reject_msg
, reject_msg_len
,
2726 _("This setting is not a boolean."));
2730 sz_strlcpy(buf
, val
);
2731 remove_leading_trailing_spaces(buf
);
2733 return (setting_match_prefix(pset
->boolean
.name
, buf
, pint_val
,
2734 reject_msg
, reject_msg_len
)
2735 && (NULL
== pset
->boolean
.validate
2736 || pset
->boolean
.validate(0 != *pint_val
, caller
, reject_msg
,
2740 /****************************************************************************
2741 Set the setting to 'val'. Returns TRUE on success. If it's not,
2742 the reason of the failure is available in the optionnal parameter
2744 ****************************************************************************/
2745 bool setting_bool_set(struct setting
*pset
, const char *val
,
2746 struct connection
*caller
, char *reject_msg
,
2747 size_t reject_msg_len
)
2751 if (!setting_is_changeable(pset
, caller
, reject_msg
, reject_msg_len
)
2752 || !setting_bool_validate_base(pset
, val
, &int_val
, caller
,
2753 reject_msg
, reject_msg_len
)) {
2757 *pset
->boolean
.pvalue
= (0 != int_val
);
2761 /****************************************************************************
2762 Returns TRUE if 'val' is a valid value for this setting. If it's not,
2763 the reason of the failure is available in the optionnal parameter
2765 ****************************************************************************/
2766 bool setting_bool_validate(const struct setting
*pset
, const char *val
,
2767 struct connection
*caller
, char *reject_msg
,
2768 size_t reject_msg_len
)
2772 return setting_bool_validate_base(pset
, val
, &int_val
, caller
,
2773 reject_msg
, reject_msg_len
);
2776 /****************************************************************************
2777 Convert the integer to the long support string representation of a boolean
2778 setting. This function must match the secfile_enum_name_data_fn_t type.
2779 ****************************************************************************/
2780 static const char *setting_bool_secfile_str(secfile_data_t data
, int val
)
2782 const struct sset_val_name
*name
=
2783 ((const struct setting
*) data
)->boolean
.name(val
);
2785 return (NULL
!= name
? name
->support
: NULL
);
2788 /****************************************************************************
2789 Compute the string representation of the value for this integer setting.
2790 ****************************************************************************/
2791 static const char *setting_int_to_str(const struct setting
*pset
,
2792 int value
, bool pretty
,
2793 char *buf
, size_t buf_len
)
2795 fc_snprintf(buf
, buf_len
, "%d", value
);
2799 /****************************************************************************
2800 Returns the minimal integer value for this setting.
2801 ****************************************************************************/
2802 int setting_int_min(const struct setting
*pset
)
2804 fc_assert_ret_val(pset
->stype
== SSET_INT
, 0);
2805 return pset
->integer
.min_value
;
2808 /****************************************************************************
2809 Returns the maximal integer value for this setting.
2810 ****************************************************************************/
2811 int setting_int_max(const struct setting
*pset
)
2813 fc_assert_ret_val(pset
->stype
== SSET_INT
, 0);
2814 return pset
->integer
.max_value
;
2817 /****************************************************************************
2818 Set the setting to 'val'. Returns TRUE on success. If it fails, the
2819 reason of the failure is available by the function setting_error().
2820 ****************************************************************************/
2821 bool setting_int_set(struct setting
*pset
, int val
,
2822 struct connection
*caller
, char *reject_msg
,
2823 size_t reject_msg_len
)
2825 if (!setting_is_changeable(pset
, caller
, reject_msg
, reject_msg_len
)
2826 || !setting_int_validate(pset
, val
, caller
, reject_msg
,
2831 *pset
->integer
.pvalue
= val
;
2835 /****************************************************************************
2836 Returns TRUE if 'val' is a valid value for this setting. If it's not,
2837 the reason of the failure is available by the function setting_error().
2839 FIXME: also check the access level of pconn.
2840 ****************************************************************************/
2841 bool setting_int_validate(const struct setting
*pset
, int val
,
2842 struct connection
*caller
, char *reject_msg
,
2843 size_t reject_msg_len
)
2845 if (SSET_INT
!= pset
->stype
) {
2846 settings_snprintf(reject_msg
, reject_msg_len
,
2847 _("This setting is not an integer."));
2851 if (val
< pset
->integer
.min_value
|| val
> pset
->integer
.max_value
) {
2852 settings_snprintf(reject_msg
, reject_msg_len
,
2853 _("Value out of range: %d (min: %d; max: %d)."),
2854 val
, pset
->integer
.min_value
, pset
->integer
.max_value
);
2858 return (!pset
->integer
.validate
2859 || pset
->integer
.validate(val
, caller
, reject_msg
,
2863 /****************************************************************************
2864 Compute the string representation of the value for this string setting.
2865 ****************************************************************************/
2866 static const char *setting_str_to_str(const struct setting
*pset
,
2867 const char *value
, bool pretty
,
2868 char *buf
, size_t buf_len
)
2871 fc_snprintf(buf
, buf_len
, "\"%s\"", value
);
2873 fc_strlcpy(buf
, value
, buf_len
);
2878 /****************************************************************************
2879 Set the setting to 'val'. Returns TRUE on success. If it fails, the
2880 reason of the failure is available by the function setting_error().
2881 ****************************************************************************/
2882 bool setting_str_set(struct setting
*pset
, const char *val
,
2883 struct connection
*caller
, char *reject_msg
,
2884 size_t reject_msg_len
)
2886 if (!setting_is_changeable(pset
, caller
, reject_msg
, reject_msg_len
)
2887 || !setting_str_validate(pset
, val
, caller
, reject_msg
,
2892 fc_strlcpy(pset
->string
.value
, val
, pset
->string
.value_size
);
2896 /****************************************************************************
2897 Returns TRUE if 'val' is a valid value for this setting. If it's not,
2898 the reason of the failure is available by the function setting_error().
2900 FIXME: also check the access level of pconn.
2901 ****************************************************************************/
2902 bool setting_str_validate(const struct setting
*pset
, const char *val
,
2903 struct connection
*caller
, char *reject_msg
,
2904 size_t reject_msg_len
)
2906 if (SSET_STRING
!= pset
->stype
) {
2907 settings_snprintf(reject_msg
, reject_msg_len
,
2908 _("This setting is not a string."));
2912 if (strlen(val
) >= pset
->string
.value_size
) {
2913 settings_snprintf(reject_msg
, reject_msg_len
,
2914 _("String value too long (max length: %lu)."),
2915 (unsigned long) pset
->string
.value_size
);
2919 return (!pset
->string
.validate
2920 || pset
->string
.validate(val
, caller
, reject_msg
,
2924 /****************************************************************************
2925 Convert the integer to the long support string representation of an
2926 enumerator. This function must match the secfile_enum_name_data_fn_t type.
2927 ****************************************************************************/
2928 static const char *setting_enum_secfile_str(secfile_data_t data
, int val
)
2930 const struct sset_val_name
*name
=
2931 ((const struct setting
*) data
)->enumerator
.name(val
);
2933 return (NULL
!= name
? name
->support
: NULL
);
2936 /****************************************************************************
2937 Convert the integer to the string representation of an enumerator.
2938 Return NULL if 'val' is not a valid enumerator.
2939 ****************************************************************************/
2940 const char *setting_enum_val(const struct setting
*pset
, int val
,
2943 const struct sset_val_name
*name
;
2945 fc_assert_ret_val(SSET_ENUM
== pset
->stype
, NULL
);
2946 name
= pset
->enumerator
.name(val
);
2949 } else if (pretty
) {
2950 return _(name
->pretty
);
2952 return name
->support
;
2956 /****************************************************************************
2957 Compute the string representation of the value for this enumerator
2959 ****************************************************************************/
2960 static const char *setting_enum_to_str(const struct setting
*pset
,
2961 int value
, bool pretty
,
2962 char *buf
, size_t buf_len
)
2964 const struct sset_val_name
*name
= pset
->enumerator
.name(value
);
2967 fc_snprintf(buf
, buf_len
, "\"%s\" (%s)",
2968 Q_(name
->pretty
), name
->support
);
2970 fc_strlcpy(buf
, name
->support
, buf_len
);
2975 /****************************************************************************
2976 Returns TRUE if 'val' is a valid value for this setting. If it's not,
2977 the reason of the failure is available in the optionnal parameter
2980 FIXME: also check the access level of pconn.
2981 ****************************************************************************/
2982 static bool setting_enum_validate_base(const struct setting
*pset
,
2983 const char *val
, int *pint_val
,
2984 struct connection
*caller
,
2986 size_t reject_msg_len
)
2990 if (SSET_ENUM
!= pset
->stype
) {
2991 settings_snprintf(reject_msg
, reject_msg_len
,
2992 _("This setting is not an enumerator."));
2996 sz_strlcpy(buf
, val
);
2997 remove_leading_trailing_spaces(buf
);
2999 return (setting_match_prefix(pset
->enumerator
.name
, buf
, pint_val
,
3000 reject_msg
, reject_msg_len
)
3001 && (NULL
== pset
->enumerator
.validate
3002 || pset
->enumerator
.validate(*pint_val
, caller
, reject_msg
,
3006 /****************************************************************************
3007 Helper function to write value to enumerator setting
3008 ****************************************************************************/
3009 static bool set_enum_value(struct setting
*pset
, int val
)
3011 switch(pset
->enumerator
.store_size
) {
3014 int *to_int
= pset
->enumerator
.pvalue
;
3021 char *to_char
= pset
->enumerator
.pvalue
;
3023 *to_char
= (char) val
;
3028 short *to_short
= pset
->enumerator
.pvalue
;
3030 *to_short
= (short) val
;
3040 /****************************************************************************
3041 Helper function to read value from enumerator setting
3042 ****************************************************************************/
3043 static int read_enum_value(const struct setting
*pset
)
3047 switch(pset
->enumerator
.store_size
) {
3049 val
= *((int *)pset
->enumerator
.pvalue
);
3052 val
= *((char *)pset
->enumerator
.pvalue
);
3055 val
= *((short *)pset
->enumerator
.pvalue
);
3058 log_error("Illegal enum store size %d, can't read value", pset
->enumerator
.store_size
);
3065 /****************************************************************************
3066 Set the setting to 'val'. Returns TRUE on success. If it fails, the
3067 reason of the failure is available in the optionnal parameter
3069 ****************************************************************************/
3070 bool setting_enum_set(struct setting
*pset
, const char *val
,
3071 struct connection
*caller
, char *reject_msg
,
3072 size_t reject_msg_len
)
3076 if (!setting_is_changeable(pset
, caller
, reject_msg
, reject_msg_len
)) {
3080 if (!setting_enum_validate_base(pset
, val
, &int_val
, caller
,
3081 reject_msg
, reject_msg_len
)) {
3085 if (!set_enum_value(pset
, int_val
)) {
3086 log_error("Illegal enumerator value size %d for %s",
3087 pset
->enumerator
.store_size
, val
);
3094 /****************************************************************************
3095 Returns TRUE if 'val' is a valid value for this setting. If it's not,
3096 the reason of the failure is available in the optionnal parameter
3098 ****************************************************************************/
3099 bool setting_enum_validate(const struct setting
*pset
, const char *val
,
3100 struct connection
*caller
, char *reject_msg
,
3101 size_t reject_msg_len
)
3105 return setting_enum_validate_base(pset
, val
, &int_val
, caller
,
3106 reject_msg
, reject_msg_len
);
3109 /****************************************************************************
3110 Convert the integer to the long support string representation of an
3111 enumerator. This function must match the secfile_enum_name_data_fn_t type.
3112 ****************************************************************************/
3113 static const char *setting_bitwise_secfile_str(secfile_data_t data
, int bit
)
3115 const struct sset_val_name
*name
=
3116 ((const struct setting
*) data
)->bitwise
.name(bit
);
3118 return (NULL
!= name
? name
->support
: NULL
);
3121 /****************************************************************************
3122 Convert the bit number to its string representation.
3123 Return NULL if 'bit' is not a valid bit.
3124 ****************************************************************************/
3125 const char *setting_bitwise_bit(const struct setting
*pset
,
3126 int bit
, bool pretty
)
3128 const struct sset_val_name
*name
;
3130 fc_assert_ret_val(SSET_BITWISE
== pset
->stype
, NULL
);
3131 name
= pset
->bitwise
.name(bit
);
3134 } else if (pretty
) {
3135 return _(name
->pretty
);
3137 return name
->support
;
3141 /****************************************************************************
3142 Compute the string representation of the value for this bitwise setting.
3143 ****************************************************************************/
3144 static const char *setting_bitwise_to_str(const struct setting
*pset
,
3145 unsigned value
, bool pretty
,
3146 char *buf
, size_t buf_len
)
3148 const struct sset_val_name
*name
;
3149 char *old_buf
= buf
;
3154 struct astring astr
= ASTRING_INIT
;
3155 struct strvec
*vec
= strvec_new();
3158 for (bit
= 0; (name
= pset
->bitwise
.name(bit
)); bit
++) {
3159 if ((1 << bit
) & value
) {
3160 /* TRANS: only emphasizing a string. */
3161 fc_snprintf(buf2
, sizeof(buf2
), _("\"%s\""), Q_(name
->pretty
));
3162 strvec_append(vec
, buf2
);
3166 if (0 == strvec_size(vec
)) {
3168 fc_assert(0 == value
);
3169 /* TRANS: Bitwise setting has no bits set. */
3170 fc_strlcpy(buf
, _("empty value"), buf_len
);
3171 strvec_destroy(vec
);
3175 strvec_to_and_list(vec
, &astr
);
3176 strvec_destroy(vec
);
3177 fc_strlcpy(buf
, astr_str(&astr
), buf_len
);
3179 fc_strlcat(buf
, " (", buf_len
);
3185 /* Long support part. */
3187 for (bit
= 0; (name
= pset
->bitwise
.name(bit
)); bit
++) {
3188 if ((1 << bit
) & value
) {
3189 if ('\0' != buf
[0]) {
3190 fc_strlcat(buf
, "|", buf_len
);
3192 fc_strlcat(buf
, name
->support
, buf_len
);
3197 fc_strlcat(buf
, ")", buf_len
);
3202 /****************************************************************************
3203 Returns TRUE if 'val' is a valid value for this setting. If it's not,
3204 the reason of the failure is available in the optionnal parameter
3207 FIXME: also check the access level of pconn.
3208 ****************************************************************************/
3209 static bool setting_bitwise_validate_base(const struct setting
*pset
,
3212 struct connection
*caller
,
3214 size_t reject_msg_len
)
3220 if (SSET_BITWISE
!= pset
->stype
) {
3221 settings_snprintf(reject_msg
, reject_msg_len
,
3222 _("This setting is not a bitwise."));
3228 /* Value names are separated by '|'. */
3230 p
= strchr(val
, '|');
3233 fc_strlcpy(buf
, val
, MIN(p
- val
, sizeof(buf
)));
3235 /* Last segment, full copy. */
3236 sz_strlcpy(buf
, val
);
3238 remove_leading_trailing_spaces(buf
);
3239 if (NULL
== p
&& '\0' == buf
[0] && 0 == *pint_val
) {
3240 /* Empty string = value 0. */
3242 } else if (!setting_match_prefix(pset
->bitwise
.name
, buf
, &bit
,
3243 reject_msg
, reject_msg_len
)) {
3246 *pint_val
|= 1 << bit
;
3248 } while (NULL
!= p
);
3250 return (NULL
== pset
->bitwise
.validate
3251 || pset
->bitwise
.validate(*pint_val
, caller
,
3252 reject_msg
, reject_msg_len
));
3255 /****************************************************************************
3256 Set the setting to 'val'. Returns TRUE on success. If it fails, the
3257 reason of the failure is available in the optionnal parameter
3259 ****************************************************************************/
3260 bool setting_bitwise_set(struct setting
*pset
, const char *val
,
3261 struct connection
*caller
, char *reject_msg
,
3262 size_t reject_msg_len
)
3266 if (!setting_is_changeable(pset
, caller
, reject_msg
, reject_msg_len
)
3267 || !setting_bitwise_validate_base(pset
, val
, &int_val
, caller
,
3268 reject_msg
, reject_msg_len
)) {
3272 *pset
->bitwise
.pvalue
= int_val
;
3276 /****************************************************************************
3277 Returns TRUE if 'val' is a valid value for this setting. If it's not,
3278 the reason of the failure is available in the optionnal parameter
3280 ****************************************************************************/
3281 bool setting_bitwise_validate(const struct setting
*pset
, const char *val
,
3282 struct connection
*caller
, char *reject_msg
,
3283 size_t reject_msg_len
)
3287 return setting_bitwise_validate_base(pset
, val
, &int_val
, caller
,
3288 reject_msg
, reject_msg_len
);
3291 /****************************************************************************
3292 Compute the name of the current value of the setting.
3293 ****************************************************************************/
3294 const char *setting_value_name(const struct setting
*pset
, bool pretty
,
3295 char *buf
, size_t buf_len
)
3297 fc_assert_ret_val(NULL
!= pset
, NULL
);
3298 fc_assert_ret_val(NULL
!= buf
, NULL
);
3299 fc_assert_ret_val(0 < buf_len
, NULL
);
3301 switch (pset
->stype
) {
3303 return setting_bool_to_str(pset
, *pset
->boolean
.pvalue
,
3304 pretty
, buf
, buf_len
);
3306 return setting_int_to_str(pset
, *pset
->integer
.pvalue
,
3307 pretty
, buf
, buf_len
);
3309 return setting_str_to_str(pset
, pset
->string
.value
,
3310 pretty
, buf
, buf_len
);
3312 return setting_enum_to_str(pset
, read_enum_value(pset
),
3313 pretty
, buf
, buf_len
);
3315 return setting_bitwise_to_str(pset
, *pset
->bitwise
.pvalue
,
3316 pretty
, buf
, buf_len
);
3319 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
3320 __FUNCTION__
, setting_name(pset
), setting_number(pset
));
3324 /****************************************************************************
3325 Compute the name of the default value of the setting.
3326 ****************************************************************************/
3327 const char *setting_default_name(const struct setting
*pset
, bool pretty
,
3328 char *buf
, size_t buf_len
)
3330 fc_assert_ret_val(NULL
!= pset
, NULL
);
3331 fc_assert_ret_val(NULL
!= buf
, NULL
);
3332 fc_assert_ret_val(0 < buf_len
, NULL
);
3334 switch (pset
->stype
) {
3336 return setting_bool_to_str(pset
, pset
->boolean
.default_value
,
3337 pretty
, buf
, buf_len
);
3339 return setting_int_to_str(pset
, pset
->integer
.default_value
,
3340 pretty
, buf
, buf_len
);
3342 return setting_str_to_str(pset
, pset
->string
.default_value
,
3343 pretty
, buf
, buf_len
);
3345 return setting_enum_to_str(pset
, pset
->enumerator
.default_value
,
3346 pretty
, buf
, buf_len
);
3348 return setting_bitwise_to_str(pset
, pset
->bitwise
.default_value
,
3349 pretty
, buf
, buf_len
);
3352 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
3353 __FUNCTION__
, setting_name(pset
), setting_number(pset
));
3357 /****************************************************************************
3358 Update the setting to the default value
3359 ****************************************************************************/
3360 static void setting_set_to_default(struct setting
*pset
)
3362 switch (pset
->stype
) {
3364 (*pset
->boolean
.pvalue
) = pset
->boolean
.default_value
;
3367 (*pset
->integer
.pvalue
) = pset
->integer
.default_value
;
3370 fc_strlcpy(pset
->string
.value
, pset
->string
.default_value
,
3371 pset
->string
.value_size
);
3374 set_enum_value(pset
, pset
->enumerator
.default_value
);
3377 (*pset
->bitwise
.pvalue
) = pset
->bitwise
.default_value
;
3382 /********************************************************************
3383 Execute the action callback if needed.
3384 *********************************************************************/
3385 void setting_action(const struct setting
*pset
)
3387 if (pset
->action
!= NULL
) {
3392 /**************************************************************************
3393 Load game settings from ruleset file 'game.ruleset'.
3394 **************************************************************************/
3395 bool settings_ruleset(struct section_file
*file
, const char *section
,
3401 /* Unlock all settings. */
3402 settings_iterate(SSET_ALL
, pset
) {
3403 setting_lock_set(pset
, FALSE
);
3404 setting_set_to_default(pset
);
3405 } settings_iterate_end
;
3408 if (NULL
== secfile_section_by_name(file
, section
)) {
3409 /* no settings in ruleset file */
3410 log_verbose("no [%s] section for game settings in %s", section
,
3411 secfile_name(file
));
3415 for (j
= 0; (name
= secfile_lookup_str_default(file
, NULL
, "%s.set%d.name",
3416 section
, j
)); j
++) {
3418 fc_snprintf(path
, sizeof(path
), "%s.set%d", section
, j
);
3420 if (!setting_ruleset_one(file
, name
, path
)) {
3421 log_error("unknown setting in '%s': %s", secfile_name(file
), name
);
3425 /* Execute all setting actions to consider actions due to the
3426 * default values. */
3428 settings_iterate(SSET_ALL
, pset
) {
3429 setting_action(pset
);
3430 } settings_iterate_end
;
3433 /* send game settings */
3434 send_server_settings(NULL
);
3439 /**************************************************************************
3440 Set one setting from the game.ruleset file.
3441 **************************************************************************/
3442 static bool setting_ruleset_one(struct section_file
*file
,
3443 const char *name
, const char *path
)
3445 struct setting
*pset
= NULL
;
3446 char reject_msg
[256], buf
[256];
3449 settings_iterate(SSET_ALL
, pset_check
) {
3450 if (0 == fc_strcasecmp(setting_name(pset_check
), name
)) {
3454 } settings_iterate_end
;
3457 /* no setting found */
3461 switch (pset
->stype
) {
3467 /* Allow string with same boolean representation as accepted on
3468 * server command line */
3469 if (secfile_lookup_enum_data(file
, &ival
, FALSE
,
3470 setting_bool_secfile_str
, pset
,
3471 "%s.value", path
)) {
3473 } else if (!secfile_lookup_bool(file
, &val
, "%s.value", path
)) {
3474 log_error("Can't read value for setting '%s': %s", name
,
3478 if (val
!= *pset
->boolean
.pvalue
) {
3479 if (NULL
== pset
->boolean
.validate
3480 || pset
->boolean
.validate(val
, NULL
, reject_msg
,
3481 sizeof(reject_msg
))) {
3482 *pset
->boolean
.pvalue
= val
;
3483 log_normal(_("Ruleset: '%s' has been set to %s."),
3485 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3487 log_error("%s", reject_msg
);
3497 if (!secfile_lookup_int(file
, &val
, "%s.value", path
)) {
3498 log_error("Can't read value for setting '%s': %s", name
,
3500 } else if (val
!= *pset
->integer
.pvalue
) {
3501 if (setting_int_set(pset
, val
, NULL
, reject_msg
,
3502 sizeof(reject_msg
))) {
3503 log_normal(_("Ruleset: '%s' has been set to %s."),
3505 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3507 log_error("%s", reject_msg
);
3515 const char *val
= secfile_lookup_str(file
, "%s.value", path
);
3518 log_error("Can't read value for setting '%s': %s", name
,
3520 } else if (0 != strcmp(val
, pset
->string
.value
)) {
3521 if (setting_str_set(pset
, val
, NULL
, reject_msg
,
3522 sizeof(reject_msg
))) {
3523 log_normal(_("Ruleset: '%s' has been set to %s."),
3525 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3527 log_error("%s", reject_msg
);
3537 if (!secfile_lookup_enum_data(file
, &val
, FALSE
,
3538 setting_enum_secfile_str
, pset
,
3539 "%s.value", path
)) {
3540 log_error("Can't read value for setting '%s': %s",
3541 name
, secfile_error());
3542 } else if (val
!= read_enum_value(pset
)) {
3543 if (NULL
== pset
->enumerator
.validate
3544 || pset
->enumerator
.validate(val
, NULL
, reject_msg
,
3545 sizeof(reject_msg
))) {
3546 set_enum_value(pset
, val
);
3547 log_normal(_("Ruleset: '%s' has been set to %s."),
3549 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3551 log_error("%s", reject_msg
);
3561 if (!secfile_lookup_enum_data(file
, &val
, TRUE
,
3562 setting_bitwise_secfile_str
, pset
,
3563 "%s.value", path
)) {
3564 log_error("Can't read value for setting '%s': %s",
3565 name
, secfile_error());
3566 } else if (val
!= *pset
->bitwise
.pvalue
) {
3567 if (NULL
== pset
->bitwise
.validate
3568 || pset
->bitwise
.validate((unsigned) val
, NULL
,
3569 reject_msg
, sizeof(reject_msg
))) {
3570 *pset
->bitwise
.pvalue
= val
;
3571 log_normal(_("Ruleset: '%s' has been set to %s."),
3573 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3575 log_error("%s", reject_msg
);
3583 lock
= secfile_lookup_bool_default(file
, FALSE
, "%s.lock", path
);
3587 setting_lock_set(pset
, lock
);
3588 log_normal(_("Ruleset: '%s' has been locked by the ruleset."),
3589 setting_name(pset
));
3595 /**************************************************************************
3596 Returns whether the setting has been changed (is not default).
3597 **************************************************************************/
3598 bool setting_changed(const struct setting
*pset
)
3600 switch (setting_type(pset
)) {
3602 return (*pset
->boolean
.pvalue
!= pset
->boolean
.default_value
);
3604 return (*pset
->integer
.pvalue
!= pset
->integer
.default_value
);
3606 return (0 != strcmp(pset
->string
.value
, pset
->string
.default_value
));
3608 return (read_enum_value(pset
) != pset
->enumerator
.default_value
);
3610 return (*pset
->bitwise
.pvalue
!= pset
->bitwise
.default_value
);
3613 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
3614 __FUNCTION__
, setting_name(pset
), setting_number(pset
));
3618 /**************************************************************************
3619 Returns if the setting is locked by the ruleset.
3620 **************************************************************************/
3621 bool setting_locked(const struct setting
*pset
)
3623 return pset
->locked
;
3626 /**************************************************************************
3627 Set the value for the lock of a setting.
3628 **************************************************************************/
3629 void setting_lock_set(struct setting
*pset
, bool lock
)
3631 pset
->locked
= lock
;
3634 /**************************************************************************
3635 Save the setting value of the current game.
3636 **************************************************************************/
3637 static void setting_game_set(struct setting
*pset
, bool init
)
3639 switch (setting_type(pset
)) {
3641 pset
->boolean
.game_value
= *pset
->boolean
.pvalue
;
3645 pset
->integer
.game_value
= *pset
->integer
.pvalue
;
3650 pset
->string
.game_value
3651 = fc_calloc(1, pset
->string
.value_size
3652 * sizeof(pset
->string
.game_value
));
3654 fc_strlcpy(pset
->string
.game_value
, pset
->string
.value
,
3655 pset
->string
.value_size
);
3659 pset
->enumerator
.game_value
= read_enum_value(pset
);
3663 pset
->bitwise
.game_value
= *pset
->bitwise
.pvalue
;
3668 /**************************************************************************
3669 Free the memory used for the settings at game start.
3670 **************************************************************************/
3671 static void setting_game_free(struct setting
*pset
)
3673 if (setting_type(pset
) == SSET_STRING
) {
3674 FC_FREE(pset
->string
.game_value
);
3678 /**************************************************************************
3679 Restore the setting to the value used at the start of the current game.
3680 **************************************************************************/
3681 static void setting_game_restore(struct setting
*pset
)
3683 char reject_msg
[256] = "", buf
[256];
3686 if (!setting_is_changeable(pset
, NULL
, reject_msg
, sizeof(reject_msg
))) {
3687 log_debug("Can't restore '%s': %s", setting_name(pset
),
3692 switch (setting_type(pset
)) {
3694 res
= (NULL
!= setting_bool_to_str(pset
, pset
->boolean
.game_value
,
3695 FALSE
, buf
, sizeof(buf
))
3696 && setting_bool_set(pset
, buf
, NULL
, reject_msg
,
3697 sizeof(reject_msg
)));
3701 res
= setting_int_set(pset
, pset
->integer
.game_value
, NULL
, reject_msg
,
3702 sizeof(reject_msg
));
3706 res
= setting_str_set(pset
, pset
->string
.game_value
, NULL
, reject_msg
,
3707 sizeof(reject_msg
));
3711 res
= (NULL
!= setting_enum_to_str(pset
, pset
->enumerator
.game_value
,
3712 FALSE
, buf
, sizeof(buf
))
3713 && setting_enum_set(pset
, buf
, NULL
, reject_msg
,
3714 sizeof(reject_msg
)));
3718 res
= (NULL
!= setting_bitwise_to_str(pset
, pset
->bitwise
.game_value
,
3719 FALSE
, buf
, sizeof(buf
))
3720 && setting_bitwise_set(pset
, buf
, NULL
, reject_msg
,
3721 sizeof(reject_msg
)));
3726 log_error("Error restoring setting '%s' to the value from game start: "
3727 "%s", setting_name(pset
), reject_msg
);
3731 /**************************************************************************
3732 Save setting values at the start of the game.
3733 **************************************************************************/
3734 void settings_game_start(void)
3736 settings_iterate(SSET_ALL
, pset
) {
3737 setting_game_set(pset
, FALSE
);
3738 } settings_iterate_end
;
3740 /* Settings from the start of the game are saved. */
3741 game
.server
.settings_gamestart_valid
= TRUE
;
3744 /********************************************************************
3746 *********************************************************************/
3747 void settings_game_save(struct section_file
*file
, const char *section
)
3751 settings_iterate(SSET_ALL
, pset
) {
3752 secfile_insert_str(file
, setting_name(pset
),
3753 "%s.set%d.name", section
, set_count
);
3754 switch (setting_type(pset
)) {
3756 secfile_insert_bool(file
, *pset
->boolean
.pvalue
,
3757 "%s.set%d.value", section
, set_count
);
3758 secfile_insert_bool(file
, pset
->boolean
.game_value
,
3759 "%s.set%d.gamestart", section
, set_count
);
3762 secfile_insert_int(file
, *pset
->integer
.pvalue
,
3763 "%s.set%d.value", section
, set_count
);
3764 secfile_insert_int(file
, pset
->integer
.game_value
,
3765 "%s.set%d.gamestart", section
, set_count
);
3768 secfile_insert_str(file
, pset
->string
.value
,
3769 "%s.set%d.value", section
, set_count
);
3770 secfile_insert_str(file
, pset
->string
.game_value
,
3771 "%s.set%d.gamestart", section
, set_count
);
3774 secfile_insert_enum_data(file
, read_enum_value(pset
), FALSE
,
3775 setting_enum_secfile_str
, pset
,
3776 "%s.set%d.value", section
, set_count
);
3777 secfile_insert_enum_data(file
, pset
->enumerator
.game_value
, FALSE
,
3778 setting_enum_secfile_str
, pset
,
3779 "%s.set%d.gamestart", section
, set_count
);
3782 secfile_insert_enum_data(file
, *pset
->bitwise
.pvalue
, TRUE
,
3783 setting_bitwise_secfile_str
, pset
,
3784 "%s.set%d.value", section
, set_count
);
3785 secfile_insert_enum_data(file
, pset
->bitwise
.game_value
, TRUE
,
3786 setting_bitwise_secfile_str
, pset
,
3787 "%s.set%d.gamestart", section
, set_count
);
3791 } settings_iterate_end
;
3793 secfile_insert_int(file
, set_count
, "%s.set_count", section
);
3794 secfile_insert_bool(file
, game
.server
.settings_gamestart_valid
,
3795 "%s.gamestart_valid", section
);
3798 /********************************************************************
3799 Restore all settings from a savegame.
3800 *********************************************************************/
3801 void settings_game_load(struct section_file
*file
, const char *section
)
3804 char reject_msg
[256], buf
[256];
3806 int oldcitymindist
= game
.info
.citymindist
; /* backwards compat, see below */
3808 /* Compatibility with savegames created with older versions is usually
3809 * handled as conversions in savegame2.c compat_load_<version>() */
3811 if (!secfile_lookup_int(file
, &set_count
, "%s.set_count", section
)) {
3812 /* Old savegames and scenarios doesn't contain this, not an error. */
3813 log_verbose("Can't read the number of settings in the save file.");
3817 /* Check if the saved settings are valid settings from game start. */
3818 game
.server
.settings_gamestart_valid
3819 = secfile_lookup_bool_default(file
, FALSE
, "%s.gamestart_valid",
3822 for (i
= 0; i
< set_count
; i
++) {
3823 name
= secfile_lookup_str(file
, "%s.set%d.name", section
, i
);
3825 settings_iterate(SSET_ALL
, pset
) {
3826 if (fc_strcasecmp(setting_name(pset
), name
) != 0) {
3830 /* Load the current value of the setting. */
3831 switch (pset
->stype
) {
3836 if (!secfile_lookup_bool(file
, &val
, "%s.set%d.value", section
,
3838 log_verbose("Option '%s' not defined in the savegame: %s", name
,
3840 } else if (val
!= *pset
->boolean
.pvalue
) {
3841 if (setting_is_changeable(pset
, NULL
, reject_msg
,
3843 && (NULL
== pset
->boolean
.validate
3844 || pset
->boolean
.validate(val
, NULL
, reject_msg
,
3845 sizeof(reject_msg
)))) {
3846 *pset
->boolean
.pvalue
= val
;
3847 log_normal(_("Savegame: '%s' has been set to %s."),
3849 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3851 log_error("Savegame: error restoring '%s' . (%s)",
3852 setting_name(pset
), reject_msg
);
3862 if (!secfile_lookup_int(file
, &val
, "%s.set%d.value", section
, i
)) {
3863 log_verbose("Option '%s' not defined in the savegame: %s", name
,
3865 } else if (val
!= *pset
->integer
.pvalue
) {
3866 if (setting_is_changeable(pset
, NULL
, reject_msg
,
3868 && (NULL
== pset
->integer
.validate
3869 || pset
->integer
.validate(val
, NULL
, reject_msg
,
3870 sizeof(reject_msg
)))) {
3871 *pset
->integer
.pvalue
= val
;
3872 log_normal(_("Savegame: '%s' has been set to %s."),
3874 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3876 log_error("Savegame: error restoring '%s' . (%s)",
3877 setting_name(pset
), reject_msg
);
3885 const char *val
= secfile_lookup_str(file
, "%s.set%d.value",
3889 log_verbose("Option '%s' not defined in the savegame: %s", name
,
3891 } else if (0 != strcmp(val
, pset
->string
.value
)) {
3892 if (setting_str_set(pset
, val
, NULL
, reject_msg
,
3893 sizeof(reject_msg
))) {
3894 log_normal(_("Savegame: '%s' has been set to %s."),
3896 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3898 log_error("Savegame: error restoring '%s' . (%s)",
3899 setting_name(pset
), reject_msg
);
3909 if (!secfile_lookup_enum_data(file
, &val
, FALSE
,
3910 setting_enum_secfile_str
, pset
,
3911 "%s.set%d.value", section
, i
)) {
3912 log_verbose("Option '%s' not defined in the savegame: %s", name
,
3914 } else if (val
!= read_enum_value(pset
)) {
3915 if (setting_is_changeable(pset
, NULL
, reject_msg
,
3917 && (NULL
== pset
->enumerator
.validate
3918 || pset
->enumerator
.validate(val
, NULL
, reject_msg
,
3919 sizeof(reject_msg
)))) {
3920 set_enum_value(pset
, val
);
3921 log_normal(_("Savegame: '%s' has been set to %s."),
3923 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3925 log_error("Savegame: error restoring '%s' . (%s)",
3926 setting_name(pset
), reject_msg
);
3936 if (!secfile_lookup_enum_data(file
, &val
, TRUE
,
3937 setting_bitwise_secfile_str
, pset
,
3938 "%s.set%d.value", section
, i
)) {
3939 log_verbose("Option '%s' not defined in the savegame: %s", name
,
3941 } else if (val
!= *pset
->bitwise
.pvalue
) {
3942 if (setting_is_changeable(pset
, NULL
, reject_msg
,
3944 && (NULL
== pset
->bitwise
.validate
3945 || pset
->bitwise
.validate(val
, NULL
, reject_msg
,
3946 sizeof(reject_msg
)))) {
3947 *pset
->bitwise
.pvalue
= val
;
3948 log_normal(_("Savegame: '%s' has been set to %s."),
3950 setting_value_name(pset
, TRUE
, buf
, sizeof(buf
)));
3952 log_error("Savegame: error restoring '%s' . (%s)",
3953 setting_name(pset
), reject_msg
);
3960 if (game
.server
.settings_gamestart_valid
) {
3961 /* Load the value of the setting at the start of the game. */
3962 switch (pset
->stype
) {
3964 pset
->boolean
.game_value
=
3965 secfile_lookup_bool_default(file
, *pset
->boolean
.pvalue
,
3966 "%s.set%d.gamestart", section
, i
);
3970 pset
->integer
.game_value
=
3971 secfile_lookup_int_default(file
, *pset
->integer
.pvalue
,
3972 "%s.set%d.gamestart", section
, i
);
3976 fc_strlcpy(pset
->string
.game_value
,
3977 secfile_lookup_str_default(file
, pset
->string
.value
,
3978 "%s.set%d.gamestart",
3980 pset
->string
.value_size
);
3984 pset
->enumerator
.game_value
=
3985 secfile_lookup_enum_default_data(file
,
3986 read_enum_value(pset
), FALSE
, setting_enum_secfile_str
,
3987 pset
, "%s.set%d.gamestart", section
, i
);
3991 pset
->bitwise
.game_value
=
3992 secfile_lookup_enum_default_data(file
,
3993 *pset
->bitwise
.pvalue
, TRUE
, setting_bitwise_secfile_str
,
3994 pset
, "%s.set%d.gamestart", section
, i
);
3998 } settings_iterate_end
;
4001 /* Backwards compatibility for pre-2.4 savegames: citymindist=0 used to mean
4002 * take from ruleset min_dist_bw_cities, but that no longer exists.
4003 * This is here rather than in savegame2.c compat functions, as we need
4004 * to have loaded the relevant ruleset to know what to set it to (the
4005 * ruleset and any 'citymindist' setting it contains will have been loaded
4006 * before this function was called). */
4007 if (game
.info
.citymindist
== 0) {
4008 game
.info
.citymindist
= oldcitymindist
;
4011 settings_iterate(SSET_ALL
, pset
) {
4012 /* Have to do this at the end due to dependencies ('aifill' and
4014 setting_action(pset
);
4015 } settings_iterate_end
;
4018 /**************************************************************************
4019 Reset all settings to the values at game start.
4020 **************************************************************************/
4021 bool settings_game_reset(void)
4023 if (!game
.server
.settings_gamestart_valid
) {
4024 log_debug("No saved settings from the game start available.");
4028 settings_iterate(SSET_ALL
, pset
) {
4029 setting_game_restore(pset
);
4030 } settings_iterate_end
;
4035 /**************************************************************************
4036 Initialize stuff related to this code module.
4037 **************************************************************************/
4038 void settings_init(bool act
)
4040 settings_list_init();
4042 settings_iterate(SSET_ALL
, pset
) {
4043 setting_lock_set(pset
, FALSE
);
4044 setting_set_to_default(pset
);
4045 setting_game_set(pset
, TRUE
);
4047 setting_action(pset
);
4049 } settings_iterate_end
;
4051 settings_list_update();
4054 /********************************************************************
4055 Reset all settings iff they are changeable.
4056 *********************************************************************/
4057 void settings_reset(void)
4059 settings_iterate(SSET_ALL
, pset
) {
4060 if (setting_is_changeable(pset
, NULL
, NULL
, 0)) {
4061 setting_set_to_default(pset
);
4062 setting_action(pset
);
4064 } settings_iterate_end
;
4067 /**************************************************************************
4068 Update stuff every turn that is related to this code module. Run this
4070 **************************************************************************/
4071 void settings_turn(void)
4073 /* Nothing at the moment. */
4076 /**************************************************************************
4077 Deinitialize stuff related to this code module.
4078 **************************************************************************/
4079 void settings_free(void)
4081 settings_iterate(SSET_ALL
, pset
) {
4082 setting_game_free(pset
);
4083 } settings_iterate_end
;
4085 settings_list_free();
4088 /****************************************************************************
4089 Returns the total number of settings.
4090 ****************************************************************************/
4091 int settings_number(void)
4093 return SETTINGS_NUM
;
4096 /****************************************************************************
4097 Tell the client about just one server setting. Call this after a setting
4099 ****************************************************************************/
4100 void send_server_setting(struct conn_list
*dest
, const struct setting
*pset
)
4103 dest
= game
.est_connections
;
4106 #define PACKET_COMMON_INIT(packet, pset, pconn) \
4107 memset(&packet, 0, sizeof(packet)); \
4108 packet.id = setting_number(pset); \
4109 packet.is_visible = setting_is_visible(pset, pconn); \
4110 packet.is_changeable = setting_is_changeable(pset, pconn, NULL, 0); \
4111 packet.initial_setting = game.info.is_new_game;
4113 switch (setting_type(pset
)) {
4116 struct packet_server_setting_bool packet
;
4118 conn_list_iterate(dest
, pconn
) {
4119 PACKET_COMMON_INIT(packet
, pset
, pconn
);
4120 if (packet
.is_visible
) {
4121 packet
.val
= *pset
->boolean
.pvalue
;
4122 packet
.default_val
= pset
->boolean
.default_value
;
4124 send_packet_server_setting_bool(pconn
, &packet
);
4125 } conn_list_iterate_end
;
4130 struct packet_server_setting_int packet
;
4132 conn_list_iterate(dest
, pconn
) {
4133 PACKET_COMMON_INIT(packet
, pset
, pconn
);
4134 if (packet
.is_visible
) {
4135 packet
.val
= *pset
->integer
.pvalue
;
4136 packet
.default_val
= pset
->integer
.default_value
;
4137 packet
.min_val
= pset
->integer
.min_value
;
4138 packet
.max_val
= pset
->integer
.max_value
;
4140 send_packet_server_setting_int(pconn
, &packet
);
4141 } conn_list_iterate_end
;
4146 struct packet_server_setting_str packet
;
4148 conn_list_iterate(dest
, pconn
) {
4149 PACKET_COMMON_INIT(packet
, pset
, pconn
);
4150 if (packet
.is_visible
) {
4151 sz_strlcpy(packet
.val
, pset
->string
.value
);
4152 sz_strlcpy(packet
.default_val
, pset
->string
.default_value
);
4154 send_packet_server_setting_str(pconn
, &packet
);
4155 } conn_list_iterate_end
;
4160 struct packet_server_setting_enum packet
;
4161 const struct sset_val_name
*val_name
;
4164 conn_list_iterate(dest
, pconn
) {
4165 PACKET_COMMON_INIT(packet
, pset
, pconn
);
4166 if (packet
.is_visible
) {
4167 packet
.val
= read_enum_value(pset
);
4168 packet
.default_val
= pset
->enumerator
.default_value
;
4169 for (i
= 0; (val_name
= pset
->enumerator
.name(i
)); i
++) {
4170 sz_strlcpy(packet
.support_names
[i
], val_name
->support
);
4171 /* Send untranslated string */
4172 sz_strlcpy(packet
.pretty_names
[i
], val_name
->pretty
);
4174 packet
.values_num
= i
;
4175 fc_assert(i
<= ARRAY_SIZE(packet
.support_names
));
4176 fc_assert(i
<= ARRAY_SIZE(packet
.pretty_names
));
4178 send_packet_server_setting_enum(pconn
, &packet
);
4179 } conn_list_iterate_end
;
4184 struct packet_server_setting_bitwise packet
;
4185 const struct sset_val_name
*val_name
;
4188 conn_list_iterate(dest
, pconn
) {
4189 PACKET_COMMON_INIT(packet
, pset
, pconn
);
4190 if (packet
.is_visible
) {
4191 packet
.val
= *pset
->bitwise
.pvalue
;
4192 packet
.default_val
= pset
->bitwise
.default_value
;
4193 for (i
= 0; (val_name
= pset
->bitwise
.name(i
)); i
++) {
4194 sz_strlcpy(packet
.support_names
[i
], val_name
->support
);
4195 /* Send untranslated string */
4196 sz_strlcpy(packet
.pretty_names
[i
], val_name
->pretty
);
4198 packet
.bits_num
= i
;
4199 fc_assert(i
<= ARRAY_SIZE(packet
.support_names
));
4200 fc_assert(i
<= ARRAY_SIZE(packet
.pretty_names
));
4202 send_packet_server_setting_bitwise(pconn
, &packet
);
4203 } conn_list_iterate_end
;
4211 /****************************************************************************
4212 Tell the client about all server settings.
4213 ****************************************************************************/
4214 void send_server_settings(struct conn_list
*dest
)
4216 settings_iterate(SSET_ALL
, pset
) {
4217 send_server_setting(dest
, pset
);
4218 } settings_iterate_end
;
4221 /****************************************************************************
4222 Send the ALLOW_HACK server settings. Usually called when the access level
4223 of the user changes.
4224 ****************************************************************************/
4225 void send_server_hack_level_settings(struct conn_list
*dest
)
4227 settings_iterate(SSET_ALL
, pset
) {
4228 if (!pset
->to_client
) {
4229 send_server_setting(dest
, pset
);
4231 } settings_iterate_end
;
4234 /****************************************************************************
4235 Tell the client about all server settings.
4236 ****************************************************************************/
4237 void send_server_setting_control(struct connection
*pconn
)
4239 struct packet_server_setting_control control
;
4240 struct packet_server_setting_const setting
;
4243 control
.settings_num
= SETTINGS_NUM
;
4245 /* Fill in the category strings. */
4246 fc_assert(SSET_NUM_CATEGORIES
<= ARRAY_SIZE(control
.category_names
));
4247 control
.categories_num
= SSET_NUM_CATEGORIES
;
4248 for (i
= 0; i
< SSET_NUM_CATEGORIES
; i
++) {
4249 /* Send untranslated name */
4250 sz_strlcpy(control
.category_names
[i
], sset_category_name(i
));
4253 /* Send off the control packet. */
4254 send_packet_server_setting_control(pconn
, &control
);
4256 /* Send the constant and common part of the settings. */
4257 settings_iterate(SSET_ALL
, pset
) {
4258 setting
.id
= setting_number(pset
);
4259 sz_strlcpy(setting
.name
, setting_name(pset
));
4260 /* Send untranslated strings to client */
4261 sz_strlcpy(setting
.short_help
, setting_short_help(pset
));
4262 sz_strlcpy(setting
.extra_help
, setting_extra_help(pset
));
4263 setting
.category
= pset
->scategory
;
4265 send_packet_server_setting_const(pconn
, &setting
);
4266 } settings_iterate_end
;
4269 /*****************************************************************************
4270 Initialise sorted settings.
4271 *****************************************************************************/
4272 static void settings_list_init(void)
4274 struct setting
*pset
;
4277 fc_assert_ret(setting_sorted
.init
== FALSE
);
4279 /* Do it for all values of enum sset_level. */
4280 for (i
= 0; i
< OLEVELS_NUM
; i
++) {
4281 setting_sorted
.level
[i
] = setting_list_new();
4284 for (i
= 0; (pset
= setting_by_number(i
)); i
++) {
4285 /* Add the setting to the list of all settings. */
4286 setting_list_append(setting_sorted
.level
[SSET_ALL
], pset
);
4288 switch (setting_level(pset
)) {
4290 /* No setting should be in this level. */
4291 fc_assert_msg(setting_level(pset
) != SSET_NONE
,
4292 "No setting level defined for '%s'.", setting_name(pset
));
4295 /* Done above - list of all settings. */
4298 setting_list_append(setting_sorted
.level
[SSET_VITAL
], pset
);
4300 case SSET_SITUATIONAL
:
4301 setting_list_append(setting_sorted
.level
[SSET_SITUATIONAL
], pset
);
4304 setting_list_append(setting_sorted
.level
[SSET_RARE
], pset
);
4308 /* This is done in settings_list_update. */
4311 /* No setting should be in this level. */
4312 fc_assert_msg(setting_level(pset
) != OLEVELS_NUM
,
4313 "Invalid setting level for '%s' (%s).",
4314 setting_name(pset
), sset_level_name(setting_level(pset
)));
4319 /* Sort the lists. */
4320 for (i
= 0; i
< OLEVELS_NUM
; i
++) {
4321 setting_list_sort(setting_sorted
.level
[i
], settings_list_cmp
);
4324 setting_sorted
.init
= TRUE
;
4327 /*****************************************************************************
4328 Update sorted settings (changed and locked values).
4329 *****************************************************************************/
4330 void settings_list_update(void)
4332 struct setting
*pset
;
4335 fc_assert_ret(setting_sorted
.init
== TRUE
);
4337 /* Clear the lists for changed and locked values. */
4338 setting_list_clear(setting_sorted
.level
[SSET_CHANGED
]);
4339 setting_list_clear(setting_sorted
.level
[SSET_LOCKED
]);
4342 for (i
= 0; (pset
= setting_by_number(i
)); i
++) {
4343 if (setting_changed(pset
)) {
4344 setting_list_append(setting_sorted
.level
[SSET_CHANGED
], pset
);
4346 if (setting_locked(pset
)) {
4347 setting_list_append(setting_sorted
.level
[SSET_LOCKED
], pset
);
4352 setting_list_sort(setting_sorted
.level
[SSET_CHANGED
], settings_list_cmp
);
4353 setting_list_sort(setting_sorted
.level
[SSET_LOCKED
], settings_list_cmp
);
4356 /*****************************************************************************
4357 Update sorted settings (changed and locked values).
4358 *****************************************************************************/
4359 int settings_list_cmp(const struct setting
*const *ppset1
,
4360 const struct setting
*const *ppset2
)
4362 const struct setting
*pset1
= *ppset1
;
4363 const struct setting
*pset2
= *ppset2
;
4365 return fc_strcasecmp(setting_name(pset1
), setting_name(pset2
));
4368 /*****************************************************************************
4369 Get a settings list of a certain level. Call settings_list_update() before
4370 if something was changed.
4371 *****************************************************************************/
4372 struct setting_list
*settings_list_get(enum sset_level level
)
4374 fc_assert_ret_val(setting_sorted
.init
== TRUE
, NULL
);
4375 fc_assert_ret_val(setting_sorted
.level
[level
] != NULL
, NULL
);
4376 fc_assert_ret_val(sset_level_is_valid(level
), NULL
);
4378 return setting_sorted
.level
[level
];
4381 /*****************************************************************************
4382 Free sorted settings.
4383 *****************************************************************************/
4384 static void settings_list_free(void)
4388 fc_assert_ret(setting_sorted
.init
== TRUE
);
4390 /* Free the lists. */
4391 for (i
= 0; i
< OLEVELS_NUM
; i
++) {
4392 setting_list_destroy(setting_sorted
.level
[i
]);
4395 setting_sorted
.init
= FALSE
;