Freeciv-3.4
Loading...
Searching...
No Matches
settings.c
Go to the documentation of this file.
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)
6 any later version.
7
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***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "astring.h"
20#include "fcintl.h"
21#include "game.h"
22#include "ioz.h"
23#include "log.h"
24#include "registry.h"
25#include "shared.h"
26#include "string_vector.h"
27
28/* common */
29#include "map.h"
30
31/* server */
32#include "aiiface.h"
33#include "gamehand.h"
34#include "maphand.h"
35#include "meta.h"
36#include "nation.h"
37#include "notify.h"
38#include "plrhand.h"
39#include "report.h"
40#include "rscompat.h"
41#include "rssanity.h"
42#include "setcompat.h"
43#include "srv_main.h"
44#include "stdinhand.h"
45
46#include "settings.h"
47
48/* The following classes determine what can be changed when.
49 * Actually, some of them have the same "changeability", but
50 * different types are separated here in case they have
51 * other uses.
52 * Also, SSET_GAME_INIT/SSET_RULES separate the two sections
53 * of server settings sent to the client.
54 * See the settings[] array and setting_is_changeable() for what
55 * these correspond to and explanations.
56 */
69
70typedef bool (*bool_validate_func_t) (bool value, struct connection *pconn,
71 char *reject_msg,
72 size_t reject_msg_len);
73typedef bool (*int_validate_func_t) (int value, struct connection *pconn,
74 char *reject_msg,
75 size_t reject_msg_len);
76typedef bool (*string_validate_func_t) (const char * value,
77 struct connection *pconn,
78 char *reject_msg,
79 size_t reject_msg_len);
80typedef bool (*enum_validate_func_t) (int value, struct connection *pconn,
81 char *reject_msg,
82 size_t reject_msg_len);
83typedef bool (*bitwise_validate_func_t) (unsigned value,
84 struct connection *pconn,
85 char *reject_msg,
86 size_t reject_msg_len);
87
88typedef void (*action_callback_func_t) (const struct setting *pset);
89typedef const char *(*help_callback_func_t) (const struct setting *pset);
90typedef const struct sset_val_name * (*val_name_func_t) (int value);
91
92struct setting {
93 const char *name;
95
96 /* What access level viewing and setting the setting requires. */
99
100 /*
101 * Should be less than 42 chars (?), or shorter if the values may
102 * have more than about 4 digits. Don't put "." on the end.
103 */
104 const char *short_help;
105
106 /*
107 * May be empty string, if short_help is sufficient. Need not
108 * include embedded newlines (but may, for formatting); lines will
109 * be wrapped (and indented) automatically. Should have punctuation
110 * etc, and should end with a "."
111 */
112 const char *extra_help;
113
114 /* help function */
116
120
121 /*
122 * About the *_validate functions: If the function is non-nullptr, it
123 * is called with the new value, and returns whether the change is
124 * legal. The char * is an error message in the case of reject.
125 */
126
127 union {
128 /*** bool part ***/
129 struct {
130 bool *const pvalue;
131 const bool default_value;
136 /*** int part ***/
137 struct {
138 int *const pvalue;
139 const int default_value;
140 const int min_value;
141 const int max_value;
145 /*** string part ***/
146 struct {
147 char *const value;
148 const char *const default_value;
149 const size_t value_size;
153 /*** enumerator part ***/
154 struct {
155 void *const pvalue;
156 const int store_size;
157 const int default_value;
159 const val_name_func_t name;
160 int game_value;
162 /*** bitwise part ***/
163 struct {
164 unsigned *const pvalue;
165 const unsigned default_value;
167 const val_name_func_t name;
168 unsigned game_value;
170 };
171
172 /* action function */
174
175 /* Lock for game settings */
177
178 /* Remember if there's also ruleset lock. */
179 bool rslock;
180
182
183 /* It's not "default", even if value is the same as default */
186};
187
188static struct {
189 bool init;
191} setting_sorted = { .init = FALSE };
192
193static void setting_ruleset_setdef(struct setting *pset);
194static bool setting_ruleset_one(struct section_file *file,
195 const char *name, const char *path,
196 bool compat);
197static void setting_game_set(struct setting *pset, bool init);
198static void setting_game_free(struct setting *pset);
199static void setting_game_restore(struct setting *pset);
200
201static void settings_list_init(void);
202static void settings_list_free(void);
203int settings_list_cmp(const struct setting *const *pset1,
204 const struct setting *const *pset2);
205
206#define settings_snprintf(_buf, _buf_len, format, ...) \
207 if (_buf != nullptr) { \
208 fc_snprintf(_buf, _buf_len, format, ## __VA_ARGS__); \
209 }
210
211static bool set_enum_value(struct setting *pset, int val);
212
213/****************************************************************************
214 Enumerator name accessors.
215
216 Important note about compatibility:
217 1) you cannot modify the support name of an existent value. However, in a
218 development, you can modify it if it wasn't included in any stable
219 branch before.
220 2) Take care of modifying the pretty name of an existent value: make sure
221 to modify the help texts which are using it.
222****************************************************************************/
223
224#define NAME_CASE(_val, _support, _pretty) \
225 case _val: \
226 { \
227 static const struct sset_val_name name = { _support, _pretty }; \
228 return &name; \
229 }
230
231/************************************************************************/
235{
236 switch (caravanbonus) {
237 /* TRANS: Description of caravan bonus style setting value. */
238 NAME_CASE(CBS_CLASSIC, "CLASSIC", N_("Classic Freeciv"));
239 NAME_CASE(CBS_LOGARITHMIC, "LOGARITHMIC", N_("Log^2 N style"));
240 }
241
242 return nullptr;
243}
244
245/************************************************************************/
249static const struct sset_val_name *mapsize_name(int mapsize)
250{
251 switch (mapsize) {
252 NAME_CASE(MAPSIZE_FULLSIZE, "FULLSIZE", N_("Number of tiles"));
253 NAME_CASE(MAPSIZE_PLAYER, "PLAYER", N_("Tiles per player"));
254 NAME_CASE(MAPSIZE_XYSIZE, "XYSIZE", N_("Width and height"));
255 }
256
257 return nullptr;
258}
259
260/************************************************************************/
263static const struct sset_val_name *topology_name(int topology_bit)
264{
265 switch (1 << topology_bit) {
266 NAME_CASE(TF_ISO, "ISO", N_("Isometric"));
267 NAME_CASE(TF_HEX, "HEX", N_("Hexagonal"));
268 }
269
270 return nullptr;
271}
272
273/************************************************************************/
276static const struct sset_val_name *wrap_name(int wrap_bit)
277{
278 switch (1 << wrap_bit) {
279 NAME_CASE(WRAP_X, "WRAPX", N_("Wrap East-West"));
280 NAME_CASE(WRAP_Y, "WRAPY", N_("Wrap North-South"));
281 }
282
283 return nullptr;
284}
285
286/************************************************************************/
290{
291 switch (revenue_style) {
292 /* TRANS: Description of trade revenue style setting value. */
293 NAME_CASE(TRS_CLASSIC, "CLASSIC", N_("Classic Freeciv"));
294 NAME_CASE(TRS_SIMPLE, "SIMPLE", N_("Proportional to tile trade"));
295 }
296
297 return nullptr;
298}
299
300/************************************************************************/
303static const struct sset_val_name *generator_name(int generator)
304{
305 switch (generator) {
306 NAME_CASE(MAPGEN_SCENARIO, "SCENARIO", N_("Scenario map"));
307 NAME_CASE(MAPGEN_RANDOM, "RANDOM", N_("Fully random height"));
308 NAME_CASE(MAPGEN_FRACTAL, "FRACTAL", N_("Pseudo-fractal height"));
309 NAME_CASE(MAPGEN_ISLAND, "ISLAND", N_("Island-based"));
310 NAME_CASE(MAPGEN_FAIR, "FAIR", N_("Fair islands"));
311 NAME_CASE(MAPGEN_FRACTURE, "FRACTURE", N_("Fracture map"));
312 }
313
314 return nullptr;
315}
316
317/************************************************************************/
320static const struct sset_val_name *startpos_name(int startpos)
321{
322 switch (startpos) {
324 N_("Generator's choice"));
326 N_("One player per continent"));
328 N_("Two or three players per continent"));
330 N_("All players on a single continent"));
332 N_("Depending on size of continents"));
333 }
334
335 return nullptr;
336}
337
338/************************************************************************/
341static const struct sset_val_name *teamplacement_name(int team_placement)
342{
343 switch (team_placement) {
345 N_("Disabled"));
347 N_("As close as possible"));
349 N_("On the same continent"));
351 N_("Horizontal placement"));
353 N_("Vertical placement"));
354 }
355
356 return nullptr;
357}
358
359/************************************************************************/
362static const struct sset_val_name *persistentready_name(int persistent_ready)
363{
364 switch (persistent_ready) {
366 N_("Disabled"));
367 NAME_CASE(PERSISTENTR_CONNECTED, "CONNECTED",
368 N_("As long as connected"));
369 }
370
371 return nullptr;
372}
373
374/************************************************************************/
378{
379 switch (condition_bit) {
380 NAME_CASE(VC_SPACERACE, "SPACERACE", N_("Spacerace"));
381 NAME_CASE(VC_ALLIED, "ALLIED", N_("Allied victory"));
382 NAME_CASE(VC_CULTURE, "CULTURE", N_("Culture victory"));
383 NAME_CASE(VC_WORLDPEACE, "WORLDPEACE", N_("World Peace victory"));
384 };
385
386 return nullptr;
387}
388
389/************************************************************************/
393{
394 switch (autosaves_bit) {
395 NAME_CASE(AS_TURN, "TURN", N_("New turn"));
396 NAME_CASE(AS_GAME_OVER, "GAMEOVER", N_("Game over"));
397 NAME_CASE(AS_QUITIDLE, "QUITIDLE", N_("No player connections"));
398 NAME_CASE(AS_INTERRUPT, "INTERRUPT", N_("Server interrupted"));
399 NAME_CASE(AS_TIMER, "TIMER", N_("Timer"));
400 };
401
402 return nullptr;
403}
404
405/************************************************************************/
408static const struct sset_val_name *borders_name(int borders)
409{
410 switch (borders) {
411 NAME_CASE(BORDERS_DISABLED, "DISABLED", N_("Disabled"));
412 NAME_CASE(BORDERS_ENABLED, "ENABLED", N_("Enabled"));
413 NAME_CASE(BORDERS_SEE_INSIDE, "SEE_INSIDE",
414 N_("See everything inside borders"));
415 NAME_CASE(BORDERS_EXPAND, "EXPAND",
416 N_("Borders expand to unknown, revealing tiles"));
417 }
418
419 return nullptr;
420}
421
422/************************************************************************/
425static const struct sset_val_name *trait_dist_name(int trait_dist)
426{
427 switch (trait_dist) {
428 NAME_CASE(TDM_FIXED, "FIXED", N_("Fixed"));
429 NAME_CASE(TDM_EVEN, "EVEN", N_("Even"));
430 }
431
432 return nullptr;
433}
434
435/************************************************************************/
438static const struct sset_val_name *plrcol_name(int plrcol)
439{
440 switch (plrcol) {
441 NAME_CASE(PLRCOL_PLR_ORDER, "PLR_ORDER", N_("Per-player, in order"));
442 NAME_CASE(PLRCOL_PLR_RANDOM, "PLR_RANDOM", N_("Per-player, random"));
443 NAME_CASE(PLRCOL_PLR_SET, "PLR_SET", N_("Set manually"));
444 NAME_CASE(PLRCOL_TEAM_ORDER, "TEAM_ORDER", N_("Per-team, in order"));
445 NAME_CASE(PLRCOL_NATION_ORDER, "NATION_ORDER", N_("Per-nation, in order"));
446 }
447
448 return nullptr;
449}
450
451/************************************************************************/
454static const struct sset_val_name *happyborders_name(int happyborders)
455{
456 switch (happyborders) {
457 NAME_CASE(HB_DISABLED, "DISABLED", N_("Borders are not helping"));
458 NAME_CASE(HB_NATIONAL, "NATIONAL", N_("Happy within own borders"));
459 NAME_CASE(HB_ALLIANCE, "ALLIED", N_("Happy within allied borders"));
460 }
461
462 return nullptr;
463}
464
465/************************************************************************/
468static const struct sset_val_name *diplomacy_name(int diplomacy)
469{
470 switch (diplomacy) {
471 NAME_CASE(DIPLO_FOR_ALL, "ALL", N_("Enabled for everyone"));
473 N_("Only allowed between human players"));
474 NAME_CASE(DIPLO_FOR_AIS, "AI", N_("Only allowed between AI players"));
475 NAME_CASE(DIPLO_NO_AIS, "NOAI", N_("Only allowed when human involved"));
476 NAME_CASE(DIPLO_NO_MIXED, "NOMIXED", N_("Only allowed between two humans, or two AI players"));
477 NAME_CASE(DIPLO_FOR_TEAMS, "TEAM", N_("Restricted to teams"));
478 NAME_CASE(DIPLO_DISABLED, "DISABLED", N_("Disabled for everyone"));
479 }
480
481 return nullptr;
482}
483
484/************************************************************************/
487static const struct sset_val_name *citynames_name(int citynames)
488{
489 switch (citynames) {
490 NAME_CASE(CNM_NO_RESTRICTIONS, "NO_RESTRICTIONS", N_("No restrictions"));
491 NAME_CASE(CNM_PLAYER_UNIQUE, "PLAYER_UNIQUE", N_("Unique to a player"));
492 NAME_CASE(CNM_GLOBAL_UNIQUE, "GLOBAL_UNIQUE", N_("Globally unique"));
493 NAME_CASE(CNM_NO_STEALING, "NO_STEALING", N_("No city name stealing"));
494 }
495
496 return nullptr;
497}
498
499/************************************************************************/
502static const struct sset_val_name *barbarians_name(int barbarians)
503{
504 switch (barbarians) {
505 NAME_CASE(BARBS_DISABLED, "DISABLED", N_("No barbarians"));
506 NAME_CASE(BARBS_HUTS_ONLY, "HUTS_ONLY", N_("Only in huts"));
507 NAME_CASE(BARBS_NORMAL, "NORMAL", N_("Normal rate of appearance"));
508 NAME_CASE(BARBS_FREQUENT, "FREQUENT", N_("Frequent barbarian uprising"));
509 NAME_CASE(BARBS_HORDES, "HORDES", N_("Raging hordes"));
510 }
511
512 return nullptr;
513}
514
515/************************************************************************/
518static const struct sset_val_name *revolentype_name(int revolentype)
519{
520 switch (revolentype) {
521 NAME_CASE(REVOLEN_FIXED, "FIXED", N_("Fixed to 'revolen' turns"));
522 NAME_CASE(REVOLEN_RANDOM, "RANDOM", N_("Randomly 1-'revolen' turns"));
523 NAME_CASE(REVOLEN_QUICKENING, "QUICKENING", N_("First time 'revolen', then always quicker"));
524 NAME_CASE(REVOLEN_RANDQUICK, "RANDQUICK", N_("Random, max always quicker"));
525 }
526
527 return nullptr;
528}
529
530/************************************************************************/
533static const struct sset_val_name *revealmap_name(int bit)
534{
535 switch (1 << bit) {
536 NAME_CASE(REVEAL_MAP_START, "START", N_("Reveal map at game start"));
537 NAME_CASE(REVEAL_MAP_DEAD, "DEAD", N_("Unfog map for dead players"));
538 }
539
540 return nullptr;
541}
542
543/************************************************************************/
546static const struct sset_val_name *airliftingstyle_name(int bit)
547{
548 switch (1 << bit) {
549 NAME_CASE(AIRLIFTING_ALLIED_SRC, "FROM_ALLIES",
550 N_("Allows units to be airlifted from allied cities"));
552 N_("Allows units to be airlifted to allied cities"));
553 NAME_CASE(AIRLIFTING_UNLIMITED_SRC, "SRC_UNLIMITED",
554 N_("Unlimited units from source city"));
555 NAME_CASE(AIRLIFTING_UNLIMITED_DEST, "DEST_UNLIMITED",
556 N_("Unlimited units to destination city"));
557 }
558
559 return nullptr;
560}
561
562/************************************************************************/
565static const struct sset_val_name *phasemode_name(int phasemode)
566{
567 switch (phasemode) {
568 NAME_CASE(PMT_CONCURRENT, "ALL", N_("All players move concurrently"));
570 "PLAYER", N_("All players alternate movement"));
571 NAME_CASE(PMT_TEAMS_ALTERNATE, "TEAM", N_("Team alternate movement"));
572 }
573
574 return nullptr;
575}
576
577/************************************************************************/
580static const struct sset_val_name *
582{
583 switch (sl_level) {
584 NAME_CASE(SL_ALL, "ALL", N_("All players"));
585 NAME_CASE(SL_HUMANS, "HUMANS", N_("Human players only"));
586 }
587
588 return nullptr;
589}
590
591/************************************************************************/
594static const struct sset_val_name *
596{
597 switch (compresstype) {
598 NAME_CASE(FZ_PLAIN, "PLAIN", N_("No compression"));
599#ifdef FREECIV_HAVE_LIBZ
600 NAME_CASE(FZ_ZLIB, "LIBZ", N_("Using zlib (gzip format)"));
601#endif
602#ifdef FREECIV_HAVE_LIBBZ2
603 case FZ_BZIP2:
604 break;
605#endif
606#ifdef FREECIV_HAVE_LIBLZMA
607 NAME_CASE(FZ_XZ, "XZ", N_("Using xz"));
608#endif
609#ifdef FREECIV_HAVE_LIBZSTD
610 NAME_CASE(FZ_ZSTD, "ZSTD", N_("Using zstd"));
611#endif
612 }
613
614 return nullptr;
615}
616
617/************************************************************************/
620static const struct sset_val_name *
621ailevel_name(enum ai_level lvl)
622{
623 const char *lvlname;
624
625 if (lvl >= AI_LEVEL_AWAY) {
626 return nullptr;
627 }
628
630
631 if (lvlname != nullptr) {
632 static struct sset_val_name name[AI_LEVEL_COUNT];
633
636
637 return &name[lvl];
638 }
639
640 return nullptr;
641}
642
643/************************************************************************/
646static const struct sset_val_name *bool_name(int enable)
647{
648 switch (enable) {
649 NAME_CASE(FALSE, "DISABLED", N_("disabled"));
650 NAME_CASE(TRUE, "ENABLED", N_("enabled"));
651 }
652
653 return nullptr;
654}
655
656#undef NAME_CASE
657
658/****************************************************************************
659 Help callback functions.
660****************************************************************************/
661
662/************************************************************************/
665static const char *phasemode_help(const struct setting *pset)
666{
667 static char pmhelp[512];
668
669 /* Translated here */
670 fc_snprintf(pmhelp, sizeof(pmhelp),
671 _("This setting controls whether players may make "
672 "moves at the same time during a turn. Change "
673 "in setting takes effect next turn. Currently, at least "
674 "to the end of this turn, mode is \"%s\"."),
676
677 return pmhelp;
678}
679
680/************************************************************************/
683static const char *huts_help(const struct setting *pset)
684{
685 if (wld.map.server.huts_absolute >= 0) {
686 static char hutshelp[512];
687
688 /* Translated here */
690 _("%s\n"
691 "Currently this setting is being overridden by an "
692 "old scenario or savegame, which has set the absolute "
693 "number of huts to %d. Explicitly set this setting "
694 "again to make it take effect instead."),
695 _(pset->extra_help), wld.map.server.huts_absolute);
696
697 return hutshelp;
698 }
699
700 return pset->extra_help;
701}
702
703/****************************************************************************
704 Action callback functions.
705****************************************************************************/
706
707/************************************************************************/
710static void scorelog_action(const struct setting *pset)
711{
712 if (*pset->boolean.pvalue) {
714 } else {
716 }
717}
718
719/************************************************************************/
722static void aifill_action(const struct setting *pset)
723{
724 const char *msg = aifill(*pset->integer.pvalue);
725 if (msg) {
726 log_normal(_("Warning: aifill not met: %s."), msg);
727 notify_conn(nullptr, nullptr, E_SETTING, ftc_server,
728 _("Warning: aifill not met: %s."), msg);
729 }
730}
731
732/************************************************************************/
735static void nationset_action(const struct setting *pset)
736{
737 /* If any player's existing selection is invalid, abort it */
738 players_iterate(pplayer) {
739 if (pplayer->nation != nullptr) {
740 if (!nation_is_in_current_set(pplayer->nation)) {
743 }
744 }
748
749 /* There might now be too many players for the available nations.
750 * Rather than getting rid of some players arbitrarily, we let the
751 * situation persist for all already-connected players; the server
752 * will simply refuse to start until someone reduces the number of
753 * players. This policy also avoids annoyance if nationset is
754 * accidentally and transiently set to an unintended value.
755 * (However, new connections will start out detached.) */
756 if (normal_player_count() > server.playable_nations) {
757 notify_conn(nullptr, nullptr, E_SETTING, ftc_server, "%s",
758 _("Warning: not enough nations in this nation set "
759 "for all current players."));
760 }
761
763}
764
765/************************************************************************/
768static void plrcol_action(const struct setting *pset)
769{
770 if (!game_was_started()) {
772 players_iterate(pplayer) {
773 server_player_set_color(pplayer, nullptr);
775 }
776
777 /* Update clients with new color scheme. */
778 send_player_info_c(nullptr, nullptr);
779 }
780}
781
782/************************************************************************/
785static void autotoggle_action(const struct setting *pset)
786{
787 if (*pset->boolean.pvalue) {
788 players_iterate(pplayer) {
789 if (is_human(pplayer) && !pplayer->is_connected) {
790 toggle_ai_player_direct(nullptr, pplayer);
792 }
794 }
795}
796
797/************************************************************************/
801static void timeout_action(const struct setting *pset)
802{
803 if (S_S_RUNNING == server_state()) {
804 int timeout = *pset->integer.pvalue;
805
806 if (game.info.turn != 1 || game.info.first_timeout == -1) {
807 /* This may cause the current turn to end immediately. */
809 }
810
811 send_game_info(nullptr);
812 }
813}
814
815/************************************************************************/
819static void first_timeout_action(const struct setting *pset)
820{
821 if (S_S_RUNNING == server_state()) {
822 int timeout = *pset->integer.pvalue;
823
824 if (game.info.turn == 1) {
825 /* This may cause the current turn to end immediately. */
826 if (timeout != -1) {
828 } else {
830 }
831 }
832
833 send_game_info(nullptr);
834 }
835}
836
837/************************************************************************/
840static void huts_action(const struct setting *pset)
841{
843}
844
845/************************************************************************/
848static void topology_action(const struct setting *pset)
849{
850 struct packet_set_topology packet;
851
852 packet.topology_id = *pset->integer.pvalue;
853 packet.wrap_id = wld.map.wrap_id;
854
858}
859
860/************************************************************************/
863static void wrap_action(const struct setting *pset)
864{
865 struct packet_set_topology packet;
866
868 packet.wrap_id = *pset->integer.pvalue;
869
873}
874
875/************************************************************************/
879static void metamessage_action(const struct setting *pset)
880{
881 /* Set the metaserver message based on the new meta server user message.
882 * An empty user metaserver message results in an automatic meta message.
883 * A non empty user meta message results in the user meta message. */
884 set_user_meta_message_string(pset->string.value);
885
886 if (is_metaserver_open()) {
887 /* Update the meta server. */
889 }
890}
891
892/************************************************************************/
895static void aitype_action(const struct setting *pset)
896{
897 if (!set_default_ai_type_name(pset->string.value)) {
898 log_warn(_("Failed to update default AI type."));
899 }
900}
901
902/****************************************************************************
903 Validation callback functions.
904****************************************************************************/
905
906/************************************************************************/
909static bool savename_validate(const char *value, struct connection *caller,
910 char *reject_msg, size_t reject_msg_len)
911{
912 char buf[MAX_LEN_PATH];
913
914 generate_save_name(value, buf, sizeof(buf), nullptr);
915
916 if (!is_safe_filename(buf)) {
918 _("Invalid save name definition: '%s' "
919 "(resolves to '%s')."), value, buf);
920 return FALSE;
921 }
922
923 return TRUE;
924}
925
926/************************************************************************/
930static bool generator_validate(int value, struct connection *caller,
931 char *reject_msg, size_t reject_msg_len)
932{
933 if (map_is_empty()) {
934 if (MAPGEN_SCENARIO == value
935 && (caller != nullptr || !game.scenario.is_scenario)) {
937 _("You cannot disable the map generator."));
938 return FALSE;
939 }
940 return TRUE;
941 } else {
942 if (MAPGEN_SCENARIO != value) {
944 _("You cannot require a map generator "
945 "when a map is loaded."));
946 return FALSE;
947 }
948 }
949 return TRUE;
950}
951
952/************************************************************************/
955#ifndef FREECIV_WEB
956static bool scorefile_validate(const char *value, struct connection *caller,
957 char *reject_msg, size_t reject_msg_len)
958{
959 if (!is_safe_filename(value)) {
961 _("Invalid score name definition: '%s'."), value);
962 return FALSE;
963 }
964
965 return TRUE;
966}
967#endif /* !FREECIV_WEB */
968
969/************************************************************************/
973static bool demography_callback(const char *value,
974 struct connection *caller,
975 char *reject_msg,
976 size_t reject_msg_len)
977{
978 int error;
979
980 if (is_valid_demography(value, &error)) {
981 return TRUE;
982 } else {
984 _("Demography string validation failed at character: "
985 "'%c'. Try \"/help demography\"."), value[error]);
986 return FALSE;
987 }
988}
989
990/************************************************************************/
993static bool autosaves_callback(unsigned value, struct connection *caller,
994 char *reject_msg, size_t reject_msg_len)
995{
996 if (S_S_RUNNING == server_state()) {
997 if ((value & (1 << AS_TIMER))
998 && !(game.server.autosaves & (1 << AS_TIMER))) {
1001 game.server.save_timer != nullptr
1002 ? nullptr : "save interval");
1004 } else if (!(value & (1 << AS_TIMER))
1005 && (game.server.autosaves & (1 << AS_TIMER))) {
1008 game.server.save_timer = nullptr;
1009 }
1010 }
1011
1012 return TRUE;
1013}
1014
1015/************************************************************************/
1019static bool allowtake_callback(const char *value,
1020 struct connection *caller,
1021 char *reject_msg,
1022 size_t reject_msg_len)
1023{
1024 int len = strlen(value), i;
1026
1027 /* We check each character individually to see if it's valid. This
1028 * does not check for duplicate entries.
1029 *
1030 * We also track the state of the machine. havecharacter_state is
1031 * true if the preceding character was a primary label, e.g.
1032 * NHhAadb. It is false if the preceding character was a modifier
1033 * or if this is the first character. */
1034
1035 for (i = 0; i < len; i++) {
1036 /* Check to see if the character is a primary label. */
1037 if (strchr("HhAadbOo", value[i])) {
1039 continue;
1040 }
1041
1042 /* If we've already passed a primary label, check to see if the
1043 * character is a modifier. */
1044 if (havecharacter_state && strchr("1234", value[i])) {
1046 continue;
1047 }
1048
1049 /* Looks like the character was invalid. */
1051 _("Allowed take string validation failed at "
1052 "character: '%c'. Try \"/help allowtake\"."),
1053 value[i]);
1054 return FALSE;
1055 }
1056
1057 /* All characters were valid. */
1058 return TRUE;
1059}
1060
1061/************************************************************************/
1065static bool startunits_callback(const char *value,
1066 struct connection *caller,
1067 char *reject_msg,
1068 size_t reject_msg_len)
1069{
1070 int len = strlen(value), i;
1072 bool firstnative = FALSE;
1073
1074 if (len == 0) {
1075 return TRUE;
1076 }
1077
1078 /* We check each character individually to see if it's valid. */
1079 for (i = 0; i < len; i++) {
1080 if (strchr("cwxksfdDaA", value[i])) {
1081 continue;
1082 }
1083
1084 /* Looks like the character was invalid. */
1086 _("Starting units string validation failed at "
1087 "character '%c'. Try \"/help startunits\"."),
1088 value[i]);
1089 return FALSE;
1090 }
1091
1092 /* Check the first character to make sure it can use a startpos. */
1094 crole_to_role_id(value[0]), 0)));
1095 terrain_type_iterate(pterrain) {
1096 if (terrain_has_flag(pterrain, TER_STARTER)
1097 && BV_ISSET(pterrain->native_to, first_role)) {
1098 firstnative = TRUE;
1099 break;
1100 }
1102
1103 if (!firstnative) {
1104 /* Loading would cause an infinite loop hunting for a valid startpos. */
1106 _("The first starting unit must be native to at "
1107 "least one \"Starter\" terrain. "
1108 "Try \"/help startunits\"."));
1109 return FALSE;
1110 }
1111
1112 /* Everything seems fine. */
1113 return TRUE;
1114}
1115
1116/************************************************************************/
1119static bool endturn_callback(int value, struct connection *caller,
1120 char *reject_msg, size_t reject_msg_len)
1121{
1122 if (value < game.info.turn) {
1123 /* Tried to set endturn earlier than current turn */
1125 _("Cannot set endturn earlier than current turn."));
1126 return FALSE;
1127 }
1128 return TRUE;
1129}
1130
1131/************************************************************************/
1134static bool maxplayers_callback(int value, struct connection *caller,
1135 char *reject_msg, size_t reject_msg_len)
1136{
1137 if (value < player_count()) {
1139 _("Number of players (%d) is higher than requested "
1140 "value (%d). Keeping old value."), player_count(),
1141 value);
1142 return FALSE;
1143 }
1144 /* If any start positions are defined by a scenario, we can only
1145 * accommodate as many players as we have start positions. */
1147 && 0 < map_startpos_count() && value > map_startpos_count()) {
1149 _("Requested value (%d) is greater than number of "
1150 "available start positions (%d). Keeping old value."),
1151 value, map_startpos_count());
1152 return FALSE;
1153 }
1154
1155 return TRUE;
1156}
1157
1158/************************************************************************/
1161static bool nationset_callback(const char *value,
1162 struct connection *caller,
1163 char *reject_msg,
1164 size_t reject_msg_len)
1165{
1166 if (strlen(value) == 0) {
1167 return TRUE;
1168 } else if (nation_set_by_rule_name(value)) {
1169 return TRUE;
1170 } else {
1172 /* TRANS: do not translate 'list nationsets' */
1173 _("Unknown nation set \"%s\". See '%slist nationsets' "
1174 "for possible values."), value, caller ? "/" : "");
1175 return FALSE;
1176 }
1177}
1178
1179/************************************************************************/
1182static bool timeout_callback(int value, struct connection *caller,
1183 char *reject_msg, size_t reject_msg_len)
1184{
1185 /* Disallow low timeout values for non-hack connections. */
1186 if (caller && caller->access_level < ALLOW_HACK
1187 && value < 30 && value != 0) {
1189 _("You are not allowed to set timeout values less "
1190 "than 30 seconds."));
1191 return FALSE;
1192 }
1193
1194 if (value == -1 && game.server.unitwaittime != 0) {
1195 /* autogame only with 'unitwaittime' = 0 */
1197 /* TRANS: Do not translate setting names in ''. */
1198 _("For autogames ('timeout' = -1) 'unitwaittime' "
1199 "should be deactivated (= 0)."));
1200 return FALSE;
1201 }
1202
1203 if (value > 0 && value < game.server.unitwaittime * 3 / 2) {
1204 /* for normal games 'timeout' should be at least 3/2 times the value
1205 * of 'unitwaittime' */
1207 /* TRANS: Do not translate setting names in ''. */
1208 _("'timeout' can not be lower than 3/2 of the "
1209 "'unitwaittime' setting (= %d). Please change "
1210 "'unitwaittime' first."), game.server.unitwaittime);
1211 return FALSE;
1212 }
1213
1214 return TRUE;
1215}
1216
1217/************************************************************************/
1220static bool first_timeout_callback(int value, struct connection *caller,
1221 char *reject_msg, size_t reject_msg_len)
1222{
1223 /* Disallow low timeout values for non-hack connections. */
1224 if (caller && caller->access_level < ALLOW_HACK
1225 && value < 30 && value != 0) {
1227 _("You are not allowed to set timeout values less "
1228 "than 30 seconds."));
1229 return FALSE;
1230 }
1231
1232 return TRUE;
1233}
1234
1235/************************************************************************/
1238static bool unitwaittime_callback(int value, struct connection *caller,
1239 char *reject_msg, size_t reject_msg_len)
1240{
1241 if (game.info.timeout == -1 && value != 0) {
1243 /* TRANS: Do not translate setting names in ''. */
1244 _("For autogames ('timeout' = -1) 'unitwaittime' "
1245 "should be deactivated (= 0)."));
1246 return FALSE;
1247 }
1248
1249 if (game.info.timeout > 0 && value > game.info.timeout * 2 / 3) {
1251 /* TRANS: Do not translate setting names in ''. */
1252 _("'unitwaittime' has to be lower than 2/3 of the "
1253 "'timeout' setting (= %d). Please change 'timeout' "
1254 "first."), game.info.timeout);
1255 return FALSE;
1256 }
1257
1258 return TRUE;
1259}
1260
1261/************************************************************************/
1264static bool mapsize_callback(int value, struct connection *caller,
1265 char *reject_msg, size_t reject_msg_len)
1266{
1267 if (value == MAPSIZE_XYSIZE && MAP_IS_ISOMETRIC
1268 && MAP_NATIVE_HEIGHT % 2 != 0) {
1269 /* An isometric map needs a even ysize. It is calculated automatically
1270 * for all settings but mapsize=XYSIZE. */
1272 _("For an isometric or hexagonal map the ysize must be "
1273 "even."));
1274 return FALSE;
1275 }
1276
1277 return TRUE;
1278}
1279
1280/************************************************************************/
1283static bool xsize_callback(int value, struct connection *caller,
1284 char *reject_msg, size_t reject_msg_len)
1285{
1286 int size = value * MAP_NATIVE_HEIGHT;
1287
1288 if (size < MAP_MIN_SIZE * 1000) {
1290 _("The map size (%d * %d = %d) must be larger than "
1291 "%d tiles."), value, MAP_NATIVE_HEIGHT, size,
1292 MAP_MIN_SIZE * 1000);
1293 return FALSE;
1294 } else if (size > MAP_MAX_SIZE * 1000) {
1296 _("The map size (%d * %d = %d) must be lower than "
1297 "%d tiles."), value, MAP_NATIVE_HEIGHT, size,
1298 MAP_MAX_SIZE * 1000);
1299 return FALSE;
1300 }
1301
1302 return TRUE;
1303}
1304
1305/************************************************************************/
1308static bool ysize_callback(int value, struct connection *caller,
1309 char *reject_msg, size_t reject_msg_len)
1310{
1311 int size = MAP_NATIVE_WIDTH * value;
1312
1313 if (size < MAP_MIN_SIZE * 1000) {
1315 _("The map size (%d * %d = %d) must be larger than "
1316 "%d tiles."), MAP_NATIVE_WIDTH, value, size,
1317 MAP_MIN_SIZE * 1000);
1318 return FALSE;
1319 } else if (size > MAP_MAX_SIZE * 1000) {
1321 _("The map size (%d * %d = %d) must be lower than "
1322 "%d tiles."), MAP_NATIVE_WIDTH, value, size,
1323 MAP_MAX_SIZE * 1000);
1324 return FALSE;
1326 && value % 2 != 0) {
1327 /* An isometric map needs a even ysize. It is calculated automatically
1328 * for all settings but mapsize=XYSIZE. */
1330 _("For an isometric or hexagonal map the ysize must be "
1331 "even."));
1332 return FALSE;
1333 }
1334
1335 return TRUE;
1336}
1337
1338/************************************************************************/
1341static bool topology_callback(unsigned value, struct connection *caller,
1342 char *reject_msg, size_t reject_msg_len)
1343{
1345 && ((value & (TF_ISO)) != 0 || (value & (TF_HEX)) != 0)
1346 && MAP_NATIVE_HEIGHT % 2 != 0) {
1347 /* An isometric map needs a even ysize. It is calculated automatically
1348 * for all settings but mapsize=XYSIZE. */
1350 _("For an isometric or hexagonal map the ysize must be "
1351 "even."));
1352 return FALSE;
1353 }
1354
1355#ifdef FREECIV_WEB
1356 /* Remember to update the help text too if Freeciv-web gets the ability
1357 * to display other map topologies. */
1358
1359 /* Are you removing this because Freeciv-web gained the ability to
1360 * display isometric maps? Why don't you remove the Freeciv-web
1361 * specific MAP_DEFAULT_TOPO too? */
1362 if ((value & (TF_ISO)) != 0
1363 || (value & (TF_HEX)) != 0) {
1364 /* The Freeciv-web client can't display these topologies yet. */
1366 _("Freeciv-web doesn't support this topology."));
1367 return FALSE;
1368 }
1369#endif /* FREECIV_WEB */
1370
1371 return TRUE;
1372}
1373
1374/************************************************************************/
1377static bool aitype_callback(const char *value, struct connection *caller,
1378 char *reject_msg, size_t reject_msg_len)
1379{
1380 if (ai_type_by_name(value) == nullptr) {
1382 _("No such AI type loaded."));
1383
1384 return FALSE;
1385 }
1386
1387 return TRUE;
1388}
1389
1390/************************************************************************/
1393static bool wrap_callback(unsigned value, struct connection *caller,
1394 char *reject_msg, size_t reject_msg_len)
1395{
1396#ifdef FREECIV_WEB
1397 /* Remember to update the help text too if Freeciv-web gets the ability
1398 * to display other map wraps. */
1399 if ((value & (WRAP_Y)) != 0) {
1400 /* The Freeciv-web client can't display wraps mapped this way. */
1402 _("Freeciv-web doesn't support this map wrap."));
1403 return FALSE;
1404 }
1405#endif /* FREECIV_WEB */
1406
1407 return TRUE;
1408}
1409
1410/************************************************************************/
1413static bool plrcol_validate(int value, struct connection *caller,
1414 char *reject_msg, size_t reject_msg_len)
1415{
1416 enum plrcolor_mode mode = value;
1417 if (mode == PLRCOL_NATION_ORDER) {
1418 nations_iterate(pnation) {
1419 if (nation_color(pnation)) {
1420 /* At least one nation has a color. Allow this mode. */
1421 return TRUE;
1422 }
1425 _("No nations in the currently loaded ruleset have "
1426 "associated colors."));
1427 return FALSE;
1428 }
1429 return TRUE;
1430}
1431
1432#define GEN_BOOL(name, value, sclass, scateg, slevel, al_read, al_write, \
1433 short_help, extra_help, func_validate, func_action, \
1434 _default) \
1435 {name, sclass, al_read, al_write, short_help, extra_help, nullptr, SST_BOOL, \
1436 scateg, slevel, \
1437 INIT_BRACE_BEGIN \
1438 .boolean = {&value, _default, func_validate, bool_name, \
1439 FALSE} INIT_BRACE_END , func_action, FALSE, .ruleset_settable = TRUE},
1440
1441#define GEN_INT(name, value, sclass, scateg, slevel, al_read, al_write, \
1442 short_help, extra_help, func_help, \
1443 func_validate, func_action, \
1444 _min, _max, _default) \
1445 {name, sclass, al_read, al_write, short_help, extra_help, func_help, \
1446 SST_INT, scateg, slevel, \
1447 INIT_BRACE_BEGIN \
1448 .integer = {(int *) &value, _default, _min, _max, func_validate, \
1449 0} INIT_BRACE_END, \
1450 func_action, FALSE, .ruleset_settable = TRUE},
1451
1452#define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, \
1453 short_help, extra_help, func_validate, func_action, \
1454 _default) \
1455 {name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1456 SST_STRING, scateg, slevel, \
1457 INIT_BRACE_BEGIN \
1458 .string = {value, _default, sizeof(value), func_validate, ""} \
1459 INIT_BRACE_END, \
1460 func_action, FALSE, .ruleset_settable = TRUE},
1461
1462#define GEN_STRING_NRS(name, value, sclass, scateg, slevel, al_read, al_write, \
1463 short_help, extra_help, func_validate, func_action, \
1464 _default) \
1465 {name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1466 SST_STRING, scateg, slevel, \
1467 INIT_BRACE_BEGIN \
1468 .string = {value, _default, sizeof(value), func_validate, ""} \
1469 INIT_BRACE_END, \
1470 func_action, FALSE, .ruleset_settable = FALSE},
1471
1472#define GEN_ENUM(name, value, sclass, scateg, slevel, al_read, al_write, \
1473 short_help, extra_help, func_help, func_validate, \
1474 func_action, func_name, _default) \
1475 { name, sclass, al_read, al_write, short_help, extra_help, func_help, \
1476 SST_ENUM, scateg, slevel, \
1477 INIT_BRACE_BEGIN \
1478 .enumerator = { &value, sizeof(value), _default, \
1479 func_validate, \
1480 (val_name_func_t) func_name, 0 } INIT_BRACE_END, \
1481 func_action, FALSE, .ruleset_settable = TRUE},
1482
1483#define GEN_BITWISE(name, value, sclass, scateg, slevel, al_read, al_write, \
1484 short_help, extra_help, func_validate, func_action, \
1485 func_name, _default) \
1486 { name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1487 SST_BITWISE, scateg, slevel, \
1488 INIT_BRACE_BEGIN \
1489 .bitwise = { (unsigned *) (void *) &value, _default, func_validate, \
1490 func_name, 0 } INIT_BRACE_END, \
1491 func_action, FALSE, .ruleset_settable = TRUE},
1492
1493/* game settings */
1494static struct setting settings[] = {
1495
1496 /* These should be grouped by sclass */
1497
1498 /* Map size parameters: adjustable if we don't yet have a map */
1501 N_("Map size definition"),
1502 /* TRANS: The strings between double quotes are also translated
1503 * separately (they must match!). The strings between single
1504 * quotes are setting names and shouldn't be translated. The
1505 * strings between parentheses and in uppercase must stay as
1506 * untranslated. */
1507 N_("Chooses the method used to define the map size. Other options "
1508 "specify the parameters for each method.\n"
1509 "- \"Number of tiles\" (FULLSIZE): Map area (option 'size').\n"
1510 "- \"Tiles per player\" (PLAYER): Number of (land) tiles per "
1511 "player (option 'tilesperplayer').\n"
1512 "- \"Width and height\" (XYSIZE): Map width and height in "
1513 "tiles (options 'xsize' and 'ysize')."), nullptr,
1515
1518 N_("Map area (in thousands of tiles)"),
1519 /* TRANS: The strings between double quotes are also translated
1520 * separately (they must match!). The strings between single
1521 * quotes are setting names and shouldn't be translated. The
1522 * strings between parentheses and in uppercase must stay as
1523 * untranslated. */
1524 N_("This value is used to determine the map area.\n"
1525 " size = 4 is a normal map of 4,000 tiles (default)\n"
1526 " size = 20 is a huge map of 20,000 tiles\n"
1527 "For this option to take effect, the \"Map size definition\" "
1528 "option ('mapsize') must be set to \"Number of tiles\" "
1529 "(FULLSIZE)."), nullptr, nullptr, nullptr,
1531
1532 GEN_INT("tilesperplayer", wld.map.server.tilesperplayer, SSET_MAP_SIZE,
1534 N_("Number of (land) tiles per player"),
1535 /* TRANS: The strings between double quotes are also translated
1536 * separately (they must match!). The strings between single
1537 * quotes are setting names and shouldn't be translated. The
1538 * strings between parentheses and in uppercase must stay as
1539 * untranslated. */
1540 N_("This value is used to determine the map dimensions. It "
1541 "calculates the map size at game start based on the number "
1542 "of players and the value of the setting 'landmass'.\n"
1543 "For this option to take effect, the \"Map size definition\" "
1544 "option ('mapsize') must be set to \"Tiles per player\" "
1545 "(PLAYER)."),
1546 nullptr, nullptr, nullptr, MAP_MIN_TILESPERPLAYER,
1548
1549 GEN_INT("xsize", wld.map.xsize, SSET_MAP_SIZE,
1551 N_("Map width in tiles"),
1552 /* TRANS: The strings between double quotes are also translated
1553 * separately (they must match!). The strings between single
1554 * quotes are setting names and shouldn't be translated. The
1555 * strings between parentheses and in uppercase must stay as
1556 * untranslated. */
1557 N_("Defines the map width.\n"
1558 "For this option to take effect, the \"Map size definition\" "
1559 "option ('mapsize') must be set to \"Width and height\" "
1560 "(XYSIZE)."),
1561 nullptr, xsize_callback, nullptr,
1563 GEN_INT("ysize", wld.map.ysize, SSET_MAP_SIZE,
1565 N_("Map height in tiles"),
1566 /* TRANS: The strings between double quotes are also translated
1567 * separately (they must match!). The strings between single
1568 * quotes are setting names and shouldn't be translated. The
1569 * strings between parentheses and in uppercase must stay as
1570 * untranslated. */
1571 N_("Defines the map height.\n"
1572 "For this option to take effect, the \"Map size definition\" "
1573 "option ('mapsize') must be set to \"Width and height\" "
1574 "(XYSIZE)."),
1575 nullptr, ysize_callback, nullptr,
1577
1580 N_("Map topology"),
1582 /* TRANS: Freeciv-web version of the help text. */
1583 N_("Freeciv-web maps are always two-dimensional.\n"),
1584#else /* FREECIV_WEB */
1585 /* TRANS: do not edit the ugly ASCII art */
1586 N_("Freeciv maps are always two-dimensional. "
1587 "Individual tiles may "
1588 "be rectangular or hexagonal, with either an overhead "
1589 "(\"classic\") or isometric alignment.\n"
1590 "To play with a particular topology, clients will need a "
1591 "matching tileset.\n"
1592 "Overhead rectangular: Isometric rectangular:\n"
1593 " _________ /\\/\\/\\/\\/\\\n"
1594 " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1595 " |_|_|_|_|_| \\/\\/\\/\\/\\/\\\n"
1596 " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1597 " \\/\\/\\/\\/\\/\n"
1598 "Hex: Iso-hex:\n"
1599 " /\\/\\/\\/\\/\\/\\ _ _ _ _ _\n"
1600 " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1601 " \\/\\/\\/\\/\\/\\/\\"
1602 " \\_/ \\_/ \\_/ \\_/ \\_/\n"
1603 " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1604 " \\/\\/\\/\\/\\/\\/"
1605 " \\_/ \\_/ \\_/ \\_/ \\_/\n"),
1606#endif /* FREECIV_WEB */
1608
1611 N_("Map wrap"),
1613 /* TRANS: Freeciv-web version of the help text. */
1614 N_("Freeciv-web maps may wrap "
1615 "at the east-west directions to form a flat map or a "
1616 "cylinder.\n"),
1617#else /* FREECIV_WEB */
1618 /* TRANS: do not edit the ugly ASCII art */
1619 N_("Freeciv maps may wrap at "
1620 "the north-south and east-west directions to form a flat "
1621 "map, a cylinder, or a torus (donut)."),
1622#endif /* FREECIV_WEB */
1624
1625 GEN_ENUM("generator", wld.map.server.generator,
1627 N_("Method used to generate map"),
1628 /* TRANS: The strings between double quotes are also translated
1629 * separately (they must match!). The strings between single
1630 * quotes (except 'fair') are setting names and shouldn't be
1631 * translated. The strings between parentheses and in uppercase
1632 * must stay as untranslated. */
1633 N_("Specifies the algorithm used to generate the map. If the "
1634 "default value of the 'startpos' option is used, then the "
1635 "chosen generator chooses an appropriate 'startpos' setting; "
1636 "otherwise, the generated map tries to accommodate the "
1637 "chosen 'startpos' setting.\n"
1638 "- \"Scenario map\" (SCENARIO): indicates a pre-generated map. "
1639 "By default, if the scenario does not specify start positions, "
1640 "they will be allocated depending on the size of continents.\n"
1641 "- \"Fully random height\" (RANDOM): generates maps with a "
1642 "number of equally spaced, relatively small islands. By default, "
1643 "start positions are allocated depending on continent size.\n"
1644 "- \"Pseudo-fractal height\" (FRACTAL): generates Earthlike "
1645 "worlds with one or more large continents and a scattering of "
1646 "smaller islands. By default, players are all placed on a "
1647 "single continent.\n"
1648 "- \"Island-based\" (ISLAND): generates 'fair' maps with a "
1649 "number of similarly-sized and -shaped islands, each with "
1650 "approximately the same ratios of terrain types. By default, "
1651 "each player gets their own island.\n"
1652 "- \"Fair islands\" (FAIR): generates the exact copy of the "
1653 "same island for every player or every team.\n"
1654 "- \"Fracture map\" (FRACTURE): generates maps from a fracture "
1655 "pattern. Tends to place hills and mountains along the edges "
1656 "of the continents.\n"
1657 "If the requested generator is incompatible with other server "
1658 "settings, the server may fall back to another generator."),
1659 nullptr, generator_validate, nullptr, generator_name,
1661
1662 GEN_ENUM("startpos", wld.map.server.startpos,
1664 N_("Method used to choose start positions"),
1665 /* TRANS: The strings between double quotes are also translated
1666 * separately (they must match!). The strings between single
1667 * quotes (except 'best') are setting names and shouldn't be
1668 * translated. The strings between parentheses and in uppercase
1669 * must stay as untranslated. */
1670 N_("The method used to choose where each player's initial units "
1671 "start on the map. (For scenarios which include pre-set "
1672 "start positions, this setting is ignored.)\n"
1673 "- \"Generator's choice\" (DEFAULT): the start position "
1674 "placement will depend on the map generator chosen. See the "
1675 "'generator' setting.\n"
1676 "- \"One player per continent\" (SINGLE): one player is "
1677 "placed on each of a set of continents of approximately "
1678 "equivalent value (if possible).\n"
1679 "- \"Two or three players per continent\" (2or3): similar "
1680 "to SINGLE except that two players will be placed on each "
1681 "continent, with three on the 'best' continent if there is an "
1682 "odd number of players.\n"
1683 "- \"All players on a single continent\" (ALL): all players "
1684 "will start on the 'best' available continent.\n"
1685 "- \"Depending on size of continents\" (VARIABLE): players "
1686 "will be placed on the 'best' available continents such that, "
1687 "as far as possible, the number of players on each continent "
1688 "is proportional to its value.\n"
1689 "If the server cannot satisfy the requested setting due to "
1690 "there being too many players for continents, it may fall "
1691 "back to one of the others. (However, map generators try to "
1692 "create the right number of continents for the choice of this "
1693 "'startpos' setting and the number of players, so this is "
1694 "unlikely to occur.)"),
1695 nullptr, nullptr, nullptr, startpos_name, MAP_DEFAULT_STARTPOS)
1696
1697 GEN_ENUM("teamplacement", wld.map.server.team_placement,
1699 N_("Method used for placement of team mates"),
1700 /* TRANS: The strings between double quotes are also translated
1701 * separately (they must match!). The strings between single
1702 * quotes are setting names and shouldn't be translated. The
1703 * strings between parentheses and in uppercase must stay as
1704 * untranslated. */
1705 N_("After start positions have been generated thanks to the "
1706 "'startpos' setting, this setting controls how the start "
1707 "positions will be assigned to the different players of the "
1708 "same team.\n"
1709 "- \"Disabled\" (DISABLED): the start positions will be "
1710 "randomly assigned to players, regardless of teams.\n"
1711 "- \"As close as possible\" (CLOSEST): players will be "
1712 "placed as close as possible, regardless of continents.\n"
1713 "- \"On the same continent\" (CONTINENT): if possible, place "
1714 "all players of the same team onto the same "
1715 "island/continent.\n"
1716 "- \"Horizontal placement\" (HORIZONTAL): players of the same "
1717 "team will be placed horizontally.\n"
1718 "- \"Vertical placement\" (VERTICAL): players of the same "
1719 "team will be placed vertically."),
1720 nullptr, nullptr, nullptr, teamplacement_name,
1722
1723 GEN_BOOL("tinyisles", wld.map.server.tinyisles,
1725 N_("Presence of 1x1 islands"),
1726 N_("This setting controls whether the map generator is allowed "
1727 "to make islands of one only tile size."), nullptr, nullptr,
1729
1730 GEN_BOOL("separatepoles", wld.map.server.separatepoles,
1733 N_("Whether the poles are separate continents"),
1734 N_("If this setting is disabled, the continents may attach to "
1735 "poles."), nullptr, nullptr, MAP_DEFAULT_SEPARATE_POLES)
1736
1737 GEN_INT("flatpoles", wld.map.server.flatpoles,
1739 N_("How much the land at the poles is flattened"),
1740 /* TRANS: The strings in quotes shouldn't be translated. */
1741 N_("Controls how much the height of the poles is flattened "
1742 "during map generation, preventing a diversity of land "
1743 "terrain there. 0 is no flattening, 100 is maximum "
1744 "flattening. Only affects the 'RANDOM' and 'FRACTAL' "
1745 "map generators."), nullptr,
1746 nullptr, nullptr,
1748
1749 GEN_INT("northlatitude", wld.map.north_latitude,
1752 N_("Northernmost latitude"),
1753 /* TRANS: The string between single quotes is a setting name
1754 * and should not be translated. */
1755 N_("Combined with 'southlatitude', controls what climatic "
1756 "zones exist on the map. Higher values are further north, "
1757 "lower values are further south.\n"
1758 "\n"
1759 "1000 and -1000 gives a full planetary map.\n"
1760 "1000 and 0 gives only a northern hemisphere.\n"
1761 " 500 and 500 gives a map with the same middle-latitude "
1762 "climate everywhere.\n"
1763 " 300 and -300 gives an equatorial map.\n"
1764 "\n"
1765 "In rulesets that support it, latitude may also have certain "
1766 "effects during gameplay."), nullptr,
1767 nullptr, nullptr,
1770 GEN_INT("southlatitude", wld.map.south_latitude,
1773 N_("Southernmost latitude"),
1774 /* TRANS: The string between single quotes is a setting name
1775 * and should not be translated. */
1776 N_("Combined with 'northlatitude', controls what climatic "
1777 "zones exist on the map. Higher values are further north, "
1778 "lower values are further south.\n"
1779 "\n"
1780 "1000 and -1000 gives a full planetary map.\n"
1781 "1000 and 0 gives only a northern hemisphere.\n"
1782 " 500 and 500 gives a map with the same middle-latitude "
1783 "climate everywhere.\n"
1784 " 300 and -300 gives an equatorial map.\n"
1785 "\n"
1786 "In rulesets that support it, latitude may also have certain "
1787 "effects during gameplay."), nullptr,
1788 nullptr, nullptr,
1791
1792 GEN_INT("temperature", wld.map.server.temperature,
1795 N_("Average temperature of the planet"),
1796 N_("Small values will give a cold map, while larger values will "
1797 "give a hotter map.\n"
1798 "\n"
1799 "100 means a very dry and hot planet with no polar arctic "
1800 "zones, only tropical and dry zones.\n"
1801 " 70 means a hot planet with little polar ice.\n"
1802 " 50 means a temperate planet with normal polar, cold, "
1803 "temperate, and tropical zones; a desert zone overlaps "
1804 "tropical and temperate zones.\n"
1805 " 30 means a cold planet with small tropical zones.\n"
1806 " 0 means a very cold planet with large polar zones and no "
1807 "tropics."),
1808 nullptr, nullptr, nullptr,
1810
1811 GEN_INT("landmass", wld.map.server.landpercent,
1814 N_("Percentage of the map that is land"),
1815 N_("This setting gives the approximate percentage of the map "
1816 "that will be made into land."), nullptr, nullptr, nullptr,
1818
1819 GEN_INT("steepness", wld.map.server.steepness,
1822 N_("Amount of hills/mountains"),
1823 N_("Small values give flat maps, while higher values give a "
1824 "steeper map with more hills and mountains."),
1825 nullptr, nullptr, nullptr,
1827
1828 GEN_INT("wetness", wld.map.server.wetness,
1831 N_("Amount of water on landmasses"),
1832 N_("Small values mean lots of dry, desert-like land; "
1833 "higher values give a wetter map with more swamps, "
1834 "jungles, and rivers."), nullptr, nullptr, nullptr,
1836
1837 GEN_BOOL("globalwarming", game.info.global_warming,
1839 N_("Global warming"),
1840 N_("If turned off, global warming will not occur "
1841 "as a result of pollution. This setting does not "
1842 "affect pollution."), nullptr, nullptr,
1844
1845 GEN_INT("globalwarming_percent", game.server.global_warming_percent,
1847 N_("Global warming percent"),
1848 N_("This is a multiplier for the rate of accumulation of global "
1849 "warming."), nullptr, nullptr, nullptr,
1853
1854 GEN_BOOL("nuclearwinter", game.info.nuclear_winter,
1856 N_("Nuclear winter"),
1857 N_("If turned off, nuclear winter will not occur "
1858 "as a result of nuclear war."), nullptr, nullptr,
1860
1861 GEN_INT("nuclearwinter_percent", game.server.nuclear_winter_percent,
1863 N_("Nuclear winter percent"),
1864 N_("This is a multiplier for the rate of accumulation of nuclear "
1865 "winter."), nullptr, nullptr, nullptr,
1869
1870 GEN_INT("mapseed", wld.map.server.seed_setting,
1874#else /* FREECIV_WEB */
1876#endif /* FREECIV_WEB */
1877 N_("Map generation random seed"),
1878 N_("The same seed will always produce the same map; "
1879 "for zero (the default) a seed will be generated randomly, "
1880 "based on gameseed. If also gameseed is zero, "
1881 "the map will be completely random."),
1882 nullptr, nullptr, nullptr,
1884
1885 /* Map additional stuff: huts and specials. gameseed also goes here
1886 * because huts and specials are the first time the gameseed gets used (?)
1887 * These are done when the game starts, so these are historical and
1888 * fixed after the game has started.
1889 */
1890 GEN_INT("gameseed", game.server.seed_setting,
1894#else /* FREECIV_WEB */
1896#endif /* FREECIV_WEB */
1897 N_("Game random seed"),
1898 N_("For zero (the default) a seed will be chosen based "
1899 "on system entropy or, failing that, the current time."),
1900 nullptr, nullptr, nullptr,
1902
1903 GEN_INT("specials", wld.map.server.riches,
1905 N_("Amount of \"special\" resource tiles"),
1906 N_("Special resources improve the basic terrain type they "
1907 "are on. The server variable's scale is parts per "
1908 "thousand."), nullptr, nullptr, nullptr,
1910
1911 GEN_INT("huts", wld.map.server.huts,
1913 N_("Amount of huts (bonus extras)"),
1914 N_("Huts are tile extras that usually may be investigated by "
1915 "units. "
1916 "The server variable's scale is huts per thousand tiles."),
1917 huts_help, nullptr, huts_action,
1919
1920 GEN_INT("animals", wld.map.server.animals,
1922 N_("Amount of animals"),
1923 N_("Number of animals initially created on terrains "
1924 "defined for them in the ruleset (if the ruleset supports it). "
1925 "The server variable's scale is animals per "
1926 "thousand tiles."), nullptr, nullptr, nullptr,
1928
1929 /* Options affecting numbers of players and AI players. These only
1930 * affect the start of the game and can not be adjusted after that.
1931 */
1932 GEN_INT("minplayers", game.server.min_players,
1935 N_("Minimum number of players"),
1936 N_("There must be at least this many players (connected "
1937 "human players) before the game can start."),
1938 nullptr, nullptr, nullptr,
1940
1941 GEN_INT("maxplayers", game.server.max_players,
1943 N_("Maximum number of players"),
1944 N_("The maximal number of human and AI players who can be in "
1945 "the game. When this number of players are connected in "
1946 "the pregame state, any new players who try to connect "
1947 "will be rejected.\n"
1948 "When playing a scenario which defines player start positions, "
1949 "this setting cannot be set to greater than the number of "
1950 "defined start positions."),
1951 nullptr, maxplayers_callback, nullptr,
1953
1954 GEN_INT("aifill", game.info.aifill,
1956 N_("Limited number of AI players"),
1957 N_("If set to a positive value, then AI players will be "
1958 "automatically created or removed to keep the total "
1959 "number of players at this amount. As more players join, "
1960 "these AI players will be replaced. When set to zero, "
1961 "all AI players will be removed."),
1962 nullptr, nullptr, aifill_action,
1964
1965 GEN_ENUM("persistentready", game.info.persistent_ready,
1967 N_("When the Readiness of a player gets autotoggled off"),
1968 N_("In pre-game, usually when new players join or old ones leave, "
1969 "those who have already accepted game to start by toggling \"Ready\" "
1970 "get that autotoggled off in the changed situation. This setting "
1971 "can be used to make readiness more persistent."),
1972 nullptr, nullptr, nullptr, persistentready_name,
1974
1975 GEN_STRING("nationset", game.server.nationset,
1978 N_("Set of nations to choose from"),
1979 /* TRANS: do not translate '/list nationsets' */
1980 N_("Controls the set of nations allowed in the game. The "
1981 "choices are defined by the ruleset.\n"
1982 "Only nations in the set selected here will be allowed in "
1983 "any circumstances, including new players and civil war; "
1984 "small sets may thus limit the number of players in a game.\n"
1985 "If this is left blank, the ruleset's default nation set is "
1986 "used.\n"
1987 "See '/list nationsets' for possible choices for the "
1988 "currently loaded ruleset."),
1990
1991 GEN_INT("ec_turns", game.server.event_cache.turns,
1994 N_("Event cache for this number of turns"),
1995 N_("Event messages are saved for this number of turns. A value of "
1996 "0 deactivates the event cache."),
1997 nullptr, nullptr, nullptr, GAME_MIN_EVENT_CACHE_TURNS,
1999
2000 GEN_INT("ec_max_size", game.server.event_cache.max_size,
2003 N_("Size of the event cache"),
2004 N_("This defines the maximal number of events in the event cache."),
2005 nullptr, nullptr, nullptr, GAME_MIN_EVENT_CACHE_MAX_SIZE,
2007
2008 GEN_BOOL("ec_chat", game.server.event_cache.chat,
2011 N_("Save chat messages in the event cache"),
2012 N_("If turned on, chat messages will be saved in the event "
2013 "cache."), nullptr, nullptr, GAME_DEFAULT_EVENT_CACHE_CHAT)
2014
2015 GEN_BOOL("ec_info", game.server.event_cache.info,
2018 N_("Print turn and time for each cached event"),
2019 /* TRANS: Don't translate the text between single quotes. */
2020 N_("If turned on, all cached events will be marked by the turn "
2021 "and time of the event like '(T2 - 15:29:52)'."),
2022 nullptr, nullptr, GAME_DEFAULT_EVENT_CACHE_INFO)
2023
2024 /* Game initialization parameters (only affect the first start of the game,
2025 * and not reloads). Can not be changed after first start of game.
2026 */
2027 GEN_STRING("startunits", game.server.start_units,
2030 N_("List of players' initial units"),
2031 N_("This should be a string of characters, each of which "
2032 "specifies a unit role. The first character must be native to "
2033 "at least one \"Starter\" terrain. The characters and their "
2034 "meanings are:\n"
2035 " c = City founder (eg., Settlers)\n"
2036 " w = Terrain worker (eg., Engineers)\n"
2037 " x = Explorer (eg., Explorer)\n"
2038 " k = Gameloss (eg., King)\n"
2039 " s = Diplomat (eg., Diplomat)\n"
2040 " f = Ferryboat (eg., Trireme)\n"
2041 " d = Ok defense unit (eg., Warriors)\n"
2042 " D = Good defense unit (eg., Phalanx)\n"
2043 " a = Fast attack unit (eg., Horsemen)\n"
2044 " A = Strong attack unit (eg., Catapult)\n"),
2046
2047 GEN_BOOL("startcity", game.server.start_city,
2050 N_("Whether player starts with a city"),
2051 N_("If this is set, game will start with player's first "
2052 "city already founded to starting location."),
2053 nullptr, nullptr, GAME_DEFAULT_START_CITY)
2054
2055 GEN_INT("dispersion", game.server.dispersion,
2058 N_("Area where initial units are located"),
2059 N_("This is the radius within "
2060 "which the initial units are dispersed."),
2061 nullptr, nullptr, nullptr,
2063
2064 GEN_INT("gold", game.info.gold,
2067 N_("Starting gold per player"),
2068 N_("At the beginning of the game, each player is given this "
2069 "much gold."), nullptr, nullptr, nullptr,
2071
2072 GEN_INT("infrapoints", game.info.infrapoints,
2075 N_("Starting infrapoints per player"),
2076 N_("At the beginning of the game, each player is given this "
2077 "many infrapoints."), nullptr, nullptr, nullptr,
2079
2080 GEN_INT("techlevel", game.info.tech,
2083 N_("Number of initial techs per player"),
2084 /* TRANS: The string between single quotes is a setting name and
2085 * should not be translated. */
2086 N_("At the beginning of the game, each player is given this "
2087 "many technologies. The technologies chosen are random for "
2088 "each player. Depending on the value of tech_cost_style in "
2089 "the ruleset, a big value for 'techlevel' can make the next "
2090 "techs really expensive."), nullptr, nullptr, nullptr,
2092
2093 GEN_INT("sciencebox", game.info.sciencebox,
2096 N_("Technology cost multiplier percentage"),
2097 N_("This affects how quickly players can research new "
2098 "technology. All tech costs are multiplied by this amount "
2099 "(as a percentage). The base tech costs are determined by "
2100 "the ruleset or other game settings."),
2101 nullptr, nullptr, nullptr, GAME_MIN_SCIENCEBOX, GAME_MAX_SCIENCEBOX,
2103
2104 GEN_BOOL("multiresearch", game.server.multiresearch,
2106 N_("Allow researching multiple technologies"),
2107 N_("Allows switching to any technology without wasting old "
2108 "research. Bulbs are never transferred to new technology. "
2109 "Techpenalty options are ineffective after enabling that "
2110 "option."), nullptr, nullptr,
2112
2113 GEN_INT("techpenalty", game.server.techpenalty,
2115 N_("Percentage penalty when changing tech"),
2116 N_("If you change your current research technology, and you have "
2117 "positive research points, you lose this percentage of those "
2118 "research points. This does not apply when you have just gained "
2119 "a technology this turn."), nullptr, nullptr, nullptr,
2122
2123 GEN_INT("techlost_recv", game.server.techlost_recv,
2125 N_("Chance to lose a technology while receiving it"),
2126 N_("The chance that learning a technology by treaty or theft "
2127 "will fail."),
2128 nullptr, nullptr, nullptr, GAME_MIN_TECHLOST_RECV,
2130
2131 GEN_INT("techlost_donor", game.server.techlost_donor,
2133 N_("Chance to lose a technology while giving it"),
2134 N_("The chance that your civilization will lose a technology if "
2135 "you teach it to someone else by treaty, or if it is stolen "
2136 "from you."),
2137 nullptr, nullptr, nullptr, GAME_MIN_TECHLOST_DONOR,
2139
2140 GEN_INT("techleak", game.info.tech_leak_pct,
2142 N_("Tech leakage percent"),
2143 N_("The rate of the tech leakage. This multiplied by the "
2144 "percentage of players who know the tech tell which "
2145 "percentage of tech's bulb cost gets leaked each turn. "
2146 "This setting has no effect if the ruleset has disabled "
2147 "tech leakage."),
2148 nullptr, nullptr, nullptr, GAME_MIN_TECHLEAK, GAME_MAX_TECHLEAK,
2150
2151 GEN_BOOL("team_pooled_research", game.info.team_pooled_research,
2153 N_("Team pooled research"),
2154 N_("If this setting is turned on, then the team mates will share "
2155 "the science research. Else, every player of the team will "
2156 "have to make its own."),
2157 nullptr, nullptr, GAME_DEFAULT_TEAM_POOLED_RESEARCH)
2158
2159 GEN_INT("diplbulbcost", game.server.diplbulbcost,
2161 N_("Penalty when getting tech from treaty"),
2162 N_("For each technology you gain from a diplomatic treaty, you "
2163 "lose research points equal to this percentage of the cost to "
2164 "research a new technology. If this is non-zero, you can end up "
2165 "with negative research points."),
2166 nullptr, nullptr, nullptr,
2169
2170 GEN_INT("diplgoldcost", game.server.diplgoldcost,
2172 N_("Penalty when getting gold from treaty"),
2173 N_("When transferring gold in diplomatic treaties, this percentage "
2174 "of the agreed sum is lost to both parties; it is deducted from "
2175 "the donor but not received by the recipient."),
2176 nullptr, nullptr, nullptr,
2179
2180 GEN_INT("incite_gold_loss_chance", game.server.incite_gold_loss_chance,
2182 N_("Probability of gold loss during inciting revolt"),
2183 N_("When unit trying to incite revolt is eliminated, half of the gold "
2184 "(or quarter, if unit was caught), prepared to bribe citizens, "
2185 "can be lost or captured by enemy."),
2186 nullptr, nullptr, nullptr,
2189
2190 GEN_INT("incite_gold_capt_chance", game.server.incite_gold_capt_chance,
2192 N_("Probability of gold capture during inciting revolt"),
2193 N_("When unit trying to incite revolt is eliminated and lose its "
2194 "gold, there is chance that this gold would be captured by "
2195 "city defender. Transfer tax would be applied, though. "
2196 "This setting is irrelevant, if incite_gold_loss_chance is zero."),
2197 nullptr, nullptr, nullptr,
2200
2201 GEN_INT("conquercost", game.server.conquercost,
2203 N_("Penalty when getting tech from conquering"),
2204 N_("For each technology you gain by conquering an enemy city, you "
2205 "lose research points equal to this percentage of the cost to "
2206 "research a new technology. If this is non-zero, you can end up "
2207 "with negative research points."),
2208 nullptr, nullptr, nullptr,
2211
2212 GEN_INT("freecost", game.server.freecost,
2214 N_("Penalty when getting a free tech"),
2215 /* TRANS: The strings between single quotes are setting names and
2216 * shouldn't be translated. */
2217 N_("For each technology you gain \"for free\" (other than "
2218 "covered by 'diplcost' or 'conquercost': for instance, from huts "
2219 "or from Great Library effects), you lose research points "
2220 "equal to this percentage of the cost to research a new "
2221 "technology. If this is non-zero, you can end up "
2222 "with negative research points."),
2223 nullptr, nullptr, nullptr,
2225
2226 GEN_INT("techlossforgiveness", game.info.techloss_forgiveness,
2228 N_("Research point debt threshold for losing tech"),
2229 N_("When you have negative research points, and your shortfall is "
2230 "greater than this percentage of the cost of your current "
2231 "research, you forget a technology you already knew.\n"
2232 "The special value -1 prevents loss of technology regardless of "
2233 "research points."),
2234 nullptr, nullptr, nullptr,
2237
2238 GEN_INT("techlossrestore", game.server.techloss_restore,
2240 N_("Research points restored after losing a tech"),
2241 N_("When you lose a technology due to a negative research balance "
2242 "(see 'techlossforgiveness'), this percentage of its research "
2243 "cost is credited to your research balance (this may not be "
2244 "sufficient to make it positive).\n"
2245 "The special value -1 means that your research balance is always "
2246 "restored to zero, regardless of your previous shortfall."),
2247 nullptr, nullptr, nullptr,
2250
2251 GEN_INT("foodbox", game.info.foodbox,
2254 N_("Food required for a city to grow"),
2255 N_("This is the base amount of food required to grow a city. "
2256 "This value is multiplied by another factor that comes from "
2257 "the ruleset and is dependent on the size of the city."),
2258 nullptr, nullptr, nullptr,
2260
2261 GEN_INT("aqueductloss", game.server.aqueductloss,
2263 N_("Percentage food lost when city can't grow"),
2264 N_("If a city would expand, but it can't because it lacks some "
2265 "prerequisite (traditionally an Aqueduct or Sewer System), "
2266 "this is the base percentage of its foodbox that is lost "
2267 "each turn; the penalty may be reduced by buildings or other "
2268 "circumstances, depending on the ruleset."),
2269 nullptr, nullptr, nullptr,
2272
2273 GEN_INT("shieldbox", game.info.shieldbox,
2276 N_("Multiplier percentage for production costs"),
2277 N_("This affects how quickly units and buildings can be "
2278 "produced. The base costs are multiplied by this value (as "
2279 "a percentage)."),
2280 nullptr, nullptr, nullptr,
2282
2283 /* Notradesize and fulltradesize used to have callbacks to prevent them
2284 * from being set illegally (notradesize > fulltradesize). However this
2285 * provided a problem when setting them both through the client's settings
2286 * dialog, since they cannot both be set atomically. So the callbacks were
2287 * removed and instead the game now knows how to deal with invalid
2288 * settings. */
2289 GEN_INT("fulltradesize", game.info.fulltradesize,
2291 N_("Minimum city size to get full trade"),
2292 /* TRANS: The strings between single quotes are setting names and
2293 * shouldn't be translated. */
2294 N_("There is a trade penalty in all cities smaller than this. "
2295 "The penalty is 100% (no trade at all) for sizes up to "
2296 "'notradesize', and decreases gradually to 0% (no penalty "
2297 "except the normal corruption) for size='fulltradesize'. "
2298 "See also 'notradesize'."), nullptr, nullptr, nullptr,
2301
2302 GEN_INT("notradesize", game.info.notradesize,
2304 N_("Maximum size of a city without trade"),
2305 /* TRANS: The strings between single quotes are setting names and
2306 * shouldn't be translated. */
2307 N_("Cities do not produce any trade at all unless their size "
2308 "is larger than this amount. The produced trade increases "
2309 "gradually for cities larger than 'notradesize' and smaller "
2310 "than 'fulltradesize'. See also 'fulltradesize'."),
2311 nullptr, nullptr, nullptr,
2314
2315 GEN_INT("tradeworldrelpct", game.info.trade_world_rel_pct,
2317 N_("How largely trade distance is relative to world size"),
2318 /* TRANS: The strings between single quotes are setting names and
2319 * shouldn't be translated. */
2320 N_("When determining trade between cities, the distance factor "
2321 "can be partly or fully relative to world size. This setting "
2322 "determines how big percentage of the bonus calculation is "
2323 "relative to world size, and how much only absolute distance "
2324 "matters."),
2325 nullptr, nullptr, nullptr,
2328
2329 GEN_INT("citymindist", game.info.citymindist,
2332 N_("Minimum distance between cities"),
2333 N_("When a player attempts to found a new city, it is prevented "
2334 "if the distance from any existing city is less than this "
2335 "setting. For example, when this setting is 3, there must be "
2336 "at least two clear tiles in any direction between all existing "
2337 "cities and the new city site. A value of 1 removes any such "
2338 "restriction on city placement."),
2339 nullptr, nullptr, nullptr,
2342
2343 GEN_BOOL("trading_tech", game.info.trading_tech,
2345 N_("Technology trading"),
2346 N_("If turned off, trading technologies in the diplomacy dialog "
2347 "is not allowed."), nullptr, nullptr,
2349
2350 GEN_BOOL("trading_gold", game.info.trading_gold,
2352 N_("Gold trading"),
2353 N_("If turned off, trading gold in the diplomacy dialog "
2354 "is not allowed."), nullptr, nullptr,
2356
2357 GEN_BOOL("trading_city", game.info.trading_city,
2359 N_("City trading"),
2360 N_("If turned off, trading cities in the diplomacy dialog "
2361 "is not allowed."), nullptr, nullptr,
2363
2364 GEN_ENUM("caravan_bonus_style", game.info.caravan_bonus_style,
2366 N_("Caravan bonus style"),
2367 N_("The formula for the bonus when a caravan enters a city. "
2368 "CLASSIC bonuses are proportional to distance and trade "
2369 "of source and destination with multipliers for overseas and "
2370 "international destinations. LOGARITHMIC bonuses are "
2371 "proportional to log^2(distance + trade)."),
2372 nullptr, nullptr, nullptr, caravanbonusstyle_name,
2374
2375 GEN_ENUM("trade_revenue_style", game.info.trade_revenue_style,
2377 N_("Trade revenue style"),
2378 N_("The formula for the trade a city receives from a trade route. "
2379 "CLASSIC revenues are given by the sum of the two city sizes "
2380 "plus the distance between them, with multipliers for overseas "
2381 "and international routes. "
2382 "SIMPLE revenues are proportional to the average trade of the "
2383 "two cities."),
2384 nullptr, nullptr, nullptr, traderevenuestyle_name,
2386
2387 GEN_INT("trademindist", game.info.trademindist,
2389 N_("Minimum distance for trade routes"),
2390 N_("In order for two cities in the same civilization to establish "
2391 "a trade route, they must be at least this far apart on the "
2392 "map. For square grids, the distance is calculated as "
2393 "\"Manhattan distance\", that is, the sum of the displacements "
2394 "along the x and y directions."), nullptr, nullptr, nullptr,
2397
2398 GEN_INT("rapturedelay", game.info.rapturedelay,
2401 N_("Number of turns between rapture effect"),
2402 N_("Sets the number of turns between rapture growth of a city. "
2403 "If set to n a city will grow after celebrating for n+1 "
2404 "turns."),
2405 nullptr, nullptr, nullptr,
2408
2409 GEN_INT("disasters", game.info.disasters,
2412 N_("Frequency of disasters"),
2413 N_("Affects how often random disasters happen to cities, "
2414 "if any are defined by the ruleset. The relative frequency "
2415 "of disaster types is set by the ruleset. Zero prevents "
2416 "any random disasters from occurring."),
2417 nullptr, nullptr, nullptr,
2420
2421 GEN_ENUM("traitdistribution", game.server.trait_dist,
2423 N_("AI trait distribution method"),
2424 N_("How trait values are given to AI players."),
2425 nullptr, nullptr, nullptr, trait_dist_name,
2427
2428 GEN_INT("razechance", game.server.razechance,
2430 N_("Chance for conquered building destruction"),
2431 N_("When a player conquers a city, each city improvement has this "
2432 "percentage chance to be destroyed."), nullptr, nullptr, nullptr,
2434
2435 GEN_INT("occupychance", game.server.occupychance,
2437 N_("Chance of moving into tile after attack"),
2438 N_("If set to 0, combat is Civ1/2-style (when you attack, "
2439 "you remain in place). If set to 100, attacking units "
2440 "will always move into the tile they attacked when they win "
2441 "the combat (and no enemy units remain in the tile). If "
2442 "set to a value between 0 and 100, this will be used as "
2443 "the percent chance of \"occupying\" territory."),
2444 nullptr, nullptr, nullptr,
2447
2450 N_("Turn on/off server-side autoattack"),
2451 N_("If set to on, units with moves left will automatically "
2452 "consider attacking enemy units that move adjacent to them."),
2453 nullptr, nullptr, GAME_DEFAULT_AUTOATTACK)
2454
2455 GEN_BOOL("killstack", game.info.killstack,
2458 N_("Do all units in tile die with defender"),
2459 N_("If this is enabled, each time a defender unit loses in combat, "
2460 "and is not inside a city or suitable base, all units in the same "
2461 "tile are destroyed along with the defender. If this is disabled, "
2462 "only the defender unit is destroyed."),
2463 nullptr, nullptr, GAME_DEFAULT_KILLSTACK)
2464
2465 GEN_BOOL("killcitizen", game.info.killcitizen,
2467 N_("Reduce city population after attack"),
2468 N_("This flag indicates whether a city's population is reduced "
2469 "after a successful attack by an enemy unit. If this is "
2470 "disabled, population is never reduced. Even when this is "
2471 "enabled, only some units may kill citizens."),
2472 nullptr, nullptr, GAME_DEFAULT_KILLCITIZEN)
2473
2474 GEN_INT("killunhomed", game.server.killunhomed,
2476 N_("Slowly kill units without home cities (e.g., starting units)"),
2477 N_("If greater than 0, then every unit without a homecity will "
2478 "lose hitpoints each turn. The number of hitpoints lost is "
2479 "given by 'killunhomed' percent of the hitpoints of the unit "
2480 "type. At least one hitpoint is lost every turn until the "
2481 "death of the unit."),
2482 nullptr, nullptr, nullptr, GAME_MIN_KILLUNHOMED, GAME_MAX_KILLUNHOMED,
2484
2485 GEN_ENUM("borders", game.info.borders,
2488 N_("National borders"),
2489 N_("If this is not disabled, then any land tiles around a "
2490 "city or border-claiming extra (like the classic ruleset's "
2491 "Fortress base) will be owned by that nation. "
2492 "SEE_INSIDE and EXPAND makes everything inside a player's "
2493 "borders visible at once. ENABLED will, in some rulesets, "
2494 "grant the same visibility if certain conditions are met."),
2495 nullptr, nullptr, nullptr, borders_name, GAME_DEFAULT_BORDERS)
2496
2497 GEN_ENUM("happyborders", game.info.happyborders,
2500 N_("Units inside borders cause no unhappiness"),
2501 N_("If this is set, units will not cause unhappiness when "
2502 "inside your borders, or even allies borders, depending "
2503 "on value."), nullptr, nullptr, nullptr,
2505
2506 GEN_ENUM("diplomacy", game.info.diplomacy,
2509 N_("Ability to do diplomacy with other players"),
2510 N_("This setting controls the ability to do diplomacy with "
2511 "other players."),
2512 nullptr, nullptr, nullptr, diplomacy_name, GAME_DEFAULT_DIPLOMACY)
2513
2516 N_("Allowed city names"),
2517 /* TRANS: The strings between double quotes are also translated
2518 * separately (they must match!). The strings between parentheses
2519 * and in uppercase must not be translated. */
2520 N_("- \"No restrictions\" (NO_RESTRICTIONS): players can have "
2521 "multiple cities with the same names.\n"
2522 "- \"Unique to a player\" (PLAYER_UNIQUE): one player can't "
2523 "have multiple cities with the same name.\n"
2524 "- \"Globally unique\" (GLOBAL_UNIQUE): all cities in a game "
2525 "have to have different names.\n"
2526 "- \"No city name stealing\" (NO_STEALING): like "
2527 "\"Globally unique\", but a player isn't allowed to use a "
2528 "default city name of another nation unless it is a default "
2529 "for their nation also."),
2530 nullptr, nullptr, nullptr, citynames_name,
2532
2533 GEN_ENUM("plrcolormode", game.server.plrcolormode,
2535 N_("How to pick player colors"),
2536 /* TRANS: The strings between double quotes are also translated
2537 * separately (they must match!). The strings between single quotes
2538 * are setting names and shouldn't be translated. The strings
2539 * between parentheses and in uppercase must not be translated. */
2540 N_("This setting determines how player colors are chosen. Player "
2541 "colors are used in the Nations report, for national borders on "
2542 "the map, and so on.\n"
2543 "- \"Per-player, in order\" (PLR_ORDER): colors are assigned to "
2544 "individual players in order from a list defined by the "
2545 "ruleset.\n"
2546 "- \"Per-player, random\" (PLR_RANDOM): colors are assigned "
2547 "to individual players randomly from the set defined by the "
2548 "ruleset.\n"
2549 "- \"Set manually\" (PLR_SET): colors can be set with the "
2550 "'playercolor' command before the game starts; these are not "
2551 "restricted to the ruleset colors. Any players for which no "
2552 "color is set when the game starts get a random color from the "
2553 "ruleset.\n"
2554 "- \"Per-team, in order\" (TEAM_ORDER): colors are assigned to "
2555 "teams from the list in the ruleset. Every player on the same "
2556 "team gets the same color.\n"
2557 "- \"Per-nation, in order\" (NATION_ORDER): if the ruleset "
2558 "defines a color for a player's nation, the player takes that "
2559 "color. Any players whose nations don't have associated colors "
2560 "get a random color from the list in the ruleset.\n"
2561 "Regardless of this setting, individual player colors can be "
2562 "changed after the game starts with the 'playercolor' command."),
2565
2566 /* Flexible rules: these can be changed after the game has started.
2567 *
2568 * The distinction between "rules" and "flexible rules" is not always
2569 * clearcut, and some existing cases may be largely historical or
2570 * accidental. However some generalizations can be made:
2571 *
2572 * -- Low-level game mechanics should not be flexible (eg, rulesets).
2573 * -- Options which would affect the game "state" (city production etc)
2574 * should not be flexible (eg, foodbox).
2575 * -- Options which are explicitly sent to the client (eg, in
2576 * packet_game_info) should probably not be flexible, or at
2577 * least need extra care to be flexible.
2578 */
2579 GEN_ENUM("barbarians", game.server.barbarianrate,
2582 N_("Barbarian appearance frequency"),
2583 /* TRANS: The string between single quotes is a setting name and
2584 * should not be translated. */
2585 N_("This setting controls how frequently the barbarians appear "
2586 "in the game. See also the 'onsetbarbs' setting."),
2587 nullptr, nullptr, nullptr, barbarians_name,
2589
2590 GEN_INT("onsetbarbs", game.server.onsetbarbarian,
2593 N_("Barbarian onset turn"),
2594 N_("Barbarians will not appear before this turn."),
2595 nullptr, nullptr, nullptr,
2598
2599 GEN_ENUM("revolentype", game.info.revolentype,
2601 N_("Way to determine revolution length"),
2602 N_("Which method is used in determining how long period of anarchy "
2603 "lasts when changing government. The actual value is set with "
2604 "'revolen' setting. The 'quickening' methods depend on how "
2605 "many times any player has changed to this type of government "
2606 "before, so it becomes easier to establish a new system of "
2607 "government if it has been done before."),
2608 nullptr, nullptr, nullptr, revolentype_name,
2610
2614 N_("Length of revolution"),
2615 N_("When changing governments, a period of anarchy will occur. "
2616 "Value of this setting, used the way 'revolentype' setting "
2617 "dictates, defines the length of the anarchy."),
2618 nullptr, nullptr, nullptr,
2621
2622 GEN_BOOL("fogofwar", game.info.fogofwar,
2624 N_("Whether to enable fog of war"),
2625 N_("If this is enabled, only those units and cities within "
2626 "the vision range of your own units and cities will be "
2627 "revealed to you. You will not see new cities or terrain "
2628 "changes in tiles not observed."),
2629 nullptr, nullptr, GAME_DEFAULT_FOGOFWAR)
2630
2631 GEN_BOOL("foggedborders", game.server.foggedborders,
2633 N_("Whether fog of war applies to border changes"),
2634 N_("If this setting is enabled, players will not be able "
2635 "to see changes in tile ownership if they do not have "
2636 "direct sight of the affected tiles. Otherwise, players "
2637 "can see any or all changes to borders as long as they "
2638 "have previously seen the tiles."),
2639 nullptr, nullptr, GAME_DEFAULT_FOGGEDBORDERS)
2640
2641 GEN_BITWISE("airliftingstyle", game.info.airlifting_style,
2643 ALLOW_NONE, ALLOW_BASIC, N_("Airlifting style"),
2644 /* TRANS: The strings between double quotes are also
2645 * translated separately (they must match!). The strings
2646 * between parenthesis and in uppercase must not be
2647 * translated. */
2648 N_("This setting affects airlifting units between cities. It "
2649 "can be a set of the following values:\n"
2650 "- \"Allows units to be airlifted from allied cities\" "
2651 "(FROM_ALLIES).\n"
2652 "- \"Allows units to be airlifted to allied cities\" "
2653 "(TO_ALLIES).\n"
2654 "- \"Unlimited units from source city\" (SRC_UNLIMITED): "
2655 "airlifting from a city doesn't reduce the "
2656 "airlifted counter. It depends on the ruleset whether "
2657 "this is possible even with zero airlift capacity.\n"
2658 "- \"Unlimited units to destination city\" "
2659 "(DEST_UNLIMITED): airlifting to a city doesn't "
2660 "reduce the airlifted counter. It depends on the ruleset "
2661 "whether this is possible even with zero airlift capacity."),
2662 nullptr, nullptr, airliftingstyle_name,
2664
2665 GEN_INT("diplchance", game.server.diplchance,
2668 N_("Base chance for diplomats and spies to succeed"),
2669 N_("The base chance of a spy returning from a successful mission and "
2670 "the base chance of success for diplomats and spies for most "
2671 "aggressive mission types. Not all the mission types use diplchance "
2672 "as a base chance – a ruleset can even say that no action at all does. "
2673 "Unit Bribing, and Unit Sabotaging never do. "
2674 "Non-aggressive missions typically have no base chance "
2675 "at all, but always success."),
2676 nullptr, nullptr, nullptr,
2678
2682 N_("What kinds of victories are possible"),
2683 /* TRANS: The strings between double quotes are also translated
2684 * separately (they must match!). The strings between single
2685 * quotes are setting names and shouldn't be translated.
2686 * The strings between parentheses and in uppercase must stay as
2687 * untranslated. */
2688 N_("This setting controls how game can be won. One can always "
2689 "win by conquering entire planet, but other victory conditions "
2690 "can be enabled or disabled:\n"
2691 "- \"Spacerace\" (SPACERACE): Spaceship is built and travels to "
2692 "Alpha Centauri.\n"
2693 "- \"Allied\" (ALLIED): After defeating enemies, all remaining "
2694 "players are allied.\n"
2695 "- \"Culture\" (CULTURE): Player meets ruleset defined cultural "
2696 "domination criteria.\n"
2697 "- \"World Peace\" (WORLDPEACE): There's no wars in the world for "
2698 "the specified amount of turns.\n"),
2699 nullptr, nullptr, victory_conditions_name,
2701
2704 N_("Should the game end if the spaceship arrives?"),
2705 N_("If this option is turned on, the game will end with the "
2706 "arrival of a spaceship at Alpha Centauri."),
2707 nullptr, nullptr, GAME_DEFAULT_END_SPACESHIP)
2708
2709 GEN_INT("spaceship_travel_pct", game.server.spaceship_travel_pct,
2712 N_("Percentage to multiply spaceship travel time by"),
2713 N_("This percentage is multiplied onto the time it will take for "
2714 "a spaceship to arrive at Alpha Centauri."),
2715 nullptr, nullptr, nullptr,
2718
2719 GEN_INT("civilwarsize", game.server.civilwarsize,
2722 N_("Minimum number of cities for civil war"),
2723 N_("A civil war is triggered when a player has at least this "
2724 "many cities and the player's capital is captured. If "
2725 "this option is set to the maximum value, civil wars are "
2726 "turned off altogether."), nullptr, nullptr, nullptr,
2729
2730 GEN_BOOL("restrictinfra", game.info.restrictinfra,
2733 N_("Restrict the use of the infrastructure for enemy units"),
2734 N_("If this option is enabled, the use of roads and rails "
2735 "will be restricted for enemy units."), nullptr, nullptr,
2737
2738 GEN_BOOL("unreachableprotects", game.info.unreachable_protects,
2741 N_("Does unreachable unit protect reachable ones"),
2742 N_("This option controls whether tiles with both unreachable "
2743 "and reachable units can be attacked. If disabled, any "
2744 "tile with reachable units can be attacked. If enabled, "
2745 "tiles with an unreachable unit in them cannot be attacked. "
2746 "Some units in some rulesets may override this, never "
2747 "protecting reachable units on their tile."),
2748 nullptr, nullptr, GAME_DEFAULT_UNRPROTECTS)
2749
2750 GEN_INT("contactturns", game.server.contactturns,
2753 N_("Turns until player contact is lost"),
2754 N_("Players may meet for diplomacy this number of turns "
2755 "after their units have last met, even when they do not have "
2756 "an embassy. If set to zero, then players cannot meet unless "
2757 "they have an embassy."),
2758 nullptr, nullptr, nullptr,
2761
2762 GEN_BOOL("savepalace", game.server.savepalace,
2765 N_("Rebuild palace whenever capital is conquered"),
2766 N_("If this is turned on, when the capital is conquered the "
2767 "palace is automatically rebuilt for free in another randomly "
2768 "chosen city. This is significant because the technology "
2769 "requirement for building a palace will be ignored. (In "
2770 "some rulesets, buildings other than the palace are affected "
2771 "by this setting.)"),
2772 nullptr, nullptr, GAME_DEFAULT_SAVEPALACE)
2773
2774 GEN_BOOL("homecaughtunits", game.server.homecaughtunits,
2777 N_("Give caught units a homecity"),
2778 /* TRANS: The string between single quotes is a setting name and
2779 * should not be translated. */
2780 N_("If unset, caught units will have no homecity and will be "
2781 "subject to the 'killunhomed' option."),
2782 nullptr, nullptr, GAME_DEFAULT_HOMECAUGHTUNITS)
2783
2784 GEN_BOOL("naturalcitynames", game.server.natural_city_names,
2787 N_("Whether to use natural city names"),
2788 N_("If enabled, the default city names will be determined based "
2789 "on the surrounding terrain."),
2790 nullptr, nullptr, GAME_DEFAULT_NATURALCITYNAMES)
2791
2792 GEN_BOOL("migration", game.server.migration,
2795 N_("Whether to enable citizen migration"),
2796 /* TRANS: The strings between single quotes are setting names
2797 * and should not be translated. */
2798 N_("This is the master setting that controls whether citizen "
2799 "migration is active in the game. If enabled, citizens may "
2800 "automatically move from less desirable cities to more "
2801 "desirable ones. The \"desirability\" of a given city is "
2802 "calculated from a number of factors. In general larger "
2803 "cities with more income and improvements will be preferred. "
2804 "Citizens will never migrate out of the capital, or cause "
2805 "a wonder to be lost by disbanding a city. A number of other "
2806 "settings control how migration behaves:\n"
2807 " 'mgr_turninterval' - How often citizens try to migrate.\n"
2808 " 'mgr_foodneeded' - Whether destination food is checked.\n"
2809 " 'mgr_distance' - How far citizens will migrate.\n"
2810 " 'mgr_worldchance' - Chance for inter-nation migration.\n"
2811 " 'mgr_nationchance' - Chance for intra-nation migration."),
2812 nullptr, nullptr, GAME_DEFAULT_MIGRATION)
2813
2814 GEN_INT("mgr_turninterval", game.server.mgr_turninterval,
2817 N_("Number of turns between migrations from a city"),
2818 /* TRANS: Do not translate 'migration' setting name. */
2819 N_("This setting controls the number of turns between migration "
2820 "checks for a given city. The interval is calculated from "
2821 "the founding turn of the city. So for example if this "
2822 "setting is 5, citizens will look for a suitable migration "
2823 "destination every five turns from the founding of their "
2824 "current city. Migration will never occur the same turn "
2825 "that a city is built. This setting has no effect unless "
2826 "migration is enabled by the 'migration' setting."),
2827 nullptr, nullptr, nullptr,
2830
2831 GEN_BOOL("mgr_foodneeded", game.server.mgr_foodneeded,
2834 N_("Whether migration is limited by food"),
2835 /* TRANS: Do not translate 'migration' setting name. */
2836 N_("If this setting is enabled, citizens will not migrate to "
2837 "cities which would not have enough food to support them. "
2838 "This setting has no effect unless migration is enabled by "
2839 "the 'migration' setting."), nullptr, nullptr,
2841
2842 GEN_INT("mgr_distance", game.server.mgr_distance,
2845 N_("Maximum distance citizens may migrate"),
2846 /* TRANS: Do not translate 'migration' setting name. */
2847 N_("This setting controls how far citizens may look for a "
2848 "suitable migration destination when deciding which city "
2849 "to migrate to. The value is added to the candidate target "
2850 "city's radius and compared to the distance between the "
2851 "two cities. If the distance is lower or equal, migration "
2852 "is possible. (So with a setting of 0, citizens will only "
2853 "consider migrating if their city's center is within the "
2854 "destination city's working radius.) This setting has no "
2855 "effect unless migration is enabled by the 'migration' "
2856 "setting."),
2857 nullptr, nullptr, nullptr, GAME_MIN_MGR_DISTANCE,
2859
2860 GEN_INT("mgr_nationchance", game.server.mgr_nationchance,
2863 N_("Percent probability for migration within the same nation"),
2864 /* TRANS: Do not translate 'migration' setting name. */
2865 N_("This setting controls how likely it is for citizens to "
2866 "migrate between cities owned by the same player. Zero "
2867 "indicates migration will never occur, 100 means that "
2868 "migration will always occur if the citizens find a suitable "
2869 "destination. This setting has no effect unless migration "
2870 "is activated by the 'migration' setting."),
2871 nullptr, nullptr, nullptr,
2874
2875 GEN_INT("mgr_worldchance", game.server.mgr_worldchance,
2878 N_("Percent probability for migration between foreign cities"),
2879 /* TRANS: Do not translate 'migration' setting name. */
2880 N_("This setting controls how likely it is for migration "
2881 "to occur between cities owned by different players. "
2882 "Zero indicates migration will never occur, 100 means "
2883 "that citizens will always migrate if they find a suitable "
2884 "destination. This setting has no effect if migration is "
2885 "not enabled by the 'migration' setting."),
2886 nullptr, nullptr, nullptr,
2889
2890 /* Meta options: these don't affect the internal rules of the game, but
2891 * do affect players. Also options which only produce extra server
2892 * "output" and don't affect the actual game.
2893 * ("endturn" is here, and not RULES_FLEXIBLE, because it doesn't
2894 * affect what happens in the game, it just determines when the
2895 * players stop playing and look at the score.)
2896 */
2897 GEN_STRING("allowtake", game.server.allow_take,
2899 N_("Players that users are allowed to take"),
2900 /* TRANS: the strings in double quotes are server command names
2901 * and should not be translated. */
2902 N_("This should be a string of characters, each of which "
2903 "specifies a type or status of a civilization (player).\n"
2904 "Clients will only be permitted to take or observe those "
2905 "players which match one of the specified letters. This "
2906 "only affects future uses of the \"take\" or \"observe\" "
2907 "commands; it is not retroactive. The characters and their "
2908 "meanings are:\n"
2909 " o,O = Global observer\n"
2910 " b = Barbarian players\n"
2911 " d = Dead players\n"
2912 " a,A = AI players\n"
2913 " h,H = Human players\n"
2914 "The first description on this list which matches a "
2915 "player is the one which applies. Thus 'd' does not "
2916 "include dead barbarians, 'a' does not include dead AI "
2917 "players, and so on. Upper case letters apply before "
2918 "the game has started, lower case letters afterwards.\n"
2919 "Each character above may be followed by one of the "
2920 "following numbers to allow or restrict the manner "
2921 "of connection:\n"
2922 "(none) = Controller allowed, observers allowed, "
2923 "can displace connections. (Displacing a connection means "
2924 "that you may take over a player, even when another user "
2925 "already controls that player.)\n"
2926 " 1 = Controller allowed, observers allowed, "
2927 "can't displace connections;\n"
2928 " 2 = Controller allowed, no observers allowed, "
2929 "can displace connections;\n"
2930 " 3 = Controller allowed, no observers allowed, "
2931 "can't displace connections;\n"
2932 " 4 = No controller allowed, observers allowed"),
2934
2935 GEN_BOOL("autotoggle", game.server.auto_ai_toggle,
2938 N_("Whether AI-status toggles with connection"),
2939 N_("If enabled, AI status is turned off when a player "
2940 "connects, and on when a player disconnects."),
2942
2943 GEN_INT("endturn", game.server.end_turn,
2945 N_("Turn the game ends"),
2946 N_("The game will end at the end of the given turn."),
2947 nullptr, endturn_callback, nullptr,
2949
2952 N_("Reveal the map"),
2953 /* TRANS: The strings between double quotes are also translated
2954 * separately (they must match!). The strings between single
2955 * quotes are setting names and shouldn't be translated.
2956 * The strings between parentheses and in uppercase must not be
2957 * translated. */
2958 N_("If \"Reveal map at game start\" (START) is set, the "
2959 "initial state of the entire map will be known to all "
2960 "players from the start of the game, although it may "
2961 "still be fogged (depending on the 'fogofwar' setting). "
2962 "If \"Unfog map for dead players\" (DEAD) is set, dead "
2963 "players can see the entire map, if they are alone in "
2964 "their team."),
2965 nullptr, nullptr, revealmap_name, GAME_DEFAULT_REVEALMAP)
2966
2967 GEN_INT("timeout", game.info.timeout,
2969 N_("Maximum seconds per turn"),
2970 /* TRANS: \"Turn Done\" refers to the client button; it is also
2971 * translated separately, the translation should be the same.
2972 * \"timeoutincrease\" is a command name and must not to be
2973 * translated. */
2974 N_("If all players have not hit \"Turn Done\" before this "
2975 "time is up, then the turn ends automatically. Zero "
2976 "means there is no timeout. In servers compiled with "
2977 "debugging, a timeout of -1 sets the autogame test mode. "
2978 "Only connections with hack level access may set the "
2979 "timeout to fewer than 30 seconds. Use this with the "
2980 "command \"timeoutincrease\" to have a dynamic timer. "
2981 "The first turn is treated as a special case and is controlled "
2982 "by the 'first_timeout' setting."),
2985
2986 GEN_INT("first_timeout", game.info.first_timeout,
2988 N_("First turn timeout"),
2989 /* TRANS: The strings between single quotes are setting names and
2990 * should not be translated. */
2991 N_("If greater than 0, T1 will last for 'first_timeout' seconds.\n"
2992 "If set to 0, T1 will not have a timeout.\n"
2993 "If set to -1, the special treatment of T1 will be disabled.\n"
2994 "See also 'timeout'."),
2998
2999 GEN_INT("timeaddenemymove", game.server.timeoutaddenemymove,
3001 N_("Timeout at least n seconds when enemy moved"),
3002 N_("Any time a unit moves while in sight of an enemy player, "
3003 "the remaining timeout is increased to this value."),
3004 nullptr, nullptr, nullptr,
3006
3007 GEN_INT("unitwaittime", game.server.unitwaittime,
3010 N_("Minimum time between unit actions over turn change"),
3011 /* TRANS: The string between single quotes is a setting name and
3012 * should not be translated. */
3013 N_("This setting gives the minimum amount of time in seconds "
3014 "between unit moves and other significant actions (such as "
3015 "building cities) after a turn change occurs. For example, "
3016 "if this setting is set to 20 and a unit moves 5 seconds "
3017 "before the turn change, it will not be able to move or act "
3018 "in the next turn for at least 15 seconds. This value is "
3019 "limited to a maximum value of 2/3 'timeout'."),
3022
3023 /* This setting points to the "stored" value; changing it won't have
3024 * an effect until the next synchronization point (i.e., the start of
3025 * the next turn). */
3029 N_("Control of simultaneous player/team phases"),
3030 N_("This setting controls whether players may make "
3031 "moves at the same time during a turn. Change "
3032 "in setting takes effect next turn."),
3033 phasemode_help, nullptr, nullptr, phasemode_name,
3035
3036 GEN_INT("nettimeout", game.server.tcptimeout,
3038 N_("Seconds to let a client's network connection block"),
3039 N_("If a network connection is blocking for a time greater than "
3040 "this value, then the connection is closed. Zero "
3041 "means there is no timeout (although connections will be "
3042 "automatically disconnected eventually)."),
3043 nullptr, nullptr, nullptr,
3045
3046 GEN_INT("netwait", game.server.netwait,
3048 N_("Max seconds for network buffers to drain"),
3049 N_("The server will wait for up to the value of this "
3050 "parameter in seconds, for all client connection network "
3051 "buffers to unblock. Zero means the server will not "
3052 "wait at all."), nullptr, nullptr, nullptr,
3054
3055 GEN_INT("pingtime", game.server.pingtime,
3057 N_("Seconds between PINGs"),
3058 N_("The server will poll the clients with a PING request "
3059 "each time this period elapses."), nullptr, nullptr, nullptr,
3061
3062 GEN_INT("pingtimeout", game.server.pingtimeout,
3065 N_("Time to cut a client"),
3066 N_("If a client doesn't reply to a PING in this time the "
3067 "client is disconnected."), nullptr, nullptr, nullptr,
3069
3070 GEN_BOOL("iphide", game.server.ip_hide,
3073 N_("Keep client IP hidden"),
3074 N_("Don't tell client IP address to other clients. Server operator "
3075 "can still see it. Also, changing this setting cannot do anything "
3076 "to the information already sent before."),
3077 nullptr, nullptr, GAME_DEFAULT_IPHIDE)
3078
3079 GEN_BOOL("turnblock", game.server.turnblock,
3082 N_("Turn-blocking game play mode"),
3083 N_("If this is turned on, the game turn is not advanced "
3084 "until all players have finished their turn, including "
3085 "disconnected players."),
3086 nullptr, nullptr, GAME_DEFAULT_TURNBLOCK)
3087
3088 GEN_BOOL("fixedlength", game.server.fixedlength,
3091 N_("Fixed-length turns play mode"),
3092 /* TRANS: \"Turn Done\" refers to the client button; it is also
3093 * translated separately, the translation should be the same. */
3094 N_("If this is turned on the game turn will not advance "
3095 "until the timeout has expired, even after all players "
3096 "have clicked on \"Turn Done\"."),
3097 nullptr, nullptr, FALSE)
3098
3099 GEN_INT("top_cities", game.info.top_cities_count,
3102 N_("Number of cities in Top Cities report"),
3103 N_("How many cities should the Top Cities report contain? "
3104 "If this is zero, Top Cities report is not available "
3105 "at all."), nullptr, nullptr, nullptr,
3108
3109 GEN_STRING("demography", game.server.demography,
3112 N_("What is in the Demographics report"),
3113 /* TRANS: The strings between double quotes should be
3114 * translated. */
3115 N_("This should be a string of characters, each of which "
3116 "specifies the inclusion of a line of information "
3117 "in the Demographics report.\n"
3118 "The characters and their meanings are:\n"
3119 " N = include Population\n"
3120 " P = include Production\n"
3121 " A = include Land Area\n"
3122 " L = include Literacy\n"
3123 " R = include Research Speed\n"
3124 " S = include Settled Area\n"
3125 " E = include Economics\n"
3126 " M = include Military Service\n"
3127 " O = include Pollution\n"
3128 " C = include Culture\n"
3129 "Additionally, the following characters control whether "
3130 "or not certain columns are displayed in the report:\n"
3131 " q = display \"quantity\" column\n"
3132 " r = display \"rank\" column\n"
3133 " b = display \"best nation\" column\n"
3134 "The order of characters is not significant, but "
3135 "their capitalization is."),
3137
3138 GEN_INT("saveturns", game.server.save_nturns,
3140 N_("Turns per auto-save"),
3141 /* TRANS: The string between double quotes is also translated
3142 * separately (it must match!). The string between single
3143 * quotes is a setting name and shouldn't be translated. */
3144 N_("How many turns elapse between automatic game saves. This "
3145 "setting only has an effect when the 'autosaves' setting "
3146 "includes \"New turn\"."), nullptr, nullptr, nullptr,
3148
3149 GEN_INT("savefrequency", game.server.save_frequency,
3151 N_("Minutes per auto-save"),
3152 /* TRANS: The string between double quotes is also translated
3153 * separately (it must match!). The string between single
3154 * quotes is a setting name and shouldn't be translated. */
3155 N_("How many minutes elapse between automatic game saves. "
3156 "Unlike other save types, this save is only meant as backup "
3157 "for computer memory, and it always uses the same name, older "
3158 "saves are not kept. This setting only has an effect when the "
3159 "'autosaves' setting includes \"Timer\"."),
3160 nullptr, nullptr, nullptr,
3163
3164 GEN_BITWISE("autosaves", game.server.autosaves,
3166 N_("Which savegames are generated automatically"),
3167 /* TRANS: The strings between double quotes are also translated
3168 * separately (they must match!). The strings between single
3169 * quotes are setting names and shouldn't be translated. The
3170 * strings between parentheses and in uppercase must stay as
3171 * untranslated. */
3172 N_("This setting controls which autosave types get generated:\n"
3173 "- \"New turn\" (TURN): Save when turn begins, once every "
3174 "'saveturns' turns.\n"
3175 "- \"Game over\" (GAMEOVER): Final save when game ends.\n"
3176 "- \"No player connections\" (QUITIDLE): "
3177 "Save before server restarts due to lack of players.\n"
3178 "- \"Server interrupted\" (INTERRUPT): Save when server "
3179 "quits due to interrupt.\n"
3180 "- \"Timer\" (TIMER): Save every 'savefrequency' minutes."),
3183
3184 GEN_BOOL("threaded_save", game.server.threaded_save,
3186 N_("Whether to do saving in separate thread"),
3187 /* TRANS: The string between single quotes is a setting name and
3188 * should not be translated. */
3189 N_("If this is turned in, compressing and saving the actual "
3190 "file containing the game situation takes place in "
3191 "the background while game otherwise continues. This way "
3192 "users are not required to wait for the save to finish."),
3193 nullptr, nullptr, GAME_DEFAULT_THREADED_SAVE)
3194
3197 N_("Savegame compression level"),
3198 /* TRANS: 'compresstype' setting name should not be translated. */
3199 N_("If non-zero, saved games will be compressed depending on the "
3200 "'compresstype' setting. Larger values will give better "
3201 "compression but take longer."),
3202 nullptr, nullptr, nullptr,
3205
3206 GEN_ENUM("compresstype", game.server.save_compress_type,
3208 N_("Savegame compression algorithm"),
3209 N_("Compression library to use for savegames."),
3210 nullptr, nullptr, nullptr, compresstype_name,
3212
3213 GEN_STRING("savename", game.server.save_name,
3215 N_("Definition of the save file name"),
3216 /* TRANS: %R, %S, %T and %Y must not be translated.
3217 * The strings (examples and setting names) between single quotes
3218 * neither. The strings between <> should be translated.
3219 * xgettext:no-c-format */
3220 N_("Within the string the following custom formats are "
3221 "allowed:\n"
3222 " %R = <reason>\n"
3223 " %S = <suffix>\n"
3224 " %T = <turn-number>\n"
3225 " %Y = <game-year>\n"
3226 "\n"
3227 "Example: 'freeciv-T%04T-Y%+05Y-%R' => "
3228 "'freeciv-T0100-Y00001-manual'\n"
3229 "\n"
3230 "Be careful to use at least one of %T and %Y, else newer "
3231 "savegames will overwrite old ones. If none of the formats "
3232 "is used '-T%04T-Y%05Y-%R' is appended to the value of "
3233 "'savename'."),
3235
3236 GEN_BOOL("scorelog", game.server.scorelog,
3240#else /* FREECIV_WEB */
3242#endif /* FREECIV_WEB */
3243 N_("Whether to log player statistics"),
3244 /* TRANS: The string between single quotes is a setting name and
3245 * should not be translated. */
3246 N_("If this is turned on, player statistics are appended to "
3247 "the file defined by the option 'scorefile' every turn. "
3248 "These statistics can be used to create power graphs after "
3249 "the game."), nullptr, scorelog_action, GAME_DEFAULT_SCORELOG)
3250
3251 GEN_ENUM("scoreloglevel", game.server.scoreloglevel,
3254 N_("Scorelog level"),
3255 N_("Whether scores are logged for all players including AIs, "
3256 "or only for human players."), nullptr, nullptr, nullptr,
3258
3259#ifndef FREECIV_WEB
3260 GEN_STRING("scorefile", game.server.scorefile,
3263 N_("Name for the score log file"),
3264 /* TRANS: Don't translate the string in single quotes. */
3265 N_("The default name for the score log file is "
3266 "'freeciv-score.log'."),
3268#endif /* !FREECIV_WEB */
3269
3270 GEN_INT("maxconnectionsperhost", game.server.maxconnectionsperhost,
3273 N_("Maximum number of connections to the server per host"),
3274 N_("New connections from a given host will be rejected if "
3275 "the total number of connections from the very same host "
3276 "equals or exceeds this value. A value of 0 means that "
3277 "there is no limit, at least up to the maximum number of "
3278 "connections supported by the server."),
3279 nullptr, nullptr, nullptr,
3282
3283 GEN_INT("kicktime", game.server.kick_time,
3286 N_("Time before a kicked user can reconnect"),
3287 /* TRANS: The string in double quotes is a server command name and
3288 * should not be translated */
3289 N_("Gives the time in seconds before a user kicked using the "
3290 "\"kick\" command may reconnect. Changing this setting will "
3291 "affect users kicked in the past."),
3292 nullptr, nullptr, nullptr,
3294
3295 GEN_INT("luatimeout", game.lua_timeout,
3297 N_("Lua timeout"),
3298 N_("Time in seconds that a single lua script can run before it gets "
3299 "forcibly terminated."), nullptr, nullptr, nullptr,
3301
3304 N_("Metaserver info line"),
3305 N_("User defined metaserver info line. For most of the time "
3306 "a user defined metamessage will be used instead of an "
3307 "automatically generated message. "
3308 "Set to empty (\"\", not \"empty\") to always use an "
3309 "automatically generated meta server message."),
3311
3312 GEN_ENUM("ailevel", game.info.skill_level,
3314 N_("Level of new AIs"),
3315 N_("Difficulty level of any AI players to be created now on. "
3316 "Changing value of this setting does not affect "
3317 "existing players."), nullptr, nullptr, nullptr,
3319
3322 N_("Default AI type"),
3323 N_("Name of the default AI type. New AI players will be "
3324 "created with that type by default. Changing this "
3325 "setting does not affect existing AI players."),
3327};
3328
3329#undef GEN_BOOL
3330#undef GEN_INT
3331#undef GEN_STRING
3332#undef GEN_ENUM
3333#undef GEN_BITWISE
3334
3335/* The number of settings, not including the END. */
3337
3338/************************************************************************/
3342{
3343 return (0 <= id && id < SETTINGS_NUM ? settings + id : nullptr);
3344}
3345
3346/************************************************************************/
3349struct setting *setting_by_name(const char *name)
3350{
3351 fc_assert_ret_val(name, nullptr);
3352
3354 if (0 == strcmp(name, pset->name)) {
3355 return pset;
3356 }
3358
3359 return nullptr;
3360}
3361
3362/************************************************************************/
3365int setting_number(const struct setting *pset)
3366{
3367 fc_assert_ret_val(pset != nullptr, -1);
3368
3369 return pset - settings;
3370}
3371
3372/************************************************************************/
3375const char *setting_name(const struct setting *pset)
3376{
3377 return pset->name;
3378}
3379
3380/************************************************************************/
3383const char *setting_short_help(const struct setting *pset)
3384{
3385 return pset->short_help;
3386}
3387
3388/************************************************************************/
3392const char *setting_extra_help(const struct setting *pset, bool constant)
3393{
3394 if (!constant && pset->help_func != nullptr) {
3395 return pset->help_func(pset);
3396 }
3397
3398 return _(pset->extra_help);
3399}
3400
3401/************************************************************************/
3405{
3406 return pset->stype;
3407}
3408
3409/************************************************************************/
3413{
3414 return pset->slevel;
3415}
3416
3417/************************************************************************/
3421{
3422 return pset->scategory;
3423}
3424
3425/************************************************************************/
3430static bool setting_is_free_to_change(const struct setting *pset,
3431 char *reject_msg,
3432 size_t reject_msg_len)
3433{
3434 switch (pset->sclass) {
3435 case SSET_MAP_SIZE:
3436 case SSET_MAP_GEN:
3437 /* Only change map options if we don't yet have a map: */
3438 if (map_is_empty()) {
3439 return TRUE;
3440 }
3441
3443 _("The setting '%s' can't be modified after the map "
3444 "is fixed."), setting_name(pset));
3445 return FALSE;
3446
3448 /* Like SSET_RULES except that it can be changed before the game starts
3449 * for heavy scenarios. A heavy scenario comes with players. It can
3450 * include cities, units, diplomatic relations and other complex
3451 * state. Make sure that changing a setting can't make the state of a
3452 * heavy scenario illegal if you want to change it from SSET_RULES to
3453 * SSET_RULES_SCENARIO. */
3454
3456 && server_state() == S_S_INITIAL) {
3457 /* Special case detected. */
3458 return TRUE;
3459 }
3460
3461 /* The special case didn't make it legal to change the setting. Don't
3462 * give up. It could still be legal. Fall through so the non special
3463 * cases are checked too. */
3465
3466 case SSET_MAP_ADD:
3467 case SSET_PLAYERS:
3468 case SSET_GAME_INIT:
3469 case SSET_RULES:
3470 /* Only change start params and most rules if we don't yet have a map,
3471 * or if we do have a map but its a scenario one (ie, the game has
3472 * never actually been started).
3473 */
3474 if (map_is_empty() || game.info.is_new_game) {
3475 return TRUE;
3476 }
3477
3479 _("The setting '%s' can't be modified after the game "
3480 "has started."), setting_name(pset));
3481 return FALSE;
3482
3485 case SSET_META:
3486 /* These can always be changed: */
3487 return TRUE;
3488 }
3489
3490 log_error("Wrong class variant for setting %s (%d): %d.",
3492 settings_snprintf(reject_msg, reject_msg_len, _("Internal error."));
3493
3494 return FALSE;
3495}
3496
3497/************************************************************************/
3503 struct connection *caller, char *reject_msg,
3504 size_t reject_msg_len)
3505{
3506 if (caller
3507 && (caller->access_level < pset->access_level_write)) {
3509 _("You are not allowed to change the setting '%s'."),
3511 return FALSE;
3512 }
3513
3514 switch (pset->lock) {
3515 case SLOCK_NONE:
3516 break;
3517 case SLOCK_RULESET:
3518 /* Setting is locked by the ruleset */
3520 _("The setting '%s' is locked by the ruleset."),
3522 return FALSE;
3523 case SLOCK_ADMIN:
3524 /* Setting is locked by admin */
3526 _("The setting '%s' is locked by admin."),
3528 return FALSE;
3529 }
3530
3532}
3533
3534/************************************************************************/
3539 enum cmdlevel plevel)
3540{
3541 return (plevel >= pset->access_level_read);
3542}
3543
3544/************************************************************************/
3549 struct connection *caller)
3550{
3551 return (!caller
3553}
3554
3555/************************************************************************/
3561static enum m_pre_result
3563 const char *prefix, int *ind_result,
3564 const char **matches, size_t max_matches,
3565 size_t *pnum_matches)
3566{
3567 const struct sset_val_name *name;
3568 size_t len = strlen(prefix);
3569 size_t num_matches;
3570 int i;
3571
3572 *pnum_matches = 0;
3573
3574 if (0 == len) {
3575 return M_PRE_EMPTY;
3576 }
3577
3578 for (i = 0, num_matches = 0; (name = name_fn(i)); i++) {
3579 if (0 == fc_strncasecmp(name->support, prefix, len)) {
3580 if (strlen(name->support) == len) {
3581 *ind_result = i;
3582 return M_PRE_EXACT;
3583 }
3584 if (num_matches < max_matches) {
3585 matches[num_matches] = name->support;
3586 (*pnum_matches)++;
3587 }
3588 if (0 == num_matches++) {
3589 *ind_result = i;
3590 }
3591 }
3592 }
3593
3594 if (1 == num_matches) {
3595 return M_PRE_ONLY;
3596 } else if (1 < num_matches) {
3597 return M_PRE_AMBIGUOUS;
3598 } else {
3599 return M_PRE_FAIL;
3600 }
3601}
3602
3603/************************************************************************/
3608 const char *prefix, int *pvalue,
3609 char *reject_msg,
3610 size_t reject_msg_len)
3611{
3612 const char *matches[16];
3613 size_t num_matches;
3614
3615 switch (setting_match_prefix_base(name_fn, prefix, pvalue, matches,
3617 case M_PRE_EXACT:
3618 case M_PRE_ONLY:
3619 return TRUE; /* Ok. */
3620 case M_PRE_AMBIGUOUS:
3621 {
3622 struct astring astr = ASTRING_INIT;
3623
3624 fc_assert(2 <= num_matches);
3626 _("\"%s\" prefix is ambiguous. Candidates are: %s."),
3627 prefix,
3629 astr_free(&astr);
3630 }
3631 return FALSE;
3632 case M_PRE_EMPTY:
3633 settings_snprintf(reject_msg, reject_msg_len, _("Missing value."));
3634 return FALSE;
3635 case M_PRE_LONG:
3636 case M_PRE_FAIL:
3637 case M_PRE_LAST:
3638 break;
3639 }
3640
3642 _("No match for \"%s\"."), prefix);
3643 return FALSE;
3644}
3645
3646/************************************************************************/
3649static const char *setting_bool_to_str(const struct setting *pset,
3650 bool value, bool pretty,
3651 char *buf, size_t buf_len)
3652{
3653 const struct sset_val_name *name = pset->boolean.name(value);
3654
3655 if (pretty) {
3656 fc_snprintf(buf, buf_len, "%s", Q_(name->pretty));
3657 } else {
3658 fc_strlcpy(buf, name->support, buf_len);
3659 }
3660 return buf;
3661}
3662
3663/************************************************************************/
3670static bool setting_bool_validate_base(const struct setting *pset,
3671 const char *val, int *pint_val,
3672 struct connection *caller,
3673 char *reject_msg,
3674 size_t reject_msg_len)
3675{
3676 char buf[256];
3677
3678 if (SST_BOOL != pset->stype) {
3680 _("This setting is not a boolean."));
3681 return FALSE;
3682 }
3683
3684 sz_strlcpy(buf, val);
3686
3687 return (setting_match_prefix(pset->boolean.name, buf, pint_val,
3689 && (pset->boolean.validate == nullptr
3690 || pset->boolean.validate(0 != *pint_val, caller, reject_msg,
3691 reject_msg_len)));
3692}
3693
3694/************************************************************************/
3699bool setting_bool_set(struct setting *pset, const char *val,
3700 struct connection *caller, char *reject_msg,
3701 size_t reject_msg_len)
3702{
3703 int int_val;
3704
3706 || !setting_bool_validate_base(pset, val, &int_val, caller,
3708 return FALSE;
3709 }
3710
3711 *pset->boolean.pvalue = (0 != int_val);
3712 return TRUE;
3713}
3714
3715/************************************************************************/
3719{
3721
3722 return *pset->boolean.pvalue;
3723}
3724
3725/************************************************************************/
3730bool setting_bool_validate(const struct setting *pset, const char *val,
3731 struct connection *caller, char *reject_msg,
3732 size_t reject_msg_len)
3733{
3734 int int_val;
3735
3736 return setting_bool_validate_base(pset, val, &int_val, caller,
3738}
3739
3740/************************************************************************/
3744static const char *setting_bool_secfile_str(secfile_data_t data, int val)
3745{
3746 const struct sset_val_name *name =
3747 ((const struct setting *) data)->boolean.name(val);
3748
3749 return (name != nullptr ? name->support : nullptr);
3750}
3751
3752/************************************************************************/
3755static const char *setting_int_to_str(const struct setting *pset,
3756 int value, bool pretty,
3757 char *buf, size_t buf_len)
3758{
3759 fc_snprintf(buf, buf_len, "%d", value);
3760 return buf;
3761}
3762
3763/************************************************************************/
3766int setting_int_min(const struct setting *pset)
3767{
3768 fc_assert_ret_val(pset->stype == SST_INT, 0);
3769 return pset->integer.min_value;
3770}
3771
3772/************************************************************************/
3775int setting_int_max(const struct setting *pset)
3776{
3777 fc_assert_ret_val(pset->stype == SST_INT, 0);
3778 return pset->integer.max_value;
3779}
3780
3781/************************************************************************/
3785bool setting_int_set(struct setting *pset, int val,
3786 struct connection *caller, char *reject_msg,
3787 size_t reject_msg_len)
3788{
3790 || !setting_int_validate(pset, val, caller, reject_msg,
3791 reject_msg_len)) {
3792 return FALSE;
3793 }
3794
3795 *pset->integer.pvalue = val;
3796 return TRUE;
3797}
3798
3799/************************************************************************/
3805bool setting_int_validate(const struct setting *pset, int val,
3806 struct connection *caller, char *reject_msg,
3807 size_t reject_msg_len)
3808{
3809 if (SST_INT != pset->stype) {
3811 _("This setting is not an integer."));
3812 return FALSE;
3813 }
3814
3815 if (val < pset->integer.min_value || val > pset->integer.max_value) {
3817 _("Value out of range: %d (min: %d; max: %d)."),
3818 val, pset->integer.min_value, pset->integer.max_value);
3819 return FALSE;
3820 }
3821
3822 return (!pset->integer.validate
3823 || pset->integer.validate(val, caller, reject_msg,
3825}
3826
3827/************************************************************************/
3831{
3833
3834 return *pset->integer.pvalue;
3835}
3836
3837/************************************************************************/
3840static const char *setting_str_to_str(const struct setting *pset,
3841 const char *value, bool pretty,
3842 char *buf, size_t buf_len)
3843{
3844 if (pretty) {
3845 fc_snprintf(buf, buf_len, "\"%s\"", value);
3846 } else {
3848 }
3849 return buf;
3850}
3851
3852/************************************************************************/
3856bool setting_str_set(struct setting *pset, const char *val,
3857 struct connection *caller, char *reject_msg,
3858 size_t reject_msg_len)
3859{
3861 || !setting_str_validate(pset, val, caller, reject_msg,
3862 reject_msg_len)) {
3863 return FALSE;
3864 }
3865
3866 fc_strlcpy(pset->string.value, val, pset->string.value_size);
3867 return TRUE;
3868}
3869
3870/************************************************************************/
3876bool setting_str_validate(const struct setting *pset, const char *val,
3877 struct connection *caller, char *reject_msg,
3878 size_t reject_msg_len)
3879{
3880 if (SST_STRING != pset->stype) {
3882 _("This setting is not a string."));
3883 return FALSE;
3884 }
3885
3886 if (strlen(val) >= pset->string.value_size) {
3888 _("String value too long (max length: %lu)."),
3889 (unsigned long) pset->string.value_size);
3890 return FALSE;
3891 }
3892
3893 return (!pset->string.validate
3894 || pset->string.validate(val, caller, reject_msg,
3896}
3897
3898/************************************************************************/
3902{
3904
3905 return pset->string.value;
3906}
3907
3908/************************************************************************/
3913{
3914 struct sf_cb_data *info = (struct sf_cb_data *)data;
3915 const struct sset_val_name *name;
3916
3917 name = info->set->enumerator.name(val);
3918
3919 if (info->compat && name != nullptr) {
3920 const char *ret = setcompat_current_val_from_previous(info->set,
3921 name->support);
3922
3923 if (ret != nullptr) {
3924 return ret;
3925 }
3926 }
3927
3928 return (name != nullptr ? name->support : nullptr);
3929}
3930
3931/************************************************************************/
3935const char *setting_enum_val(const struct setting *pset, int val, bool pretty)
3936{
3937 const struct sset_val_name *name;
3938
3939 fc_assert_ret_val(SST_ENUM == pset->stype, nullptr);
3940
3941 name = pset->enumerator.name(val);
3942 if (name == nullptr) {
3943 return nullptr;
3944 } else if (pretty) {
3945 return _(name->pretty);
3946 } else {
3947 return name->support;
3948 }
3949}
3950
3951/************************************************************************/
3955static const char *setting_enum_to_str(const struct setting *pset,
3956 int value, bool pretty,
3957 char *buf, size_t buf_len)
3958{
3959 const struct sset_val_name *name = pset->enumerator.name(value);
3960
3961 if (pretty) {
3962 fc_snprintf(buf, buf_len, "\"%s\" (%s)",
3963 Q_(name->pretty), name->support);
3964 } else {
3965 fc_strlcpy(buf, name->support, buf_len);
3966 }
3967 return buf;
3968}
3969
3970/************************************************************************/
3977static bool setting_enum_validate_base(const struct setting *pset,
3978 const char *val, int *pint_val,
3979 struct connection *caller,
3980 char *reject_msg,
3981 size_t reject_msg_len)
3982{
3983 char buf[256];
3984
3985 if (SST_ENUM != pset->stype) {
3987 _("This setting is not an enumerator."));
3988 return FALSE;
3989 }
3990
3991 sz_strlcpy(buf, val);
3993
3994 return (setting_match_prefix(pset->enumerator.name, buf, pint_val,
3996 && (pset->enumerator.validate == nullptr
3997 || pset->enumerator.validate(*pint_val, caller, reject_msg,
3998 reject_msg_len)));
3999}
4000
4001/************************************************************************/
4004static bool set_enum_value(struct setting *pset, int val)
4005{
4006 switch (pset->enumerator.store_size) {
4007 case sizeof(int):
4008 {
4009 int *to_int = pset->enumerator.pvalue;
4010
4011 *to_int = val;
4012 }
4013 break;
4014 case sizeof(char):
4015 {
4016 char *to_char = pset->enumerator.pvalue;
4017
4018 *to_char = (char) val;
4019 }
4020 break;
4021 case sizeof(short):
4022 {
4023 short *to_short = pset->enumerator.pvalue;
4024
4025 *to_short = (short) val;
4026 }
4027 break;
4028 default:
4029 return FALSE;
4030 }
4031
4032 return TRUE;
4033}
4034
4035/************************************************************************/
4038int read_enum_value(const struct setting *pset)
4039{
4040 int val;
4041
4042 switch (pset->enumerator.store_size) {
4043 case sizeof(int):
4044 val = *((int *)pset->enumerator.pvalue);
4045 break;
4046 case sizeof(char):
4047 val = *((char *)pset->enumerator.pvalue);
4048 break;
4049 case sizeof(short):
4050 val = *((short *)pset->enumerator.pvalue);
4051 break;
4052 default:
4053 log_error("Illegal enum store size %d, can't read value", pset->enumerator.store_size);
4054 return 0;
4055 }
4056
4057 return val;
4058}
4059
4060/************************************************************************/
4065bool setting_enum_set(struct setting *pset, const char *val,
4066 struct connection *caller, char *reject_msg,
4067 size_t reject_msg_len)
4068{
4069 int int_val;
4070
4072 return FALSE;
4073 }
4074
4075 if (!setting_enum_validate_base(pset, val, &int_val, caller,
4077 return FALSE;
4078 }
4079
4080 if (!set_enum_value(pset, int_val)) {
4081 log_error("Illegal enumerator value size %d for %s",
4082 pset->enumerator.store_size, val);
4083 return FALSE;
4084 }
4085
4086 return TRUE;
4087}
4088
4089/************************************************************************/
4094bool setting_enum_validate(const struct setting *pset, const char *val,
4095 struct connection *caller, char *reject_msg,
4096 size_t reject_msg_len)
4097{
4098 int int_val;
4099
4100 return setting_enum_validate_base(pset, val, &int_val, caller,
4102}
4103
4104/************************************************************************/
4109{
4110 struct sf_cb_data *info = (struct sf_cb_data *)data;
4111 const struct sset_val_name *name = info->set->bitwise.name(bit);
4112
4113 if (info->compat && name == nullptr) {
4114 if (!fc_strcasecmp("topology", setting_name(info->set))) {
4115 if ((1 << bit) == TF_OLD_WRAPX) {
4116 return "WrapX";
4117 }
4118 if ((1 << bit) == TF_OLD_WRAPY) {
4119 return "WrapY";
4120 }
4121 }
4122 }
4123
4124 return (name != nullptr ? name->support : nullptr);
4125}
4126
4127/************************************************************************/
4131const char *setting_bitwise_bit(const struct setting *pset,
4132 int bit, bool pretty)
4133{
4134 const struct sset_val_name *name;
4135
4136 fc_assert_ret_val(SST_BITWISE == pset->stype, nullptr);
4137
4138 name = pset->bitwise.name(bit);
4139 if (name == nullptr) {
4140 return nullptr;
4141 } else if (pretty) {
4142 return _(name->pretty);
4143 } else {
4144 return name->support;
4145 }
4146}
4147
4148/************************************************************************/
4151static const char *setting_bitwise_to_str(const struct setting *pset,
4152 unsigned value, bool pretty,
4153 char *buf, size_t buf_len)
4154{
4155 const struct sset_val_name *name;
4156 char *old_buf = buf;
4157 int bit;
4158
4159 if (pretty) {
4160 char buf2[256];
4161 struct astring astr = ASTRING_INIT;
4162 struct strvec *vec = strvec_new();
4163 size_t len;
4164
4165 for (bit = 0; (name = pset->bitwise.name(bit)); bit++) {
4166 if ((1 << bit) & value) {
4167 /* TRANS: only emphasizing a string. */
4168 fc_snprintf(buf2, sizeof(buf2), _("\"%s\""), Q_(name->pretty));
4170 }
4171 }
4172
4173 if (0 == strvec_size(vec)) {
4174 /* No value. */
4175 fc_assert(0 == value);
4176 /* TRANS: Bitwise setting has no bits set. */
4177 fc_strlcpy(buf, _("empty value"), buf_len);
4179 return buf;
4180 }
4181
4185 astr_free(&astr);
4186 fc_strlcat(buf, " (", buf_len);
4187 len = strlen(buf);
4188 buf += len;
4189 buf_len -= len;
4190 }
4191
4192 /* Long support part. */
4193 buf[0] = '\0';
4194 for (bit = 0; (name = pset->bitwise.name(bit)); bit++) {
4195 if ((1 << bit) & value) {
4196 if ('\0' != buf[0]) {
4197 fc_strlcat(buf, "|", buf_len);
4198 }
4199 fc_strlcat(buf, name->support, buf_len);
4200 }
4201 }
4202
4203 if (pretty) {
4204 fc_strlcat(buf, ")", buf_len);
4205 }
4206 return old_buf;
4207}
4208
4209/************************************************************************/
4217 const char *val,
4218 unsigned *pint_val,
4219 struct connection *caller,
4220 char *reject_msg,
4221 size_t reject_msg_len)
4222{
4223 char buf[256];
4224 const char *p;
4225 int bit;
4226
4227 if (SST_BITWISE != pset->stype) {
4229 _("This setting is not a bitwise."));
4230 return FALSE;
4231 }
4232
4233 *pint_val = 0;
4234
4235 /* Value names are separated by '|'. */
4236 do {
4237 p = strchr(val, '|');
4238 if (p != nullptr) {
4239 p++;
4240 fc_strlcpy(buf, val, MIN(p - val, sizeof(buf)));
4241 } else {
4242 /* Last segment, full copy. */
4243 sz_strlcpy(buf, val);
4244 }
4246 if (p == nullptr && '\0' == buf[0] && 0 == *pint_val) {
4247 /* Empty string = value 0. */
4248 break;
4249 } else if (!setting_match_prefix(pset->bitwise.name, buf, &bit,
4251 return FALSE;
4252 }
4253 *pint_val |= 1 << bit;
4254 val = p;
4255 } while (p != nullptr);
4256
4257 return (pset->bitwise.validate == nullptr
4258 || pset->bitwise.validate(*pint_val, caller,
4260}
4261
4262/************************************************************************/
4267bool setting_bitwise_set(struct setting *pset, const char *val,
4268 struct connection *caller, char *reject_msg,
4269 size_t reject_msg_len)
4270{
4271 unsigned int_val;
4272
4274 || !setting_bitwise_validate_base(pset, val, &int_val, caller,
4276 return FALSE;
4277 }
4278
4279 *pset->bitwise.pvalue = int_val;
4280 return TRUE;
4281}
4282
4283/************************************************************************/
4288bool setting_bitwise_validate(const struct setting *pset, const char *val,
4289 struct connection *caller, char *reject_msg,
4290 size_t reject_msg_len)
4291{
4292 unsigned int_val;
4293
4294 return setting_bitwise_validate_base(pset, val, &int_val, caller,
4296}
4297
4298/************************************************************************/
4302{
4304
4305 return *pset->bitwise.pvalue;
4306}
4307
4308/************************************************************************/
4311const char *setting_value_name(const struct setting *pset, bool pretty,
4312 char *buf, size_t buf_len)
4313{
4314 fc_assert_ret_val(pset != nullptr, nullptr);
4315 fc_assert_ret_val(buf != nullptr, nullptr);
4316 fc_assert_ret_val(0 < buf_len, nullptr);
4317
4318 switch (pset->stype) {
4319 case SST_BOOL:
4320 return setting_bool_to_str(pset, *pset->boolean.pvalue,
4321 pretty, buf, buf_len);
4322 case SST_INT:
4323 return setting_int_to_str(pset, *pset->integer.pvalue,
4324 pretty, buf, buf_len);
4325 case SST_STRING:
4326 return setting_str_to_str(pset, pset->string.value,
4327 pretty, buf, buf_len);
4328 case SST_ENUM:
4330 pretty, buf, buf_len);
4331 case SST_BITWISE:
4332 return setting_bitwise_to_str(pset, *pset->bitwise.pvalue,
4333 pretty, buf, buf_len);
4334 case SST_COUNT:
4335 /* Error logged below. */
4336 break;
4337 }
4338
4339 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
4341 return nullptr;
4342}
4343
4344/************************************************************************/
4347const char *setting_default_name(const struct setting *pset, bool pretty,
4348 char *buf, size_t buf_len)
4349{
4350 fc_assert_ret_val(pset != nullptr, nullptr);
4351 fc_assert_ret_val(buf != nullptr, nullptr);
4352 fc_assert_ret_val(0 < buf_len, nullptr);
4353
4354 switch (pset->stype) {
4355 case SST_BOOL:
4356 return setting_bool_to_str(pset, pset->boolean.default_value,
4357 pretty, buf, buf_len);
4358 case SST_INT:
4359 return setting_int_to_str(pset, pset->integer.default_value,
4360 pretty, buf, buf_len);
4361 case SST_STRING:
4362 return setting_str_to_str(pset, pset->string.default_value,
4363 pretty, buf, buf_len);
4364 case SST_ENUM:
4365 return setting_enum_to_str(pset, pset->enumerator.default_value,
4366 pretty, buf, buf_len);
4367 case SST_BITWISE:
4368 return setting_bitwise_to_str(pset, pset->bitwise.default_value,
4369 pretty, buf, buf_len);
4370 case SST_COUNT:
4371 /* Error logged below. */
4372 break;
4373 }
4374
4375 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
4377 return nullptr;
4378}
4379
4380/************************************************************************/
4384{
4385 switch (pset->stype) {
4386 case SST_BOOL:
4387 (*pset->boolean.pvalue) = pset->boolean.default_value;
4388 break;
4389 case SST_INT:
4390 (*pset->integer.pvalue) = pset->integer.default_value;
4391 break;
4392 case SST_STRING:
4393 fc_strlcpy(pset->string.value, pset->string.default_value,
4394 pset->string.value_size);
4395 break;
4396 case SST_ENUM:
4397 set_enum_value(pset, pset->enumerator.default_value);
4398 break;
4399 case SST_BITWISE:
4400 (*pset->bitwise.pvalue) = pset->bitwise.default_value;
4401 break;
4402 case SST_COUNT:
4403 fc_assert(pset->stype != SST_COUNT);
4404 break;
4405 }
4406
4407 pset->setdef = SETDEF_INTERNAL;
4408}
4409
4410/************************************************************************/
4413void setting_action(const struct setting *pset)
4414{
4415 if (pset->action != nullptr) {
4416 pset->action(pset);
4417 }
4418}
4419
4420/************************************************************************/
4423bool settings_ruleset(struct section_file *file, const char *section,
4424 bool act, bool compat)
4425{
4426 const char *name;
4427 int j;
4428
4429 /* Unlock all settings. */
4432 if (pset->ruleset_settable && !setting_locked(pset)) {
4434 }
4436
4437 /* Settings */
4438 if (secfile_section_by_name(file, section) == nullptr) {
4439 /* No settings in ruleset file */
4440 log_verbose("no [%s] section for game settings in %s", section,
4441 secfile_name(file));
4442 } else {
4443 for (j = 0; (name = secfile_lookup_str_default(file, nullptr,
4444 "%s.set%d.name",
4445 section, j)); j++) {
4446 char path[256];
4447
4448 fc_snprintf(path, sizeof(path), "%s.set%d", section, j);
4449
4450 if (compat) {
4452 }
4453
4454 if (!setting_ruleset_one(file, name, path, compat)) {
4455 log_error("unknown unsettable setting in '%s': %s",
4456 secfile_name(file), name);
4457 }
4458 }
4459 }
4460
4461 /* Execute all setting actions to consider actions due to the
4462 * default values. */
4463 if (act) {
4465 if (pset->ruleset_settable) {
4467 }
4469 }
4470
4472
4473 /* Send game settings */
4474 send_server_settings(nullptr);
4475
4476 return TRUE;
4477}
4478
4479/***********************************************************************/
4482static inline void setting_ruleset_setdef(struct setting *pset)
4483{
4484 pset->setdef = SETDEF_RULESET;
4485}
4486
4487/************************************************************************/
4490static bool setting_ruleset_one(struct section_file *file,
4491 const char *name, const char *path,
4492 bool compat)
4493{
4494 struct setting *pset = nullptr;
4495 char reject_msg[256], buf[256];
4496 bool lock;
4497 struct sf_cb_data info = { pset, compat };
4498
4501 pset = pset_check;
4502 break;
4503 }
4505
4506 if (pset == nullptr || !pset->ruleset_settable) {
4507 /* No setting found or it's not settable by ruleset */
4508 return FALSE;
4509 }
4510
4511 if (!setting_locked(pset)) {
4512 info.set = pset;
4513 info.compat = compat;
4514
4515 switch (pset->stype) {
4516 case SST_BOOL:
4517 {
4518 int ival;
4519 bool val;
4520
4521 /* Allow string with same boolean representation as accepted on
4522 * server command line */
4525 "%s.value", path)) {
4526 val = (ival != 0);
4527 } else if (!secfile_lookup_bool(file, &val, "%s.value", path)) {
4528 log_error("Can't read value for setting '%s': %s", name,
4529 secfile_error());
4530 break;
4531 }
4532 if (val != *pset->boolean.pvalue) {
4533 if (pset->boolean.validate == nullptr
4534 || pset->boolean.validate(val, nullptr, reject_msg,
4535 sizeof(reject_msg))) {
4536 *pset->boolean.pvalue = val;
4537 log_normal(_("Ruleset: '%s' has been set to %s."),
4539 setting_value_name(pset, TRUE, buf, sizeof(buf)));
4540 } else {
4541 log_error("%s", reject_msg);
4542 }
4543 }
4544 }
4545 break;
4546
4547 case SST_INT:
4548 {
4549 int val;
4550
4551 if (!secfile_lookup_int(file, &val, "%s.value", path)) {
4552 log_error("Can't read value for setting '%s': %s", name,
4553 secfile_error());
4554 } else if (val != *pset->integer.pvalue) {
4555 if (setting_int_set(pset, val, nullptr, reject_msg,
4556 sizeof(reject_msg))) {
4557 log_normal(_("Ruleset: '%s' has been set to %s."),
4559 setting_value_name(pset, TRUE, buf, sizeof(buf)));
4560 } else {
4561 log_error("%s", reject_msg);
4562 }
4563 }
4564 }
4565 break;
4566
4567 case SST_STRING:
4568 {
4569 const char *val = secfile_lookup_str(file, "%s.value", path);
4570
4571 if (val == nullptr) {
4572 log_error("Can't read value for setting '%s': %s", name,
4573 secfile_error());
4574 } else if (0 != strcmp(val, pset->string.value)) {
4575 if (setting_str_set(pset, val, nullptr, reject_msg,
4576 sizeof(reject_msg))) {
4577 log_normal(_("Ruleset: '%s' has been set to %s."),
4579 setting_value_name(pset, TRUE, buf, sizeof(buf)));
4580 } else {
4581 log_error("%s", reject_msg);
4582 }
4583 }
4584 }
4585 break;
4586
4587 case SST_ENUM:
4588 {
4589 int val;
4590
4591 if (!secfile_lookup_enum_data(file, &val, FALSE,
4593 "%s.value", path)) {
4594 log_error("Can't read value for setting '%s': %s",
4595 name, secfile_error());
4596 } else if (val != read_enum_value(pset)) {
4597 if (pset->enumerator.validate == nullptr
4598 || pset->enumerator.validate(val, nullptr, reject_msg,
4599 sizeof(reject_msg))) {
4600 set_enum_value(pset, val);
4601 log_normal(_("Ruleset: '%s' has been set to %s."),
4603 setting_value_name(pset, TRUE, buf, sizeof(buf)));
4604 } else {
4605 log_error("%s", reject_msg);
4606 }
4607 }
4608 }
4609 break;
4610
4611 case SST_BITWISE:
4612 {
4613 int val;
4614
4615 if (!secfile_lookup_enum_data(file, &val, TRUE,
4617 "%s.value", path)) {
4618 log_error("Can't read value for setting '%s': %s",
4619 name, secfile_error());
4620 } else if (val != *pset->bitwise.pvalue) {
4621 if (pset->bitwise.validate == nullptr
4622 || pset->bitwise.validate((unsigned) val, nullptr,
4623 reject_msg, sizeof(reject_msg))) {
4624 *pset->bitwise.pvalue = val;
4625 log_normal(_("Ruleset: '%s' has been set to %s."),
4627 setting_value_name(pset, TRUE, buf, sizeof(buf)));
4628 } else {
4629 log_error("%s", reject_msg);
4630 }
4631 }
4632 }
4633 break;
4634
4635 case SST_COUNT:
4636 fc_assert(pset->stype != SST_COUNT);
4637 break;
4638 }
4639
4641 }
4642
4643 /* Set lock */
4644 lock = secfile_lookup_bool_default(file, FALSE, "%s.lock", path);
4645
4646 if (lock) {
4647 /* Set lock */
4649 log_normal(_("Ruleset: '%s' has been locked by the ruleset."),
4651 }
4652
4653 return TRUE;
4654}
4655
4656/************************************************************************/
4660{
4661 switch (setting_type(pset)) {
4662 case SST_BOOL:
4663 return (*pset->boolean.pvalue != pset->boolean.default_value);
4664 case SST_INT:
4665 return (*pset->integer.pvalue != pset->integer.default_value);
4666 case SST_STRING:
4667 return (0 != strcmp(pset->string.value, pset->string.default_value));
4668 case SST_ENUM:
4669 return (read_enum_value(pset) != pset->enumerator.default_value);
4670 case SST_BITWISE:
4671 return (*pset->bitwise.pvalue != pset->bitwise.default_value);
4672 case SST_COUNT:
4673 /* Error logged below. */
4674 break;
4675 }
4676
4677 log_error("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
4679 return FALSE;
4680}
4681
4682/************************************************************************/
4685bool setting_locked(const struct setting *pset)
4686{
4687 return pset->lock != SLOCK_NONE;
4688}
4689
4690/************************************************************************/
4694{
4695 return pset->rslock;
4696}
4697
4698/************************************************************************/
4702{
4703 if (pset->lock < SLOCK_RULESET) {
4704 /* No downgrading the lock */
4705 pset->lock = SLOCK_RULESET;
4706 }
4707 pset->rslock = TRUE;
4708}
4709
4710/************************************************************************/
4714{
4715 pset->lock = SLOCK_ADMIN;
4716}
4717
4718/************************************************************************/
4722{
4723 if (pset->lock == SLOCK_RULESET) {
4724 /* No clearing upper level locks */
4725 pset->lock = SLOCK_RULESET;
4726 }
4727 pset->rslock = FALSE;
4728}
4729
4730/************************************************************************/
4734{
4735 if (pset->rslock) {
4736 pset->lock = SLOCK_RULESET;
4737 } else {
4738 pset->lock = SLOCK_NONE;
4739 }
4740}
4741
4742/************************************************************************/
4745static void setting_game_set(struct setting *pset, bool init)
4746{
4747 switch (setting_type(pset)) {
4748 case SST_BOOL:
4749 pset->boolean.game_value = *pset->boolean.pvalue;
4750 break;
4751
4752 case SST_INT:
4753 pset->integer.game_value = *pset->integer.pvalue;
4754 break;
4755
4756 case SST_STRING:
4757 if (init) {
4758 pset->string.game_value
4759 = fc_calloc(1, pset->string.value_size
4760 * sizeof(pset->string.game_value));
4761 }
4762 fc_strlcpy(pset->string.game_value, pset->string.value,
4763 pset->string.value_size);
4764 break;
4765
4766 case SST_ENUM:
4767 pset->enumerator.game_value = read_enum_value(pset);
4768 break;
4769
4770 case SST_BITWISE:
4771 pset->bitwise.game_value = *pset->bitwise.pvalue;
4772 break;
4773
4774 case SST_COUNT:
4776 break;
4777 }
4778
4779 pset->game_setdef = pset->setdef;
4780}
4781
4782/************************************************************************/
4785static void setting_game_free(struct setting *pset)
4786{
4787 if (setting_type(pset) == SST_STRING) {
4788 FC_FREE(pset->string.game_value);
4789 }
4790}
4791
4792/************************************************************************/
4796{
4797 char reject_msg[256] = "", buf[256];
4798 bool res = FALSE;
4799
4800 if (!setting_is_changeable(pset, nullptr, reject_msg, sizeof(reject_msg))) {
4801 log_debug("Can't restore '%s': %s", setting_name(pset),
4802 reject_msg);
4803 return;
4804 }
4805
4806 if (pset->game_setdef == SETDEF_INTERNAL) {
4808 return;
4809 }
4810
4811 switch (setting_type(pset)) {
4812 case SST_BOOL:
4813 res = (setting_bool_to_str(pset, pset->boolean.game_value,
4814 FALSE, buf, sizeof(buf)) != nullptr
4815 && setting_bool_set(pset, buf, nullptr, reject_msg,
4816 sizeof(reject_msg)));
4817 break;
4818
4819 case SST_INT:
4820 res = setting_int_set(pset, pset->integer.game_value, nullptr, reject_msg,
4821 sizeof(reject_msg));
4822 break;
4823
4824 case SST_STRING:
4825 res = setting_str_set(pset, pset->string.game_value, nullptr, reject_msg,
4826 sizeof(reject_msg));
4827 break;
4828
4829 case SST_ENUM:
4830 res = (setting_enum_to_str(pset, pset->enumerator.game_value,
4831 FALSE, buf, sizeof(buf)) != nullptr
4832 && setting_enum_set(pset, buf, nullptr, reject_msg,
4833 sizeof(reject_msg)));
4834 break;
4835
4836 case SST_BITWISE:
4837 res = (setting_bitwise_to_str(pset, pset->bitwise.game_value,
4838 FALSE, buf, sizeof(buf)) != nullptr
4839 && setting_bitwise_set(pset, buf, nullptr, reject_msg,
4840 sizeof(reject_msg)));
4841 break;
4842
4843 case SST_COUNT:
4844 res = FALSE;
4845 break;
4846 }
4847
4848 if (!res) {
4849 log_error("Error restoring setting '%s' to the value from game start: "
4850 "%s", setting_name(pset), reject_msg);
4851 }
4852}
4853
4854/************************************************************************/
4858{
4862
4863 /* Settings from the start of the game are saved. */
4865}
4866
4867/************************************************************************/
4870void settings_game_save(struct section_file *file, const char *section)
4871{
4872 int set_count = 0;
4873
4875 char errbuf[200];
4876 struct sf_cb_data info = { pset, FALSE };
4877
4878 if (/* It's explicitly set to some value to save */
4880 /* It must be same at loading time as it was saving time, even if
4881 * freeciv's default has changed. */
4884
4886 "%s.set%d.name", section, set_count);
4887 switch (setting_type(pset)) {
4888 case SST_BOOL:
4889 secfile_insert_bool(file, *pset->boolean.pvalue,
4890 "%s.set%d.value", section, set_count);
4891 if (gamestart) {
4892 secfile_insert_bool(file, pset->boolean.game_value,
4893 "%s.set%d.gamestart", section, set_count);
4894 }
4895 break;
4896 case SST_INT:
4897 secfile_insert_int(file, *pset->integer.pvalue,
4898 "%s.set%d.value", section, set_count);
4899 if (gamestart) {
4900 secfile_insert_int(file, pset->integer.game_value,
4901 "%s.set%d.gamestart", section, set_count);
4902 }
4903 break;
4904 case SST_STRING:
4905 secfile_insert_str(file, pset->string.value,
4906 "%s.set%d.value", section, set_count);
4907 if (gamestart) {
4908 secfile_insert_str(file, pset->string.game_value,
4909 "%s.set%d.gamestart", section, set_count);
4910 }
4911 break;
4912 case SST_ENUM:
4915 "%s.set%d.value", section, set_count);
4916 if (gamestart) {
4917 secfile_insert_enum_data(file, pset->enumerator.game_value, FALSE,
4919 "%s.set%d.gamestart", section, set_count);
4920 }
4921 break;
4922 case SST_BITWISE:
4923 secfile_insert_enum_data(file, *pset->bitwise.pvalue, TRUE,
4925 "%s.set%d.value", section, set_count);
4926 if (gamestart) {
4927 secfile_insert_enum_data(file, pset->bitwise.game_value, TRUE,
4929 "%s.set%d.gamestart", section, set_count);
4930 }
4931 break;
4932 case SST_COUNT:
4934 secfile_insert_str(file, "Unknown setting type",
4935 "%s.set%d.value", section, set_count);
4936 if (gamestart) {
4937 secfile_insert_str(file, "Unknown setting type",
4938 "%s.set%d.gamestart", section, set_count);
4939 }
4940 break;
4941 }
4942 if (gamestart) {
4944 "%s.set%d.gamesetdef", section, set_count);
4945 }
4946 set_count++;
4947 }
4949
4950 secfile_insert_int(file, set_count, "%s.set_count", section);
4952 "%s.gamestart_valid", section);
4953}
4954
4955/************************************************************************/
4958void settings_game_load(struct section_file *file, const char *section)
4959{
4960 const char *name;
4961 char reject_msg[256], buf[256];
4962 int i, set_count;
4963 int oldcitymindist = game.info.citymindist; /* backwards compat, see below */
4964
4965 /* Compatibility with savegames created with older versions is usually
4966 * handled as conversions in savecompat.c compat_load_<version>() */
4967
4968 if (!secfile_lookup_int(file, &set_count, "%s.set_count", section)) {
4969 /* Old savegames and scenarios doesn't contain this, not an error. */
4970 log_verbose("Can't read the number of settings in the save file.");
4971 return;
4972 }
4973
4974 /* Check if the saved settings are valid settings from game start. */
4976 = secfile_lookup_bool_default(file, FALSE, "%s.gamestart_valid",
4977 section);
4978
4979 for (i = 0; i < set_count; i++) {
4980 name = secfile_lookup_str(file, "%s.set%d.name", section, i);
4981
4983 struct sf_cb_data info = { pset, FALSE };
4984
4985 if (fc_strcasecmp(setting_name(pset), name) != 0) {
4986 continue;
4987 }
4988
4989 /* Load the current value of the setting. */
4990 switch (pset->stype) {
4991 case SST_BOOL:
4992 {
4993 bool val;
4994
4995 if (!secfile_lookup_bool(file, &val, "%s.set%d.value", section,
4996 i)) {
4997 log_verbose("Option '%s' not defined in the savegame: %s", name,
4998 secfile_error());
4999 } else {
5000 pset->setdef = SETDEF_CHANGED;
5001
5002 if (val != *pset->boolean.pvalue) {
5004 sizeof(reject_msg))
5005 && (pset->boolean.validate == nullptr
5006 || pset->boolean.validate(val, nullptr, reject_msg,
5007 sizeof(reject_msg)))) {
5008 *pset->boolean.pvalue = val;
5009 log_normal(_("Savegame: '%s' has been set to %s."),
5011 setting_value_name(pset, TRUE, buf, sizeof(buf)));
5012 } else {
5013 log_error("Savegame: error restoring '%s' . (%s)",
5015 }
5016 } else {
5017 log_normal(_("Savegame: '%s' explicitly set to value same as default."),
5019 }
5020 }
5021 }
5022 break;
5023
5024 case SST_INT:
5025 {
5026 int val;
5027
5028 if (!secfile_lookup_int(file, &val, "%s.set%d.value", section, i)) {
5029 log_verbose("Option '%s' not defined in the savegame: %s", name,
5030 secfile_error());
5031 } else {
5032 pset->setdef = SETDEF_CHANGED;
5033
5034 if (val != *pset->integer.pvalue) {
5036 sizeof(reject_msg))
5037 && (pset->integer.validate == nullptr
5038 || pset->integer.validate(val, nullptr, reject_msg,
5039 sizeof(reject_msg)))) {
5040 *pset->integer.pvalue = val;
5041 log_normal(_("Savegame: '%s' has been set to %s."),
5043 setting_value_name(pset, TRUE, buf, sizeof(buf)));
5044 } else {
5045 log_error("Savegame: error restoring '%s' . (%s)",
5047 }
5048 } else {
5049 log_normal(_("Savegame: '%s' explicitly set to value same as default."),
5051 }
5052 }
5053 }
5054 break;
5055
5056 case SST_STRING:
5057 {
5058 const char *val = secfile_lookup_str(file, "%s.set%d.value",
5059 section, i);
5060
5061 if (val == nullptr) {
5062 log_verbose("Option '%s' not defined in the savegame: %s", name,
5063 secfile_error());
5064 } else {
5065 pset->setdef = SETDEF_CHANGED;
5066
5067 if (0 != strcmp(val, pset->string.value)) {
5068 if (setting_str_set(pset, val, nullptr, reject_msg,
5069 sizeof(reject_msg))) {
5070 log_normal(_("Savegame: '%s' has been set to %s."),
5072 setting_value_name(pset, TRUE, buf, sizeof(buf)));
5073 } else {
5074 log_error("Savegame: error restoring '%s' . (%s)",
5076 }
5077 } else {
5078 log_normal(_("Savegame: '%s' explicitly set to value same as default."),
5080 }
5081 }
5082 }
5083 break;
5084
5085 case SST_ENUM:
5086 {
5087 int val;
5088
5089 if (!secfile_lookup_enum_data(file, &val, FALSE,
5091 "%s.set%d.value", section, i)) {
5092 log_verbose("Option '%s' not defined in the savegame: %s", name,
5093 secfile_error());
5094 } else {
5095 pset->setdef = SETDEF_CHANGED;
5096
5097 if (val != read_enum_value(pset)) {
5099 sizeof(reject_msg))
5100 && (pset->enumerator.validate == nullptr
5101 || pset->enumerator.validate(val, nullptr, reject_msg,
5102 sizeof(reject_msg)))) {
5103 set_enum_value(pset, val);
5104 log_normal(_("Savegame: '%s' has been set to %s."),
5106 setting_value_name(pset, TRUE, buf, sizeof(buf)));
5107 } else {
5108 log_error("Savegame: error restoring '%s' . (%s)",
5110 }
5111 } else {
5112 log_normal(_("Savegame: '%s' explicitly set to value same as default."),
5114 }
5115 }
5116 }
5117 break;
5118
5119 case SST_BITWISE:
5120 {
5121 int val;
5122
5123 if (!secfile_lookup_enum_data(file, &val, TRUE,
5125 "%s.set%d.value", section, i)) {
5126 log_verbose("Option '%s' not defined in the savegame: %s", name,
5127 secfile_error());
5128 } else {
5129 pset->setdef = SETDEF_CHANGED;
5130
5131 if (val != *pset->bitwise.pvalue) {
5133 sizeof(reject_msg))
5134 && (pset->bitwise.validate == nullptr
5135 || pset->bitwise.validate(val, nullptr, reject_msg,
5136 sizeof(reject_msg)))) {
5137 *pset->bitwise.pvalue = val;
5138 log_normal(_("Savegame: '%s' has been set to %s."),
5140 setting_value_name(pset, TRUE, buf, sizeof(buf)));
5141 } else {
5142 log_error("Savegame: error restoring '%s' . (%s)",
5144 }
5145 } else {
5146 log_normal(_("Savegame: '%s' explicitly set to value same as default."),
5148 }
5149 }
5150 }
5151 break;
5152
5153 case SST_COUNT:
5154 fc_assert(pset->stype != SST_COUNT);
5155 break;
5156 }
5157
5159 const char *sdname;
5160
5161 /* Load the value of the setting at the start of the game. */
5162 switch (pset->stype) {
5163 case SST_BOOL:
5164 pset->boolean.game_value =
5165 secfile_lookup_bool_default(file, *pset->boolean.pvalue,
5166 "%s.set%d.gamestart", section, i);
5167 break;
5168
5169 case SST_INT:
5170 pset->integer.game_value =
5171 secfile_lookup_int_default(file, *pset->integer.pvalue,
5172 "%s.set%d.gamestart", section, i);
5173 break;
5174
5175 case SST_STRING:
5176 fc_strlcpy(pset->string.game_value,
5177 secfile_lookup_str_default(file, pset->string.value,
5178 "%s.set%d.gamestart",
5179 section, i),
5180 pset->string.value_size);
5181 break;
5182
5183 case SST_ENUM:
5184 pset->enumerator.game_value =
5187 &info, "%s.set%d.gamestart", section, i);
5188 break;
5189
5190 case SST_BITWISE:
5191 pset->bitwise.game_value =
5193 *pset->bitwise.pvalue, TRUE, setting_bitwise_secfile_str,
5194 &info, "%s.set%d.gamestart", section, i);
5195 break;
5196
5197 case SST_COUNT:
5198 fc_assert(pset->stype != SST_COUNT);
5199 break;
5200 }
5201
5202 sdname
5205 "%s.set%d.gamesetdef", section, i);
5208
5209 if (!setting_default_level_is_valid(pset->game_setdef)) {
5210 log_error("Setting %s has invalid gamesetdef value %s",
5212 pset->game_setdef = SETDEF_CHANGED;
5213 }
5214 } else {
5215 pset->game_setdef = SETDEF_CHANGED;
5216 }
5218 }
5219
5220 /* Backwards compatibility for pre-2.4 savegames: citymindist=0 used to mean
5221 * take from ruleset min_dist_bw_cities, but that no longer exists.
5222 * This is here rather than in savegame2.c compat functions, as we need
5223 * to have loaded the relevant ruleset to know what to set it to (the
5224 * ruleset and any 'citymindist' setting it contains will have been loaded
5225 * before this function was called). */
5226 if (game.info.citymindist == 0) {
5228 }
5229
5231 /* Have to do this at the end due to dependencies ('aifill' and
5232 * 'maxplayer'). */
5235}
5236
5237/************************************************************************/
5241{
5243 log_debug("No saved settings from the game start available.");
5244 return FALSE;
5245 }
5246
5250
5251 return TRUE;
5252}
5253
5254/************************************************************************/
5273
5274/************************************************************************/
5278{
5280 if (setting_is_changeable(pset, nullptr, nullptr, 0)) {
5283 }
5285}
5286
5287/************************************************************************/
5292{
5293 /* Nothing at the moment. */
5294}
5295
5296/************************************************************************/
5307
5308/************************************************************************/
5312{
5313 return SETTINGS_NUM;
5314}
5315
5316/************************************************************************/
5320void send_server_setting(struct conn_list *dest, const struct setting *pset)
5321{
5322 if (!dest) {
5323 dest = game.est_connections;
5324 }
5325
5326#define PACKET_COMMON_INIT(packet, pset, pconn) \
5327 memset(&packet, 0, sizeof(packet)); \
5328 packet.id = setting_number(pset); \
5329 packet.is_visible = setting_is_visible(pset, pconn); \
5330 packet.is_changeable = setting_is_changeable(pset, pconn, nullptr, 0); \
5331 packet.initial_setting = game.info.is_new_game; \
5332 packet.setdef = setting_get_setdef(pset);
5333
5334 switch (setting_type(pset)) {
5335 case SST_BOOL:
5336 {
5337 struct packet_server_setting_bool packet;
5338
5339 conn_list_iterate(dest, pconn) {
5340 PACKET_COMMON_INIT(packet, pset, pconn);
5341 if (packet.is_visible) {
5342 packet.val = *pset->boolean.pvalue;
5343 packet.default_val = pset->boolean.default_value;
5344 }
5347 }
5348 break;
5349 case SST_INT:
5350 {
5351 struct packet_server_setting_int packet;
5352
5353 conn_list_iterate(dest, pconn) {
5354 PACKET_COMMON_INIT(packet, pset, pconn);
5355 if (packet.is_visible) {
5356 packet.val = *pset->integer.pvalue;
5357 packet.default_val = pset->integer.default_value;
5358 packet.min_val = pset->integer.min_value;
5359 packet.max_val = pset->integer.max_value;
5360 }
5363 }
5364 break;
5365 case SST_STRING:
5366 {
5367 struct packet_server_setting_str packet;
5368
5369 conn_list_iterate(dest, pconn) {
5370 PACKET_COMMON_INIT(packet, pset, pconn);
5371 if (packet.is_visible) {
5372 sz_strlcpy(packet.val, pset->string.value);
5373 sz_strlcpy(packet.default_val, pset->string.default_value);
5374 }
5377 }
5378 break;
5379 case SST_ENUM:
5380 {
5381 struct packet_server_setting_enum packet;
5382 const struct sset_val_name *val_name;
5383 int i;
5384
5385 conn_list_iterate(dest, pconn) {
5386 PACKET_COMMON_INIT(packet, pset, pconn);
5387 if (packet.is_visible) {
5388 packet.val = read_enum_value(pset);
5389 packet.default_val = pset->enumerator.default_value;
5390 for (i = 0; (val_name = pset->enumerator.name(i)); i++) {
5391 sz_strlcpy(packet.support_names[i], val_name->support);
5392 /* Send untranslated string */
5393 sz_strlcpy(packet.pretty_names[i], val_name->pretty);
5394 }
5395 packet.values_num = i;
5396 fc_assert(i <= ARRAY_SIZE(packet.support_names));
5397 fc_assert(i <= ARRAY_SIZE(packet.pretty_names));
5398 }
5401 }
5402 break;
5403 case SST_BITWISE:
5404 {
5405 struct packet_server_setting_bitwise packet;
5406 const struct sset_val_name *val_name;
5407 int i;
5408
5409 conn_list_iterate(dest, pconn) {
5410 PACKET_COMMON_INIT(packet, pset, pconn);
5411 if (packet.is_visible) {
5412 packet.val = *pset->bitwise.pvalue;
5413 packet.default_val = pset->bitwise.default_value;
5414 for (i = 0; (val_name = pset->bitwise.name(i)); i++) {
5415 sz_strlcpy(packet.support_names[i], val_name->support);
5416 /* Send untranslated string */
5417 sz_strlcpy(packet.pretty_names[i], val_name->pretty);
5418 }
5419 packet.bits_num = i;
5420 fc_assert(i <= ARRAY_SIZE(packet.support_names));
5421 fc_assert(i <= ARRAY_SIZE(packet.pretty_names));
5422 }
5425 }
5426 break;
5427
5428 case SST_COUNT:
5430 break;
5431 }
5432
5433#undef PACKET_INIT
5434}
5435
5436/************************************************************************/
5445
5446/************************************************************************/
5452 enum cmdlevel old_level,
5453 enum cmdlevel new_level)
5454{
5455 enum cmdlevel min_level;
5456 enum cmdlevel max_level;
5457
5458 if (old_level == new_level) {
5459 return;
5460 }
5461
5462 if (old_level < new_level) {
5465 } else {
5468 }
5469
5471 if ((pset->access_level_read >= min_level
5472 && pset->access_level_read <= max_level)
5473 || (pset->access_level_write >= min_level
5474 && pset->access_level_write <= max_level)) {
5476 }
5478}
5479
5480/************************************************************************/
5484{
5485 struct packet_server_setting_control control;
5487 int i;
5488
5489 control.settings_num = SETTINGS_NUM;
5490
5491 /* Fill in the category strings. */
5494 for (i = 0; i < SSET_NUM_CATEGORIES; i++) {
5495 /* Send untranslated name */
5497 }
5498
5499 /* Send off the control packet. */
5501
5502 pconn->server.settings_sent = TRUE;
5503
5504 /* Send the constant and common part of the settings. */
5508 /* Send untranslated strings to client */
5511 setting.category = pset->scategory;
5512
5515}
5516
5517/************************************************************************/
5520static void settings_list_init(void)
5521{
5522 struct setting *pset;
5523 int i;
5524
5526
5527 /* Do it for all values of enum sset_level. */
5528 for (i = 0; i < OLEVELS_NUM; i++) {
5530 }
5531
5532 for (i = 0; (pset = setting_by_number(i)); i++) {
5533 /* Add the setting to the list of all settings. */
5535
5536 switch (setting_level(pset)) {
5537 case SSET_NONE:
5538 /* No setting should be in this level. */
5540 "No setting level defined for '%s'.", setting_name(pset));
5541 break;
5542 case SSET_ALL:
5543 /* Done above - list of all settings. */
5544 break;
5545 case SSET_VITAL:
5547 break;
5548 case SSET_SITUATIONAL:
5550 break;
5551 case SSET_RARE:
5553 break;
5554 case SSET_CHANGED:
5555 case SSET_LOCKED:
5556 /* This is done in settings_list_update(). */
5557 break;
5558 case OLEVELS_NUM:
5559 /* No setting should be in this level. */
5561 "Invalid setting level for '%s' (%s).",
5563 break;
5564 }
5565 }
5566
5567 /* Sort the lists. */
5568 for (i = 0; i < OLEVELS_NUM; i++) {
5570 }
5571
5572 setting_sorted.init = TRUE;
5573}
5574
5575/************************************************************************/
5579{
5580 struct setting *pset;
5581 int i;
5582
5584
5585 /* Clear the lists for changed and locked values. */
5588
5589 /* Refill them. */
5590 for (i = 0; (pset = setting_by_number(i)); i++) {
5593 }
5594 if (setting_locked(pset)) {
5596 }
5597 }
5598
5599 /* Sort them. */
5602}
5603
5604/************************************************************************/
5607int settings_list_cmp(const struct setting *const *ppset1,
5608 const struct setting *const *ppset2)
5609{
5610 const struct setting *pset1 = *ppset1;
5611 const struct setting *pset2 = *ppset2;
5612
5614}
5615
5616/************************************************************************/
5621{
5622 fc_assert_ret_val(setting_sorted.init, nullptr);
5623 fc_assert_ret_val(setting_sorted.level[level] != nullptr, nullptr);
5625
5626 return setting_sorted.level[level];
5627}
5628
5629/************************************************************************/
5632static void settings_list_free(void)
5633{
5634 int i;
5635
5637
5638 /* Free the lists. */
5639 for (i = 0; i < OLEVELS_NUM; i++) {
5641 }
5642
5643 setting_sorted.init = FALSE;
5644}
5645
5646/************************************************************************/
5650{
5651 pset->setdef = SETDEF_CHANGED;
5652}
5653
5654/************************************************************************/
5658{
5659 return pset->setdef;
5660}
struct ai_type * ai_type_by_name(const char *search)
Definition ai.c:290
bool set_default_ai_type_name(const char *name)
Definition aiiface.c:258
void astr_free(struct astring *astr)
Definition astring.c:148
const char * astr_build_and_list(struct astring *astr, const char *const *items, size_t number)
Definition astring.c:351
static const char * astr_str(const struct astring *astr) fc__attribute((nonnull(1)))
Definition astring.h:93
#define ASTRING_INIT
Definition astring.h:44
#define BV_ISSET(bv, bit)
Definition bitvector.h:86
char * incite_cost
Definition comments.c:76
#define conn_list_iterate(connlist, pconn)
Definition connection.h:108
#define conn_list_iterate_end
Definition connection.h:110
@ TDM_FIXED
Definition fc_types.h:737
@ TDM_EVEN
Definition fc_types.h:738
@ DIPLO_NO_MIXED
Definition fc_types.h:747
@ DIPLO_FOR_TEAMS
Definition fc_types.h:748
@ DIPLO_NO_AIS
Definition fc_types.h:746
@ DIPLO_FOR_HUMANS
Definition fc_types.h:744
@ DIPLO_FOR_ALL
Definition fc_types.h:743
@ DIPLO_FOR_AIS
Definition fc_types.h:745
@ DIPLO_DISABLED
Definition fc_types.h:749
@ REVOLEN_RANDOM
Definition fc_types.h:978
@ REVOLEN_RANDQUICK
Definition fc_types.h:980
@ REVOLEN_FIXED
Definition fc_types.h:977
@ REVOLEN_QUICKENING
Definition fc_types.h:979
int Unit_Class_id
Definition fc_types.h:276
@ HB_ALLIANCE
Definition fc_types.h:986
@ HB_DISABLED
Definition fc_types.h:984
@ HB_NATIONAL
Definition fc_types.h:985
@ VC_SPACERACE
Definition fc_types.h:964
@ VC_CULTURE
Definition fc_types.h:966
@ VC_ALLIED
Definition fc_types.h:965
@ VC_WORLDPEACE
Definition fc_types.h:967
@ BORDERS_ENABLED
Definition fc_types.h:731
@ BORDERS_DISABLED
Definition fc_types.h:730
@ BORDERS_SEE_INSIDE
Definition fc_types.h:732
@ BORDERS_EXPAND
Definition fc_types.h:733
#define Q_(String)
Definition fcintl.h:70
#define _(String)
Definition fcintl.h:67
#define N_(String)
Definition fcintl.h:69
const struct ft_color ftc_server
struct civ_game game
Definition game.c:62
struct world wld
Definition game.c:63
int generate_save_name(const char *format, char *buf, int buflen, const char *reason)
Definition game.c:799
#define GAME_MIN_TOP_CITIES_COUNT
Definition game.h:707
#define GAME_DEFAULT_TECHPENALTY
Definition game.h:559
#define GAME_MAX_RAPTUREDELAY
Definition game.h:511
#define GAME_DEFAULT_START_CITY
Definition game.h:388
#define GAME_DEFAULT_SKILL_LEVEL
Definition game.h:702
#define GAME_DEFAULT_KILLSTACK
Definition game.h:552
@ BARBS_HUTS_ONLY
Definition game.h:53
@ BARBS_FREQUENT
Definition game.h:55
@ BARBS_NORMAL
Definition game.h:54
@ BARBS_DISABLED
Definition game.h:52
@ BARBS_HORDES
Definition game.h:56
#define GAME_DEFAULT_INFRA
Definition game.h:383
#define GAME_MAX_DIPLCHANCE
Definition game.h:470
#define GAME_MAX_SCIENCEBOX
Definition game.h:428
#define GAME_DEFAULT_LUA_TIMEOUT
Definition game.h:759
#define GAME_MAX_EVENT_CACHE_MAX_SIZE
Definition game.h:719
#define GAME_DEFAULT_REVOLENTYPE
Definition game.h:743
#define GAME_DEFAULT_AUTO_AI_TOGGLE
Definition game.h:598
#define GAME_MIN_RAZECHANCE
Definition game.h:575
#define GAME_MIN_GLOBAL_WARMING_PERCENT
Definition game.h:453
#define GAME_DEFAULT_CARAVAN_BONUS_STYLE
Definition game.h:658
#define GAME_MIN_SEED
Definition game.h:376
#define GAME_MAX_TECHLOSSFG
Definition game.h:482
#define GAME_DEFAULT_TCPTIMEOUT
Definition game.h:624
#define GAME_MAX_INFRA
Definition game.h:385
#define GAME_DEFAULT_EVENT_CACHE_INFO
Definition game.h:723
#define GAME_DEFAULT_MGR_FOODNEEDED
Definition game.h:531
#define GAME_DEFAULT_TECHLOST_DONOR
Definition game.h:567
#define GAME_DEFAULT_ALLOWED_CITY_NAMES
Definition game.h:739
#define GAME_MIN_TRADEWORLDRELPCT
Definition game.h:647
#define GAME_DEFAULT_SCORELOG
Definition game.h:580
#define GAME_MAX_KILLUNHOMED
Definition game.h:557
#define GAME_MIN_TECHLOST_RECV
Definition game.h:564
#define GAME_MIN_FREECOST
Definition game.h:473
#define GAME_MAX_CONTACTTURNS
Definition game.h:505
#define GAME_MAX_TECHLOST_RECV
Definition game.h:565
#define GAME_DEFAULT_OCCUPYCHANCE
Definition game.h:672
#define GAME_DEFAULT_USER_META_MESSAGE
Definition game.h:700
#define GAME_MAX_FOODBOX
Definition game.h:420
#define GAME_DEFAULT_GLOBAL_WARMING_PERCENT
Definition game.h:452
#define GAME_DEFAULT_TRADING_TECH
Definition game.h:654
#define GAME_MIN_SCIENCEBOX
Definition game.h:427
#define GAME_MAX_PINGTIMEOUT
Definition game.h:638
#define GAME_MAX_SAVEFREQUENCY
Definition game.h:690
#define GAME_MIN_REVOLUTION_LENGTH
Definition game.h:745
#define GAME_MAX_MGR_TURNINTERVAL
Definition game.h:529
#define GAME_DEFAULT_SAVETURNS
Definition game.h:685
#define GAME_DEFAULT_IPHIDE
Definition game.h:640
#define GAME_DEFAULT_BORDERS
Definition game.h:462
#define GAME_DEFAULT_AIRLIFTINGSTYLE
Definition game.h:750
#define GAME_DEFAULT_SPACESHIP_TRAVEL_PCT
Definition game.h:592
#define GAME_MAX_CONQUERCOST
Definition game.h:478
#define GAME_MAX_TOP_CITIES_COUNT
Definition game.h:708
#define GAME_DEFAULT_TOP_CITIES_COUNT
Definition game.h:706
#define GAME_MAX_AQUEDUCTLOSS
Definition game.h:550
#define GAME_DEFAULT_KILLUNHOMED
Definition game.h:555
#define GAME_DEFAULT_SCIENCEBOX
Definition game.h:426
#define GAME_MIN_DIPLGOLDCOST
Definition game.h:435
#define GAME_DEFAULT_MGR_WORLDCHANCE
Definition game.h:544
#define GAME_MIN_PINGTIME
Definition game.h:633
#define GAME_DEFAULT_ONSETBARBARIAN
Definition game.h:668
#define GAME_MIN_ONSETBARBARIAN
Definition game.h:669
#define GAME_MAX_TECHLOSSREST
Definition game.h:486
#define GAME_DEFAULT_KILLCITIZEN
Definition game.h:553
#define GAME_MIN_INCITE_GOLD_LOSS_CHANCE
Definition game.h:439
#define GAME_MIN_MGR_NATIONCHANCE
Definition game.h:541
#define GAME_MAX_COMPRESS_LEVEL
Definition game.h:727
#define GAME_DEFAULT_NATIONSET
Definition game.h:416
#define GAME_DEFAULT_SHIELDBOX
Definition game.h:422
#define GAME_MIN_NOTRADESIZE
Definition game.h:643
#define GAME_MIN_GOLD
Definition game.h:380
#define GAME_MAX_OCCUPYCHANCE
Definition game.h:674
#define GAME_MIN_SPACESHIP_TRAVEL_PCT
Definition game.h:593
#define GAME_DEFAULT_MAXCONNECTIONSPERHOST
Definition game.h:609
#define GAME_DEFAULT_INCITE_GOLD_CAPT_CHANCE
Definition game.h:442
#define GAME_DEFAULT_DEMOGRAPHY
Definition game.h:710
#define GAME_MIN_MAXCONNECTIONSPERHOST
Definition game.h:610
#define GAME_DEFAULT_FULLTRADESIZE
Definition game.h:650
#define GAME_MAX_DISPERSION
Definition game.h:392
#define GAME_MIN_TECHLOST_DONOR
Definition game.h:568
#define GAME_DEFAULT_RAPTUREDELAY
Definition game.h:509
#define GAME_MIN_MGR_TURNINTERVAL
Definition game.h:528
#define GAME_DEFAULT_REVOLUTION_LENGTH
Definition game.h:744
#define GAME_DEFAULT_MGR_TURNINTERVAL
Definition game.h:527
scorelog_level
Definition game.h:67
@ SL_HUMANS
Definition game.h:69
@ SL_ALL
Definition game.h:68
#define GAME_DEFAULT_START_UNITS
Definition game.h:387
#define GAME_MAX_TCPTIMEOUT
Definition game.h:626
#define GAME_DEFAULT_ALLOW_TAKE
Definition game.h:711
#define GAME_DEFAULT_THREADED_SAVE
Definition game.h:698
#define GAME_MIN_INFRA
Definition game.h:384
#define GAME_MAX_TRADEWORLDRELPCT
Definition game.h:648
#define GAME_DEFAULT_MIN_PLAYERS
Definition game.h:404
#define GAME_MIN_CONQUERCOST
Definition game.h:477
#define GAME_MAX_MGR_DISTANCE
Definition game.h:538
#define GAME_MIN_TECHLOSSREST
Definition game.h:485
#define GAME_DEFAULT_AUTOATTACK
Definition game.h:676
#define GAME_DEFAULT_SAVEFREQUENCY
Definition game.h:688
#define GAME_MAX_GOLD
Definition game.h:381
#define GAME_DEFAULT_REVEALMAP
Definition game.h:578
#define GAME_DEFAULT_SCOREFILE
Definition game.h:582
#define GAME_MAX_FIRST_TIMEOUT
Definition game.h:616
#define GAME_MIN_MGR_DISTANCE
Definition game.h:537
#define GAME_MIN_DISPERSION
Definition game.h:391
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
Definition game.h:571
#define GAME_DEFAULT_SEED
Definition game.h:375
#define GAME_DEFAULT_HOMECAUGHTUNITS
Definition game.h:521
#define GAME_MAX_GLOBAL_WARMING_PERCENT
Definition game.h:454
#define GAME_MAX_MAXCONNECTIONSPERHOST
Definition game.h:611
#define GAME_DEFAULT_NETWAIT
Definition game.h:628
#define GAME_MIN_PINGTIMEOUT
Definition game.h:637
#define GAME_MIN_TECHPENALTY
Definition game.h:560
#define GAME_MIN_CONTACTTURNS
Definition game.h:504
#define GAME_MAX_INCITE_GOLD_LOSS_CHANCE
Definition game.h:440
#define GAME_DEFAULT_KICK_TIME
Definition game.h:755
#define GAME_DEFAULT_PLRCOLORMODE
Definition game.h:741
#define GAME_MAX_CITYMINDIST
Definition game.h:494
#define GAME_DEFAULT_DIPLCHANCE
Definition game.h:468
#define GAME_MAX_NUCLEAR_WINTER_PERCENT
Definition game.h:460
#define GAME_MIN_LUA_TIMEOUT
Definition game.h:760
#define GAME_MIN_END_TURN
Definition game.h:401
#define GAME_DEFAULT_UNRPROTECTS
Definition game.h:501
#define GAME_MIN_MGR_WORLDCHANCE
Definition game.h:545
#define GAME_DEFAULT_RAZECHANCE
Definition game.h:574
#define GAME_MIN_SHIELDBOX
Definition game.h:423
#define GAME_MIN_FIRST_TIMEOUT
Definition game.h:615
#define GAME_MAX_RAZECHANCE
Definition game.h:576
#define GAME_MIN_TIMEOUT
Definition game.h:613
#define GAME_MAX_ONSETBARBARIAN
Definition game.h:670
#define GAME_MIN_FOODBOX
Definition game.h:419
#define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE
Definition game.h:438
#define GAME_MAX_MAX_PLAYERS
Definition game.h:410
#define GAME_DEFAULT_TRADING_CITY
Definition game.h:656
#define GAME_DEFAULT_FOODBOX
Definition game.h:418
#define GAME_DEFAULT_COMPRESS_TYPE
Definition game.h:736
#define GAME_MAX_TIMEOUT
Definition game.h:614
#define GAME_MAX_SPACESHIP_TRAVEL_PCT
Definition game.h:594
#define GAME_DEFAULT_PINGTIMEOUT
Definition game.h:636
#define GAME_DEFAULT_TRADE_REVENUE_STYLE
Definition game.h:664
#define GAME_DEFAULT_SAVEPALACE
Definition game.h:519
#define GAME_MIN_EVENT_CACHE_TURNS
Definition game.h:714
#define GAME_DEFAULT_GLOBAL_WARMING
Definition game.h:450
#define GAME_MAX_SEED
Definition game.h:377
#define GAME_MAX_DIPLGOLDCOST
Definition game.h:436
#define GAME_DEFAULT_TECHLOST_RECV
Definition game.h:563
#define GAME_DEFAULT_NOTRADESIZE
Definition game.h:642
#define GAME_DEFAULT_COMPRESS_LEVEL
Definition game.h:725
#define GAME_MAX_TECHLOST_DONOR
Definition game.h:569
#define GAME_MIN_SAVETURNS
Definition game.h:686
#define GAME_MAX_UNITWAITTIME
Definition game.h:619
#define GAME_DEFAULT_FIRST_TIMEOUT
Definition game.h:601
#define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT
Definition game.h:458
#define GAME_MIN_CIVILWARSIZE
Definition game.h:497
#define GAME_DEFAULT_TRADING_GOLD
Definition game.h:655
#define GAME_MIN_TECHLEAK
Definition game.h:489
#define GAME_DEFAULT_TRAIT_DIST_MODE
Definition game.h:517
#define GAME_DEFAULT_NUCLEAR_WINTER
Definition game.h:456
#define GAME_MIN_DISASTERS
Definition game.h:514
#define GAME_MIN_OCCUPYCHANCE
Definition game.h:673
#define GAME_DEFAULT_FREECOST
Definition game.h:472
#define GAME_MIN_KICK_TIME
Definition game.h:756
#define GAME_DEFAULT_MAX_PLAYERS
Definition game.h:408
#define GAME_DEFAULT_CITYMINDIST
Definition game.h:492
#define GAME_MIN_NUCLEAR_WINTER_PERCENT
Definition game.h:459
#define GAME_DEFAULT_PHASE_MODE
Definition game.h:622
#define GAME_DEFAULT_AIFILL
Definition game.h:412
#define GAME_DEFAULT_TRADEWORLDRELPCT
Definition game.h:646
#define GAME_DEFAULT_MULTIRESEARCH
Definition game.h:572
#define GAME_DEFAULT_CONQUERCOST
Definition game.h:476
#define GAME_MAX_TECHPENALTY
Definition game.h:561
#define GAME_DEFAULT_TIMEOUT
Definition game.h:600
#define GAME_MAX_DISASTERS
Definition game.h:515
#define GAME_MIN_INCITE_GOLD_CAPT_CHANCE
Definition game.h:443
#define GAME_MIN_TECHLOSSFG
Definition game.h:481
#define GAME_MAX_END_TURN
Definition game.h:402
#define GAME_MIN_COMPRESS_LEVEL
Definition game.h:726
#define GAME_DEFAULT_TECHLOSSREST
Definition game.h:484
#define GAME_MIN_KILLUNHOMED
Definition game.h:556
#define GAME_MAX_NOTRADESIZE
Definition game.h:644
#define GAME_DEFAULT_CONTACTTURNS
Definition game.h:503
#define GAME_DEFAULT_SCORELOGLEVEL
Definition game.h:581
#define GAME_DEFAULT_TECHLOSSFG
Definition game.h:480
#define GAME_DEFAULT_TECHLEVEL
Definition game.h:394
#define GAME_MIN_MAX_PLAYERS
Definition game.h:409
#define GAME_DEFAULT_DISASTERS
Definition game.h:513
#define GAME_MAX_FREECOST
Definition game.h:474
#define GAME_MAX_REVOLUTION_LENGTH
Definition game.h:746
#define GAME_MAX_AIFILL
Definition game.h:414
#define GAME_DEFAULT_GOLD
Definition game.h:379
#define GAME_MIN_AQUEDUCTLOSS
Definition game.h:549
#define GAME_MIN_DIPLBULBCOST
Definition game.h:431
#define GAME_DEFAULT_MIGRATION
Definition game.h:525
@ AS_INTERRUPT
Definition game.h:63
@ AS_GAME_OVER
Definition game.h:61
@ AS_QUITIDLE
Definition game.h:62
@ AS_TIMER
Definition game.h:64
@ AS_TURN
Definition game.h:60
#define GAME_MIN_EVENT_CACHE_MAX_SIZE
Definition game.h:718
#define GAME_MIN_CITYMINDIST
Definition game.h:493
#define GAME_MIN_AIFILL
Definition game.h:413
#define GAME_MIN_SAVEFREQUENCY
Definition game.h:689
#define GAME_DEFAULT_NATURALCITYNAMES
Definition game.h:523
#define GAME_DEFAULT_EVENT_CACHE_TURNS
Definition game.h:713
#define GAME_DEFAULT_VICTORY_CONDITIONS
Definition game.h:589
#define GAME_MIN_UNITWAITTIME
Definition game.h:618
#define GAME_DEFAULT_FOGGEDBORDERS
Definition game.h:448
#define GAME_DEFAULT_UNITWAITTIME
Definition game.h:620
#define GAME_DEFAULT_TIMEOUTADDEMOVE
Definition game.h:606
#define GAME_DEFAULT_DISPERSION
Definition game.h:390
#define GAME_MAX_CIVILWARSIZE
Definition game.h:498
#define GAME_DEFAULT_AUTOSAVES
Definition game.h:695
#define GAME_DEFAULT_EVENT_CACHE_CHAT
Definition game.h:721
#define GAME_DEFAULT_DIPLOMACY
Definition game.h:466
#define GAME_DEFAULT_MGR_DISTANCE
Definition game.h:536
#define GAME_MIN_DIPLCHANCE
Definition game.h:469
#define GAME_DEFAULT_TURNBLOCK
Definition game.h:596
#define GAME_MAX_SAVETURNS
Definition game.h:687
#define GAME_MAX_PINGTIME
Definition game.h:634
#define GAME_DEFAULT_PINGTIME
Definition game.h:632
@ CNM_PLAYER_UNIQUE
Definition game.h:46
@ CNM_GLOBAL_UNIQUE
Definition game.h:47
@ CNM_NO_RESTRICTIONS
Definition game.h:45
@ CNM_NO_STEALING
Definition game.h:48
#define GAME_DEFAULT_AQUEDUCTLOSS
Definition game.h:548
#define GAME_DEFAULT_TRADEMINDIST
Definition game.h:660
#define GAME_DEFAULT_BARBARIANRATE
Definition game.h:666
#define GAME_DEFAULT_HAPPYBORDERS
Definition game.h:464
#define GAME_MAX_FULLTRADESIZE
Definition game.h:652
#define GAME_MAX_TECHLEAK
Definition game.h:490
#define GAME_MAX_MGR_NATIONCHANCE
Definition game.h:542
#define GAME_MAX_TECHLEVEL
Definition game.h:396
#define GAME_MAX_MGR_WORLDCHANCE
Definition game.h:546
#define GAME_MIN_MIN_PLAYERS
Definition game.h:405
#define GAME_MAX_TRADEMINDIST
Definition game.h:662
#define GAME_DEFAULT_END_TURN
Definition game.h:400
#define GAME_MAX_EVENT_CACHE_TURNS
Definition game.h:715
#define GAME_MAX_DIPLBULBCOST
Definition game.h:432
#define GAME_DEFAULT_DIPLGOLDCOST
Definition game.h:434
#define GAME_MAX_SHIELDBOX
Definition game.h:424
#define GAME_DEFAULT_TECHLEAK
Definition game.h:488
#define GAME_MAX_MIN_PLAYERS
Definition game.h:406
#define GAME_MAX_NETWAIT
Definition game.h:630
#define GAME_MIN_TCPTIMEOUT
Definition game.h:625
#define GAME_DEFAULT_END_SPACESHIP
Definition game.h:590
#define GAME_MIN_RAPTUREDELAY
Definition game.h:510
#define GAME_MIN_NETWAIT
Definition game.h:629
#define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
Definition game.h:717
#define GAME_DEFAULT_SAVE_NAME
Definition game.h:684
#define GAME_MAX_LUA_TIMEOUT
Definition game.h:761
#define GAME_MIN_TRADEMINDIST
Definition game.h:661
#define GAME_DEFAULT_MGR_NATIONCHANCE
Definition game.h:540
#define GAME_MIN_TECHLEVEL
Definition game.h:395
#define GAME_MAX_INCITE_GOLD_CAPT_CHANCE
Definition game.h:444
#define GAME_DEFAULT_FOGOFWAR
Definition game.h:446
#define GAME_DEFAULT_PERSISTENTREADY
Definition game.h:751
#define GAME_MIN_FULLTRADESIZE
Definition game.h:651
#define GAME_DEFAULT_DIPLBULBCOST
Definition game.h:430
#define GAME_DEFAULT_RESTRICTINFRA
Definition game.h:500
#define GAME_MAX_KICK_TIME
Definition game.h:757
#define GAME_DEFAULT_CIVILWARSIZE
Definition game.h:496
void send_game_info(struct conn_list *dest)
Definition gamehand.c:910
enum unit_role_id crole_to_role_id(char crole)
Definition gamehand.c:87
#define enable(id)
Definition widget.h:223
const char * name
Definition inputfile.c:127
fz_method
Definition ioz.h:37
@ FZ_PLAIN
Definition ioz.h:38
static enum log_level max_level
Definition log.c:49
#define fc_assert_msg(condition, message,...)
Definition log.h:182
#define fc_assert_ret(condition)
Definition log.h:192
#define log_warn(message,...)
Definition log.h:106
#define log_verbose(message,...)
Definition log.h:110
#define fc_assert(condition)
Definition log.h:177
#define fc_assert_ret_val(condition, val)
Definition log.h:195
#define log_debug(message,...)
Definition log.h:116
#define log_normal(message,...)
Definition log.h:108
#define log_error(message,...)
Definition log.h:104
int send_packet_server_setting_bitwise(struct connection *pc, const struct packet_server_setting_bitwise *packet)
int send_packet_server_setting_str(struct connection *pc, const struct packet_server_setting_str *packet)
int send_packet_server_setting_const(struct connection *pc, const struct packet_server_setting_const *packet)
int send_packet_server_setting_int(struct connection *pc, const struct packet_server_setting_int *packet)
int send_packet_server_setting_control(struct connection *pc, const struct packet_server_setting_control *packet)
int send_packet_server_setting_bool(struct connection *pc, const struct packet_server_setting_bool *packet)
int send_packet_set_topology(struct connection *pc, const struct packet_set_topology *packet)
int send_packet_server_setting_enum(struct connection *pc, const struct packet_server_setting_enum *packet)
int map_startpos_count(void)
Definition map.c:2008
bool map_is_empty(void)
Definition map.c:148
#define MAP_MAX_SIZE
Definition map.h:652
#define MAP_MIN_HUTS
Definition map.h:633
#define MAP_MIN_STEEPNESS
Definition map.h:699
#define MAP_MIN_LANDMASS
Definition map.h:691
#define MAP_DEFAULT_SIZE
Definition map.h:650
#define MAP_MAX_LINEAR_SIZE
Definition map.h:668
#define MAP_MAX_TILESPERPLAYER
Definition map.h:664
#define MAP_DEFAULT_HUTS
Definition map.h:632
#define MAP_MAX_FLATPOLES
Definition map.h:720
#define MAP_MIN_TILESPERPLAYER
Definition map.h:663
#define MAP_DEFAULT_LINEAR_SIZE
Definition map.h:667
#define MAP_DEFAULT_STARTPOS
Definition map.h:708
#define MAP_DEFAULT_ANIMALS
Definition map.h:636
#define MAP_MIN_WETNESS
Definition map.h:703
#define MAP_MAX_SEED
Definition map.h:688
#define MAP_DEFAULT_TEAM_PLACEMENT
Definition map.h:726
#define MAP_DEFAULT_TOPO
Definition map.h:682
#define MAP_DEFAULT_SEED
Definition map.h:686
#define MAP_MIN_TEMPERATURE
Definition map.h:723
#define MAP_DEFAULT_MAPSIZE
Definition map.h:640
#define MAP_MIN_LINEAR_SIZE
Definition map.h:669
#define MAP_MAX_STEEPNESS
Definition map.h:700
#define MAP_DEFAULT_LANDMASS
Definition map.h:690
#define MAP_MIN_FLATPOLES
Definition map.h:719
#define MAP_MAX_LANDMASS
Definition map.h:692
#define MAP_MIN_SEED
Definition map.h:687
#define MAP_MAX_ANIMALS
Definition map.h:638
#define MAP_DEFAULT_WRAP
Definition map.h:683
#define MAP_MAX_TEMPERATURE
Definition map.h:724
#define MAP_MAX_LATITUDE_BOUND
Definition map.h:604
#define MAP_MIN_SIZE
Definition map.h:651
#define MAP_MIN_RICHES
Definition map.h:695
#define MAP_DEFAULT_NORTH_LATITUDE
Definition map.h:606
#define MAP_MIN_ANIMALS
Definition map.h:637
#define MAP_DEFAULT_SEPARATE_POLES
Definition map.h:714
#define MAP_DEFAULT_RICHES
Definition map.h:694
#define MAP_DEFAULT_TINYISLES
Definition map.h:710
#define MAP_MIN_LATITUDE_BOUND
Definition map.h:605
#define MAP_DEFAULT_TILESPERPLAYER
Definition map.h:662
#define MAP_DEFAULT_TEMPERATURE
Definition map.h:722
#define MAP_DEFAULT_SOUTH_LATITUDE
Definition map.h:607
#define MAP_MAX_RICHES
Definition map.h:696
#define MAP_DEFAULT_GENERATOR
Definition map.h:706
#define MAP_MAX_HUTS
Definition map.h:634
#define MAP_DEFAULT_FLATPOLES
Definition map.h:718
#define MAP_DEFAULT_WETNESS
Definition map.h:702
#define MAP_MAX_WETNESS
Definition map.h:704
#define MAP_DEFAULT_STEEPNESS
Definition map.h:698
@ MAPSIZE_FULLSIZE
Definition map_types.h:39
@ MAPSIZE_PLAYER
Definition map_types.h:40
@ MAPSIZE_XYSIZE
Definition map_types.h:43
@ MAPGEN_SCENARIO
Definition map_types.h:47
@ MAPGEN_FRACTURE
Definition map_types.h:52
@ MAPGEN_ISLAND
Definition map_types.h:50
@ MAPGEN_FAIR
Definition map_types.h:51
@ MAPGEN_FRACTAL
Definition map_types.h:49
@ MAPGEN_RANDOM
Definition map_types.h:48
@ MAPSTARTPOS_VARIABLE
Definition map_types.h:60
@ MAPSTARTPOS_2or3
Definition map_types.h:58
@ MAPSTARTPOS_ALL
Definition map_types.h:59
@ MAPSTARTPOS_DEFAULT
Definition map_types.h:56
@ MAPSTARTPOS_SINGLE
Definition map_types.h:57
#define fc_calloc(n, esz)
Definition mem.h:38
#define FC_FREE(ptr)
Definition mem.h:41
bool is_metaserver_open(void)
Definition meta.c:483
bool send_server_info_to_metaserver(enum meta_flag flag)
Definition meta.c:491
void set_user_meta_message_string(const char *string)
Definition meta.c:188
@ META_INFO
Definition meta.h:26
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Definition nation.c:705
struct nation_set * nation_set_by_rule_name(const char *name)
Definition nation.c:806
#define nations_iterate_end
Definition nation.h:338
#define nations_iterate(NAME_pnation)
Definition nation.h:335
#define NO_NATION_SELECTED
Definition nation.h:30
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
Definition notify.c:238
int len
Definition packhand.c:128
int player_count(void)
Definition player.c:819
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Definition player.c:864
#define players_iterate_end
Definition player.h:542
#define players_iterate(_pplayer)
Definition player.h:537
plrcolor_mode
Definition player.h:52
@ PLRCOL_PLR_RANDOM
Definition player.h:54
@ PLRCOL_PLR_SET
Definition player.h:55
@ PLRCOL_NATION_ORDER
Definition player.h:57
@ PLRCOL_TEAM_ORDER
Definition player.h:56
@ PLRCOL_PLR_ORDER
Definition player.h:53
#define is_human(plr)
Definition player.h:231
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Definition plrhand.c:2647
int normal_player_count(void)
Definition plrhand.c:3209
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition plrhand.c:1825
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1148
void count_playable_nations(void)
Definition plrhand.c:2604
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2595
const char * secfile_error(void)
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
bool secfile_lookup_enum_data(const struct section_file *secfile, int *pvalue, bool bitwise, secfile_enum_name_data_fn_t name_fn, secfile_data_t data, const char *path,...)
int secfile_lookup_enum_default_data(const struct section_file *secfile, int defval, bool bitwise, secfile_enum_name_data_fn_t name_fn, secfile_data_t data, const char *path,...)
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
const char * secfile_name(const struct section_file *secfile)
struct section * secfile_section_by_name(const struct section_file *secfile, const char *name)
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
#define secfile_insert_int(secfile, value, path,...)
#define secfile_insert_str(secfile, string, path,...)
#define secfile_insert_bool(secfile, value, path,...)
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
const void * secfile_data_t
void log_civ_score_free(void)
Definition report.c:1514
bool is_valid_demography(const char *demography, int *error)
Definition report.c:1158
void log_civ_score_init(void)
Definition report.c:1491
bool autolock_settings(void)
Definition rssanity.c:1717
static struct compatibility compat[]
Definition savecompat.c:117
#define setcompat_current_val_from_previous(_set_, _old_val_)
Definition setcompat.h:22
#define setcompat_current_name_from_previous(_old_name_)
Definition setcompat.h:20
bool setting_ruleset_locked(const struct setting *pset)
Definition settings.c:4693
bool setting_int_validate(const struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3805
static void metamessage_action(const struct setting *pset)
Definition settings.c:879
static const struct sset_val_name * phasemode_name(int phasemode)
Definition settings.c:565
void settings_init(bool act)
Definition settings.c:5257
static bool savename_validate(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:909
static const char * setting_bool_to_str(const struct setting *pset, bool value, bool pretty, char *buf, size_t buf_len)
Definition settings.c:3649
#define PACKET_COMMON_INIT(packet, pset, pconn)
static bool endturn_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1119
void setting_action(const struct setting *pset)
Definition settings.c:4413
bool(* bitwise_validate_func_t)(unsigned value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition settings.c:83
static const struct sset_val_name * revealmap_name(int bit)
Definition settings.c:533
void setting_ruleset_lock_clear(struct setting *pset)
Definition settings.c:4721
void setting_admin_lock_clear(struct setting *pset)
Definition settings.c:4733
#define GEN_BOOL(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
Definition settings.c:1432
int setting_int_get(struct setting *pset)
Definition settings.c:3830
static const char * setting_bool_secfile_str(secfile_data_t data, int val)
Definition settings.c:3744
static void nationset_action(const struct setting *pset)
Definition settings.c:735
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4347
bool setting_enum_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4094
struct setting * setting_by_name(const char *name)
Definition settings.c:3349
static const struct sset_val_name * compresstype_name(enum fz_method compresstype)
Definition settings.c:595
void setting_set_to_default(struct setting *pset)
Definition settings.c:4383
static void timeout_action(const struct setting *pset)
Definition settings.c:801
static const struct sset_val_name * startpos_name(int startpos)
Definition settings.c:320
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4311
void settings_game_load(struct section_file *file, const char *section)
Definition settings.c:4958
const char * setting_extra_help(const struct setting *pset, bool constant)
Definition settings.c:3392
static bool setting_match_prefix(const val_name_func_t name_fn, const char *prefix, int *pvalue, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3607
const char *(* help_callback_func_t)(const struct setting *pset)
Definition settings.c:89
int setting_number(const struct setting *pset)
Definition settings.c:3365
struct setting * setting_by_number(int id)
Definition settings.c:3341
bool setting_int_set(struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3785
enum sset_category setting_category(const struct setting *pset)
Definition settings.c:3420
static bool aitype_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1377
bool setting_is_visible(const struct setting *pset, struct connection *caller)
Definition settings.c:3548
static bool first_timeout_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1220
static void setting_ruleset_setdef(struct setting *pset)
Definition settings.c:4482
bool setting_locked(const struct setting *pset)
Definition settings.c:4685
bool setting_non_default(const struct setting *pset)
Definition settings.c:4659
static bool wrap_callback(unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1393
static bool xsize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1283
static const struct sset_val_name * airliftingstyle_name(int bit)
Definition settings.c:546
enum sset_type setting_type(const struct setting *pset)
Definition settings.c:3404
void settings_free(void)
Definition settings.c:5299
static const struct sset_val_name * caravanbonusstyle_name(int caravanbonus)
Definition settings.c:234
void setting_admin_lock_set(struct setting *pset)
Definition settings.c:4713
static void settings_list_free(void)
Definition settings.c:5632
bool setting_str_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3856
#define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
Definition settings.c:1452
static const struct sset_val_name * bool_name(int enable)
Definition settings.c:646
bool init
Definition settings.c:189
static const struct sset_val_name * revolentype_name(int revolentype)
Definition settings.c:518
int setting_int_max(const struct setting *pset)
Definition settings.c:3775
enum sset_level setting_level(const struct setting *pset)
Definition settings.c:3412
static struct setting settings[]
Definition settings.c:1494
static void first_timeout_action(const struct setting *pset)
Definition settings.c:819
static bool allowtake_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1019
static void wrap_action(const struct setting *pset)
Definition settings.c:863
static const char * setting_bitwise_to_str(const struct setting *pset, unsigned value, bool pretty, char *buf, size_t buf_len)
Definition settings.c:4151
static const struct sset_val_name * topology_name(int topology_bit)
Definition settings.c:263
bool setting_bitwise_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4267
static void topology_action(const struct setting *pset)
Definition settings.c:848
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Definition settings.c:3912
void settings_game_save(struct section_file *file, const char *section)
Definition settings.c:4870
int settings_number(void)
Definition settings.c:5311
bool setting_str_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3876
static const struct sset_val_name * traderevenuestyle_name(int revenue_style)
Definition settings.c:289
bool(* string_validate_func_t)(const char *value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition settings.c:76
#define NAME_CASE(_val, _support, _pretty)
Definition settings.c:224
void settings_turn(void)
Definition settings.c:5291
#define GEN_STRING_NRS(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
Definition settings.c:1462
static bool setting_is_free_to_change(const struct setting *pset, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3430
static const char * setting_enum_to_str(const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
Definition settings.c:3955
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
Definition settings.c:3935
struct setting_list * level[OLEVELS_NUM]
Definition settings.c:190
void setting_changed(struct setting *pset)
Definition settings.c:5649
#define GEN_ENUM(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_help, func_validate, func_action, func_name, _default)
Definition settings.c:1472
static bool startunits_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1065
static void huts_action(const struct setting *pset)
Definition settings.c:840
static bool nationset_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1161
enum setting_default_level setting_get_setdef(const struct setting *pset)
Definition settings.c:5657
static bool mapsize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1264
static const char * setting_int_to_str(const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
Definition settings.c:3755
static bool setting_bool_validate_base(const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3670
static bool setting_ruleset_one(struct section_file *file, const char *name, const char *path, bool compat)
Definition settings.c:4490
static bool demography_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:973
static struct @119 setting_sorted
bool(* enum_validate_func_t)(int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition settings.c:80
void settings_game_start(void)
Definition settings.c:4857
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4065
const char * setting_short_help(const struct setting *pset)
Definition settings.c:3383
static const struct sset_val_name * citynames_name(int citynames)
Definition settings.c:487
void send_server_setting_control(struct connection *pconn)
Definition settings.c:5483
static bool plrcol_validate(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1413
static const struct sset_val_name * generator_name(int generator)
Definition settings.c:303
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
Definition settings.c:4131
static bool autosaves_callback(unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:993
static bool maxplayers_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1134
int setting_int_min(const struct setting *pset)
Definition settings.c:3766
bool(* bool_validate_func_t)(bool value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition settings.c:70
static bool setting_enum_validate_base(const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3977
static void autotoggle_action(const struct setting *pset)
Definition settings.c:785
bool setting_bitwise_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4288
void setting_ruleset_lock_set(struct setting *pset)
Definition settings.c:4701
static const struct sset_val_name * ailevel_name(enum ai_level lvl)
Definition settings.c:621
static const struct sset_val_name * victory_conditions_name(int condition_bit)
Definition settings.c:377
#define GEN_INT(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_help, func_validate, func_action, _min, _max, _default)
Definition settings.c:1441
bool setting_bool_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3730
struct setting_list * settings_list_get(enum sset_level level)
Definition settings.c:5620
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3502
static const struct sset_val_name * teamplacement_name(int team_placement)
Definition settings.c:341
int settings_list_cmp(const struct setting *const *pset1, const struct setting *const *pset2)
Definition settings.c:5607
static bool setting_bitwise_validate_base(const struct setting *pset, const char *val, unsigned *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:4216
static enum m_pre_result setting_match_prefix_base(const val_name_func_t name_fn, const char *prefix, int *ind_result, const char **matches, size_t max_matches, size_t *pnum_matches)
Definition settings.c:3562
static void settings_list_init(void)
Definition settings.c:5520
void settings_reset(void)
Definition settings.c:5277
const char * setting_name(const struct setting *pset)
Definition settings.c:3375
static const int SETTINGS_NUM
Definition settings.c:3336
static const char * phasemode_help(const struct setting *pset)
Definition settings.c:665
static bool ysize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1308
bool settings_game_reset(void)
Definition settings.c:5240
static void scorelog_action(const struct setting *pset)
Definition settings.c:710
static const struct sset_val_name * happyborders_name(int happyborders)
Definition settings.c:454
int setting_bitwise_get(struct setting *pset)
Definition settings.c:4301
static const struct sset_val_name * scoreloglevel_name(enum scorelog_level sl_level)
Definition settings.c:581
static const struct sset_val_name * wrap_name(int wrap_bit)
Definition settings.c:276
void settings_list_update(void)
Definition settings.c:5578
static bool timeout_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1182
sset_class
Definition settings.c:57
@ SSET_RULES
Definition settings.c:64
@ SSET_PLAYERS
Definition settings.c:61
@ SSET_GAME_INIT
Definition settings.c:63
@ SSET_MAP_GEN
Definition settings.c:59
@ SSET_RULES_FLEXIBLE
Definition settings.c:66
@ SSET_META
Definition settings.c:67
@ SSET_MAP_ADD
Definition settings.c:60
@ SSET_PLAYERS_CHANGEABLE
Definition settings.c:62
@ SSET_MAP_SIZE
Definition settings.c:58
@ SSET_RULES_SCENARIO
Definition settings.c:65
static bool generator_validate(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:930
static const char * setting_str_to_str(const struct setting *pset, const char *value, bool pretty, char *buf, size_t buf_len)
Definition settings.c:3840
void(* action_callback_func_t)(const struct setting *pset)
Definition settings.c:88
#define settings_snprintf(_buf, _buf_len, format,...)
Definition settings.c:206
char * setting_str_get(struct setting *pset)
Definition settings.c:3901
const struct sset_val_name *(* val_name_func_t)(int value)
Definition settings.c:90
bool settings_ruleset(struct section_file *file, const char *section, bool act, bool compat)
Definition settings.c:4423
bool setting_bool_get(struct setting *pset)
Definition settings.c:3718
static bool set_enum_value(struct setting *pset, int val)
Definition settings.c:4004
static void setting_game_set(struct setting *pset, bool init)
Definition settings.c:4745
static void setting_game_free(struct setting *pset)
Definition settings.c:4785
static bool scorefile_validate(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:956
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Definition settings.c:4108
static void aitype_action(const struct setting *pset)
Definition settings.c:895
static void aifill_action(const struct setting *pset)
Definition settings.c:722
static const struct sset_val_name * trait_dist_name(int trait_dist)
Definition settings.c:425
bool setting_is_visible_at_level(const struct setting *pset, enum cmdlevel plevel)
Definition settings.c:3538
static const struct sset_val_name * plrcol_name(int plrcol)
Definition settings.c:438
bool setting_bool_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:3699
void send_server_setting(struct conn_list *dest, const struct setting *pset)
Definition settings.c:5320
static const char * huts_help(const struct setting *pset)
Definition settings.c:683
static const struct sset_val_name * persistentready_name(int persistent_ready)
Definition settings.c:362
void send_server_settings(struct conn_list *dest)
Definition settings.c:5439
#define GEN_BITWISE(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, func_name, _default)
Definition settings.c:1483
static const struct sset_val_name * mapsize_name(int mapsize)
Definition settings.c:249
static void plrcol_action(const struct setting *pset)
Definition settings.c:768
void send_server_access_level_settings(struct conn_list *dest, enum cmdlevel old_level, enum cmdlevel new_level)
Definition settings.c:5451
static const struct sset_val_name * diplomacy_name(int diplomacy)
Definition settings.c:468
static const struct sset_val_name * barbarians_name(int barbarians)
Definition settings.c:502
static void setting_game_restore(struct setting *pset)
Definition settings.c:4795
int read_enum_value(const struct setting *pset)
Definition settings.c:4038
static const struct sset_val_name * borders_name(int borders)
Definition settings.c:408
static const struct sset_val_name * autosaves_name(int autosaves_bit)
Definition settings.c:392
bool(* int_validate_func_t)(int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition settings.c:73
static bool unitwaittime_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1238
static bool topology_callback(unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Definition settings.c:1341
#define settings_iterate(_level, _pset)
Definition settings.h:188
#define settings_iterate_end
Definition settings.h:194
setting_lock_level
Definition settings.h:76
@ SLOCK_RULESET
Definition settings.h:76
@ SLOCK_ADMIN
Definition settings.h:76
@ SLOCK_NONE
Definition settings.h:76
bool is_safe_filename(const char *name)
Definition shared.c:256
void remove_leading_trailing_spaces(char *s)
Definition shared.c:444
#define ARRAY_SIZE(x)
Definition shared.h:85
#define MIN(x, y)
Definition shared.h:55
#define MAX_LEN_PATH
Definition shared.h:32
m_pre_result
Definition shared.h:213
@ M_PRE_EXACT
Definition shared.h:214
@ M_PRE_ONLY
Definition shared.h:215
@ M_PRE_LAST
Definition shared.h:220
@ M_PRE_LONG
Definition shared.h:218
@ M_PRE_AMBIGUOUS
Definition shared.h:216
@ M_PRE_EMPTY
Definition shared.h:217
@ M_PRE_FAIL
Definition shared.h:219
size_t size
Definition specvec.h:72
const char * aifill(int amount)
Definition srv_main.c:2511
bool game_was_started(void)
Definition srv_main.c:355
enum server_states server_state(void)
Definition srv_main.c:339
void toggle_ai_player_direct(struct connection *caller, struct player *pplayer)
Definition stdinhand.c:681
void strvec_destroy(struct strvec *psv)
void strvec_append(struct strvec *psv, const char *string)
struct strvec * strvec_new(void)
size_t strvec_size(const struct strvec *psv)
const char * strvec_to_and_list(const struct strvec *psv, struct astring *astr)
int diplgoldcost
Definition game.h:147
int contactturns
Definition game.h:144
enum city_names_mode allowed_city_names
Definition game.h:134
int unitwaittime
Definition game.h:205
bool multiresearch
Definition game.h:170
int incite_gold_capt_chance
Definition game.h:149
char scorefile[MAX_LEN_PATH]
Definition game.h:231
int mgr_worldchance
Definition game.h:169
int kick_time
Definition game.h:160
bool chat
Definition game.h:260
enum barbarians_rate barbarianrate
Definition game.h:140
int dispersion
Definition game.h:150
bool threaded_save
Definition game.h:187
int max_size
Definition game.h:259
int save_compress_level
Definition game.h:188
int tcptimeout
Definition game.h:202
char start_units[MAX_LEN_STARTUNIT]
Definition game.h:196
int save_nturns
Definition game.h:190
int mgr_nationchance
Definition game.h:167
bool fixedlength
Definition game.h:153
int spaceship_travel_pct
Definition game.h:186
int techlost_recv
Definition game.h:201
bool mgr_foodneeded
Definition game.h:166
int diplchance
Definition game.h:145
int netwait
Definition game.h:175
int incite_gold_loss_chance
Definition game.h:148
int end_turn
Definition game.h:151
bool settings_gamestart_valid
Definition game.h:250
enum plrcolor_mode plrcolormode
Definition game.h:135
int onsetbarbarian
Definition game.h:178
char demography[MAX_LEN_DEMOGRAPHY]
Definition game.h:247
struct conn_list * est_connections
Definition game.h:97
struct civ_game::@32::@36::@40 meta_info
struct packet_game_info info
Definition game.h:89
int mgr_turninterval
Definition game.h:168
char user_message[256]
Definition game.h:273
int min_players
Definition game.h:173
unsigned autosaves
Definition game.h:192
struct timer * save_timer
Definition game.h:224
bool endspaceship
Definition game.h:152
enum scorelog_level scoreloglevel
Definition game.h:230
int lua_timeout
Definition game.h:105
bool migration
Definition game.h:171
bool ip_hide
Definition game.h:181
int diplbulbcost
Definition game.h:146
bool natural_city_names
Definition game.h:174
int maxconnectionsperhost
Definition game.h:162
struct packet_scenario_info scenario
Definition game.h:87
int pingtimeout
Definition game.h:180
int occupychance
Definition game.h:177
randseed seed_setting
Definition game.h:233
int killunhomed
Definition game.h:161
int nuclear_winter_percent
Definition game.h:239
int conquercost
Definition game.h:143
unsigned revealmap
Definition game.h:184
int pingtime
Definition game.h:179
int techloss_restore
Definition game.h:199
char default_ai_type_name[256]
Definition game.h:285
int civilwarsize
Definition game.h:142
bool savepalace
Definition game.h:194
int freecost
Definition game.h:155
char nationset[MAX_LEN_NAME]
Definition game.h:164
int aqueductloss
Definition game.h:136
char save_name[MAX_LEN_NAME]
Definition game.h:227
enum fz_method save_compress_type
Definition game.h:189
enum trait_dist_mode trait_dist
Definition game.h:172
bool foggedborders
Definition game.h:154
bool homecaughtunits
Definition game.h:195
struct civ_game::@32::@36::@38 event_cache
struct civ_game::@32::@36 server
struct packet_timeout_info tinfo
Definition game.h:91
char allow_take[MAX_LEN_ALLOW_TAKE]
Definition game.h:248
bool autoattack
Definition game.h:138
int phase_mode_stored
Definition game.h:223
bool start_city
Definition game.h:197
int max_players
Definition game.h:163
int revolution_length
Definition game.h:185
int turns
Definition game.h:258
bool auto_ai_toggle
Definition game.h:137
int save_frequency
Definition game.h:191
int mgr_distance
Definition game.h:165
int global_warming_percent
Definition game.h:237
int techlost_donor
Definition game.h:200
int timeoutaddenemymove
Definition game.h:215
bool scorelog
Definition game.h:229
int techpenalty
Definition game.h:203
int razechance
Definition game.h:183
bool turnblock
Definition game.h:204
int animals
Definition map_types.h:109
int xsize
Definition map_types.h:79
bool tinyisles
Definition map_types.h:113
int ysize
Definition map_types.h:79
int riches
Definition map_types.h:106
int north_latitude
Definition map_types.h:80
enum mapsize_type mapsize
Definition map_types.h:101
int south_latitude
Definition map_types.h:81
enum map_startpos startpos
Definition map_types.h:112
int steepness
Definition map_types.h:118
int wetness
Definition map_types.h:117
int size
Definition map_types.h:102
int tilesperplayer
Definition map_types.h:103
randseed seed_setting
Definition map_types.h:104
int landpercent
Definition map_types.h:110
enum team_placement team_placement
Definition map_types.h:122
int topology_id
Definition map_types.h:72
struct civ_map::@44::@46 server
int flatpoles
Definition map_types.h:115
int huts
Definition map_types.h:107
int wrap_id
Definition map_types.h:73
enum map_generator generator
Definition map_types.h:111
bool separatepoles
Definition map_types.h:114
int temperature
Definition map_types.h:116
int huts_absolute
Definition map_types.h:108
enum cmdlevel access_level
Definition connection.h:177
enum borders_mode borders
enum happyborders_type happyborders
enum diplomacy_mode diplomacy
enum trade_revenue_style trade_revenue_style
enum airlifting_style airlifting_style
enum ai_level skill_level
enum revolen_type revolentype
enum phase_mode_type phase_mode
enum caravan_bonus_style caravan_bonus_style
enum persistent_ready persistent_ready
enum victory_condition_type victory_conditions
char support_names[64][MAX_LEN_NAME]
char pretty_names[64][MAX_LEN_ENUM]
char category_names[256][MAX_LEN_NAME]
char support_names[64][MAX_LEN_NAME]
char pretty_names[64][MAX_LEN_ENUM]
char default_val[MAX_LEN_PACKET]
char val[MAX_LEN_PACKET]
enum cmdlevel access_level_read
Definition settings.c:97
struct setting::@120::@126 bitwise
char * game_value
Definition settings.c:151
enum setting_default_level setdef
Definition settings.c:184
const char *const default_value
Definition settings.c:148
bool game_value
Definition settings.c:134
const int_validate_func_t validate
Definition settings.c:142
struct setting::@120::@125 enumerator
enum sset_class sclass
Definition settings.c:94
const int default_value
Definition settings.c:139
enum cmdlevel access_level_write
Definition settings.c:98
int *const pvalue
Definition settings.c:138
struct setting::@120::@122 boolean
const val_name_func_t name
Definition settings.c:133
const int max_value
Definition settings.c:141
int game_value
Definition settings.c:143
unsigned game_value
Definition settings.c:168
char *const value
Definition settings.c:147
const help_callback_func_t help_func
Definition settings.c:115
const char * name
Definition settings.c:93
enum setting_default_level game_setdef
Definition settings.c:185
bool *const pvalue
Definition settings.c:130
const enum_validate_func_t validate
Definition settings.c:158
const char * extra_help
Definition settings.c:112
const char * short_help
Definition settings.c:104
const int store_size
Definition settings.c:156
struct setting::@120::@123 integer
struct setting::@120::@124 string
const action_callback_func_t action
Definition settings.c:173
bool ruleset_settable
Definition settings.c:181
enum setting_lock_level lock
Definition settings.c:176
void *const pvalue
Definition settings.c:155
const int min_value
Definition settings.c:140
enum sset_type stype
Definition settings.c:117
const bool_validate_func_t validate
Definition settings.c:132
const string_validate_func_t validate
Definition settings.c:150
const size_t value_size
Definition settings.c:149
bool rslock
Definition settings.c:179
const bitwise_validate_func_t validate
Definition settings.c:166
const unsigned default_value
Definition settings.c:165
const bool default_value
Definition settings.c:131
unsigned *const pvalue
Definition settings.c:164
enum sset_level slevel
Definition settings.c:119
enum sset_category scategory
Definition settings.c:118
struct setting * set
Definition settings.h:82
bool compat
Definition settings.h:83
const char * support
Definition settings.h:29
const char * pretty
Definition settings.h:31
Definition map.c:40
char ** vec
struct civ_map map
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:960
size_t fc_strlcpy(char *dest, const char *src, size_t n)
Definition support.c:777
int fc_strcasecmp(const char *str0, const char *str1)
Definition support.c:186
size_t fc_strlcat(char *dest, const char *src, size_t n)
Definition support.c:822
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Definition support.c:235
#define sz_strlcpy(dest, src)
Definition support.h:195
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
#define bool
Definition support.h:71
#define fc__fallthrough
Definition support.h:119
#define terrain_type_iterate(_p)
Definition terrain.h:266
#define terrain_type_iterate_end
Definition terrain.h:272
#define terrain_has_flag(terr, flag)
Definition terrain.h:176
void timer_destroy(struct timer *t)
Definition timing.c:208
void timer_start(struct timer *t)
Definition timing.c:263
void timer_stop(struct timer *t)
Definition timing.c:305
struct timer * timer_renew(struct timer *t, enum timer_timetype type, enum timer_use use, const char *name)
Definition timing.c:180
@ TIMER_ACTIVE
Definition timing.h:46
@ TIMER_USER
Definition timing.h:42
struct unit_type * get_role_unit(int role, int role_index)
Definition unittype.c:2279
#define utype_class(_t_)
Definition unittype.h:756
#define uclass_index(_c_)
Definition unittype.h:749
#define MAP_NATIVE_WIDTH
#define MAP_IS_ISOMETRIC
#define MAP_NATIVE_HEIGHT