Freeciv21
Develop your civilization from humble roots to a global empire
settings.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 1996-2020 Freeciv21 and Freeciv contributors. This file is
3  __ __ part of Freeciv21. Freeciv21 is free software: you can
4 / \\..// \ redistribute it and/or modify it under the terms of the GNU
5  ( oo ) General Public License as published by the Free Software
6  \__/ Foundation, either version 3 of the License, or (at your
7  option) any later version. You should have received
8  a copy of the GNU General Public License along with Freeciv21. If not,
9  see https://www.gnu.org/licenses/.
10  */
11 
12 #include <fc_config.h>
13 
14 // utility
15 #include "astring.h"
16 #include "fcintl.h"
17 #include "game.h"
18 #include "log.h"
19 #include "registry.h"
20 #include "shared.h"
21 
22 // common
23 #include "map.h"
24 #include "nation.h"
25 
26 // server
27 #include "gamehand.h"
28 #include "maphand.h"
29 #include "meta.h"
30 #include "notify.h"
31 #include "plrhand.h"
32 #include "report.h"
33 #include "rssanity.h"
34 #include "settings.h"
35 #include "srv_main.h"
36 #include "stdinhand.h"
37 
38 /* The following classes determine what can be changed when. Actually, some
39  * of them have the same "changeability", but different types are separated
40  * here in case they have other uses. Also, SSET_GAME_INIT/SSET_RULES
41  * separate the two sections of server settings sent to the client. See the
42  * settings[] array and setting_is_changeable() for what these correspond to
43  * and explanations.
44  */
45 enum sset_class {
54  SSET_META
55 };
56 
57 typedef bool (*bool_validate_func_t)(bool value, struct connection *pconn,
58  char *reject_msg,
59  size_t reject_msg_len);
60 typedef bool (*int_validate_func_t)(int value, struct connection *pconn,
61  char *reject_msg, size_t reject_msg_len);
62 typedef bool (*string_validate_func_t)(const char *value,
63  struct connection *pconn,
64  char *reject_msg,
65  size_t reject_msg_len);
66 typedef bool (*enum_validate_func_t)(int value, struct connection *pconn,
67  char *reject_msg,
68  size_t reject_msg_len);
69 typedef bool (*bitwise_validate_func_t)(unsigned value,
70  struct connection *pconn,
71  char *reject_msg,
72  size_t reject_msg_len);
73 
74 typedef void (*action_callback_func_t)(const struct setting *pset);
75 typedef const char *(*help_callback_func_t)(const struct setting *pset);
76 typedef const struct sset_val_name *(*val_name_func_t)(int value);
77 
78 struct setting {
79  const char *name;
80  enum sset_class sclass;
81 
82  // What access level viewing and setting the setting requires.
83  enum cmdlevel access_level_read;
84  enum cmdlevel access_level_write;
85 
86  /* Should be less than 42 chars (?), or shorter if the values may have more
87  * than about 4 digits. Don't put "." on the end.
88  */
89  const char *short_help;
90 
91  /* May be empty string, if short_help is sufficient. Need not include
92  * embedded newlines (but may, for formatting); lines will be wrapped (and
93  * indented) automatically. Should have punctuation etc, and should end
94  * with a "."
95  */
96  const char *extra_help;
97 
98  // help function
100 
101  enum sset_type stype;
102  enum sset_category scategory;
103  enum sset_level slevel;
104 
105  /* About the *_validate functions: If the function is non-nullptr, it is
106  * called with the new value, and returns whether the change is legal. The
107  * char * is an error message in the case of reject.
108  */
109 
110  union {
111  /*** bool part ***/
112  struct {
113  bool *const pvalue;
114  const bool default_value;
119  /*** int part ***/
120  struct {
121  int *const pvalue;
122  const int default_value;
123  const int min_value;
124  const int max_value;
128  /*** string part ***/
129  struct {
130  char *const value;
131  const char *const default_value;
132  const size_t value_size;
134  char *game_value;
136  /*** enumerator part ***/
137  struct {
138  void *const pvalue;
139  const int store_size;
140  const int default_value;
142  const val_name_func_t name;
143  int game_value;
145  /*** bitwise part ***/
146  struct {
147  unsigned *const pvalue;
148  const unsigned default_value;
150  const val_name_func_t name;
151  unsigned game_value;
153  };
154 
155  // action function
157 
158  // ruleset lock for game settings
159  bool locked;
160 
161  // It's not "default", even if value is the same as default
163 };
164 
165 static struct {
166  bool init;
167  struct setting_list *level[OLEVELS_NUM];
168 } setting_sorted = {.init = false};
169 
170 static bool setting_ruleset_one(struct section_file *file, const char *name,
171  const char *path);
172 static void setting_game_set(struct setting *pset, bool init);
173 static void setting_game_free(struct setting *pset);
174 static void setting_game_restore(struct setting *pset);
175 
176 static void settings_list_init();
177 static void settings_list_free();
178 int settings_list_cmp(const struct setting *const *pset1,
179  const struct setting *const *pset2);
180 
181 #define settings_snprintf(_buf, _buf_len, format, ...) \
182  if (_buf != nullptr) { \
183  fc_snprintf(_buf, _buf_len, format, ##__VA_ARGS__); \
184  }
185 
186 static bool set_enum_value(struct setting *pset, int val);
187 
188 /*
189  Enumerator name accessors.
190 
191  Important note about compatibility:
192  1) you cannot modify the support name of an existant value. However, in a
193  developpement, you can modify it if it wasn't included in any stable
194  branch before.
195  2) Take care of modifiying the pretty name of an existant value: make sure
196  to modify the help texts which are using it.
197  */
198 
199 #define NAME_CASE(_val, _support, _pretty) \
200  case _val: { \
201  static const struct sset_val_name name = {_support, _pretty}; \
202  return &name; \
203  }
204 
208 static const struct sset_val_name *caravanbonusstyle_name(int caravanbonus)
209 {
210  switch (caravanbonus) {
211  NAME_CASE(CBS_CLASSIC, "CLASSIC", N_("Classic Freeciv"));
212  NAME_CASE(CBS_LOGARITHMIC, "LOGARITHMIC", N_("Log^2 N style"));
213  NAME_CASE(CBS_LINEAR, "LINEAR", N_("Linear max trade"));
214  NAME_CASE(CBS_DISTANCE, "DISTANCE", N_("Pure distance"));
215  }
216  return nullptr;
217 }
218 
223 static const struct sset_val_name *mapsize_name(int mapsize)
224 {
225  switch (mapsize) {
226  NAME_CASE(MAPSIZE_FULLSIZE, "FULLSIZE", N_("Number of tiles"));
227  NAME_CASE(MAPSIZE_PLAYER, "PLAYER", N_("Tiles per player"));
228  NAME_CASE(MAPSIZE_XYSIZE, "XYSIZE", N_("Width and height"));
229  }
230  return nullptr;
231 }
232 
236 static const struct sset_val_name *topology_name(int topology_bit)
237 {
238  switch (1 << topology_bit) {
239  NAME_CASE(TF_WRAPX, "WRAPX", N_("Wrap East-West"));
240  NAME_CASE(TF_WRAPY, "WRAPY", N_("Wrap North-South"));
241  NAME_CASE(TF_ISO, "ISO", N_("Isometric"));
242  NAME_CASE(TF_HEX, "HEX", N_("Hexagonal"));
243  }
244  return nullptr;
245 }
246 
250 static const struct sset_val_name *traderevenuestyle_name(int revenue_style)
251 {
252  switch (revenue_style) {
253  NAME_CASE(TRS_CLASSIC, "CLASSIC", N_("Classic Freeciv"));
254  NAME_CASE(TRS_SIMPLE, "SIMPLE", N_("Proportional to tile trade"));
255  }
256  return nullptr;
257 }
258 
262 static const struct sset_val_name *generator_name(int generator)
263 {
264  switch (generator) {
265  NAME_CASE(MAPGEN_SCENARIO, "SCENARIO", N_("Scenario map"));
266  NAME_CASE(MAPGEN_RANDOM, "RANDOM", N_("Fully random height"));
267  NAME_CASE(MAPGEN_FRACTAL, "FRACTAL", N_("Pseudo-fractal height"));
268  NAME_CASE(MAPGEN_ISLAND, "ISLAND", N_("Island-based"));
269  NAME_CASE(MAPGEN_FAIR, "FAIR", N_("Fair islands"));
270  NAME_CASE(MAPGEN_FRACTURE, "FRACTURE", N_("Fracture map"));
271  }
272  return nullptr;
273 }
274 
278 static const struct sset_val_name *startpos_name(int startpos)
279 {
280  switch (startpos) {
281  NAME_CASE(MAPSTARTPOS_DEFAULT, "DEFAULT", N_("Generator's choice"));
282  NAME_CASE(MAPSTARTPOS_SINGLE, "SINGLE", N_("One player per continent"));
283  NAME_CASE(MAPSTARTPOS_2or3, "2or3",
284  N_("Two or three players per continent"));
285  NAME_CASE(MAPSTARTPOS_ALL, "ALL",
286  N_("All players on a single continent"));
287  NAME_CASE(MAPSTARTPOS_VARIABLE, "VARIABLE",
288  N_("Depending on size of continents"));
289  }
290  return nullptr;
291 }
292 
296 static const struct sset_val_name *teamplacement_name(int team_placement)
297 {
298  switch (team_placement) {
299  NAME_CASE(TEAM_PLACEMENT_DISABLED, "DISABLED", N_("Disabled"));
300  NAME_CASE(TEAM_PLACEMENT_CLOSEST, "CLOSEST", N_("As close as possible"));
301  NAME_CASE(TEAM_PLACEMENT_CONTINENT, "CONTINENT",
302  N_("On the same continent"));
303  NAME_CASE(TEAM_PLACEMENT_HORIZONTAL, "HORIZONTAL",
304  N_("Horizontal placement"));
305  NAME_CASE(TEAM_PLACEMENT_VERTICAL, "VERTICAL", N_("Vertical placement"));
306  }
307  return nullptr;
308 }
309 
313 static const struct sset_val_name *persistentready_name(int persistent_ready)
314 {
315  switch (persistent_ready) {
316  NAME_CASE(PERSISTENTR_DISABLED, "DISABLED", N_("Disabled"));
317  NAME_CASE(PERSISTENTR_CONNECTED, "CONNECTED",
318  N_("As long as connected"));
319  }
320 
321  return nullptr;
322 }
323 
327 static const struct sset_val_name *victory_conditions_name(int condition_bit)
328 {
329  switch (condition_bit) {
330  NAME_CASE(VC_SPACERACE, "SPACERACE", N_("Spacerace"));
331  NAME_CASE(VC_ALLIED, "ALLIED", N_("Allied victory"));
332  NAME_CASE(VC_CULTURE, "CULTURE", N_("Culture victory"));
333  };
334 
335  return nullptr;
336 }
337 
341 static const struct sset_val_name *autosaves_name(int autosaves_bit)
342 {
343  switch (autosaves_bit) {
344  NAME_CASE(AS_TURN, "TURN", N_("New turn"));
345  NAME_CASE(AS_GAME_OVER, "GAMEOVER", N_("Game over"));
346  NAME_CASE(AS_QUITIDLE, "QUITIDLE", N_("No player connections"));
347  NAME_CASE(AS_INTERRUPT, "INTERRUPT", N_("Server interrupted"));
348  NAME_CASE(AS_TIMER, "TIMER", N_("Timer"));
349  };
350 
351  return nullptr;
352 }
353 
357 static const struct sset_val_name *borders_name(int borders)
358 {
359  switch (borders) {
360  NAME_CASE(BORDERS_DISABLED, "DISABLED", N_("Disabled"));
361  NAME_CASE(BORDERS_ENABLED, "ENABLED", N_("Enabled"));
362  NAME_CASE(BORDERS_SEE_INSIDE, "SEE_INSIDE",
363  N_("See everything inside borders"));
364  NAME_CASE(BORDERS_EXPAND, "EXPAND",
365  N_("Borders expand to unknown, revealing tiles"));
366  }
367  return nullptr;
368 }
369 
373 static const struct sset_val_name *trait_dist_name(int trait_dist)
374 {
375  switch (trait_dist) {
376  NAME_CASE(TDM_FIXED, "FIXED", N_("Fixed"));
377  NAME_CASE(TDM_EVEN, "EVEN", N_("Even"));
378  }
379  return nullptr;
380 }
381 
385 static const struct sset_val_name *plrcol_name(int plrcol)
386 {
387  switch (plrcol) {
388  NAME_CASE(PLRCOL_PLR_ORDER, "PLR_ORDER", N_("Per-player, in order"));
389  NAME_CASE(PLRCOL_PLR_RANDOM, "PLR_RANDOM", N_("Per-player, random"));
390  NAME_CASE(PLRCOL_PLR_SET, "PLR_SET", N_("Set manually"));
391  NAME_CASE(PLRCOL_TEAM_ORDER, "TEAM_ORDER", N_("Per-team, in order"));
392  NAME_CASE(PLRCOL_NATION_ORDER, "NATION_ORDER",
393  N_("Per-nation, in order"));
394  }
395  return nullptr;
396 }
397 
401 static const struct sset_val_name *happyborders_name(int happyborders)
402 {
403  switch (happyborders) {
404  NAME_CASE(HB_DISABLED, "DISABLED", N_("Borders are not helping"));
405  NAME_CASE(HB_NATIONAL, "NATIONAL", N_("Happy within own borders"));
406  NAME_CASE(HB_ALLIANCE, "ALLIED", N_("Happy within allied borders"));
407  }
408  return nullptr;
409 }
410 
414 static const struct sset_val_name *diplomacy_name(int diplomacy)
415 {
416  switch (diplomacy) {
417  NAME_CASE(DIPLO_FOR_ALL, "ALL", N_("Enabled for everyone"));
418  NAME_CASE(DIPLO_FOR_HUMANS, "HUMAN",
419  N_("Only allowed between human players"));
420  NAME_CASE(DIPLO_FOR_AIS, "AI", N_("Only allowed between AI players"));
421  NAME_CASE(DIPLO_NO_AIS, "NOAI", N_("Only allowed when human involved"));
422  NAME_CASE(DIPLO_NO_MIXED, "NOMIXED",
423  N_("Only allowed between two humans, or two AI players"));
424  NAME_CASE(DIPLO_FOR_TEAMS, "TEAM", N_("Restricted to teams"));
425  NAME_CASE(DIPLO_DISABLED, "DISABLED", N_("Disabled for everyone"));
426  }
427  return nullptr;
428 }
429 
433 static const struct sset_val_name *citynames_name(int citynames)
434 {
435  switch (citynames) {
436  NAME_CASE(CNM_NO_RESTRICTIONS, "NO_RESTRICTIONS", N_("No restrictions"));
437  NAME_CASE(CNM_PLAYER_UNIQUE, "PLAYER_UNIQUE", N_("Unique to a player"));
438  NAME_CASE(CNM_GLOBAL_UNIQUE, "GLOBAL_UNIQUE", N_("Globally unique"));
439  NAME_CASE(CNM_NO_STEALING, "NO_STEALING", N_("No city name stealing"));
440  }
441  return nullptr;
442 }
443 
447 static const struct sset_val_name *barbarians_name(int barbarians)
448 {
449  switch (barbarians) {
450  NAME_CASE(BARBS_DISABLED, "DISABLED", N_("No barbarians"));
451  NAME_CASE(BARBS_HUTS_ONLY, "HUTS_ONLY", N_("Only in huts"));
452  NAME_CASE(BARBS_NORMAL, "NORMAL", N_("Normal rate of appearance"));
453  NAME_CASE(BARBS_FREQUENT, "FREQUENT", N_("Frequent barbarian uprising"));
454  NAME_CASE(BARBS_HORDES, "HORDES", N_("Raging hordes"));
455  }
456  return nullptr;
457 }
458 
462 static const struct sset_val_name *revolentype_name(int revolentype)
463 {
464  switch (revolentype) {
465  NAME_CASE(REVOLEN_FIXED, "FIXED", N_("Fixed to 'revolen' turns"));
466  NAME_CASE(REVOLEN_RANDOM, "RANDOM", N_("Randomly 1-'revolen' turns"));
467  NAME_CASE(REVOLEN_QUICKENING, "QUICKENING",
468  N_("First time 'revolen', then always quicker"));
469  NAME_CASE(REVOLEN_RANDQUICK, "RANDQUICK",
470  N_("Random, max always quicker"));
471  }
472  return nullptr;
473 }
474 
478 static const struct sset_val_name *revealmap_name(int bit)
479 {
480  switch (1 << bit) {
481  NAME_CASE(REVEAL_MAP_START, "START", N_("Reveal map at game start"));
482  NAME_CASE(REVEAL_MAP_DEAD, "DEAD", N_("Unfog map for dead players"));
483  }
484  return nullptr;
485 }
486 
490 static const struct sset_val_name *airliftingstyle_name(int bit)
491 {
492  switch (1 << bit) {
493  NAME_CASE(AIRLIFTING_ALLIED_SRC, "FROM_ALLIES",
494  N_("Allows units to be airlifted from allied cities"));
495  NAME_CASE(AIRLIFTING_ALLIED_DEST, "TO_ALLIES",
496  N_("Allows units to be airlifted to allied cities"));
497  NAME_CASE(AIRLIFTING_UNLIMITED_SRC, "SRC_UNLIMITED",
498  N_("Unlimited units from source city"));
499  NAME_CASE(AIRLIFTING_UNLIMITED_DEST, "DEST_UNLIMITED",
500  N_("Unlimited units to destination city"));
501  }
502  return nullptr;
503 }
504 
508 static const struct sset_val_name *phasemode_name(int phasemode)
509 {
510  switch (phasemode) {
511  NAME_CASE(PMT_CONCURRENT, "ALL", N_("All players move concurrently"));
512  NAME_CASE(PMT_PLAYERS_ALTERNATE, "PLAYER",
513  N_("All players alternate movement"));
514  NAME_CASE(PMT_TEAMS_ALTERNATE, "TEAM", N_("Team alternate movement"));
515  }
516  return nullptr;
517 }
518 
522 static const struct sset_val_name *
524 {
525  switch (sl_level) {
526  NAME_CASE(SL_ALL, "ALL", N_("All players"));
527  NAME_CASE(SL_HUMANS, "HUMANS", N_("Human players only"));
528  }
529  return nullptr;
530 }
531 
535 static const struct sset_val_name *
537 {
538  switch (compresstype) {
539  NAME_CASE(COMPRESS_PLAIN, "PLAIN", N_("No compression"));
540  NAME_CASE(COMPRESS_ZLIB, "LIBZ", N_("Using zlib (gzip format)"));
541 #ifdef FREECIV_HAVE_BZ2
542  NAME_CASE(COMPRESS_BZIP2, "BZIP2", N_("Using bzip2 (deprecated)"));
543 #endif
544 #ifdef FREECIV_HAVE_LZMA
545  NAME_CASE(COMPRESS_XZ, "XZ", N_("Using xz"));
546 #endif
547 #ifdef FREECIV_HAVE_ZSTD
548  NAME_CASE(COMPRESS_ZSTD, "ZSTD", N_("Using Zstandard"));
549 #endif
550  }
551  return nullptr;
552 }
553 
557 static const struct sset_val_name *bool_name(int enable)
558 {
559  switch (enable) {
560  NAME_CASE(false, "DISABLED", N_("disabled"));
561  NAME_CASE(true, "ENABLED", N_("enabled"));
562  }
563  return nullptr;
564 }
565 
569 static const struct sset_val_name *unitwaittime_name(int bit)
570 {
571  switch (1 << bit) {
572  NAME_CASE(UWT_ACTIVITIES, "ACTIVITIES",
573  N_("Wait time applies to activity completion at turn change"));
574  }
575  return NULL;
576 }
577 
578 #undef NAME_CASE
579 
580 /*
581  * Help callback functions.
582  */
583 
587 static const char *phasemode_help(const struct setting *pset)
588 {
589  static char pmhelp[512];
590 
591  // Translated here
592  fc_snprintf(
593  pmhelp, sizeof(pmhelp),
594  _("This setting controls whether players may make moves at the same "
595  "time during a turn. Change in setting takes effect next turn. "
596  "Currently, at least to the end of this turn, mode is \"%s\"."),
597  phasemode_name(game.info.phase_mode)->pretty);
598 
599  return pmhelp;
600 }
601 
605 static const char *huts_help(const struct setting *pset)
606 {
607  if (wld.map.server.huts_absolute >= 0) {
608  static char hutshelp[512];
609 
610  // Translated here
611  fc_snprintf(hutshelp, sizeof(hutshelp),
612  _("%s\n"
613  "Currently this setting is being overridden by an old "
614  "scenario or savegame, which has set the absolute number "
615  "of huts to %d. Explicitly set this setting again to make "
616  "it take effect instead."),
617  _(pset->extra_help), wld.map.server.huts_absolute);
618 
619  return hutshelp;
620  }
621 
622  return pset->extra_help;
623 }
624 
625 /*
626  * Action callback functions.
627  */
628 
632 static void scorelog_action(const struct setting *pset)
633 {
634  if (*pset->boolean.pvalue) {
636  } else {
638  }
639 }
640 
644 static void aifill_action(const struct setting *pset)
645 {
646  const char *msg = aifill(*pset->integer.pvalue);
647  if (msg) {
648  qInfo(_("Warning: aifill not met: %s."), msg);
649  notify_conn(nullptr, nullptr, E_SETTING, ftc_server,
650  _("Warning: aifill not met: %s."), msg);
651  }
652 }
653 
657 static void nationset_action(const struct setting *pset)
658 {
659  // If any player's existing selection is invalid, abort it
660  players_iterate(pplayer)
661  {
662  if (pplayer->nation != nullptr) {
663  if (!nation_is_in_current_set(pplayer->nation)) {
664  (void) player_set_nation(pplayer, NO_NATION_SELECTED);
666  }
667  }
668  }
671  (void) aifill(game.info.aifill);
672 
673  /* There might now be too many players for the available nations. Rather
674  * than getting rid of some players arbitrarily, we let the situation
675  * persist for all already-connected players; the server will simply refuse
676  * to start until someone reduces the number of players. This policy also
677  * avoids annoyance if nationset is accidentally and transiently set to an
678  * unintended value. (However, new connections will start out detached.) */
679  if (normal_player_count() > server.playable_nations) {
680  notify_conn(nullptr, nullptr, E_SETTING, ftc_server, "%s",
681  _("Warning: not enough nations in this nation set for all "
682  "current players."));
683  }
684 
686 }
687 
691 static void plrcol_action(const struct setting *pset)
692 {
693  if (!game_was_started()) {
694  if (read_enum_value(pset) != PLRCOL_PLR_SET) {
695  players_iterate(pplayer) { server_player_set_color(pplayer, nullptr); }
697  }
698  // Update clients with new color scheme.
699  send_player_info_c(nullptr, nullptr);
700  }
701 }
702 
706 static void autotoggle_action(const struct setting *pset)
707 {
708  if (*pset->boolean.pvalue) {
709  players_iterate(pplayer)
710  {
711  if (is_human(pplayer) && !pplayer->is_connected) {
712  toggle_ai_player_direct(nullptr, pplayer);
714  }
715  }
717  }
718 }
719 
724 static void timeout_action(const struct setting *pset)
725 {
726  if (S_S_RUNNING == server_state()) {
727  int timeout = *pset->integer.pvalue;
728 
729  if (game.info.turn != 1 || game.info.first_timeout == -1) {
730  // This may cause the current turn to end immediately.
731  game.tinfo.seconds_to_phasedone = timeout;
732  }
733  send_game_info(nullptr);
734  }
735 }
736 
741 static void first_timeout_action(const struct setting *pset)
742 {
743  if (S_S_RUNNING == server_state()) {
744  int timeout = *pset->integer.pvalue;
745 
746  if (game.info.turn == 1) {
747  // This may cause the current turn to end immediately.
748  if (timeout != -1) {
749  game.tinfo.seconds_to_phasedone = timeout;
750  } else {
751  game.tinfo.seconds_to_phasedone = game.info.timeout;
752  }
753  }
754  send_game_info(nullptr);
755  }
756 }
757 
761 static void huts_action(const struct setting *pset)
762 {
763  wld.map.server.huts_absolute = -1;
764 }
765 
769 static void topology_action(const struct setting *pset)
770 {
771  struct packet_set_topology packet;
772 
773  packet.topology_id = *pset->integer.pvalue;
774 
776  {
777  send_packet_set_topology(pconn, &packet);
778  }
780 }
781 
786 static void metamessage_action(const struct setting *pset)
787 {
788  /* Set the metaserver message based on the new meta server user message. An
789  * empty user metaserver message results in an automatic meta message. A
790  * non empty user meta message results in the user meta message. */
792 
793  if (is_metaserver_open()) {
794  // Update the meta server.
796  }
797 }
798 
799 /*
800  * Validation callback functions.
801  */
802 
806 static bool savename_validate(const char *value, struct connection *caller,
807  char *reject_msg, size_t reject_msg_len)
808 {
809  char buf[MAX_LEN_PATH];
810 
811  generate_save_name(value, buf, sizeof(buf), nullptr);
812 
813  if (!is_safe_filename(buf)) {
815  reject_msg, reject_msg_len,
816  _("Invalid save name definition: '%s' (resolves to '%s')."), value,
817  buf);
818  return false;
819  }
820 
821  return true;
822 }
823 
828 static bool generator_validate(int value, struct connection *caller,
829  char *reject_msg, size_t reject_msg_len)
830 {
831  if (map_is_empty()) {
832  if (MAPGEN_SCENARIO == value
833  && (nullptr != caller || !game.scenario.is_scenario)) {
834  settings_snprintf(reject_msg, reject_msg_len,
835  _("You cannot disable the map generator."));
836  return false;
837  }
838  return true;
839  } else {
840  if (MAPGEN_SCENARIO != value) {
842  reject_msg, reject_msg_len,
843  _("You cannot require a map generator when a map is loaded."));
844  return false;
845  }
846  }
847  return true;
848 }
849 
853 static bool scorefile_validate(const char *value, struct connection *caller,
854  char *reject_msg, size_t reject_msg_len)
855 {
856  if (!is_safe_filename(value)) {
857  settings_snprintf(reject_msg, reject_msg_len,
858  _("Invalid score name definition: '%s'."), value);
859  return false;
860  }
861 
862  return true;
863 }
864 
869 static bool demography_callback(const char *value, struct connection *caller,
870  char *reject_msg, size_t reject_msg_len)
871 {
872  int error;
873 
874  if (is_valid_demography(value, &error)) {
875  return true;
876  } else {
877  settings_snprintf(reject_msg, reject_msg_len,
878  _("Demography string validation failed at character: "
879  "'%c'. Try \"/help demography\"."),
880  value[error]);
881  return false;
882  }
883 }
884 
888 static bool autosaves_callback(unsigned value, struct connection *caller,
889  char *reject_msg, size_t reject_msg_len)
890 {
891  if (S_S_RUNNING == server_state()) {
892  if ((value & (1 << AS_TIMER))
893  && !(game.server.autosaves & (1 << AS_TIMER))) {
894  game.server.save_timer =
896  timer_start(game.server.save_timer);
897  } else if (!(value & (1 << AS_TIMER))
898  && (game.server.autosaves & (1 << AS_TIMER))) {
899  timer_stop(game.server.save_timer);
900  timer_destroy(game.server.save_timer);
901  game.server.save_timer = nullptr;
902  }
903  }
904 
905  return true;
906 }
907 
912 static bool allowtake_callback(const char *value, struct connection *caller,
913  char *reject_msg, size_t reject_msg_len)
914 {
915  int len = qstrlen(value), i;
916  bool havecharacter_state = false;
917 
918  /* We check each character individually to see if it's valid. This does
919  * not check for duplicate entries.
920  * We also track the state of the machine. havecharacter_state is true if
921  * the preceeding character was a primary label, e.g. NHhAadb. It is false
922  * if the preceeding character was a modifier or if this is the first
923  * character. */
924 
925  for (i = 0; i < len; i++) {
926  // Check to see if the character is a primary label.
927  if (strchr("HhAadbOo", value[i])) {
928  havecharacter_state = true;
929  continue;
930  }
931 
932  /* If we've already passed a primary label, check to see if the character
933  * is a modifier. */
934  if (havecharacter_state && strchr("1234", value[i])) {
935  havecharacter_state = false;
936  continue;
937  }
938 
939  // Looks like the character was invalid.
940  settings_snprintf(reject_msg, reject_msg_len,
941  _("Allowed take string validation failed at "
942  "character: '%c'. Try \"/help allowtake\"."),
943  value[i]);
944  return false;
945  }
946 
947  // All characters were valid.
948  return true;
949 }
950 
955 static bool startunits_callback(const char *value, struct connection *caller,
956  char *reject_msg, size_t reject_msg_len)
957 {
958  int len = qstrlen(value), i;
959  Unit_Class_id first_role;
960  bool firstnative = false;
961 
962  // We check each character individually to see if it's valid.
963  for (i = 0; i < len; i++) {
964  if (strchr("cwxksfdDaA", value[i])) {
965  continue;
966  }
967 
968  // Looks like the character was invalid.
969  settings_snprintf(reject_msg, reject_msg_len,
970  _("Starting units string validation failed at "
971  "character '%c'. Try \"/help startunits\"."),
972  value[i]);
973  return false;
974  }
975 
976  // Check the first character to make sure it can use a startpos.
977  first_role = uclass_index(
979  terrain_type_iterate(pterrain)
980  {
981  if (terrain_has_flag(pterrain, TER_STARTER)
982  && BV_ISSET(pterrain->native_to, first_role)) {
983  firstnative = true;
984  break;
985  }
986  }
988 
989  if (!firstnative) {
990  // Loading would cause an infinite loop hunting for a valid startpos.
992  reject_msg, reject_msg_len,
993  _("The first starting unit must be native to at least one "
994  "\"Starter\" terrain. Try \"/help startunits\"."));
995  return false;
996  }
997 
998  // Everything seems fine.
999  return true;
1000 }
1001 
1005 static bool endturn_callback(int value, struct connection *caller,
1006  char *reject_msg, size_t reject_msg_len)
1007 {
1008  if (value < game.info.turn) {
1009  // Tried to set endturn earlier than current turn
1010  settings_snprintf(reject_msg, reject_msg_len,
1011  _("Cannot set endturn earlier than current turn."));
1012  return false;
1013  }
1014  return true;
1015 }
1016 
1020 static bool maxplayers_callback(int value, struct connection *caller,
1021  char *reject_msg, size_t reject_msg_len)
1022 {
1023  if (value < player_count()) {
1024  settings_snprintf(reject_msg, reject_msg_len,
1025  _("Number of players (%d) is higher than requested "
1026  "value (%d). Keeping old value."),
1027  player_count(), value);
1028  return false;
1029  }
1030  /* If any start positions are defined by a scenario, we can only
1031  * accommodate as many players as we have start positions. */
1032  if (0 < map_startpos_count() && value > map_startpos_count()) {
1034  reject_msg, reject_msg_len,
1035  _("Requested value (%d) is greater than number of available start "
1036  "positions (%d). Keeping old value."),
1037  value, map_startpos_count());
1038  return false;
1039  }
1040 
1041  return true;
1042 }
1043 
1047 static bool nationset_callback(const char *value, struct connection *caller,
1048  char *reject_msg, size_t reject_msg_len)
1049 {
1050  if (strlen(value) == 0) {
1051  return true;
1052  } else if (nation_set_by_rule_name(value)) {
1053  return true;
1054  } else {
1055  settings_snprintf(reject_msg, reject_msg_len,
1056  // TRANS: do not translate 'list nationsets'
1057  _("Unknown nation set \"%s\". See '%slist nationsets' "
1058  "for possible values."),
1059  value, caller ? "/" : "");
1060  return false;
1061  }
1062 }
1063 
1067 static bool timeout_callback(int value, struct connection *caller,
1068  char *reject_msg, size_t reject_msg_len)
1069 {
1070  // Disallow low timeout values for non-hack connections.
1071  if (caller && caller->access_level < ALLOW_HACK && value < 30
1072  && value != 0) {
1073  settings_snprintf(reject_msg, reject_msg_len,
1074  _("You are not allowed to set timeout values less "
1075  "than 30 seconds."));
1076  return false;
1077  }
1078 
1079  if (value == -1 && game.server.unitwaittime != 0) {
1080  // autogame only with 'unitwaittime' = 0
1081  settings_snprintf(reject_msg, reject_msg_len,
1082  // TRANS: Do not translate setting names in ''.
1083  _("For autogames ('timeout' = -1) 'unitwaittime' "
1084  "should be deactivated (= 0)."));
1085  return false;
1086  }
1087 
1088  if (value > 0 && value < game.server.unitwaittime * 3 / 2) {
1089  /* for normal games 'timeout' should be at least 3/2 times the value of
1090  * 'unitwaittime' */
1092  reject_msg, reject_msg_len,
1093  // TRANS: Do not translate setting names in ''.
1094  _("'timeout' can not be lower than 3/2 of the 'unitwaittime' "
1095  "setting (= %d). Please change 'unitwaittime' first."),
1096  game.server.unitwaittime);
1097  return false;
1098  }
1099 
1100  return true;
1101 }
1102 
1106 static bool first_timeout_callback(int value, struct connection *caller,
1107  char *reject_msg, size_t reject_msg_len)
1108 {
1109  // Disallow low timeout values for non-hack connections.
1110  if (caller && caller->access_level < ALLOW_HACK && value < 30
1111  && value != 0) {
1112  settings_snprintf(reject_msg, reject_msg_len,
1113  _("You are not allowed to set timeout values less "
1114  "than 30 seconds."));
1115  return false;
1116  }
1117 
1118  return true;
1119 }
1120 
1124 static bool unitwaittime_callback(int value, struct connection *caller,
1125  char *reject_msg, size_t reject_msg_len)
1126 {
1127  if (game.info.timeout == -1 && value != 0) {
1128  settings_snprintf(reject_msg, reject_msg_len,
1129  // TRANS: Do not translate setting names in ''.
1130  _("For autogames ('timeout' = -1) 'unitwaittime' "
1131  "should be deactivated (= 0)."));
1132  return false;
1133  }
1134 
1135  if (game.info.timeout > 0 && value > game.info.timeout * 2 / 3) {
1137  reject_msg, reject_msg_len,
1138  // TRANS: Do not translate setting names in ''.
1139  _("'unitwaittime' has to be lower than 2/3 of the 'timeout' setting "
1140  "(= %d). Please change 'timeout' first."),
1141  game.info.timeout);
1142  return false;
1143  }
1144 
1145  return true;
1146 }
1147 
1151 static bool mapsize_callback(int value, struct connection *caller,
1152  char *reject_msg, size_t reject_msg_len)
1153 {
1154  if (value == MAPSIZE_XYSIZE && MAP_IS_ISOMETRIC
1155  && wld.map.ysize % 2 != 0) {
1156  /* An isometric map needs a even ysize. It is calculated automatically
1157  * for all settings but mapsize=XYSIZE. */
1159  reject_msg, reject_msg_len,
1160  _("For an isometric or hexagonal map the ysize must be even."));
1161  return false;
1162  }
1163 
1164  return true;
1165 }
1166 
1170 static bool xsize_callback(int value, struct connection *caller,
1171  char *reject_msg, size_t reject_msg_len)
1172 {
1173  int size = value * wld.map.ysize;
1174 
1175  if (size < MAP_MIN_SIZE * 1000) {
1177  reject_msg, reject_msg_len,
1178  _("The map size (%d * %d = %d) must be larger than %d tiles."),
1179  value, wld.map.ysize, size, MAP_MIN_SIZE * 1000);
1180  return false;
1181  } else if (size > MAP_MAX_SIZE * 1000) {
1183  reject_msg, reject_msg_len,
1184  _("The map size (%d * %d = %d) must be lower than %d tiles."), value,
1185  wld.map.ysize, size, MAP_MAX_SIZE * 1000);
1186  return false;
1187  }
1188 
1189  return true;
1190 }
1191 
1195 static bool ysize_callback(int value, struct connection *caller,
1196  char *reject_msg, size_t reject_msg_len)
1197 {
1198  int size = wld.map.xsize * value;
1199 
1200  if (size < MAP_MIN_SIZE * 1000) {
1202  reject_msg, reject_msg_len,
1203  _("The map size (%d * %d = %d) must be larger than %d tiles."),
1204  wld.map.xsize, value, size, MAP_MIN_SIZE * 1000);
1205  return false;
1206  } else if (size > MAP_MAX_SIZE * 1000) {
1208  reject_msg, reject_msg_len,
1209  _("The map size (%d * %d = %d) must be lower than %d tiles."),
1210  wld.map.xsize, value, size, MAP_MAX_SIZE * 1000);
1211  return false;
1212  } else if (wld.map.server.mapsize == MAPSIZE_XYSIZE && MAP_IS_ISOMETRIC
1213  && value % 2 != 0) {
1214  /* An isometric map needs a even ysize. It is calculated automatically
1215  * for all settings but mapsize=XYSIZE. */
1217  reject_msg, reject_msg_len,
1218  _("For an isometric or hexagonal map the ysize must be even."));
1219  return false;
1220  }
1221 
1222  return true;
1223 }
1224 
1228 static bool topology_callback(unsigned value, struct connection *caller,
1229  char *reject_msg, size_t reject_msg_len)
1230 {
1231  if (wld.map.server.mapsize == MAPSIZE_XYSIZE
1232  && ((value & (TF_ISO)) != 0 || (value & (TF_HEX)) != 0)
1233  && wld.map.ysize % 2 != 0) {
1234  /* An isometric map needs a even ysize. It is calculated automatically
1235  * for all settings but mapsize=XYSIZE. */
1237  reject_msg, reject_msg_len,
1238  _("For an isometric or hexagonal map the ysize must be even."));
1239  return false;
1240  }
1241 
1242  return true;
1243 }
1244 
1248 static bool compresstype_callback(int value, struct connection *caller,
1249  char *reject_msg, size_t reject_msg_len)
1250 {
1251 #ifdef FREECIV_HAVE_BZ2
1252  if (value == COMPRESS_BZIP2) {
1253  qWarning(
1254  _("Bzip2 is deprecated as compresstype. Consider other options."));
1255  }
1256 #endif // FREECIV_HAVE_BZ2
1257 
1258  return true;
1259 }
1260 
1264 static bool plrcol_validate(int value, struct connection *caller,
1265  char *reject_msg, size_t reject_msg_len)
1266 {
1267  plrcolor_mode mode = plrcolor_mode(value);
1268  if (mode == PLRCOL_NATION_ORDER) {
1269  for (const auto &pnation : nations) {
1270  if (nation_color(&pnation)) {
1271  // At least one nation has a color. Allow this mode.
1272  return true;
1273  }
1274  }
1275  settings_snprintf(reject_msg, reject_msg_len,
1276  _("No nations in the currently loaded ruleset have "
1277  "associated colors."));
1278  return false;
1279  }
1280  return true;
1281 }
1282 
1283 #define GEN_BOOL(name, value, sclass, scateg, slevel, al_read, al_write, \
1284  short_help, extra_help, func_validate, func_action, \
1285  _default) \
1286  { \
1287  name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1288  SST_BOOL, scateg, slevel, \
1289  {.boolean = {&value, _default, func_validate, bool_name, false}}, \
1290  func_action, false \
1291  }
1292 
1293 #define GEN_INT(name, value, sclass, scateg, slevel, al_read, al_write, \
1294  short_help, extra_help, func_help, func_validate, \
1295  func_action, _min, _max, _default) \
1296  { \
1297  name, sclass, al_read, al_write, short_help, extra_help, func_help, \
1298  SST_INT, scateg, slevel, \
1299  {.integer = {(int *) &value, _default, _min, _max, func_validate, \
1300  0}}, \
1301  func_action, false \
1302  }
1303 
1304 #define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, \
1305  short_help, extra_help, func_validate, func_action, \
1306  _default) \
1307  { \
1308  name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1309  SST_STRING, scateg, slevel, \
1310  {.string = {value, _default, sizeof(value), func_validate, \
1311  (char *) ""}}, \
1312  func_action, false \
1313  }
1314 
1315 #define GEN_ENUM(name, value, sclass, scateg, slevel, al_read, al_write, \
1316  short_help, extra_help, func_help, func_validate, \
1317  func_action, func_name, _default) \
1318  { \
1319  name, sclass, al_read, al_write, short_help, extra_help, func_help, \
1320  SST_ENUM, scateg, slevel, \
1321  {.enumerator = {&value, sizeof(value), _default, func_validate, \
1322  (val_name_func_t) func_name, 0}}, \
1323  func_action, false \
1324  }
1325 
1326 #define GEN_BITWISE(name, value, sclass, scateg, slevel, al_read, al_write, \
1327  short_help, extra_help, func_validate, func_action, \
1328  func_name, _default) \
1329  { \
1330  name, sclass, al_read, al_write, short_help, extra_help, nullptr, \
1331  SST_BITWISE, scateg, slevel, \
1332  {.bitwise = {(unsigned *) (void *) &value, _default, func_validate, \
1333  func_name, 0}}, \
1334  func_action, false \
1335  }
1336 
1337 // game settings
1338 static struct setting settings[] = {
1339  // These should be grouped by sclass
1340 
1341  // Map size parameters: adjustable if we don't yet have a map
1342  GEN_ENUM(
1343  "mapsize", wld.map.server.mapsize, SSET_MAP_SIZE, SSET_GEOLOGY,
1344  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("Map size definition"),
1345  /* TRANS: The strings between double quotes are also translated
1346  separately (they must match!). The strings between single quotes
1347  are setting names and shouldn't be translated. The strings between
1348  parentheses and in uppercase must stay as untranslated. */
1349  N_("Chooses the method used to define the map size. Other options "
1350  "specify the parameters for each method.\n"
1351  "- \"Number of tiles\" (FULLSIZE): Map area (option 'size').\n"
1352  "- \"Tiles per player\" (PLAYER): Number of (land) tiles per "
1353  "player (option 'tilesperplayer').\n"
1354  "- \"Width and height\" (XYSIZE): Map width and height in tiles "
1355  "(options 'xsize' and 'ysize')."),
1356  nullptr, mapsize_callback, nullptr, mapsize_name,
1358 
1359  GEN_INT(
1360  "size", wld.map.server.size, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_VITAL,
1361  ALLOW_NONE, ALLOW_BASIC, N_("Map area (in thousands of tiles)"),
1362  /* TRANS: The strings between double quotes are also translated
1363  separately (they must match!). The strings between single quotes
1364  are setting names and shouldn't be translated. The strings between
1365  parentheses and in uppercase must stay as untranslated. */
1366  N_("This value is used to determine the map area.\n"
1367  " size = 4 is a normal map of 4,000 tiles (default)\n"
1368  " size = 20 is a huge map of 20,000 tiles\n"
1369  "For this option to take effect, the \"Map size definition\" "
1370  "option ('mapsize') must be set to \"Number of tiles\" "
1371  "(FULLSIZE)."),
1372  nullptr, nullptr, nullptr, MAP_MIN_SIZE, MAP_MAX_SIZE,
1374 
1375  GEN_INT(
1376  "tilesperplayer", wld.map.server.tilesperplayer, SSET_MAP_SIZE,
1377  SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1378  N_("Number of (land) tiles per player"),
1379  /* TRANS: The strings between double quotes are also translated
1380  separately (they must match!). The strings between single quotes
1381  are setting names and shouldn't be translated. The strings between
1382  parentheses and in uppercase must stay as untranslated. */
1383  N_("This value is used to determine the map dimensions. It "
1384  "calculates the map size at game start based on the number of "
1385  "players and the value of the setting 'landmass'.\n"
1386  "For this option to take effect, the \"Map size definition\" "
1387  "option ('mapsize') must be set to \"Tiles per player\" "
1388  "(PLAYER)."),
1389  nullptr, nullptr, nullptr, MAP_MIN_TILESPERPLAYER,
1391 
1392  GEN_INT(
1393  "xsize", wld.map.xsize, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_VITAL,
1394  ALLOW_NONE, ALLOW_BASIC, N_("Map width in tiles"),
1395  /* TRANS: The strings between double quotes are also translated
1396  separately (they must match!). The strings between single quotes
1397  are setting names and shouldn't be translated. The strings between
1398  parentheses and in uppercase must stay as untranslated. */
1399  N_("Defines the map width.\n"
1400  "For this option to take effect, the \"Map size definition\" "
1401  "option ('mapsize') must be set to \"Width and height\" "
1402  "(XYSIZE)."),
1403  nullptr, xsize_callback, nullptr, MAP_MIN_LINEAR_SIZE,
1405  GEN_INT(
1406  "ysize", wld.map.ysize, SSET_MAP_SIZE, SSET_GEOLOGY, SSET_VITAL,
1407  ALLOW_NONE, ALLOW_BASIC, N_("Map height in tiles"),
1408  /* TRANS: The strings between double quotes are also translated
1409  separately (they must match!). The strings between single quotes
1410  are setting names and shouldn't be translated. The strings between
1411  parentheses and in uppercase must stay as untranslated. */
1412  N_("Defines the map height.\n"
1413  "For this option to take effect, the \"Map size definition\" "
1414  "option ('mapsize') must be set to \"Width and height\" "
1415  "(XYSIZE)."),
1416  nullptr, ysize_callback, nullptr, MAP_MIN_LINEAR_SIZE,
1418 
1419  GEN_BITWISE(
1420  "topology", wld.map.topology_id, SSET_MAP_SIZE, SSET_GEOLOGY,
1421  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("Map topology"),
1422  // TRANS: do not edit the ugly ASCII art
1423  N_("Freeciv21 maps are always two-dimensional. They may wrap at the "
1424  "north-south and east-west directions to form a flat map, a "
1425  "cylinder, or a torus (donut). Individual tiles may be "
1426  "rectangular or hexagonal, with either an overhead (\"classic\") "
1427  "or isometric alignment.\n"
1428  "To play with a particular topology, clients will need a "
1429  "matching tileset.\n"
1430  "Overhead rectangular: Isometric rectangular:\n"
1431  " _________ /\\/\\/\\/\\/\\\n"
1432  " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1433  " |_|_|_|_|_| \\/\\/\\/\\/\\/\\\n"
1434  " |_|_|_|_|_| /\\/\\/\\/\\/\\/\n"
1435  " \\/\\/\\/\\/\\/\n"
1436  "Hex: Iso-hex:\n"
1437  " /\\/\\/\\/\\/\\/\\ _ _ _ _ _\n"
1438  " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1439  " \\/\\/\\/\\/\\/\\/\\"
1440  " \\_/ \\_/ \\_/ \\_/ \\_/\n"
1441  " | | | | | | | / \\_/ \\_/ \\_/ \\_/ \\\n"
1442  " \\/\\/\\/\\/\\/\\/ \\_/ \\_/ \\_/ \\_/ \\_/\n"),
1444 
1445  GEN_ENUM(
1446  "generator", wld.map.server.generator, SSET_MAP_GEN, SSET_GEOLOGY,
1447  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1448  N_("Method used to generate map"),
1449  /* TRANS: The strings between double quotes are also translated
1450  separately (they must match!). The strings between single
1451  quotes (except 'fair') are setting names and shouldn't be
1452  translated. The strings between parentheses and in uppercase
1453  must stay as untranslated. */
1454  N_("Specifies the algorithm used to generate the map. If the "
1455  "default value of the 'startpos' option is used, then the chosen "
1456  "generator chooses an appropriate 'startpos' setting; otherwise, "
1457  "the generated map tries to accommodate the chosen 'startpos' "
1458  "setting.\n"
1459  "- \"Scenario map\" (SCENARIO): indicates a pre-generated map. "
1460  "By default, if the scenario does not specify start positions, "
1461  "they will be allocated depending on the size of continents.\n"
1462  "- \"Fully random height\" (RANDOM): generates maps with a "
1463  "number of equally spaced, relatively small islands. By default, "
1464  "start positions are allocated depending on continent size.\n"
1465  "- \"Pseudo-fractal height\" (FRACTAL): generates Earthlike "
1466  "worlds with one or more large continents and a scattering of "
1467  "smaller islands. By default, players are all placed on a single "
1468  "continent.\n"
1469  "- \"Island-based\" (ISLAND): generates 'fair' maps with a "
1470  "number of similarly-sized and -shaped islands, each with "
1471  "approximately the same ratios of terrain types. By default, "
1472  "each player gets their own island.\n"
1473  "- \"Fair islands\" (FAIR): generates the exact copy of the same "
1474  "island for every player or every team.\n"
1475  "- \"Fracture map\" (FRACTURE): generates maps from a fracture "
1476  "pattern. Tends to place hills and mountains along the edges of "
1477  "the continents.\n"
1478  "If the requested generator is incompatible with other server "
1479  "settings, the server may fall back to another generator."),
1480  nullptr, generator_validate, nullptr, generator_name,
1482 
1483  GEN_ENUM(
1484  "startpos", wld.map.server.startpos, SSET_MAP_GEN, SSET_GEOLOGY,
1485  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1486  N_("Method used to choose start positions"),
1487  /* TRANS: The strings between double quotes are also translated
1488  separately (they must match!). The strings between single
1489  quotes (except 'best') are setting names and shouldn't be
1490  translated. The strings between parentheses and in uppercase
1491  must stay as untranslated. */
1492  N_("The method used to choose where each player's initial units "
1493  "start on the map. (For scenarios which include pre-set start "
1494  "positions, this setting is ignored.)\n"
1495  "- \"Generator's choice\" (DEFAULT): the start position "
1496  "placement will depend on the map generator chosen. See the "
1497  "'generator' setting.\n"
1498  "- \"One player per continent\" (SINGLE): one player is placed "
1499  "on each of a set of continents of approximately equivalent "
1500  "value (if possible).\n"
1501  "- \"Two or three players per continent\" (2or3): similar to "
1502  "SINGLE except that two players will be placed on each "
1503  "continent, with three on the 'best' continent if there is an "
1504  "odd number of players.\n"
1505  "- \"All players on a single continent\" (ALL): all players will "
1506  "start on the 'best' available continent.\n"
1507  "- \"Depending on size of continents\" (VARIABLE): players will "
1508  "be placed on the 'best' available continents such that, as far "
1509  "as possible, the number of players on each continent is "
1510  "proportional to its value.\n"
1511  "If the server cannot satisfy the requested setting due to there "
1512  "being too many players for continents, it may fall back to one "
1513  "of the others. (However, map generators try to create the right "
1514  "number of continents for the choice of this 'startpos' setting "
1515  "and the number of players, so this is unlikely to occur.)"),
1516  nullptr, nullptr, nullptr, startpos_name, MAP_DEFAULT_STARTPOS),
1517 
1518  GEN_ENUM(
1519  "teamplacement", wld.map.server.team_placement, SSET_MAP_GEN,
1520  SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1521  N_("Method used for placement of team mates"),
1522  /* TRANS: The strings between double quotes are also translated
1523  separately (they must match!). The strings between single quotes
1524  are setting names and shouldn't be translated. The strings between
1525  parentheses and in uppercase must stay as untranslated. */
1526  N_("After start positions have been generated thanks to the "
1527  "'startpos' setting, this setting controls how the start "
1528  "positions will be assigned to the different players of the same "
1529  "team.\n"
1530  "- \"Disabled\" (DISABLED): the start positions will be randomly "
1531  "assigned to players, regardless of teams.\n"
1532  "- \"As close as possible\" (CLOSEST): players will be placed as "
1533  "close as possible, regardless of continents.\n"
1534  "- \"On the same continent\" (CONTINENT): if possible, place all "
1535  "players of the same team onto the same island/continent.\n"
1536  "- \"Horizontal placement\" (HORIZONTAL): players of the same "
1537  "team will be placed horizontally.\n"
1538  "- \"Vertical placement\" (VERTICAL): players of the same team "
1539  "will be placed vertically."),
1540  nullptr, nullptr, nullptr, teamplacement_name,
1542 
1543  GEN_BOOL("tinyisles", wld.map.server.tinyisles, SSET_MAP_GEN,
1544  SSET_GEOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1545  N_("Presence of 1x1 islands"),
1546  N_("This setting controls whether the map generator is allowed "
1547  "to make islands of one only tile size."),
1548  nullptr, nullptr, MAP_DEFAULT_TINYISLES),
1549 
1550  GEN_BOOL("separatepoles", wld.map.server.separatepoles, SSET_MAP_GEN,
1551  SSET_GEOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1552  N_("Whether the poles are separate continents"),
1553  N_("If this setting is disabled, the continents may attach to "
1554  "poles."),
1555  nullptr, nullptr, MAP_DEFAULT_SEPARATE_POLES),
1556 
1557  GEN_INT(
1558  "flatpoles", wld.map.server.flatpoles, SSET_MAP_GEN, SSET_GEOLOGY,
1559  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1560  N_("How much the land at the poles is flattened"),
1561  /* TRANS: The strings in
1562  quotes shouldn't be
1563  translated. */
1564  N_("Controls how much the height of the poles is flattened during "
1565  "map generation, preventing a diversity of land terrain there. 0 "
1566  "is no flattening, 100 is maximum flattening. Only affects the "
1567  "'RANDOM' and 'FRACTAL' map generators."),
1568  nullptr, nullptr, nullptr, MAP_MIN_FLATPOLES, MAP_MAX_FLATPOLES,
1570 
1571  GEN_BOOL("singlepole", wld.map.server.single_pole, SSET_MAP_GEN,
1572  SSET_GEOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1573  N_("Whether there's just one pole generated"),
1574  N_("If this setting is enabled, only one side of the map will "
1575  "have a pole. This setting has no effect if the map wraps "
1576  "both directions."),
1577  nullptr, nullptr, MAP_DEFAULT_SINGLE_POLE),
1578 
1579  GEN_BOOL("alltemperate", wld.map.server.alltemperate, SSET_MAP_GEN,
1580  SSET_GEOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1581  N_("All the map is temperate"),
1582  N_("If this setting is enabled, the temperature will be "
1583  "equivalent everywhere on the map. As a result, the poles "
1584  "won't be generated."),
1585  nullptr, nullptr, MAP_DEFAULT_ALLTEMPERATE),
1586 
1587  GEN_INT("temperature", wld.map.server.temperature, SSET_MAP_GEN,
1588  SSET_GEOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1589  N_("Average temperature of the planet"),
1590  N_("Small values will give a cold map, while larger values will "
1591  "give a hotter map.\n"
1592  "\n"
1593  "100 means a very dry and hot planet with no polar arctic "
1594  "zones, only tropical and dry zones.\n"
1595  " 70 means a hot planet with little polar ice.\n"
1596  " 50 means a temperate planet with normal polar, cold, "
1597  "temperate, and tropical zones; a desert zone overlaps "
1598  "tropical and temperate zones.\n"
1599  " 30 means a cold planet with small tropical zones.\n"
1600  " 0 means a very cold planet with large polar zones and no "
1601  "tropics."),
1602  nullptr, nullptr, nullptr, MAP_MIN_TEMPERATURE,
1604 
1605  GEN_INT("landmass", wld.map.server.landpercent, SSET_MAP_GEN,
1606  SSET_GEOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1607  N_("Percentage of the map that is land"),
1608  N_("This setting gives the approximate percentage of the map "
1609  "that will be made into land."),
1610  nullptr, nullptr, nullptr, MAP_MIN_LANDMASS, MAP_MAX_LANDMASS,
1612 
1613  GEN_INT("steepness", wld.map.server.steepness, SSET_MAP_GEN,
1614  SSET_GEOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1615  N_("Amount of hills/mountains"),
1616  N_("Small values give flat maps, while higher values give a "
1617  "steeper map with more hills and mountains."),
1618  nullptr, nullptr, nullptr, MAP_MIN_STEEPNESS, MAP_MAX_STEEPNESS,
1620 
1621  GEN_INT(
1622  "wetness", wld.map.server.wetness, SSET_MAP_GEN, SSET_GEOLOGY,
1623  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1624  N_("Amount of water on landmasses"),
1625  N_("Small values mean lots of dry, desert-like land; higher values "
1626  "give a wetter map with more swamps, jungles, and rivers."),
1627  nullptr, nullptr, nullptr, MAP_MIN_WETNESS, MAP_MAX_WETNESS,
1629 
1630  GEN_BOOL("globalwarming", game.info.global_warming, SSET_RULES,
1631  SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1632  N_("Global warming"),
1633  N_("If turned off, global warming will not occur as a result "
1634  "of pollution. This setting does not affect pollution."),
1635  nullptr, nullptr, GAME_DEFAULT_GLOBAL_WARMING),
1636 
1637  GEN_INT("globalwarming_percent", game.server.global_warming_percent,
1638  SSET_RULES, SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1639  N_("Global warming percent"),
1640  N_("This is a multiplier for the rate of accumulation of global "
1641  "warming."),
1642  nullptr, nullptr, nullptr, GAME_MIN_GLOBAL_WARMING_PERCENT,
1645 
1646  GEN_BOOL("nuclearwinter", game.info.nuclear_winter, SSET_RULES,
1647  SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1648  N_("Nuclear winter"),
1649  N_("If turned off, nuclear winter will not occur as a result "
1650  "of nuclear war."),
1651  nullptr, nullptr, GAME_DEFAULT_NUCLEAR_WINTER),
1652 
1653  GEN_INT("nuclearwinter_percent", game.server.nuclear_winter_percent,
1654  SSET_RULES, SSET_GEOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1655  N_("Nuclear winter percent"),
1656  N_("This is a multiplier for the rate of accumulation of "
1657  "nuclear winter."),
1658  nullptr, nullptr, nullptr, GAME_MIN_NUCLEAR_WINTER_PERCENT,
1661 
1662  GEN_INT("mapseed", wld.map.server.seed_setting, SSET_MAP_GEN,
1663  SSET_INTERNAL, SSET_RARE, ALLOW_HACK, ALLOW_HACK,
1664  N_("Map generation random seed"),
1665  N_("The same seed will always produce the same map; for zero "
1666  "(the default) a seed will be chosen based on the time to "
1667  "give a random map."),
1668  nullptr, nullptr, nullptr, MAP_MIN_SEED, MAP_MAX_SEED,
1670 
1671  /* Map additional stuff: huts and specials. gameseed also goes here
1672  * because huts and specials are the first time the gameseed gets used
1673  * (?) These are done when the game starts, so these are historical and
1674  * fixed after the game has started.
1675  */
1676  GEN_INT("gameseed", game.server.seed_setting, SSET_MAP_ADD,
1677  SSET_INTERNAL, SSET_RARE, ALLOW_HACK, ALLOW_HACK,
1678  N_("Game random seed"),
1679  N_("For zero (the default) a seed will be chosen based on the "
1680  "current time."),
1681  nullptr, nullptr, nullptr, GAME_MIN_SEED, GAME_MAX_SEED,
1683 
1684  GEN_INT("specials", wld.map.server.riches, SSET_MAP_ADD, SSET_GEOLOGY,
1685  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1686  N_("Amount of \"special\" resource tiles"),
1687  N_("Special resources improve the basic terrain type they are "
1688  "on. The server variable's scale is parts per thousand."),
1689  nullptr, nullptr, nullptr, MAP_MIN_RICHES, MAP_MAX_RICHES,
1691 
1692  GEN_INT(
1693  "huts", wld.map.server.huts, SSET_MAP_ADD, SSET_GEOLOGY, SSET_VITAL,
1694  ALLOW_NONE, ALLOW_BASIC, N_("Amount of huts (bonus extras)"),
1695  N_("Huts are tile extras that usually may be investigated by "
1696  "units.The server variable's scale is huts per thousand tiles."),
1699 
1700  GEN_INT("animals", wld.map.server.animals, SSET_MAP_ADD, SSET_GEOLOGY,
1701  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("Amount of animals"),
1702  N_("Number of animals initially created on terrains defined for "
1703  "them in the ruleset (if the ruleset supports it). The "
1704  "server variable's scale is animals per thousand tiles."),
1705  nullptr, nullptr, nullptr, MAP_MIN_ANIMALS, MAP_MAX_ANIMALS,
1707 
1708  /* Options affecting numbers of players and AI players. These only
1709  * affect the start of the game and can not be adjusted after that.
1710  */
1711  GEN_INT("minplayers", game.server.min_players, SSET_PLAYERS,
1712  SSET_INTERNAL, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1713  N_("Minimum number of players"),
1714  N_("There must be at least this many players (connected human "
1715  "players) before the game can start."),
1716  nullptr, nullptr, nullptr, GAME_MIN_MIN_PLAYERS,
1718 
1719  GEN_INT(
1720  "maxplayers", game.server.max_players, SSET_PLAYERS, SSET_INTERNAL,
1721  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("Maximum number of players"),
1722  N_("The maximal number of human and AI players who can be in the "
1723  "game. When this number of players are connected in the pregame "
1724  "state, any new players who try to connect will be rejected.\n"
1725  "When playing a scenario which defines player start positions, "
1726  "this setting cannot be set to greater than the number of "
1727  "defined start positions."),
1728  nullptr, maxplayers_callback, nullptr, GAME_MIN_MAX_PLAYERS,
1730 
1731  GEN_INT("aifill", game.info.aifill, SSET_PLAYERS, SSET_INTERNAL,
1732  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1733  N_("Limited number of AI players"),
1734  N_("If set to a positive value, then AI players will be "
1735  "automatically created or removed to keep the total number "
1736  "of players at this amount. As more players join, these AI "
1737  "players will be replaced. When set to zero, all AI players "
1738  "will be removed."),
1739  nullptr, nullptr, aifill_action, GAME_MIN_AIFILL,
1741 
1742  GEN_ENUM(
1743  "persistentready", game.info.persistent_ready, SSET_META,
1744  SSET_NETWORK, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1745  N_("When the Readiness of a player gets autotoggled off"),
1746  N_("In pre-game, usually when new players join or old ones leave, "
1747  "those who have already accepted game to start by toggling "
1748  "\"Ready\" get that autotoggled off in the changed situation. "
1749  "This setting can be used to make readiness more persistent."),
1750  nullptr, nullptr, nullptr, persistentready_name,
1752 
1753  GEN_STRING(
1754  "nationset", game.server.nationset, SSET_PLAYERS, SSET_INTERNAL,
1755  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1756  N_("Set of nations to choose from"),
1757  /* TRANS: do not translate '/list nationsets' */
1758  N_("Controls the set of nations allowed in the game. The choices "
1759  "are defined by the ruleset.\n"
1760  "Only nations in the set selected here will be allowed in any "
1761  "circumstances, including new players and civil war; small sets "
1762  "may thus limit the number of players in a game.\n"
1763  "If this is left blank, the ruleset's default nation set is "
1764  "used.\n"
1765  "See '/list nationsets' for possible choices for the currently "
1766  "loaded ruleset."),
1768 
1769  GEN_INT("ec_turns", game.server.event_cache.turns, SSET_META,
1770  SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1771  N_("Event cache for this number of turns"),
1772  N_("Event messages are saved for this number of turns. A value "
1773  "of 0 deactivates the event cache."),
1774  nullptr, nullptr, nullptr, GAME_MIN_EVENT_CACHE_TURNS,
1776 
1777  GEN_INT(
1778  "ec_max_size", game.server.event_cache.max_size, SSET_META,
1779  SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1780  N_("Size of the event cache"),
1781  N_("This defines the maximal number of events in the event cache."),
1782  nullptr, nullptr, nullptr, GAME_MIN_EVENT_CACHE_MAX_SIZE,
1784 
1785  GEN_BOOL(
1786  "ec_chat", game.server.event_cache.chat, SSET_META, SSET_INTERNAL,
1787  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1788  N_("Save chat messages in the event cache"),
1789  N_("If turned on, chat messages will be saved in the event cache."),
1790  nullptr, nullptr, GAME_DEFAULT_EVENT_CACHE_CHAT),
1791 
1792  GEN_BOOL("ec_info", game.server.event_cache.info, SSET_META,
1793  SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1794  N_("Print turn and time for each cached event"),
1795  /* TRANS: Don't translate the text
1796  between single quotes. */
1797  N_("If turned on, all cached events will be marked by the turn "
1798  "and time of the event like '(T2 - 15:29:52)'."),
1799  nullptr, nullptr, GAME_DEFAULT_EVENT_CACHE_INFO),
1800 
1801  /* Game initialization parameters (only affect the first start of the
1802  * game, and not reloads). Can not be changed after first start of game.
1803  */
1804  GEN_STRING(
1805  "startunits", game.server.start_units, SSET_GAME_INIT,
1806  SSET_SOCIOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1807  N_("List of players' initial units"),
1808  N_("This should be a string of characters, each of which specifies "
1809  "a unit role. The first character must be native to at least one "
1810  "\"Starter\" terrain. The characters and their meanings are:\n"
1811  " c = City founder (eg., Settlers)\n"
1812  " w = Terrain worker (eg., Engineers)\n"
1813  " x = Explorer (eg., Explorer)\n"
1814  " k = Gameloss (eg., King)\n"
1815  " s = Diplomat (eg., Diplomat)\n"
1816  " f = Ferryboat (eg., Trireme)\n"
1817  " d = Ok defense unit (eg., Warriors)\n"
1818  " D = Good defense unit (eg., Phalanx)\n"
1819  " a = Fast attack unit (eg., Horsemen)\n"
1820  " A = Strong attack unit (eg., Catapult)\n"),
1822 
1823  GEN_BOOL("startcity", game.server.start_city, SSET_GAME_INIT,
1824  SSET_SOCIOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1825  N_("Whether player starts with a city"),
1826  N_("If this is set, game will start with player's first city "
1827  "already founded to starting location."),
1828  nullptr, nullptr, GAME_DEFAULT_START_CITY),
1829 
1830  GEN_INT("dispersion", game.server.dispersion, SSET_GAME_INIT,
1831  SSET_SOCIOLOGY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1832  N_("Area where initial units are located"),
1833  N_("This is the radius within which the initial units are "
1834  "dispersed."),
1835  nullptr, nullptr, nullptr, GAME_MIN_DISPERSION,
1837 
1838  GEN_INT(
1839  "gold", game.info.gold, SSET_GAME_INIT, SSET_ECONOMICS, SSET_VITAL,
1840  ALLOW_NONE, ALLOW_BASIC, N_("Starting gold per player"),
1841  N_("At the beginning of the game, each player is given this much "
1842  "gold."),
1843  nullptr, nullptr, nullptr, GAME_MIN_GOLD, GAME_MAX_GOLD,
1845 
1846  GEN_INT("techlevel", game.info.tech, SSET_GAME_INIT, SSET_SCIENCE,
1847  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1848  N_("Number of initial techs per player"),
1849  /* TRANS: The string between single quotes is a setting name and
1850  should not be translated. */
1851  N_("At the beginning of the game, each player is given this "
1852  "many technologies. The technologies chosen are random for "
1853  "each player. Depending on the value of tech_cost_style in "
1854  "the ruleset, a big value for 'techlevel' can make the next "
1855  "techs really expensive."),
1856  nullptr, nullptr, nullptr, GAME_MIN_TECHLEVEL,
1858 
1859  GEN_INT("sciencebox", game.info.sciencebox, SSET_RULES_SCENARIO,
1860  SSET_SCIENCE, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
1861  N_("Technology cost multiplier percentage"),
1862  N_("This affects how quickly players can research new "
1863  "technology. All tech costs are multiplied by this amount "
1864  "(as a percentage). The base tech costs are determined by "
1865  "the ruleset or other game settings."),
1866  nullptr, nullptr, nullptr, GAME_MIN_SCIENCEBOX,
1868 
1869  GEN_BOOL(
1870  "multiresearch", game.server.multiresearch, SSET_RULES, SSET_SCIENCE,
1871  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1872  N_("Allow researching multiple technologies"),
1873  N_("Allows switching to any technology without wasting old "
1874  "research. Bulbs are never transfered to new technology. "
1875  "Techpenalty options are inefective after enabling that option."),
1876  nullptr, nullptr, GAME_DEFAULT_MULTIRESEARCH),
1877 
1878  GEN_INT("techpenalty", game.server.techpenalty, SSET_RULES, SSET_SCIENCE,
1879  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1880  N_("Percentage penalty when changing tech"),
1881  N_("If you change your current research technology, and you "
1882  "have positive research points, you lose this percentage of "
1883  "those research points. This does not apply when you have "
1884  "just gained a technology this turn."),
1885  nullptr, nullptr, nullptr, GAME_MIN_TECHPENALTY,
1887 
1888  GEN_INT("techlost_recv", game.server.techlost_recv, SSET_RULES,
1889  SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1890  N_("Chance to lose a technology while receiving it"),
1891  N_("The chance that learning a technology by treaty or theft "
1892  "will fail."),
1893  nullptr, nullptr, nullptr, GAME_MIN_TECHLOST_RECV,
1895 
1896  GEN_INT("techlost_donor", game.server.techlost_donor, SSET_RULES,
1897  SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1898  N_("Chance to lose a technology while giving it"),
1899  N_("The chance that your civilization will lose a technology if "
1900  "you teach it to someone else by treaty, or if it is stolen "
1901  "from you."),
1902  nullptr, nullptr, nullptr, GAME_MIN_TECHLOST_DONOR,
1904 
1905  GEN_INT("techleak", game.info.tech_leak_pct, SSET_RULES, SSET_SCIENCE,
1906  SSET_RARE, ALLOW_NONE, ALLOW_BASIC, N_("Tech leakage percent"),
1907  N_("The rate of the tech leakage."), nullptr, nullptr, nullptr,
1909 
1910  GEN_BOOL("team_pooled_research", game.info.team_pooled_research,
1911  SSET_RULES, SSET_SCIENCE, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
1912  N_("Team pooled research"),
1913  N_("If this setting is turned on, then the team mates will "
1914  "share the science research. Else, every player of the team "
1915  "will have to make its own."),
1916  nullptr, nullptr, GAME_DEFAULT_TEAM_POOLED_RESEARCH),
1917 
1918  GEN_INT("diplbulbcost", game.server.diplbulbcost, SSET_RULES,
1919  SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1920  N_("Penalty when getting tech from treaty"),
1921  N_("For each technology you gain from a diplomatic treaty, you "
1922  "lose research points equal to this percentage of the cost "
1923  "to research a new technology. If this is non-zero, you can "
1924  "end up with negative research points."),
1925  nullptr, nullptr, nullptr, GAME_MIN_DIPLBULBCOST,
1927 
1928  GEN_INT("diplgoldcost", game.server.diplgoldcost, SSET_RULES,
1929  SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1930  N_("Penalty when getting gold from treaty"),
1931  N_("When transferring gold in diplomatic treaties, this "
1932  "percentage of the agreed sum is lost to both parties; it is "
1933  "deducted from the donor but not received by the recipient."),
1934  nullptr, nullptr, nullptr, GAME_MIN_DIPLGOLDCOST,
1936 
1937  GEN_INT("incite_gold_loss_chance", game.server.incite_gold_loss_chance,
1938  SSET_RULES, SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1939  N_("Probability of gold loss during inciting revolt"),
1940  N_("When unit trying to incite revolt is eliminated, half of "
1941  "the gold (or quarter, if unit was caught), prepared to "
1942  "bribe citizens, can be lost or captured by enemy."),
1943  nullptr, nullptr, nullptr, GAME_MIN_INCITE_GOLD_LOSS_CHANCE,
1946 
1947  GEN_INT(
1948  "incite_gold_capt_chance", game.server.incite_gold_capt_chance,
1949  SSET_RULES, SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1950  N_("Probability of gold capture during inciting revolt"),
1951  N_("When unit trying to incite revolt is eliminated and lose its "
1952  "gold, there is chance that this gold would be captured by city "
1953  "defender. Transfer tax would be applied, though. This setting "
1954  "is irrevelant, if incite_gold_loss_chance is zero."),
1955  nullptr, nullptr, nullptr, GAME_MIN_INCITE_GOLD_CAPT_CHANCE,
1958 
1959  GEN_INT("conquercost", game.server.conquercost, SSET_RULES, SSET_SCIENCE,
1960  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1961  N_("Penalty when getting tech from conquering"),
1962  N_("For each technology you gain by conquering an enemy city, "
1963  "you lose research points equal to this percentage of the "
1964  "cost to research a new technology. If this is non-zero, you "
1965  "can end up with negative research points."),
1966  nullptr, nullptr, nullptr, GAME_MIN_CONQUERCOST,
1968 
1969  GEN_INT(
1970  "freecost", game.server.freecost, SSET_RULES, SSET_SCIENCE,
1971  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1972  N_("Penalty when getting a free tech"),
1973  /* TRANS: The strings between single quotes are setting names and
1974  shouldn't be translated. */
1975  N_("For each technology you gain \"for free\" (other than covered "
1976  "by 'diplcost' or 'conquercost': for instance, from huts or from "
1977  "Great Library effects), you lose research points equal to this "
1978  "percentage of the cost to research a new technology. If this is "
1979  "non-zero, you can end up with negative research points."),
1980  nullptr, nullptr, nullptr, GAME_MIN_FREECOST, GAME_MAX_FREECOST,
1982 
1983  GEN_INT("techlossforgiveness", game.info.techloss_forgiveness,
1984  SSET_RULES, SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1985  N_("Research point debt threshold for losing tech"),
1986  N_("When you have negative research points, and your shortfall "
1987  "is greater than this percentage of the cost of your current "
1988  "research, you forget a technology you already knew.\n"
1989  "The special value -1 prevents loss of technology regardless "
1990  "of research points."),
1991  nullptr, nullptr, nullptr, GAME_MIN_TECHLOSSFG,
1993 
1994  GEN_INT(
1995  "techlossrestore", game.server.techloss_restore, SSET_RULES,
1996  SSET_SCIENCE, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
1997  N_("Research points restored after losing a tech"),
1998  N_("When you lose a technology due to a negative research balance "
1999  "(see 'techlossforgiveness'), this percentage of its research "
2000  "cost is credited to your research balance (this may not be "
2001  "sufficient to make it positive).\n"
2002  "The special value -1 means that your research balance is always "
2003  "restored to zero, regardless of your previous shortfall."),
2004  nullptr, nullptr, nullptr, GAME_MIN_TECHLOSSREST,
2006 
2007  GEN_INT("foodbox", game.info.foodbox, SSET_RULES, SSET_ECONOMICS,
2008  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2009  N_("Food required for a city to grow"),
2010  N_("This is the base amount of food required to grow a city. "
2011  "This value is multiplied by another factor that comes from "
2012  "the ruleset and is dependent on the size of the city."),
2013  nullptr, nullptr, nullptr, GAME_MIN_FOODBOX, GAME_MAX_FOODBOX,
2015 
2016  GEN_INT("aqueductloss", game.server.aqueductloss, SSET_RULES,
2017  SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2018  N_("Percentage food lost when city can't grow"),
2019  N_("If a city would expand, but it can't because it lacks some "
2020  "prerequisite (traditionally an Aqueduct or Sewer System), "
2021  "this is the base percentage of its foodbox that is lost "
2022  "each turn; the penalty may be reduced by buildings or other "
2023  "circumstances, depending on the ruleset."),
2024  nullptr, nullptr, nullptr, GAME_MIN_AQUEDUCTLOSS,
2026 
2027  GEN_INT(
2028  "shieldbox", game.info.shieldbox, SSET_RULES, SSET_ECONOMICS,
2029  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2030  N_("Multiplier percentage for production costs"),
2031  N_("This affects how quickly units and buildings can be produced. "
2032  "The base costs are multiplied by this value (as a percentage)."),
2033  nullptr, nullptr, nullptr, GAME_MIN_SHIELDBOX, GAME_MAX_SHIELDBOX,
2035 
2036  /* Notradesize and fulltradesize used to have callbacks to prevent them
2037  from being set illegally (notradesize > fulltradesize). However this
2038  provided a problem when setting them both through the client's
2039  settings dialog, since they cannot both be set atomically. So the
2040  callbacks were removed and instead the game now knows how to deal with
2041  invalid settings. */
2042  GEN_INT("fulltradesize", game.info.fulltradesize, SSET_RULES,
2043  SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2044  N_("Minimum city size to get full trade"),
2045  /* TRANS: The strings between single quotes are setting names and
2046  shouldn't be translated. */
2047  N_("There is a trade penalty in all cities smaller than this. "
2048  "The penalty is 100% (no trade at all) for sizes up to "
2049  "'notradesize', and decreases gradually to 0% (no penalty "
2050  "except the normal corruption) for size='fulltradesize'. See "
2051  "also 'notradesize'."),
2052  nullptr, nullptr, nullptr, GAME_MIN_FULLTRADESIZE,
2054 
2055  GEN_INT("notradesize", game.info.notradesize, SSET_RULES, SSET_ECONOMICS,
2056  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2057  N_("Maximum size of a city without trade"),
2058  /* TRANS: The strings between single quotes are setting names and
2059  shouldn't be translated. */
2060  N_("Cities do not produce any trade at all unless their size is "
2061  "larger than this amount. The produced trade increases "
2062  "gradually for cities larger than 'notradesize' and smaller "
2063  "than 'fulltradesize'. See also 'fulltradesize'."),
2064  nullptr, nullptr, nullptr, GAME_MIN_NOTRADESIZE,
2066 
2067  GEN_INT("tradeworldrelpct", game.info.trade_world_rel_pct, SSET_RULES,
2068  SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2069  N_("How largely trade distance is relative to world size"),
2070  /* TRANS: The strings between single quotes are setting names and
2071  shouldn't be translated. */
2072  N_("When determining trade between cities, the distance factor "
2073  "can be partly or fully relative to world size. This setting "
2074  "determines how big percentage of the bonus calculation is "
2075  "relative to world size, and how much only absolute distance "
2076  "matters."),
2077  nullptr, nullptr, nullptr, GAME_MIN_TRADEWORLDRELPCT,
2079 
2080  GEN_INT("citymindist", game.info.citymindist, SSET_RULES, SSET_SOCIOLOGY,
2081  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2082  N_("Minimum distance between cities"),
2083  N_("When a player attempts to found a new city, it is prevented "
2084  "if the distance from any existing city is less than this "
2085  "setting. For example, when this setting is 3, there must be "
2086  "at least two clear tiles in any direction between all "
2087  "existing cities and the new city site. A value of 1 removes "
2088  "any such restriction on city placement."),
2089  nullptr, nullptr, nullptr, GAME_MIN_CITYMINDIST,
2091 
2092  GEN_BOOL("trading_tech", game.info.trading_tech, SSET_RULES,
2093  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2094  N_("Technology trading"),
2095  N_("If turned off, trading technologies in the diplomacy "
2096  "dialog is not allowed."),
2097  nullptr, nullptr, GAME_DEFAULT_TRADING_TECH),
2098 
2099  GEN_BOOL("trading_gold", game.info.trading_gold, SSET_RULES,
2100  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2101  N_("Gold trading"),
2102  N_("If turned off, trading gold in the diplomacy dialog is not "
2103  "allowed."),
2104  nullptr, nullptr, GAME_DEFAULT_TRADING_GOLD),
2105 
2106  GEN_BOOL("trading_city", game.info.trading_city, SSET_RULES,
2107  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2108  N_("City trading"),
2109  N_("If turned off, trading cities in the diplomacy dialog is "
2110  "not allowed."),
2111  nullptr, nullptr, GAME_DEFAULT_TRADING_CITY),
2112 
2113  GEN_ENUM("caravan_bonus_style", game.info.caravan_bonus_style,
2114  SSET_RULES, SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2115  N_("Caravan bonus style"),
2116  N_("The formula for the bonus when a caravan enters a city. "
2117  "CLASSIC bonuses are proportional to distance and trade of "
2118  "source and destination with multipliers for overseas and "
2119  "international destinations. LOGARITHMIC bonuses are "
2120  "proportional to log^2(distance + trade). LINEAR bonuses "
2121  "are similar to CLASSIC, but (like LOGARITHMIC) use the "
2122  "max trade of the city rather than current. DISTANCE "
2123  "bonuses are proportional only to distance."),
2124  nullptr, nullptr, nullptr, caravanbonusstyle_name,
2126 
2127  GEN_ENUM(
2128  "trade_revenue_style", game.info.trade_revenue_style, SSET_RULES,
2129  SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2130  N_("Trade revenue style"),
2131  N_("The formula for the trade a city receives from a traderoute. "
2132  "CLASSIC revenues depend on distance and trade with multipliers "
2133  "for overseas and international routes. SIMPLE revenues are "
2134  "proportional to the average trade of the two cities."),
2135  nullptr, nullptr, nullptr, traderevenuestyle_name,
2137 
2138  GEN_INT("trademindist", game.info.trademindist, SSET_RULES,
2139  SSET_ECONOMICS, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2140  N_("Minimum distance for trade routes"),
2141  N_("In order for two cities in the same civilization to "
2142  "establish a trade route, they must be at least this far "
2143  "apart on the map. For square grids, the distance is "
2144  "calculated as \"Manhattan distance\", that is, the sum of "
2145  "the displacements along the x and y directions."),
2146  nullptr, nullptr, nullptr, GAME_MIN_TRADEMINDIST,
2148 
2149  GEN_INT(
2150  "rapturedelay", game.info.rapturedelay, SSET_RULES, SSET_SOCIOLOGY,
2151  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2152  N_("Number of turns between rapture effect"),
2153  N_("Sets the number of turns between rapture growth of a city. If "
2154  "set to n a city will grow after celebrating for n+1 turns."),
2155  nullptr, nullptr, nullptr, GAME_MIN_RAPTUREDELAY,
2157 
2158  GEN_INT("disasters", game.info.disasters, SSET_RULES_FLEXIBLE,
2159  SSET_SOCIOLOGY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2160  N_("Frequency of disasters"),
2161  N_("Affects how often random disasters happen to cities, if any "
2162  "are defined by the ruleset. The relative frequency of "
2163  "disaster types is set by the ruleset. Zero prevents any "
2164  "random disasters from occurring."),
2165  nullptr, nullptr, nullptr, GAME_MIN_DISASTERS,
2167 
2168  GEN_ENUM("traitdistribution", game.server.trait_dist, SSET_RULES,
2169  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2170  N_("AI trait distribution method"),
2171  N_("How trait values are given to AI players."), nullptr,
2172  nullptr, nullptr, trait_dist_name,
2174 
2175  GEN_INT("razechance", game.server.razechance, SSET_RULES, SSET_MILITARY,
2176  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2177  N_("Chance for conquered building destruction"),
2178  N_("When a player conquers a city, each city improvement has "
2179  "this percentage chance to be destroyed."),
2180  nullptr, nullptr, nullptr, GAME_MIN_RAZECHANCE,
2182 
2183  GEN_INT("occupychance", game.server.occupychance, SSET_RULES,
2184  SSET_MILITARY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2185  N_("Chance of moving into tile after attack"),
2186  N_("If set to 0, combat is Civ1/2-style (when you attack, you "
2187  "remain in place). If set to 100, attacking units will "
2188  "always move into the tile they attacked when they win the "
2189  "combat (and no enemy units remain in the tile). If set to a "
2190  "value between 0 and 100, this will be used as the percent "
2191  "chance of \"occupying\" territory."),
2192  nullptr, nullptr, nullptr, GAME_MIN_OCCUPYCHANCE,
2194 
2195  GEN_BOOL(
2196  "autoattack", game.server.autoattack, SSET_RULES_FLEXIBLE,
2197  SSET_MILITARY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2198  N_("Turn on/off server-side autoattack"),
2199  N_("If set to on, units with moves left will automatically consider "
2200  "attacking enemy units that move adjacent to them."),
2201  nullptr, nullptr, GAME_DEFAULT_AUTOATTACK),
2202 
2203  GEN_BOOL(
2204  "killstack", game.info.killstack, SSET_RULES_SCENARIO, SSET_MILITARY,
2205  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2206  N_("Do all units in tile die with defender"),
2207  N_("If this is enabled, each time a defender unit loses in combat, "
2208  "and is not inside a city or suitable base, all units in the "
2209  "same tile are destroyed along with the defender. If this is "
2210  "disabled, only the defender unit is destroyed."),
2211  nullptr, nullptr, GAME_DEFAULT_KILLSTACK),
2212 
2213  GEN_BOOL("killcitizen", game.info.killcitizen, SSET_RULES, SSET_MILITARY,
2214  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2215  N_("Reduce city population after attack"),
2216  N_("This flag indicates whether a city's population is reduced "
2217  "after a successful attack by an enemy unit. If this is "
2218  "disabled, population is never reduced. Even when this is "
2219  "enabled, only some units may kill citizens."),
2220  nullptr, nullptr, GAME_DEFAULT_KILLCITIZEN),
2221 
2222  GEN_INT(
2223  "killunhomed", game.info.killunhomed, SSET_RULES, SSET_MILITARY,
2224  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2225  N_("Slowly kill units without home cities (e.g., starting units)"),
2226  N_("If greater than 0, then every unit without a homecity will lose "
2227  "hitpoints each turn. The number of hitpoints lost is given by "
2228  "'killunhomed' percent of the hitpoints of the unit type. At "
2229  "least one hitpoint is lost every turn until the death of the "
2230  "unit."),
2231  nullptr, nullptr, nullptr, GAME_MIN_KILLUNHOMED,
2233 
2234  GEN_ENUM("borders", game.info.borders, SSET_RULES, SSET_MILITARY,
2235  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2236  N_("National borders"),
2237  N_("If this is not disabled, then any land tiles around a city "
2238  "or border-claiming extra (like the classic ruleset's "
2239  "Fortress base) will be owned by that nation. SEE_INSIDE "
2240  "and EXPAND makes everything inside a player's borders "
2241  "visible at once. ENABLED will, in some rulesets, grant the "
2242  "same visibility if certain conditions are met."),
2243  nullptr, nullptr, nullptr, borders_name, GAME_DEFAULT_BORDERS),
2244 
2245  GEN_ENUM(
2246  "happyborders", game.info.happyborders, SSET_RULES, SSET_MILITARY,
2247  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2248  N_("Units inside borders cause no unhappiness"),
2249  N_("If this is set, units will not cause unhappiness when inside "
2250  "your borders, or even allies borders, depending on value."),
2251  nullptr, nullptr, nullptr, happyborders_name,
2253 
2254  GEN_ENUM("diplomacy", game.info.diplomacy, SSET_RULES, SSET_MILITARY,
2255  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2256  N_("Ability to do diplomacy with other players"),
2257  N_("This setting controls the ability to do diplomacy with "
2258  "other players."),
2259  nullptr, nullptr, nullptr, diplomacy_name,
2261 
2262  GEN_ENUM("citynames", game.server.allowed_city_names, SSET_RULES,
2263  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2264  N_("Allowed city names"),
2265  /* TRANS: The strings between double quotes are also translated
2266  * separately (they must match!). The strings between
2267  * parentheses and in uppercase must not be translated.
2268  */
2269  N_("- \"No restrictions\" (NO_RESTRICTIONS): players can have "
2270  "multiple cities with the same names.\n"
2271  "- \"Unique to a player\" (PLAYER_UNIQUE): one player can't "
2272  "have multiple cities with the same name.\n"
2273  "- \"Globally unique\" (GLOBAL_UNIQUE): all cities in a "
2274  "game have to have different names.\n"
2275  "- \"No city name stealing\" (NO_STEALING): like \"Globally "
2276  "unique\", but a player isn't allowed to use a default city "
2277  "name of another nation unless it is a default for their "
2278  "nation also."),
2279  nullptr, nullptr, nullptr, citynames_name,
2281 
2282  GEN_ENUM(
2283  "plrcolormode", game.server.plrcolormode, SSET_RULES, SSET_INTERNAL,
2284  SSET_RARE, ALLOW_NONE, ALLOW_BASIC, N_("How to pick player colors"),
2285  /* TRANS: The strings between double quotes are also translated
2286  * separately (they must match!). The strings between single quotes
2287  * are setting names and shouldn't be translated. The strings between
2288  * parentheses and in uppercase must not be translated.
2289  */
2290  N_("This setting determines how player colors are chosen. Player "
2291  "colors are used in the Nations report, for national borders on "
2292  "the map, and so on.\n"
2293  "- \"Per-player, in order\" (PLR_ORDER): colors are assigned to "
2294  "individual players in order from a list defined by the "
2295  "ruleset.\n"
2296  "- \"Per-player, random\" (PLR_RANDOM): colors are assigned to "
2297  "individual players randomly from the set defined by the "
2298  "ruleset.\n"
2299  "- \"Set manually\" (PLR_SET): colors can be set with the "
2300  "'playercolor' command before the game starts; these are not "
2301  "restricted to the ruleset colors. Any players for which no "
2302  "color is set when the game starts get a random color from the "
2303  "ruleset.\n"
2304  "- \"Per-team, in order\" (TEAM_ORDER): colors are assigned to "
2305  "teams from the list in the ruleset. Every player on the same "
2306  "team gets the same color.\n"
2307  "- \"Per-nation, in order\" (NATION_ORDER): if the ruleset "
2308  "defines a color for a player's nation, the player takes that "
2309  "color. Any players whose nations don't have associated colors "
2310  "get a random color from the list in the ruleset.\n"
2311  "Regardless of this setting, individual player colors can be "
2312  "changed after the game starts with the 'playercolor' command."),
2315 
2316  /* Flexible rules: these can be changed after the game has started.
2317  * The distinction between "rules" and "flexible rules" is not always
2318  * clearcut, and some existing cases may be largely historical or
2319  * accidental. However some generalizations can be made:
2320  * -- Low-level game mechanics should not be flexible (eg, rulesets).
2321  * -- Options which would affect the game "state" (city production etc)
2322  * should not be flexible (eg, foodbox). -- Options which are
2323  * explicitly sent to the client (eg, in packet_game_info) should
2324  * probably not be flexible, or at least need extra care to be
2325  * flexible.
2326  */
2327  GEN_ENUM("barbarians", game.server.barbarianrate, SSET_RULES_FLEXIBLE,
2328  SSET_MILITARY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2329  N_("Barbarian appearance frequency"),
2330  /* TRANS: The string between single quotes is a setting name and
2331  should not be translated. */
2332  N_("This setting controls how frequently the barbarians appear "
2333  "in the game. See also the 'onsetbarbs' setting."),
2334  nullptr, nullptr, nullptr, barbarians_name,
2336 
2337  GEN_INT("onsetbarbs", game.server.onsetbarbarian, SSET_RULES_FLEXIBLE,
2338  SSET_MILITARY, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2339  N_("Barbarian onset turn"),
2340  N_("Barbarians will not appear before this turn."), nullptr,
2341  nullptr, nullptr, GAME_MIN_ONSETBARBARIAN,
2343 
2344  GEN_ENUM(
2345  "revolentype", game.info.revolentype, SSET_RULES, SSET_SOCIOLOGY,
2346  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2347  N_("Way to determine revolution length"),
2348  N_("Which method is used in determining how long period of anarchy "
2349  "lasts when changing government. The actual value is set with "
2350  "'revolen' setting. The 'quickening' methods depend on how many "
2351  "times any player has changed to this type of government before, "
2352  "so it becomes easier to establish a new system of government if "
2353  "it has been done before."),
2354  nullptr, nullptr, nullptr, revolentype_name,
2356 
2357  GEN_INT("revolen", game.server.revolution_length, SSET_RULES_FLEXIBLE,
2358  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2359  N_("Length of revolution"),
2360  N_("When changing governments, a period of anarchy will occur. "
2361  "Value of this setting, used the way 'revolentype' setting "
2362  "dictates, defines the length of the anarchy."),
2363  nullptr, nullptr, nullptr, GAME_MIN_REVOLUTION_LENGTH,
2365 
2366  GEN_BOOL("fogofwar", game.info.fogofwar, SSET_RULES, SSET_MILITARY,
2367  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2368  N_("Whether to enable fog of war"),
2369  N_("If this is enabled, only those units and cities within the "
2370  "vision range of your own units and cities will be revealed "
2371  "to you. You will not see new cities or terrain changes in "
2372  "tiles not observed."),
2373  nullptr, nullptr, GAME_DEFAULT_FOGOFWAR),
2374 
2375  GEN_BOOL("foggedborders", game.server.foggedborders, SSET_RULES,
2376  SSET_MILITARY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2377  N_("Whether fog of war applies to border changes"),
2378  N_("If this setting is enabled, players will not be able to "
2379  "see changes in tile ownership if they do not have direct "
2380  "sight of the affected tiles. Otherwise, players can see "
2381  "any or all changes to borders as long as they have "
2382  "previously seen the tiles."),
2383  nullptr, nullptr, GAME_DEFAULT_FOGGEDBORDERS),
2384 
2385  GEN_BITWISE(
2386  "airliftingstyle", game.info.airlifting_style, SSET_RULES_FLEXIBLE,
2387  SSET_MILITARY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2388  N_("Airlifting style"),
2389  /* TRANS: The strings between double quotes are also translated
2390  * separately (they must match!). The strings between parenthesis and
2391  * in uppercase must not be translated.
2392  */
2393  N_("This setting affects airlifting units between cities. It can be "
2394  "a set of the following values:\n"
2395  "- \"Allows units to be airlifted from allied cities\" "
2396  "(FROM_ALLIES).\n"
2397  "- \"Allows units to be airlifted to allied cities\" "
2398  "(TO_ALLIES).\n"
2399  "- \"Unlimited units from source city\" (SRC_UNLIMITED): note "
2400  "that airlifting from a city doesn't reduce the airlifted "
2401  "counter, but still needs airlift capacity of at least 1.\n"
2402  "- \"Unlimited units to destination city\" (DEST_UNLIMITED): "
2403  "note that airlifting to a city doesn't reduce the airlifted "
2404  "counter, and doesn't need any airlift capacity."),
2405  nullptr, nullptr, airliftingstyle_name,
2407 
2408  GEN_INT(
2409  "diplchance", game.server.diplchance, SSET_RULES_FLEXIBLE,
2410  SSET_MILITARY, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2411  N_("Base chance for diplomats and spies to succeed"),
2412  N_("The base chance of a spy returning from a successful mission "
2413  "and the base chance of success for diplomats and spies."),
2414  nullptr, nullptr, nullptr, GAME_MIN_DIPLCHANCE, GAME_MAX_DIPLCHANCE,
2416 
2417  GEN_BITWISE(
2418  "victories", game.info.victory_conditions, SSET_RULES_FLEXIBLE,
2419  SSET_INTERNAL, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2420  N_("What kinds of victories are possible"),
2421  /* TRANS: The strings between double quotes are also translated
2422  separately (they must match!). The strings between single quotes
2423  are setting names and shouldn't be translated. The strings between
2424  parentheses and in uppercase must stay as untranslated. */
2425  N_("This setting controls how game can be won. One can always win "
2426  "by conquering entire planet, but other victory conditions can "
2427  "be enabled or disabled:\n"
2428  "- \"Spacerace\" (SPACERACE): Spaceship is built and travels to "
2429  "Alpha Centauri.\n"
2430  "- \"Allied\" (ALLIED): After defeating enemies, all remaining "
2431  "players are allied.\n"
2432  "- \"Culture\" (CULTURE): Player meets ruleset defined cultural "
2433  "domination criteria.\n"),
2434  nullptr, nullptr, victory_conditions_name,
2436 
2437  GEN_BOOL("endspaceship", game.server.endspaceship, SSET_RULES_FLEXIBLE,
2438  SSET_SCIENCE, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2439  N_("Should the game end if the spaceship arrives?"),
2440  N_("If this option is turned on, the game will end with the "
2441  "arrival of a spaceship at Alpha Centauri."),
2442  nullptr, nullptr, GAME_DEFAULT_END_SPACESHIP),
2443 
2444  GEN_INT(
2445  "spaceship_travel_time", game.server.spaceship_travel_time,
2446  SSET_RULES_FLEXIBLE, SSET_SCIENCE, SSET_VITAL, ALLOW_NONE,
2447  ALLOW_BASIC, N_("Percentage to multiply spaceship travel time by"),
2448  N_("This percentage is multiplied onto the time it will take for a "
2449  "spaceship to arrive at Alpha Centauri."),
2450  nullptr, nullptr, nullptr, GAME_MIN_SPACESHIP_TRAVEL_TIME,
2452 
2453  GEN_INT("civilwarsize", game.server.civilwarsize, SSET_RULES_FLEXIBLE,
2454  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2455  N_("Minimum number of cities for civil war"),
2456  N_("A civil war is triggered when a player has at least this "
2457  "many cities and the player's capital is captured. If this "
2458  "option is set to the maximum value, civil wars are turned "
2459  "off altogether."),
2460  nullptr, nullptr, nullptr, GAME_MIN_CIVILWARSIZE,
2462 
2463  GEN_BOOL("restrictinfra", game.info.restrictinfra, SSET_RULES_FLEXIBLE,
2464  SSET_MILITARY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2465  N_("Restrict the use of the infrastructure for enemy units"),
2466  N_("If this option is enabled, the use of roads and rails will "
2467  "be restricted for enemy units."),
2468  nullptr, nullptr, GAME_DEFAULT_RESTRICTINFRA),
2469 
2470  GEN_BOOL("unreachableprotects", game.info.unreachable_protects,
2471  SSET_RULES_FLEXIBLE, SSET_MILITARY, SSET_RARE, ALLOW_NONE,
2472  ALLOW_BASIC, N_("Does unreachable unit protect reachable ones"),
2473  N_("This option controls whether tiles with both unreachable "
2474  "and reachable units can be attacked. If disabled, any tile "
2475  "with reachable units can be attacked. If enabled, tiles "
2476  "with an unreachable unit in them cannot be attacked. Some "
2477  "units in some rulesets may override this, never protecting "
2478  "reachable units on their tile."),
2479  nullptr, nullptr, GAME_DEFAULT_UNRPROTECTS),
2480 
2481  GEN_INT("contactturns", game.server.contactturns, SSET_RULES_FLEXIBLE,
2482  SSET_MILITARY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2483  N_("Turns until player contact is lost"),
2484  N_("Players may meet for diplomacy this number of turns after "
2485  "their units have last met, even when they do not have an "
2486  "embassy. If set to zero, then players cannot meet unless "
2487  "they have an embassy."),
2488  nullptr, nullptr, nullptr, GAME_MIN_CONTACTTURNS,
2490 
2491  GEN_BOOL(
2492  "savepalace", game.server.savepalace, SSET_RULES_FLEXIBLE,
2493  SSET_MILITARY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2494  N_("Rebuild palace whenever capital is conquered"),
2495  N_("If this is turned on, when the capital is conquered the palace "
2496  "is automatically rebuilt for free in another randomly chosen "
2497  "city. This is significant because the technology requirement "
2498  "for building a palace will be ignored. (In some rulesets, "
2499  "buildings other than the palace are affected by this setting.)"),
2500  nullptr, nullptr, GAME_DEFAULT_SAVEPALACE),
2501 
2502  GEN_BOOL("homecaughtunits", game.server.homecaughtunits,
2503  SSET_RULES_FLEXIBLE, SSET_MILITARY, SSET_RARE, ALLOW_NONE,
2504  ALLOW_BASIC, N_("Give caught units a homecity"),
2505  /* TRANS: The string between single quotes is a setting name and
2506  * should not be translated.
2507  */
2508  N_("If unset, caught units will have no homecity and will be "
2509  "subject to the 'killunhomed' option."),
2510  nullptr, nullptr, GAME_DEFAULT_HOMECAUGHTUNITS),
2511 
2512  GEN_BOOL("naturalcitynames", game.server.natural_city_names,
2513  SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE,
2514  ALLOW_BASIC, N_("Whether to use natural city names"),
2515  N_("If enabled, the default city names will be determined "
2516  "based on the surrounding terrain."),
2517  nullptr, nullptr, GAME_DEFAULT_NATURALCITYNAMES),
2518 
2519  GEN_BOOL(
2520  "migration", game.server.migration, SSET_RULES_FLEXIBLE,
2521  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2522  N_("Whether to enable citizen migration"),
2523  /* TRANS: The strings between single quotes are setting names
2524  and should not be translated. */
2525  N_("This is the master setting that controls whether citizen "
2526  "migration is active in the game. If enabled, citizens may "
2527  "automatically move from less desirable cities to more desirable "
2528  "ones. The \"desirability\" of a given city is calculated from a "
2529  "number of factors. In general larger cities with more income "
2530  "and improvements will be preferred. Citizens will never migrate "
2531  "out of the capital, or cause a wonder to be lost by disbanding "
2532  "a city. A number of other settings control how migration "
2533  "behaves:\n"
2534  " 'mgr_turninterval' - How often citizens try to migrate.\n"
2535  " 'mgr_foodneeded' - Whether destination food is checked.\n"
2536  " 'mgr_distance' - How far citizens will migrate.\n"
2537  " 'mgr_worldchance' - Chance for inter-nation migration.\n"
2538  " 'mgr_nationchance' - Chance for intra-nation migration."),
2539  nullptr, nullptr, GAME_DEFAULT_MIGRATION),
2540 
2541  GEN_INT("mgr_turninterval", game.server.mgr_turninterval,
2542  SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE,
2543  ALLOW_BASIC,
2544  N_("Number of turns between migrations from a city"),
2545  /* TRANS: Do not translate 'migration'
2546  setting name. */
2547  N_("This setting controls the number of turns between migration "
2548  "checks for a given city. The interval is calculated from "
2549  "the founding turn of the city. So for example if this "
2550  "setting is 5, citizens will look for a suitable migration "
2551  "destination every five turns from the founding of their "
2552  "current city. Migration will never occur the same turn that "
2553  "a city is built. This setting has no effect unless "
2554  "migration is enabled by the 'migration' setting."),
2555  nullptr, nullptr, nullptr, GAME_MIN_MGR_TURNINTERVAL,
2557 
2558  GEN_BOOL("mgr_foodneeded", game.server.mgr_foodneeded,
2559  SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE,
2560  ALLOW_BASIC, N_("Whether migration is limited by food"),
2561  /* TRANS: Do not translate 'migration'
2562  setting name. */
2563  N_("If this setting is enabled, citizens will not migrate to "
2564  "cities which would not have enough food to support them. "
2565  "This setting has no effect unless migration is enabled by "
2566  "the 'migration' setting."),
2567  nullptr, nullptr, GAME_DEFAULT_MGR_FOODNEEDED),
2568 
2569  GEN_INT(
2570  "mgr_distance", game.server.mgr_distance, SSET_RULES_FLEXIBLE,
2571  SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2572  N_("Maximum distance citizens may migrate"),
2573  /* TRANS: Do not translate 'migration'
2574  setting name. */
2575  N_("This setting controls how far citizens may look for a suitable "
2576  "migration destination when deciding which city to migrate to. "
2577  "The value is added to the candidate target city's radius and "
2578  "compared to the distance between the two cities. If the "
2579  "distance is lower or equal, migration is possible. (So with a "
2580  "setting of 0, citizens will only consider migrating if their "
2581  "city's center is within the destination city's working radius.) "
2582  "This setting has no effect unless migration is enabled by the "
2583  "'migration' setting."),
2584  nullptr, nullptr, nullptr, GAME_MIN_MGR_DISTANCE,
2586 
2587  GEN_INT("mgr_nationchance", game.server.mgr_nationchance,
2588  SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE,
2589  ALLOW_BASIC,
2590  N_("Percent probability for migration within the same nation"),
2591  /* TRANS: Do not translate
2592  'migration' setting name. */
2593  N_("This setting controls how likely it is for citizens to "
2594  "migrate between cities owned by the same player. Zero "
2595  "indicates migration will never occur, 100 means that "
2596  "migration will always occur if the citizens find a suitable "
2597  "destination. This setting has no effect unless migration is "
2598  "activated by the 'migration' setting."),
2599  nullptr, nullptr, nullptr, GAME_MIN_MGR_NATIONCHANCE,
2601 
2602  GEN_INT("mgr_worldchance", game.server.mgr_worldchance,
2603  SSET_RULES_FLEXIBLE, SSET_SOCIOLOGY, SSET_RARE, ALLOW_NONE,
2604  ALLOW_BASIC,
2605  N_("Percent probability for migration between foreign cities"),
2606  /* TRANS: Do not translate
2607  'migration' setting name. */
2608  N_("This setting controls how likely it is for migration to "
2609  "occur between cities owned by different players. Zero "
2610  "indicates migration will never occur, 100 means that "
2611  "citizens will always migrate if they find a suitable "
2612  "destination. This setting has no effect if migration is not "
2613  "enabled by the 'migration' setting."),
2614  nullptr, nullptr, nullptr, GAME_MIN_MGR_WORLDCHANCE,
2616 
2617  /* Meta options: these don't affect the internal rules of the game, but
2618  * do affect players. Also options which only produce extra server
2619  * "output" and don't affect the actual game. ("endturn" is here, and not
2620  * RULES_FLEXIBLE, because it doesn't affect what happens in the game, it
2621  * just determines when the players stop playing and look at the score.)
2622  */
2623  GEN_STRING(
2624  "allowtake", game.server.allow_take, SSET_META, SSET_NETWORK,
2625  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2626  N_("Players that users are allowed to take"),
2627  /* TRANS: the strings in double quotes are server command names and
2628  should not be translated. */
2629  N_("This should be a string of characters, each of which specifies "
2630  "a type or status of a civilization (player).\n"
2631  "Clients will only be permitted to take or observe those players "
2632  "which match one of the specified letters. This only affects "
2633  "future uses of the \"take\" or \"observe\" commands; it is not "
2634  "retroactive. The characters and their meanings are:\n"
2635  " o,O = Global observer\n"
2636  " b = Barbarian players\n"
2637  " d = Dead players\n"
2638  " a,A = AI players\n"
2639  " h,H = Human players\n"
2640  "The first description on this list which matches a player is "
2641  "the one which applies. Thus 'd' does not include dead "
2642  "barbarians, 'a' does not include dead AI players, and so on. "
2643  "Upper case letters apply before the game has started, lower "
2644  "case letters afterwards.\n"
2645  "Each character above may be followed by one of the following "
2646  "numbers to allow or restrict the manner of connection:\n"
2647  "(none) = Controller allowed, observers allowed, can displace "
2648  "connections. (Displacing a connection means that you may take "
2649  "over a player, even when another user already controls that "
2650  "player.)\n"
2651  " 1 = Controller allowed, observers allowed, can't displace "
2652  "connections;\n"
2653  " 2 = Controller allowed, no observers allowed, can displace "
2654  "connections;\n"
2655  " 3 = Controller allowed, no observers allowed, can't "
2656  "displace connections;\n"
2657  " 4 = No controller allowed, observers allowed"),
2659 
2660  GEN_BOOL("autotoggle", game.server.auto_ai_toggle, SSET_META,
2661  SSET_NETWORK, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2662  N_("Whether AI-status toggles with connection"),
2663  N_("If enabled, AI status is turned off when a player "
2664  "connects, and on when a player disconnects."),
2666 
2667  GEN_INT("endturn", game.server.end_turn, SSET_META, SSET_SOCIOLOGY,
2668  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("Turn the game ends"),
2669  N_("The game will end at the end of the given turn."), nullptr,
2672 
2673  GEN_BITWISE(
2674  "revealmap", game.server.revealmap, SSET_GAME_INIT, SSET_MILITARY,
2675  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC, N_("Reveal the map"),
2676  /* TRANS: The strings between double quotes are also translated
2677  separately (they must match!). The strings between single quotes
2678  are setting names and shouldn't be translated. The strings between
2679  parentheses and in uppercase must not be translated. */
2680  N_("If \"Reveal map at game start\" (START) is set, the initial "
2681  "state of the entire map will be known to all players from the "
2682  "start of the game, although it may still be fogged (depending "
2683  "on the 'fogofwar' setting). If \"Unfog map for dead players\" "
2684  "(DEAD) is set, dead players can see the entire map, if they are "
2685  "alone in their team."),
2686  nullptr, nullptr, revealmap_name, GAME_DEFAULT_REVEALMAP),
2687 
2688  GEN_INT(
2689  "timeout", game.info.timeout, SSET_META, SSET_INTERNAL, SSET_VITAL,
2690  ALLOW_NONE, ALLOW_BASIC, N_("Maximum seconds per turn"),
2691  /* TRANS: \"Turn Done\" refers to the client button; it is also
2692  translated separately, the translation should be the same.
2693  \"timeoutincrease\" is a command name and must not to be
2694  translated. */
2695  N_("If all players have not hit \"Turn Done\" before this time is "
2696  "up, then the turn ends automatically. Zero means there is no "
2697  "timeout. In servers compiled with debugging, a timeout of -1 "
2698  "sets the autogame test mode. Only connections with hack level "
2699  "access may set the timeout to fewer than 30 seconds. Use this "
2700  "with the command \"timeoutincrease\" to have a dynamic timer. "
2701  "The first turn is treated as a special case and is controlled "
2702  "by the 'first_timeout' setting."),
2705 
2706  GEN_INT(
2707  "first_timeout", game.info.first_timeout, SSET_META, SSET_INTERNAL,
2708  SSET_VITAL, ALLOW_NONE, ALLOW_BASIC, N_("First turn timeout"),
2709  /* TRANS: The strings between single quotes are setting names and
2710  should not be translated. */
2711  N_("If greater than 0, T1 will last for 'first_timeout' seconds.\n"
2712  "If set to 0, T1 will not have a timeout.\n"
2713  "If set to -1, the special treatment of T1 will be disabled.\n"
2714  "See also 'timeout'."),
2718 
2719  GEN_INT("timeaddenemymove", game.server.timeoutaddenemymove, SSET_META,
2720  SSET_INTERNAL, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2721  N_("Timeout at least n seconds when enemy moved"),
2722  N_("Any time a unit moves while in sight of an enemy player, "
2723  "the remaining timeout is increased to this value."),
2724  nullptr, nullptr, nullptr, 0, GAME_MAX_TIMEOUT,
2726 
2727  GEN_INT("unitwaittime", game.server.unitwaittime, SSET_RULES_FLEXIBLE,
2728  SSET_INTERNAL, SSET_VITAL, ALLOW_NONE, ALLOW_BASIC,
2729  N_("Minimum time between unit actions over turn change"),
2730  /* TRANS: The string between single quotes is a setting name and
2731  should not be translated. */
2732  N_("This setting gives the minimum amount of time in seconds "
2733  "between unit moves and other significant actions (such as "
2734  "building cities) after a turn change occurs. For example, "
2735  "if this setting is set to 20 and a unit moves 5 seconds "
2736  "before the turn change, it will not be able to move or act "
2737  "in the next turn for at least 15 seconds. This value is "
2738  "limited to a maximum value of 2/3 'timeout'."),
2739  nullptr, unitwaittime_callback, nullptr, GAME_MIN_UNITWAITTIME,
2741 
2742  GEN_BITWISE(
2743  "unitwaittime_style", game.server.unitwaittime_style,
2744  SSET_RULES_FLEXIBLE, SSET_INTERNAL, SSET_VITAL, ALLOW_NONE,
2745  ALLOW_BASIC, N_("Unitwaittime style"),
2746  /* TRANS: The strings between double quotes are also translated
2747  * separately (they must match!). The strings between single
2748  * quotes are setting names and shouldn't be translated. The
2749  * strings between parentheses and in uppercase must stay as
2750  * untranslated. */
2751  N_("This setting affects unitwaittime:\n"
2752  "- \"Activities\" (ACTIVITIES): Units moved less than "
2753  "'unitwaittime' seconds from turn change will not complete "
2754  "activities such as pillaging and building roads during "
2755  "turn change, but during the next turn when their wait "
2756  "expires."),
2757  nullptr, nullptr, unitwaittime_name,
2759 
2760  GEN_BOOL(
2761  "unitwaittime_extended", game.server.unitwaittime_extended,
2762  SSET_RULES_FLEXIBLE, SSET_INTERNAL, SSET_VITAL, ALLOW_NONE,
2763  ALLOW_BASIC,
2764  N_("Unitwaittime also applies to newly-built and captured/bribed "
2765  "units."),
2766  N_("If set, newly-built units are subject to unitwaittime so that "
2767  "the moment the city production was last touched counts as their "
2768  "last \"action\". Also, getting captured/bribed counts as action "
2769  "for the victim. "),
2770  nullptr, nullptr, GAME_DEFAULT_UNITWAITTIME_EXTENDED),
2771 
2772  /* This setting points to the "stored" value; changing it won't have an
2773  effect until the next synchronization point (i.e., the start of the
2774  next turn). */
2775  GEN_ENUM("phasemode", game.server.phase_mode_stored, SSET_META,
2776  SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2777  N_("Control of simultaneous player/team phases"),
2778  N_("This setting controls whether players may make moves at "
2779  "the same time during a turn. Change in setting takes "
2780  "effect next turn."),
2781  phasemode_help, nullptr, nullptr, phasemode_name,
2783 
2784  GEN_INT("netwait", game.server.netwait, SSET_META, SSET_NETWORK,
2785  SSET_RARE, ALLOW_NONE, ALLOW_BASIC,
2786  N_("Max seconds for network buffers to drain"),
2787  N_("The server will wait for up to the value of this parameter "
2788  "in seconds, for all client connection network buffers to "
2789  "unblock. Zero means the server will not wait at all."),
2790  nullptr, nullptr, nullptr, GAME_MIN_NETWAIT, GAME_MAX_NETWAIT,
2792 
2793  GEN_INT("pingtime", game.server.pingtime, SSET_META, SSET_NETWORK,
2794  SSET_RARE, ALLOW_NONE, ALLOW_BASIC, N_("Seconds between PINGs"),
2795  N_("The server will poll the clients with a PING request each "
2796  "time this period elapses."),
2797  nullptr, nullptr, nullptr, GAME_MIN_PINGTIME, GAME_MAX_PINGTIME,
2799 
2800  GEN_INT("pingtimeout", game.server.pingtimeout, SSET_META, SSET_NETWORK,
2801  SSET_RARE, ALLOW_NONE, ALLOW_BASIC, N_("Time to cut a client"),
2802  N_("If a client doesn't reply to a PING in this time the client "
2803  "is disconnected."),
2804  nullptr, nullptr, nullptr, GAME_MIN_PINGTIMEOUT,
2806 
2807  GEN_BOOL("turnblock", game.server.turnblock, SSET_META, SSET_INTERNAL,
2808  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2809  N_("Turn-blocking game play mode"),
2810  N_("If this is turned on, the game turn is not advanced until "
2811  "all players have finished their turn, including "
2812  "disconnected players."),
2813  nullptr, nullptr, GAME_DEFAULT_TURNBLOCK),
2814 
2815  GEN_BOOL("fixedlength", game.server.fixedlength, SSET_META,
2816  SSET_INTERNAL, SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2817  N_("Fixed-length turns play mode"),
2818  /* TRANS: \"Turn Done\" refers to the client button; it is also
2819  translated separately, the translation should be the same. */
2820  N_("If this is turned on the game turn will not advance until "
2821  "the timeout has expired, even after all players have "
2822  "clicked on \"Turn Done\"."),
2823  nullptr, nullptr, false),
2824 
2825  GEN_STRING(
2826  "demography", game.server.demography, SSET_META, SSET_INTERNAL,
2827  SSET_SITUATIONAL, ALLOW_NONE, ALLOW_BASIC,
2828  N_("What is in the Demographics report"),
2829  // TRANS: The strings between double quotes should be translated.
2830  N_("This should be a string of characters, each of which specifies "
2831  "the inclusion of a line of information in the Demographics "
2832  "report.\n"
2833  "The characters and their meanings are:\n"
2834  " s = include Score\n"
2835  " z = include League Score\n"
2836  " N = include Population\n"
2837  " n = include Population in Citizen Units\n"
2838  " c = include Cities\n"
2839  " i = include Improvements\n"
2840  " w = include Wonders\n"
2841  " A = include Land Area\n"
2842  " S = include Settled Area\n"
2843  " L = include Literacy\n"
2844  " a = include Agriculture\n"
2845  " P = include Production\n"
2846  " E = include Economics\n"
2847  " g = include Gold Income\n"
2848  " R = include Research Speed\n"
2849  " M = include Military Service\n"
2850  " m = include Military Units\n"
2851  " u = include Built Units\n"
2852  " k = include Killed Units\n"
2853  " l = include Lost Units\n"
2854  " O = include Pollution\n"
2855  " C = include Culture\n"
2856  "Additionally, the following characters control whether or not "
2857  "certain columns are displayed in the report:\n"
2858  " q = display \"quantity\" column\n"
2859  " r = display \"rank\" column\n"
2860  " b = display \"best nation\" column\n"
2861  "The order of characters is not significant, but their "
2862  "capitalization is."),
2864 
2865  GEN_INT("saveturns", game.server.save_nturns, SSET_META, SSET_INTERNAL,
2866  SSET_VITAL, ALLOW_HACK, ALLOW_HACK, N_("Turns per auto-save"),
2867  /* TRANS: The string between double quotes is also translated
2868  separately (it must match!). The string between single quotes
2869  is a setting name and shouldn't be translated. */
2870  N_("How many turns elapse between automatic game saves. This "
2871  "setting only has an effect when the 'autosaves' setting "
2872  "includes \"New turn\"."),
2873  nullptr, nullptr, nullptr, GAME_MIN_SAVETURNS,
2875 
2876  GEN_INT("savefrequency", game.server.save_frequency, SSET_META,
2877  SSET_INTERNAL, SSET_VITAL, ALLOW_HACK, ALLOW_HACK,
2878  N_("Minutes per auto-save"),
2879  /* TRANS: The string between double quotes is also translated
2880  separately (it must match!). The string between single quotes
2881  is a setting name and shouldn't be translated. */
2882  N_("How many minutes elapse between automatic game saves. "
2883  "Unlike other save types, this save is only meant as backup "
2884  "for computer memory, and it always uses the same name, "
2885  "older saves are not kept. This setting only has an effect "
2886  "when the 'autosaves' setting includes \"Timer\"."),
2887  nullptr, nullptr, nullptr, GAME_MIN_SAVEFREQUENCY,
2889 
2890  GEN_BITWISE(
2891  "autosaves", game.server.autosaves, SSET_META, SSET_INTERNAL,
2892  SSET_VITAL, ALLOW_HACK, ALLOW_HACK,
2893  N_("Which savegames are generated automatically"),
2894  /* TRANS: The strings between double quotes are also translated
2895  separately (they must match!). The strings between single quotes
2896  are setting names and shouldn't be translated. The strings between
2897  parentheses and in uppercase must stay as untranslated. */
2898  N_("This setting controls which autosave types get generated:\n"
2899  "- \"New turn\" (TURN): Save when turn begins, once every "
2900  "'saveturns' turns.\n"
2901  "- \"Game over\" (GAMEOVER): Final save when game ends.\n"
2902  "- \"No player connections\" (QUITIDLE): Save before server "
2903  "restarts due to lack of players.\n"
2904  "- \"Server interrupted\" (INTERRUPT): Save when server quits "
2905  "due to interrupt.\n"
2906  "- \"Timer\" (TIMER): Save every 'savefrequency' minutes."),
2908 
2909  GEN_BOOL("threaded_save", game.server.threaded_save, SSET_META,
2910  SSET_INTERNAL, SSET_RARE, ALLOW_HACK, ALLOW_HACK,
2911  N_("Whether to do saving in separate thread"),
2912  /* TRANS: The string between single quotes is a setting name and
2913  should not be translated. */
2914  N_("If this is turned in, compressing and saving the actual "
2915  "file containing the game situation takes place in the "
2916  "background while game otherwise continues. This way users "
2917  "are not required to wait for the save to finish."),
2918  nullptr, nullptr, GAME_DEFAULT_THREADED_SAVE),
2919 
2920  GEN_ENUM("compresstype", game.server.save_compress_type, SSET_META,
2921  SSET_INTERNAL, SSET_RARE, ALLOW_HACK, ALLOW_HACK,
2922  N_("Savegame compression algorithm"),
2923  N_("Compression library to use for savegames."), nullptr,
2926 
2927  GEN_STRING(
2928  "savename", game.server.save_name, SSET_META, SSET_INTERNAL,
2929  SSET_VITAL, ALLOW_HACK, ALLOW_HACK,
2930  N_("Definition of the save file name"),
2931  /* TRANS: %R, %S, %T and %Y must not be translated. The strings
2932  * (examples and setting names) between single quotes neither. The
2933  * strings between <> should be translated. xgettext:no-c-format
2934  */
2935  N_("Within the string the following custom formats are allowed:\n"
2936  " %R = <reason>\n"
2937  " %S = <suffix>\n"
2938  " %T = <turn-number>\n"
2939  " %Y = <game-year>\n"
2940  "\n"
2941  "Example: 'freeciv-T%04T-Y%+05Y-%R' => "
2942  "'freeciv-T0100-Y00001-manual'\n"
2943  "\n"
2944  "Be careful to use at least one of %T and %Y, else newer "
2945  "savegames will overwrite old ones. If none of the formats is "
2946  "used '-T%04T-Y%05Y-%R' is appended to the value of 'savename'."),
2948 
2949  GEN_BOOL(
2950  "scorelog", game.server.scorelog, SSET_META, SSET_INTERNAL,
2951  SSET_SITUATIONAL, ALLOW_HACK, ALLOW_HACK,
2952  N_("Whether to log player statistics"),
2953  /* TRANS: The string between single quotes is a setting name and
2954  * should not be translated.
2955  */
2956  N_("If this is turned on, player statistics are appended to the "
2957  "file defined by the option 'scorefile' every turn. These "
2958  "statistics can be used to create power graphs after the game."),
2960 
2961  GEN_ENUM(
2962  "scoreloglevel", game.server.scoreloglevel, SSET_META, SSET_INTERNAL,
2963  SSET_SITUATIONAL, ALLOW_HACK, ALLOW_HACK, N_("Scorelog level"),
2964  N_("Whether scores are logged for all players including AIs, or "
2965  "only for human players."),
2966  nullptr, nullptr, nullptr, scoreloglevel_name,
2968 
2969  GEN_STRING("scorefile", game.server.scorefile, SSET_META, SSET_INTERNAL,
2970  SSET_SITUATIONAL, ALLOW_HACK, ALLOW_HACK,
2971  N_("Name for the score log file"),
2972  /* TRANS:
2973  Don't
2974  translate
2975  the
2976  string
2977  in
2978  single
2979  quotes.
2980  */
2981  N_("The default name for the score log file is "
2982  "'freeciv-score.log'."),
2984 
2985  GEN_INT("maxconnectionsperhost", game.server.maxconnectionsperhost,
2986  SSET_RULES_FLEXIBLE, SSET_NETWORK, SSET_RARE, ALLOW_NONE,
2987  ALLOW_BASIC,
2988  N_("Maximum number of connections to the server per host"),
2989  N_("New connections from a given host will be rejected if the "
2990  "total number of connections from the very same host equals "
2991  "or exceeds this value. A value of 0 means that there is no "
2992  "limit, at least up to the maximum number of connections "
2993  "supported by the server."),
2994  nullptr, nullptr, nullptr, GAME_MIN_MAXCONNECTIONSPERHOST,
2997 
2998  GEN_INT("kicktime", game.server.kick_time, SSET_RULES_FLEXIBLE,
2999  SSET_NETWORK, SSET_RARE, ALLOW_HACK, ALLOW_HACK,
3000  N_("Time before a kicked user can reconnect"),
3001  /* TRANS: the string in double quotes is a server command name
3002  and should not be translated */
3003  N_("Gives the time in seconds before a user kicked using the "
3004  "\"kick\" command may reconnect. Changing this setting will "
3005  "affect users kicked in the past."),
3006  nullptr, nullptr, nullptr, GAME_MIN_KICK_TIME,
3008 
3009  GEN_STRING(
3010  "metamessage", game.server.meta_info.user_message, SSET_META,
3011  SSET_INTERNAL, SSET_RARE, ALLOW_CTRL, ALLOW_CTRL,
3012  N_("Metaserver info line"),
3013  N_("User defined metaserver info line. For most of the time a user "
3014  "defined metamessage will be used instead of an automatically "
3015  "generated message. Set to empty (\"\", not \"empty\") to always "
3016  "use an automatically generated meta server message."),
3018 
3019 #undef GEN_BOOL
3020 #undef GEN_INT
3021 #undef GEN_STRING
3022 #undef GEN_ENUM
3023 #undef GEN_BITWISE
3024 
3025 // The number of settings, not including the END.
3026 static const int SETTINGS_NUM = ARRAY_SIZE(settings);
3027 
3032 {
3033  return (0 <= id && id < SETTINGS_NUM ? settings + id : nullptr);
3034 }
3035 
3039 struct setting *setting_by_name(const char *name)
3040 {
3041  fc_assert_ret_val(name, nullptr);
3042 
3043  settings_iterate(SSET_ALL, pset)
3044  {
3045  if (0 == strcmp(name, pset->name)) {
3046  return pset;
3047  }
3048  }
3050  return nullptr;
3051 }
3052 
3056 int setting_number(const struct setting *pset)
3057 {
3058  fc_assert_ret_val(pset != nullptr, 0);
3059  return pset - settings;
3060 }
3061 
3065 const char *setting_name(const struct setting *pset) { return pset->name; }
3066 
3070 const char *setting_short_help(const struct setting *pset)
3071 {
3072  return pset->short_help;
3073 }
3074 
3080 const char *setting_extra_help(const struct setting *pset, bool constant)
3081 {
3082  if (!constant && pset->help_func != nullptr) {
3083  return pset->help_func(pset);
3084  }
3085 
3086  return _(pset->extra_help);
3087 }
3088 
3092 enum sset_type setting_type(const struct setting *pset)
3093 {
3094  return pset->stype;
3095 }
3096 
3100 enum sset_level setting_level(const struct setting *pset)
3101 {
3102  return pset->slevel;
3103 }
3104 
3108 enum sset_category setting_category(const struct setting *pset)
3109 {
3110  return pset->scategory;
3111 }
3112 
3118 static bool setting_is_free_to_change(const struct setting *pset,
3119  char *reject_msg,
3120  size_t reject_msg_len)
3121 {
3122  switch (pset->sclass) {
3123  case SSET_MAP_SIZE:
3124  case SSET_MAP_GEN:
3125  // Only change map options if we don't yet have a map:
3126  if (map_is_empty()) {
3127  return true;
3128  }
3129 
3131  reject_msg, reject_msg_len,
3132  _("The setting '%s' can't be modified after the map is fixed."),
3133  setting_name(pset));
3134  return false;
3135 
3136  case SSET_RULES_SCENARIO:
3137  /* Like SSET_RULES except that it can be changed before the game starts
3138  * for heavy scenarios. A heavy scenario comes with players. It can
3139  * include cities, units, diplomatic relations and other complex state.
3140  * Make sure that changing a setting can't make the state of a heavy
3141  * scenario illegal if you want to change it from SSET_RULES to
3142  * SSET_RULES_SCENARIO. */
3143 
3144  if (game.scenario.is_scenario && game.scenario.players
3145  && server_state() == S_S_INITIAL) {
3146  // Special case detected.
3147  return true;
3148  }
3149 
3150  /* The special case didn't make it legal to change the setting. Don't
3151  * give up. It could still be legal. Fall through so the non special
3152  * cases are checked too. */
3154 
3155  case SSET_MAP_ADD:
3156  case SSET_PLAYERS:
3157  case SSET_GAME_INIT:
3158  case SSET_RULES:
3159  /* Only change start params and most rules if we don't yet have a map, or
3160  * if we do have a map but its a scenario one (ie, the game has never
3161  * actually been started).
3162  */
3163  if (map_is_empty() || game.info.is_new_game) {
3164  return true;
3165  }
3166 
3168  reject_msg, reject_msg_len,
3169  _("The setting '%s' can't be modified after the game has started."),
3170  setting_name(pset));
3171  return false;
3172 
3173  case SSET_RULES_FLEXIBLE:
3174  case SSET_META:
3175  // These can always be changed:
3176  return true;
3177  }
3178 
3179  qCritical("Wrong class variant for setting %s (%d): %d.",
3180  setting_name(pset), setting_number(pset), pset->sclass);
3181  settings_snprintf(reject_msg, reject_msg_len, _("Internal error."));
3182 
3183  return false;
3184 }
3185 
3191 bool setting_is_changeable(const struct setting *pset,
3192  struct connection *caller, char *reject_msg,
3193  size_t reject_msg_len)
3194 {
3195  if (caller && (caller->access_level < pset->access_level_write)) {
3196  settings_snprintf(reject_msg, reject_msg_len,
3197  _("You are not allowed to change the setting '%s'."),
3198  setting_name(pset));
3199  return false;
3200  }
3201 
3202  if (setting_locked(pset)) {
3203  // setting is locked by the ruleset
3204  settings_snprintf(reject_msg, reject_msg_len,
3205  _("The setting '%s' is locked by the ruleset."),
3206  setting_name(pset));
3207  return false;
3208  }
3209 
3210  return setting_is_free_to_change(pset, reject_msg, reject_msg_len);
3211 }
3212 
3217 bool setting_is_visible_at_level(const struct setting *pset,
3218  enum cmdlevel plevel)
3219 {
3220  return (plevel >= pset->access_level_read);
3221 }
3222 
3227 bool setting_is_visible(const struct setting *pset,
3228  struct connection *caller)
3229 {
3230  return (!caller
3231  || setting_is_visible_at_level(pset, caller->access_level));
3232 }
3233 
3240 static enum m_pre_result
3241 setting_match_prefix_base(const val_name_func_t name_fn, const char *prefix,
3242  int *ind_result, QVector<QString> &matches,
3243  size_t max_matches, size_t *pnum_matches)
3244 {
3245  const struct sset_val_name *name;
3246  size_t len = qstrlen(prefix);
3247  size_t num_matches;
3248  int i;
3249 
3250  *pnum_matches = 0;
3251 
3252  if (0 == len) {
3253  return M_PRE_EMPTY;
3254  }
3255 
3256  for (i = 0, num_matches = 0; (name = name_fn(i)); i++) {
3257  if (0 == fc_strncasecmp(name->support, prefix, len)) {
3258  if (strlen(name->support) == len) {
3259  *ind_result = i;
3260  return M_PRE_EXACT;
3261  }
3262  if (num_matches < max_matches) {
3263  matches.append(name->support);
3264  (*pnum_matches)++;
3265  }
3266  if (0 == num_matches++) {
3267  *ind_result = i;
3268  }
3269  }
3270  }
3271 
3272  if (1 == num_matches) {
3273  return M_PRE_ONLY;
3274  } else if (1 < num_matches) {
3275  return M_PRE_AMBIGUOUS;
3276  } else {
3277  return M_PRE_FAIL;
3278  }
3279 }
3280 
3285 static bool setting_match_prefix(const val_name_func_t name_fn,
3286  const char *prefix, int *pvalue,
3287  char *reject_msg, size_t reject_msg_len)
3288 {
3289  QVector<QString> matches;
3290  matches.reserve(16);
3291  size_t num_matches;
3292 
3293  switch (setting_match_prefix_base(name_fn, prefix, pvalue, matches, 16,
3294  &num_matches)) {
3295  case M_PRE_EXACT:
3296  case M_PRE_ONLY:
3297  return true; // Ok.
3298  case M_PRE_AMBIGUOUS: {
3299  fc_assert(2 <= num_matches);
3300  settings_snprintf(reject_msg, reject_msg_len,
3301  _("\"%s\" prefix is ambiguous. Candidates are: %s."),
3302  prefix, qUtf8Printable(strvec_to_and_list(matches)));
3303  }
3304  return false;
3305  case M_PRE_EMPTY:
3306  settings_snprintf(reject_msg, reject_msg_len, _("Missing value."));
3307  return false;
3308  case M_PRE_LONG:
3309  case M_PRE_FAIL:
3310  case M_PRE_LAST:
3311  break;
3312  }
3313 
3314  settings_snprintf(reject_msg, reject_msg_len, _("No match for \"%s\"."),
3315  prefix);
3316  return false;
3317 }
3318 
3322 static const char *setting_bool_to_str(const struct setting *pset,
3323  bool value, bool pretty, char *buf,
3324  size_t buf_len)
3325 {
3326  const struct sset_val_name *name = pset->boolean.name(value);
3327 
3328  if (pretty) {
3329  fc_snprintf(buf, buf_len, "%s", Q_(name->pretty));
3330  } else {
3331  fc_strlcpy(buf, name->support, buf_len);
3332  }
3333  return buf;
3334 }
3335 
3343 static bool setting_bool_validate_base(const struct setting *pset,
3344  const char *val, int *pint_val,
3345  struct connection *caller,
3346  char *reject_msg,
3347  size_t reject_msg_len)
3348 {
3349  char buf[256];
3350 
3351  if (SST_BOOL != pset->stype) {
3352  settings_snprintf(reject_msg, reject_msg_len,
3353  _("This setting is not a boolean."));
3354  return false;
3355  }
3356 
3357  sz_strlcpy(buf, val);
3359 
3360  return (setting_match_prefix(pset->boolean.name, buf, pint_val, reject_msg,
3361  reject_msg_len)
3362  && (nullptr == pset->boolean.validate
3363  || pset->boolean.validate(0 != *pint_val, caller, reject_msg,
3364  reject_msg_len)));
3365 }
3366 
3372 bool setting_bool_set(struct setting *pset, const char *val,
3373  struct connection *caller, char *reject_msg,
3374  size_t reject_msg_len)
3375 {
3376  int int_val;
3377 
3378  if (!setting_is_changeable(pset, caller, reject_msg, reject_msg_len)
3379  || !setting_bool_validate_base(pset, val, &int_val, caller, reject_msg,
3380  reject_msg_len)) {
3381  return false;
3382  }
3383 
3384  *pset->boolean.pvalue = (0 != int_val);
3385  return true;
3386 }
3387 
3391 bool setting_bool_get(struct setting *pset)
3392 {
3393  fc_assert(setting_type(pset) == SST_BOOL);
3394 
3395  return *pset->boolean.pvalue;
3396 }
3397 
3403 bool setting_bool_validate(const struct setting *pset, const char *val,
3404  struct connection *caller, char *reject_msg,
3405  size_t reject_msg_len)
3406 {
3407  int int_val;
3408 
3409  return setting_bool_validate_base(pset, val, &int_val, caller, reject_msg,
3410  reject_msg_len);
3411 }
3412 
3417 static const char *setting_bool_secfile_str(secfile_data_t data, int val)
3418 {
3419  const struct sset_val_name *name =
3420  (static_cast<const struct setting *>(data))->boolean.name(val);
3421 
3422  return (nullptr != name ? name->support : nullptr);
3423 }
3424 
3428 static const char *setting_int_to_str(const struct setting *pset, int value,
3429  bool pretty, char *buf, size_t buf_len)
3430 {
3431  fc_snprintf(buf, buf_len, "%d", value);
3432  return buf;
3433 }
3434 
3438 int setting_int_min(const struct setting *pset)
3439 {
3440  fc_assert_ret_val(pset->stype == SST_INT, 0);
3441  return pset->integer.min_value;
3442 }
3443 
3447 int setting_int_max(const struct setting *pset)
3448 {
3449  fc_assert_ret_val(pset->stype == SST_INT, 0);
3450  return pset->integer.max_value;
3451 }
3452 
3457 bool setting_int_set(struct setting *pset, int val,
3458  struct connection *caller, char *reject_msg,
3459  size_t reject_msg_len)
3460 {
3461  if (!setting_is_changeable(pset, caller, reject_msg, reject_msg_len)
3462  || !setting_int_validate(pset, val, caller, reject_msg,
3463  reject_msg_len)) {
3464  return false;
3465  }
3466 
3467  *pset->integer.pvalue = val;
3468  return true;
3469 }
3470 
3477 bool setting_int_validate(const struct setting *pset, int val,
3478  struct connection *caller, char *reject_msg,
3479  size_t reject_msg_len)
3480 {
3481  if (SST_INT != pset->stype) {
3482  settings_snprintf(reject_msg, reject_msg_len,
3483  _("This setting is not an integer."));
3484  return false;
3485  }
3486 
3487  if (val < pset->integer.min_value || val > pset->integer.max_value) {
3488  settings_snprintf(reject_msg, reject_msg_len,
3489  _("Value out of range: %d (min: %d; max: %d)."), val,
3490  pset->integer.min_value, pset->integer.max_value);
3491  return false;
3492  }
3493 
3494  return (
3495  !pset->integer.validate
3496  || pset->integer.validate(val, caller, reject_msg, reject_msg_len));
3497 }
3498 
3502 int setting_int_get(struct setting *pset)
3503 {
3504  fc_assert(setting_type(pset) == SST_INT);
3505 
3506  return *pset->integer.pvalue;
3507 }
3508 
3512 static const char *setting_str_to_str(const struct setting *pset,
3513  const char *value, bool pretty,
3514  char *buf, size_t buf_len)
3515 {
3516  if (pretty) {
3517  fc_snprintf(buf, buf_len, "\"%s\"", value);
3518  } else {
3519  fc_strlcpy(buf, value, buf_len);
3520  }
3521  return buf;
3522 }
3523 
3528 bool setting_str_set(struct setting *pset, const char *val,
3529  struct connection *caller, char *reject_msg,
3530  size_t reject_msg_len)
3531 {
3532  if (!setting_is_changeable(pset, caller, reject_msg, reject_msg_len)
3533  || !setting_str_validate(pset, val, caller, reject_msg,
3534  reject_msg_len)) {
3535  return false;
3536  }
3537 
3538  fc_strlcpy(pset->string.value, val, pset->string.value_size);
3539  return true;
3540 }
3541 
3548 bool setting_str_validate(const struct setting *pset, const char *val,
3549  struct connection *caller, char *reject_msg,
3550  size_t reject_msg_len)
3551 {
3552  if (SST_STRING != pset->stype) {
3553  settings_snprintf(reject_msg, reject_msg_len,
3554  _("This setting is not a string."));
3555  return false;
3556  }
3557 
3558  if (strlen(val) >= pset->string.value_size) {
3559  settings_snprintf(reject_msg, reject_msg_len,
3560  _("String value too long (max length: %lu)."),
3561  (unsigned long) pset->string.value_size);
3562  return false;
3563  }
3564 
3565  return (!pset->string.validate
3566  || pset->string.validate(val, caller, reject_msg, reject_msg_len));
3567 }
3568 
3572 char *setting_str_get(struct setting *pset)
3573 {
3574  fc_assert(setting_type(pset) == SST_STRING);
3575 
3576  return pset->string.value;
3577 }
3578 
3583 const char *setting_enum_secfile_str(secfile_data_t data, int val)
3584 {
3585  const struct sset_val_name *name =
3586  (static_cast<const struct setting *>(data))->enumerator.name(val);
3587 
3588  return (nullptr != name ? name->support : nullptr);
3589 }
3590 
3595 const char *setting_enum_val(const struct setting *pset, int val,
3596  bool pretty)
3597 {
3598  const struct sset_val_name *name;
3599 
3600  fc_assert_ret_val(SST_ENUM == pset->stype, nullptr);
3601  name = pset->enumerator.name(val);
3602  if (nullptr == name) {
3603  return nullptr;
3604  } else if (pretty) {
3605  return _(name->pretty);
3606  } else {
3607  return name->support;
3608  }
3609 }
3610 
3615 static const char *setting_enum_to_str(const struct setting *pset, int value,
3616  bool pretty, char *buf,
3617  size_t buf_len)
3618 {
3619  const struct sset_val_name *name = pset->enumerator.name(value);
3620 
3621  if (pretty) {
3622  fc_snprintf(buf, buf_len, "\"%s\" (%s)", Q_(name->pretty),
3623  name->support);
3624  } else {
3625  fc_strlcpy(buf, name->support, buf_len);
3626  }
3627  return buf;
3628 }
3629 
3637 static bool setting_enum_validate_base(const struct setting *pset,
3638  const char *val, int *pint_val,
3639  struct connection *caller,
3640  char *reject_msg,
3641  size_t reject_msg_len)
3642 {
3643  char buf[256];
3644 
3645  if (SST_ENUM != pset->stype) {
3646  settings_snprintf(reject_msg, reject_msg_len,
3647  _("This setting is not an enumerator."));
3648  return false;
3649  }
3650 
3651  sz_strlcpy(buf, val);
3653 
3654  return (setting_match_prefix(pset->enumerator.name, buf, pint_val,
3655  reject_msg, reject_msg_len)
3656  && (nullptr == pset->enumerator.validate
3657  || pset->enumerator.validate(*pint_val, caller, reject_msg,
3658  reject_msg_len)));
3659 }
3660 
3664 static bool set_enum_value(struct setting *pset, int val)
3665 {
3666  switch (pset->enumerator.store_size) {
3667  case sizeof(int): {
3668  int *to_int = static_cast<int *>(pset->enumerator.pvalue);
3669 
3670  *to_int = val;
3671  } break;
3672  case sizeof(char): {
3673  char *to_char = static_cast<char *>(pset->enumerator.pvalue);
3674 
3675  *to_char = static_cast<char>(val);
3676  } break;
3677  case sizeof(short): {
3678  short *to_short = static_cast<short *>(pset->enumerator.pvalue);
3679 
3680  *to_short = static_cast<short>(val);
3681  } break;
3682  default:
3683  return false;
3684  }
3685 
3686  return true;
3687 }
3688 
3692 int read_enum_value(const struct setting *pset)
3693 {
3694  int val;
3695 
3696  switch (pset->enumerator.store_size) {
3697  case sizeof(int):
3698  val = *(static_cast<int *>(pset->enumerator.pvalue));
3699  break;
3700  case sizeof(char):
3701  val = *(static_cast<char *>(pset->enumerator.pvalue));
3702  break;
3703  case sizeof(short):
3704  val = *(static_cast<short *>(pset->enumerator.pvalue));
3705  break;
3706  default:
3707  qCritical("Illegal enum store size %d, can't read value",
3708  pset->enumerator.store_size);
3709  return 0;
3710  }
3711 
3712  return val;
3713 }
3714 
3720 bool setting_enum_set(struct setting *pset, const char *val,
3721  struct connection *caller, char *reject_msg,
3722  size_t reject_msg_len)
3723 {
3724  int int_val;
3725 
3726  if (!setting_is_changeable(pset, caller, reject_msg, reject_msg_len)) {
3727  return false;
3728  }
3729 
3730  if (!setting_enum_validate_base(pset, val, &int_val, caller, reject_msg,
3731  reject_msg_len)) {
3732  return false;
3733  }
3734 
3735  if (!set_enum_value(pset, int_val)) {
3736  qCritical("Illegal enumerator value size %d for %s",
3737  pset->enumerator.store_size, val);
3738  return false;
3739  }
3740 
3741  return true;
3742 }
3743 
3749 bool setting_enum_validate(const struct setting *pset, const char *val,
3750  struct connection *caller, char *reject_msg,
3751  size_t reject_msg_len)
3752 {
3753  int int_val;
3754 
3755  return setting_enum_validate_base(pset, val, &int_val, caller, reject_msg,
3756  reject_msg_len);
3757 }
3758 
3764 {
3765  const struct sset_val_name *name =
3766  (static_cast<const struct setting *>(data))->bitwise.name(bit);
3767 
3768  return (nullptr != name ? name->support : nullptr);
3769 }
3770 
3775 const char *setting_bitwise_bit(const struct setting *pset, int bit,
3776  bool pretty)
3777 {
3778  const struct sset_val_name *name;
3779 
3780  fc_assert_ret_val(SST_BITWISE == pset->stype, nullptr);
3781  name = pset->bitwise.name(bit);
3782  if (nullptr == name) {
3783  return nullptr;
3784  } else if (pretty) {
3785  return _(name->pretty);
3786  } else {
3787  return name->support;
3788  }
3789 }
3790 
3794 static const char *setting_bitwise_to_str(const struct setting *pset,
3795  unsigned value, bool pretty,
3796  char *buf, size_t buf_len)
3797 {
3798  const struct sset_val_name *name;
3799  char *old_buf = buf;
3800  int bit;
3801 
3802  if (pretty) {
3803  char buf2[256];
3804  QVector<QString> vec;
3805  size_t len;
3806 
3807  for (bit = 0; (name = pset->bitwise.name(bit)); bit++) {
3808  if ((1 << bit) & value) {
3809  // TRANS: only emphasizing a string.
3810  fc_snprintf(buf2, sizeof(buf2), _("\"%s\""), Q_(name->pretty));
3811  vec.append(buf2);
3812  }
3813  }
3814 
3815  if (0 == vec.count()) {
3816  // No value.
3817  fc_assert(0 == value);
3818  // TRANS: Bitwise setting has no bits set.
3819  fc_strlcpy(buf, _("empty value"), buf_len);
3820  return buf;
3821  }
3822  fc_strlcpy(buf, qUtf8Printable(strvec_to_and_list(vec)), buf_len);
3823  fc_strlcat(buf, " (", buf_len);
3824  len = qstrlen(buf);
3825  buf += len;
3826  buf_len -= len;
3827  }
3828 
3829  // Long support part.
3830  buf[0] = '\0';
3831  for (bit = 0; (name = pset->bitwise.name(bit)); bit++) {
3832  if ((1 << bit) & value) {
3833  if ('\0' != buf[0]) {
3834  fc_strlcat(buf, "|", buf_len);
3835  }
3836  fc_strlcat(buf, name->support, buf_len);
3837  }
3838  }
3839 
3840  if (pretty) {
3841  fc_strlcat(buf, ")", buf_len);
3842  }
3843  return old_buf;
3844 }
3845 
3853 static bool
3854 setting_bitwise_validate_base(const struct setting *pset, const char *val,
3855  unsigned *pint_val, struct connection *caller,
3856  char *reject_msg, size_t reject_msg_len)
3857 {
3858  char buf[256];
3859  const char *p;
3860  int bit;
3861 
3862  if (SST_BITWISE != pset->stype) {
3863  settings_snprintf(reject_msg, reject_msg_len,
3864  _("This setting is not a bitwise."));
3865  return false;
3866  }
3867 
3868  *pint_val = 0;
3869 
3870  // Value names are separated by '|'.
3871  do {
3872  p = strchr(val, '|');
3873  if (nullptr != p) {
3874  p++;
3875  fc_strlcpy(buf, val, MIN(p - val, sizeof(buf)));
3876  } else {
3877  // Last segment, full copy.
3878  sz_strlcpy(buf, val);
3879  }
3881  if (nullptr == p && '\0' == buf[0] && 0 == *pint_val) {
3882  // Empty string = value 0.
3883  break;
3884  } else if (!setting_match_prefix(pset->bitwise.name, buf, &bit,
3885  reject_msg, reject_msg_len)) {
3886  return false;
3887  }
3888  *pint_val |= 1 << bit;
3889  val = p;
3890  } while (nullptr != p);
3891 
3892  return (nullptr == pset->bitwise.validate
3893  || pset->bitwise.validate(*pint_val, caller, reject_msg,
3894  reject_msg_len));
3895 }
3896 
3902 bool setting_bitwise_set(struct setting *pset, const char *val,
3903  struct connection *caller, char *reject_msg,
3904  size_t reject_msg_len)
3905 {
3906  unsigned int_val;
3907 
3908  if (!setting_is_changeable(pset, caller, reject_msg, reject_msg_len)
3909  || !setting_bitwise_validate_base(pset, val, &int_val, caller,
3910  reject_msg, reject_msg_len)) {
3911  return false;
3912  }
3913 
3914  *pset->bitwise.pvalue = int_val;
3915  return true;
3916 }
3917 
3923 bool setting_bitwise_validate(const struct setting *pset, const char *val,
3924  struct connection *caller, char *reject_msg,
3925  size_t reject_msg_len)
3926 {
3927  unsigned int_val;
3928 
3929  return setting_bitwise_validate_base(pset, val, &int_val, caller,
3930  reject_msg, reject_msg_len);
3931 }
3932 
3936 int setting_bitwise_get(struct setting *pset)
3937 {
3938  fc_assert(setting_type(pset) == SST_BITWISE);
3939 
3940  return *pset->bitwise.pvalue;
3941 }
3942 
3946 const char *setting_value_name(const struct setting *pset, bool pretty,
3947  char *buf, size_t buf_len)
3948 {
3949  fc_assert_ret_val(nullptr != pset, nullptr);
3950  fc_assert_ret_val(nullptr != buf, nullptr);
3951  fc_assert_ret_val(0 < buf_len, nullptr);
3952 
3953  switch (pset->stype) {
3954  case SST_BOOL:
3955  return setting_bool_to_str(pset, *pset->boolean.pvalue, pretty, buf,
3956  buf_len);
3957  case SST_INT:
3958  return setting_int_to_str(pset, *pset->integer.pvalue, pretty, buf,
3959  buf_len);
3960  case SST_STRING:
3961  return setting_str_to_str(pset, pset->string.value, pretty, buf,
3962  buf_len);
3963  case SST_ENUM:
3964  return setting_enum_to_str(pset, read_enum_value(pset), pretty, buf,
3965  buf_len);
3966  case SST_BITWISE:
3967  return setting_bitwise_to_str(pset, *pset->bitwise.pvalue, pretty, buf,
3968  buf_len);
3969  case SST_COUNT:
3970  // Error logged below.
3971  break;
3972  }
3973 
3974  qCritical("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
3975  __FUNCTION__, setting_name(pset), setting_number(pset));
3976  return nullptr;
3977 }
3978 
3982 const char *setting_default_name(const struct setting *pset, bool pretty,
3983  char *buf, size_t buf_len)
3984 {
3985  fc_assert_ret_val(nullptr != pset, nullptr);
3986  fc_assert_ret_val(nullptr != buf, nullptr);
3987  fc_assert_ret_val(0 < buf_len, nullptr);
3988 
3989  switch (pset->stype) {
3990  case SST_BOOL:
3991  return setting_bool_to_str(pset, pset->boolean.default_value, pretty,
3992  buf, buf_len);
3993  case SST_INT:
3994  return setting_int_to_str(pset, pset->integer.default_value, pretty, buf,
3995  buf_len);
3996  case SST_STRING:
3997  return setting_str_to_str(pset, pset->string.default_value, pretty, buf,
3998  buf_len);
3999  case SST_ENUM:
4000  return setting_enum_to_str(pset, pset->enumerator.default_value, pretty,
4001  buf, buf_len);
4002  case SST_BITWISE:
4003  return setting_bitwise_to_str(pset, pset->bitwise.default_value, pretty,
4004  buf, buf_len);
4005  case SST_COUNT:
4006  // Error logged below.
4007  break;
4008  }
4009 
4010  qCritical("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
4011  __FUNCTION__, setting_name(pset), setting_number(pset));
4012  return nullptr;
4013 }
4014 
4019 {
4020  switch (pset->stype) {
4021  case SST_BOOL:
4022  (*pset->boolean.pvalue) = pset->boolean.default_value;
4023  break;
4024  case SST_INT:
4025  (*pset->integer.pvalue) = pset->integer.default_value;
4026  break;
4027  case SST_STRING:
4028  fc_strlcpy(pset->string.value, pset->string.default_value,
4029  pset->string.value_size);
4030  break;
4031  case SST_ENUM:
4032  set_enum_value(pset, pset->enumerator.default_value);
4033  break;
4034  case SST_BITWISE:
4035  (*pset->bitwise.pvalue) = pset->bitwise.default_value;
4036  break;
4037  case SST_COUNT:
4038  fc_assert(pset->stype != SST_COUNT);
4039  break;
4040  }
4041 
4042  pset->setdef = SETDEF_INTERNAL;
4043 }
4044 
4048 void setting_action(const struct setting *pset)
4049 {
4050  if (pset->action != nullptr) {
4051  pset->action(pset);
4052  }
4053 }
4054 
4058 bool settings_ruleset(struct section_file *file, const char *section,
4059  bool act)
4060 {
4061  const char *name;
4062  int j;
4063 
4064  // Unlock all settings.
4065  settings_iterate(SSET_ALL, pset)
4066  {
4067  setting_lock_set(pset, false);
4068  setting_set_to_default(pset);
4069  }
4071 
4072  // settings
4073  if (nullptr == secfile_section_by_name(file, section)) {
4074  // no settings in ruleset file
4075  qDebug("no [%s] section for game settings in %s", section,
4076  secfile_name(file));
4077  } else {
4078  for (j = 0; (name = secfile_lookup_str_default(
4079  file, nullptr, "%s.set%d.name", section, j));
4080  j++) {
4081  char path[256];
4082  fc_snprintf(path, sizeof(path), "%s.set%d", section, j);
4083 
4084  if (!setting_ruleset_one(file, name, path)) {
4085  qCritical("unknown setting in '%s': %s", secfile_name(file), name);
4086  }
4087  }
4088  }
4089 
4090  /* Execute all setting actions to consider actions due to the default
4091  * values. */
4092  if (act) {
4093  settings_iterate(SSET_ALL, pset) { setting_action(pset); }
4095  }
4096 
4098 
4099  // send game settings
4100  send_server_settings(nullptr);
4101 
4102  return true;
4103 }
4104 
4108 static bool setting_ruleset_one(struct section_file *file, const char *name,
4109  const char *path)
4110 {
4111  struct setting *pset = nullptr;
4112  char reject_msg[256], buf[256];
4113  bool lock;
4114 
4115  settings_iterate(SSET_ALL, pset_check)
4116  {
4117  if (0 == fc_strcasecmp(setting_name(pset_check), name)) {
4118  pset = pset_check;
4119  break;
4120  }
4121  }
4123 
4124  if (pset == nullptr) {
4125  // no setting found
4126  return false;
4127  }
4128 
4129  switch (pset->stype) {
4130  case SST_BOOL: {
4131  int ival;
4132  bool val;
4133 
4134  /* Allow string with same boolean representation as accepted on server
4135  * command line */
4136  if (secfile_lookup_enum_data(file, &ival, false,
4137  setting_bool_secfile_str, pset, "%s.value",
4138  path)) {
4139  val = (ival != 0);
4140  } else if (!secfile_lookup_bool(file, &val, "%s.value", path)) {
4141  qCritical("Can't read value for setting '%s': %s", name,
4142  secfile_error());
4143  break;
4144  }
4145  if (val != *pset->boolean.pvalue) {
4146  if (nullptr == pset->boolean.validate
4147  || pset->boolean.validate(val, nullptr, reject_msg,
4148  sizeof(reject_msg))) {
4149  *pset->boolean.pvalue = val;
4150  qInfo(_("Ruleset: '%s' has been set to %s."), setting_name(pset),
4151  setting_value_name(pset, true, buf, sizeof(buf)));
4152  } else {
4153  qCritical("%s", reject_msg);
4154  }
4155  }
4156  } break;
4157 
4158  case SST_INT: {
4159  int val;
4160 
4161  if (!secfile_lookup_int(file, &val, "%s.value", path)) {
4162  qCritical("Can't read value for setting '%s': %s", name,
4163  secfile_error());
4164  } else if (val != *pset->integer.pvalue) {
4165  if (setting_int_set(pset, val, nullptr, reject_msg,
4166  sizeof(reject_msg))) {
4167  qInfo(_("Ruleset: '%s' has been set to %s."), setting_name(pset),
4168  setting_value_name(pset, true, buf, sizeof(buf)));
4169  } else {
4170  qCritical("%s", reject_msg);
4171  }
4172  }
4173  } break;
4174 
4175  case SST_STRING: {
4176  const char *val = secfile_lookup_str(file, "%s.value", path);
4177 
4178  if (nullptr == val) {
4179  qCritical("Can't read value for setting '%s': %s", name,
4180  secfile_error());
4181  } else if (0 != strcmp(val, pset->string.value)) {
4182  if (setting_str_set(pset, val, nullptr, reject_msg,
4183  sizeof(reject_msg))) {
4184  qInfo(_("Ruleset: '%s' has been set to %s."), setting_name(pset),
4185  setting_value_name(pset, true, buf, sizeof(buf)));
4186  } else {
4187  qCritical("%s", reject_msg);
4188  }
4189  }
4190  } break;
4191 
4192  case SST_ENUM: {
4193  int val;
4194 
4195  if (!secfile_lookup_enum_data(file, &val, false,
4196  setting_enum_secfile_str, pset, "%s.value",
4197  path)) {
4198  qCritical("Can't read value for setting '%s': %s", name,
4199  secfile_error());
4200  } else if (val != read_enum_value(pset)) {
4201  if (nullptr == pset->enumerator.validate
4202  || pset->enumerator.validate(val, nullptr, reject_msg,
4203  sizeof(reject_msg))) {
4204  set_enum_value(pset, val);
4205  qInfo(_("Ruleset: '%s' has been set to %s."), setting_name(pset),
4206  setting_value_name(pset, true, buf, sizeof(buf)));
4207  } else {
4208  qCritical("%s", reject_msg);
4209  }
4210  }
4211  } break;
4212 
4213  case SST_BITWISE: {
4214  int val;
4215 
4216  if (!secfile_lookup_enum_data(file, &val, true,
4218  "%s.value", path)) {
4219  qCritical("Can't read value for setting '%s': %s", name,
4220  secfile_error());
4221  } else if (val != *pset->bitwise.pvalue) {
4222  if (nullptr == pset->bitwise.validate
4223  || pset->bitwise.validate(static_cast<unsigned>(val), nullptr,
4224  reject_msg, sizeof(reject_msg))) {
4225  *pset->bitwise.pvalue = val;
4226  qInfo(_("Ruleset: '%s' has been set to %s."), setting_name(pset),
4227  setting_value_name(pset, true, buf, sizeof(buf)));
4228  } else {
4229  qCritical("%s", reject_msg);
4230  }
4231  }
4232  } break;
4233 
4234  case SST_COUNT:
4235  fc_assert(pset->stype != SST_COUNT);
4236  break;
4237  }
4238 
4239  pset->setdef = SETDEF_RULESET;
4240 
4241  // set lock
4242  lock = secfile_lookup_bool_default(file, false, "%s.lock", path);
4243 
4244  if (lock) {
4245  // set lock
4246  setting_lock_set(pset, lock);
4247  qInfo(_("Ruleset: '%s' has been locked by the ruleset."),
4248  setting_name(pset));
4249  }
4250 
4251  return true;
4252 }
4253 
4257 bool setting_non_default(const struct setting *pset)
4258 {
4259  switch (setting_type(pset)) {
4260  case SST_BOOL:
4261  return (*pset->boolean.pvalue != pset->boolean.default_value);
4262  case SST_INT:
4263  return (*pset->integer.pvalue != pset->integer.default_value);
4264  case SST_STRING:
4265  return (0 != strcmp(pset->string.value, pset->string.default_value));
4266  case SST_ENUM:
4267  return (read_enum_value(pset) != pset->enumerator.default_value);
4268  case SST_BITWISE:
4269  return (*pset->bitwise.pvalue != pset->bitwise.default_value);
4270  case SST_COUNT:
4271  // Error logged below.
4272  break;
4273  }
4274 
4275  qCritical("%s(): Setting \"%s\" (nb %d) not handled in switch statement.",
4276  __FUNCTION__, setting_name(pset), setting_number(pset));
4277  return false;
4278 }
4279 
4283 bool setting_locked(const struct setting *pset) { return pset->locked; }
4284 
4288 void setting_lock_set(struct setting *pset, bool lock)
4289 {
4290  pset->locked = lock;
4291 }
4292 
4296 static void setting_game_set(struct setting *pset, bool init)
4297 {
4298  switch (setting_type(pset)) {
4299  case SST_BOOL:
4300  pset->boolean.game_value = *pset->boolean.pvalue;
4301  break;
4302 
4303  case SST_INT:
4304  pset->integer.game_value = *pset->integer.pvalue;
4305  break;
4306 
4307  case SST_STRING:
4308  if (init) {
4309  pset->string.game_value = new char[pset->string.value_size]{};
4310  }
4311  fc_strlcpy(pset->string.game_value, pset->string.value,
4312  pset->string.value_size);
4313  break;
4314 
4315  case SST_ENUM:
4316  pset->enumerator.game_value = read_enum_value(pset);
4317  break;
4318 
4319  case SST_BITWISE:
4320  pset->bitwise.game_value = *pset->bitwise.pvalue;
4321  break;
4322 
4323  case SST_COUNT:
4324  fc_assert(setting_type(pset) != SST_COUNT);
4325  break;
4326  }
4327 }
4328 
4332 static void setting_game_free(struct setting *pset)
4333 {
4334  if (setting_type(pset) == SST_STRING) {
4335  delete[] pset->string.game_value;
4336  pset->string.game_value = nullptr;
4337  }
4338 }
4339 
4343 static void setting_game_restore(struct setting *pset)
4344 {
4345  char reject_msg[256] = "", buf[256];
4346  bool res = false;
4347 
4348  if (!setting_is_changeable(pset, nullptr, reject_msg,
4349  sizeof(reject_msg))) {
4350  log_debug("Can't restore '%s': %s", setting_name(pset), reject_msg);
4351  return;
4352  }
4353 
4354  switch (setting_type(pset)) {
4355  case SST_BOOL:
4356  res = (nullptr
4357  != setting_bool_to_str(pset, pset->boolean.game_value, false,
4358  buf, sizeof(buf))
4359  && setting_bool_set(pset, buf, nullptr, reject_msg,
4360  sizeof(reject_msg)));
4361  break;
4362 
4363  case SST_INT:
4364  res = setting_int_set(pset, pset->integer.game_value, nullptr,
4365  reject_msg, sizeof(reject_msg));
4366  break;
4367 
4368  case SST_STRING:
4369  res = setting_str_set(pset, pset->string.game_value, nullptr, reject_msg,
4370  sizeof(reject_msg));
4371  break;
4372 
4373  case SST_ENUM:
4374  res = (nullptr
4375  != setting_enum_to_str(pset, pset->enumerator.game_value,
4376  false, buf, sizeof(buf))
4377  && setting_enum_set(pset, buf, nullptr, reject_msg,
4378  sizeof(reject_msg)));
4379  break;
4380 
4381  case SST_BITWISE:
4382  res = (nullptr
4383  != setting_bitwise_to_str(pset, pset->bitwise.game_value,
4384  false, buf, sizeof(buf))
4385  && setting_bitwise_set(pset, buf, nullptr, reject_msg,
4386  sizeof(reject_msg)));
4387  break;
4388 
4389  case SST_COUNT:
4390  res = false;
4391  break;
4392  }
4393 
4394  if (!res) {
4395  qCritical(
4396  "Error restoring setting '%s' to the value from game start: %s",
4397  setting_name(pset), reject_msg);
4398  }
4399 }
4400 
4405 {
4406  settings_iterate(SSET_ALL, pset) { setting_game_set(pset, false); }
4408 
4409  // Settings from the start of the game are saved.
4410  game.server.settings_gamestart_valid = true;
4411 }
4412 
4416 void settings_game_save(struct section_file *file, const char *section)
4417 {
4418  int set_count = 0;
4419 
4420  settings_iterate(SSET_ALL, pset)
4421  {
4422  char errbuf[200];
4423 
4424  if ( // It's explicitly set to some value to save
4426  /* It must be same at loading time as it was saving time, even if
4427  freeciv's default has changed. */
4428  || !setting_is_free_to_change(pset, errbuf, sizeof(errbuf))) {
4429  secfile_insert_str(file, setting_name(pset), "%s.set%d.name", section,
4430  set_count);
4431  switch (setting_type(pset)) {
4432  case SST_BOOL:
4433  secfile_insert_bool(file, *pset->boolean.pvalue, "%s.set%d.value",
4434  section, set_count);
4435  secfile_insert_bool(file, pset->boolean.game_value,
4436  "%s.set%d.gamestart", section, set_count);
4437  break;
4438  case SST_INT:
4439  secfile_insert_int(file, *pset->integer.pvalue, "%s.set%d.value",
4440  section, set_count);
4441  secfile_insert_int(file, pset->integer.game_value,
4442  "%s.set%d.gamestart", section, set_count);
4443  break;
4444  case SST_STRING:
4445  secfile_insert_str(file, pset->string.value, "%s.set%d.value",
4446  section, set_count);
4447  secfile_insert_str(file, pset->string.game_value,
4448  "%s.set%d.gamestart", section, set_count);
4449  break;
4450  case SST_ENUM:
4451  secfile_insert_enum_data(file, read_enum_value(pset), false,
4453  "%s.set%d.value", section, set_count);
4454  secfile_insert_enum_data(file, pset->enumerator.game_value, false,
4456  "%s.set%d.gamestart", section, set_count);
4457  break;
4458  case SST_BITWISE:
4459  secfile_insert_enum_data(file, *pset->bitwise.pvalue, true,
4461  "%s.set%d.value", section, set_count);
4462  secfile_insert_enum_data(file, pset->bitwise.game_value, true,
4464  "%s.set%d.gamestart", section, set_count);
4465  break;
4466  case SST_COUNT:
4467  fc_assert(setting_type(pset) != SST_COUNT);
4468  secfile_insert_str(file, "Unknown setting type", "%s.set%d.value",
4469  section, set_count);
4470  secfile_insert_str(file, "Unknown setting type",
4471  "%s.set%d.gamestart", section, set_count);
4472  break;
4473  }
4474  set_count++;
4475  }
4476  }
4478 
4479  secfile_insert_int(file, set_count, "%s.set_count", section);
4480  secfile_insert_bool(file, game.server.settings_gamestart_valid,
4481  "%s.gamestart_valid", section);
4482 }
4483 
4487 void settings_game_load(struct section_file *file, const char *section)
4488 {
4489  const char *name;
4490  char reject_msg[256], buf[256];
4491  int i, set_count;
4492  int oldcitymindist = game.info.citymindist; // backwards compat, see below
4493 
4494  /* Compatibility with savegames created with older versions is usually
4495  * handled as conversions in savecompat.c compat_load_<version>() */
4496 
4497  if (!secfile_lookup_int(file, &set_count, "%s.set_count", section)) {
4498  // Old savegames and scenarios doesn't contain this, not an error.
4499  qDebug("Can't read the number of settings in the save file.");
4500  return;
4501  }
4502 
4503  // Check if the saved settings are valid settings from game start.
4504  game.server.settings_gamestart_valid = secfile_lookup_bool_default(
4505  file, false, "%s.gamestart_valid", section);
4506 
4507  for (i = 0; i < set_count; i++) {
4508  name = secfile_lookup_str(file, "%s.set%d.name", section, i);
4509 
4510  settings_iterate(SSET_ALL, pset)
4511  {
4512  if (fc_strcasecmp(setting_name(pset), name) != 0) {
4513  continue;
4514  }
4515 
4516  // Load the current value of the setting.
4517  switch (pset->stype) {
4518  case SST_BOOL: {
4519  bool val;
4520 
4521  if (!secfile_lookup_bool(file, &val, "%s.set%d.value", section, i)) {
4522  qDebug("Option '%s' not defined in the savegame: %s", name,
4523  secfile_error());
4524  } else {
4525  pset->setdef = SETDEF_CHANGED;
4526 
4527  if (val != *pset->boolean.pvalue) {
4528  if (setting_is_changeable(pset, nullptr, reject_msg,
4529  sizeof(reject_msg))
4530  && (nullptr == pset->boolean.validate
4531  || pset->boolean.validate(val, nullptr, reject_msg,
4532  sizeof(reject_msg)))) {
4533  *pset->boolean.pvalue = val;
4534  qInfo(_("Savegame: '%s' has been set to %s."),
4535  setting_name(pset),
4536  setting_value_name(pset, true, buf, sizeof(buf)));
4537  } else {
4538  qCritical("Savegame: error restoring '%s' . (%s)",
4539  setting_name(pset), reject_msg);
4540  }
4541  } else {
4542  qInfo(
4543  _("Savegame: '%s' explicitly set to value same as default."),
4544  setting_name(pset));
4545  }
4546  }
4547  } break;
4548 
4549  case SST_INT: {
4550  int val;
4551 
4552  if (!secfile_lookup_int(file, &val, "%s.set%d.value", section, i)) {
4553  qDebug("Option '%s' not defined in the savegame: %s", name,
4554  secfile_error());
4555  } else {
4556  pset->setdef = SETDEF_CHANGED;
4557 
4558  if (val != *pset->integer.pvalue) {
4559  if (setting_is_changeable(pset, nullptr, reject_msg,
4560  sizeof(reject_msg))
4561  && (nullptr == pset->integer.validate
4562  || pset->integer.validate(val, nullptr, reject_msg,
4563  sizeof(reject_msg)))) {
4564  *pset->integer.pvalue = val;
4565  qInfo(_("Savegame: '%s' has been set to %s."),
4566  setting_name(pset),
4567  setting_value_name(pset, true, buf, sizeof(buf)));
4568  } else {
4569  qCritical("Savegame: error restoring '%s' . (%s)",
4570  setting_name(pset), reject_msg);
4571  }
4572  } else {
4573  qInfo(
4574  _("Savegame: '%s' explicitly set to value same as default."),
4575  setting_name(pset));
4576  }
4577  }
4578  } break;
4579 
4580  case SST_STRING: {
4581  const char *val =
4582  secfile_lookup_str(file, "%s.set%d.value", section, i);
4583 
4584  if (nullptr == val) {
4585  qDebug("Option '%s' not defined in the savegame: %s", name,
4586  secfile_error());
4587  } else {
4588  pset->setdef = SETDEF_CHANGED;
4589 
4590  if (0 != strcmp(val, pset->string.value)) {
4591  if (setting_str_set(pset, val, nullptr, reject_msg,
4592  sizeof(reject_msg))) {
4593  qInfo(_("Savegame: '%s' has been set to %s."),
4594  setting_name(pset),
4595  setting_value_name(pset, true, buf, sizeof(buf)));
4596  } else {
4597  qCritical("Savegame: error restoring '%s' . (%s)",
4598  setting_name(pset), reject_msg);
4599  }
4600  } else {
4601  qInfo(
4602  _("Savegame: '%s' explicitly set to value same as default."),
4603  setting_name(pset));
4604  }
4605  }
4606  } break;
4607 
4608  case SST_ENUM: {
4609  int val;
4610 
4611  if (!secfile_lookup_enum_data(file, &val, false,
4613  "%s.set%d.value", section, i)) {
4614  qDebug("Option '%s' not defined in the savegame: %s", name,
4615  secfile_error());
4616  } else {
4617  pset->setdef = SETDEF_CHANGED;
4618 
4619  if (val != read_enum_value(pset)) {
4620  if (setting_is_changeable(pset, nullptr, reject_msg,
4621  sizeof(reject_msg))
4622  && (nullptr == pset->enumerator.validate
4623  || pset->enumerator.validate(val, nullptr, reject_msg,
4624  sizeof(reject_msg)))) {
4625  set_enum_value(pset, val);
4626  qInfo(_("Savegame: '%s' has been set to %s."),
4627  setting_name(pset),
4628  setting_value_name(pset, true, buf, sizeof(buf)));
4629  } else {
4630  qCritical("Savegame: error restoring '%s' . (%s)",
4631  setting_name(pset), reject_msg);
4632  }
4633  } else {
4634  qInfo(
4635  _("Savegame: '%s' explicitly set to value same as default."),
4636  setting_name(pset));
4637  }
4638  }
4639  } break;
4640 
4641  case SST_BITWISE: {
4642  int val;
4643 
4644  if (!secfile_lookup_enum_data(file, &val, true,
4646  "%s.set%d.value", section, i)) {
4647  qDebug("Option '%s' not defined in the savegame: %s", name,
4648  secfile_error());
4649  } else {
4650  pset->setdef = SETDEF_CHANGED;
4651 
4652  if (val != *pset->bitwise.pvalue) {
4653  if (setting_is_changeable(pset, nullptr, reject_msg,
4654  sizeof(reject_msg))
4655  && (nullptr == pset->bitwise.validate
4656  || pset->bitwise.validate(val, nullptr, reject_msg,
4657  sizeof(reject_msg)))) {
4658  *pset->bitwise.pvalue = val;
4659  qInfo(_("Savegame: '%s' has been set to %s."),
4660  setting_name(pset),
4661  setting_value_name(pset, true, buf, sizeof(buf)));
4662  } else {
4663  qCritical("Savegame: error restoring '%s' . (%s)",
4664  setting_name(pset), reject_msg);
4665  }
4666  } else {
4667  qInfo(
4668  _("Savegame: '%s' explicitly set to value same as default."),
4669  setting_name(pset));
4670  }
4671  }
4672  } break;
4673 
4674  case SST_COUNT:
4675  fc_assert(pset->stype != SST_COUNT);
4676  break;
4677  }
4678 
4679  if (game.server.settings_gamestart_valid) {
4680  // Load the value of the setting at the start of the game.
4681  switch (pset->stype) {
4682  case SST_BOOL:
4683  pset->boolean.game_value = secfile_lookup_bool_default(
4684  file, *pset->boolean.pvalue, "%s.set%d.gamestart", section, i);
4685  break;
4686 
4687  case SST_INT:
4688  pset->integer.game_value = secfile_lookup_int_default(
4689  file, *pset->integer.pvalue, "%s.set%d.gamestart", section, i);
4690  break;
4691 
4692  case SST_STRING:
4693  fc_strlcpy(pset->string.game_value,
4694  secfile_lookup_str_default(file, pset->string.value,
4695  "%s.set%d.gamestart",
4696  section, i),
4697  pset->string.value_size);
4698  break;
4699 
4700  case SST_ENUM:
4701  pset->enumerator.game_value = secfile_lookup_enum_default_data(
4702  file, read_enum_value(pset), false, setting_enum_secfile_str,
4703  pset, "%s.set%d.gamestart", section, i);
4704  break;
4705 
4706  case SST_BITWISE:
4707  pset->bitwise.game_value = secfile_lookup_enum_default_data(
4708  file, *pset->bitwise.pvalue, true, setting_bitwise_secfile_str,
4709  pset, "%s.set%d.gamestart", section, i);
4710  break;
4711 
4712  case SST_COUNT:
4713  fc_assert(pset->stype != SST_COUNT);
4714  break;
4715  }
4716 
4717  pset->setdef = SETDEF_CHANGED;
4718  }
4719  }
4721  }
4722 
4723  /* Backwards compatibility for pre-2.4 savegames: citymindist=0 used to
4724  * mean take from ruleset min_dist_bw_cities, but that no longer exists.
4725  * This is here rather than in savegame2.c compat functions, as we need to
4726  * have loaded the relevant ruleset to know what to set it to (the ruleset
4727  * and any 'citymindist' setting it contains will have been loaded before
4728  * this function was called). */
4729  if (game.info.citymindist == 0) {
4730  game.info.citymindist = oldcitymindist;
4731  }
4732 
4733  settings_iterate(SSET_ALL, pset)
4734  {
4735  /* Have to do this at the end due to dependencies ('aifill' and
4736  * 'maxplayer'). */
4737  setting_action(pset);
4738  }
4740 }
4741 
4746 {
4747  if (!game.server.settings_gamestart_valid) {
4748  log_debug("No saved settings from the game start available.");
4749  return false;
4750  }
4751 
4752  settings_iterate(SSET_ALL, pset) { setting_game_restore(pset); }
4754 
4755  return true;
4756 }
4757 
4761 void settings_init(bool act)
4762 {
4764 
4765  settings_iterate(SSET_ALL, pset)
4766  {
4767  setting_lock_set(pset, false);
4768  setting_set_to_default(pset);
4769  setting_game_set(pset, true);
4770  if (act) {
4771  setting_action(pset);
4772  }
4773  }
4775 
4777 }
4778 
4783 {
4784  settings_iterate(SSET_ALL, pset)
4785  {
4786  if (setting_is_changeable(pset, nullptr, nullptr, 0)) {
4787  setting_set_to_default(pset);
4788  setting_action(pset);
4789  }
4790  }
4792 }
4793 
4799 { // Nothing at the moment.
4800 }
4801 
4806 {
4807  settings_iterate(SSET_ALL, pset) { setting_game_free(pset); }
4809 
4811 }
4812 
4817 
4822 void send_server_setting(struct conn_list *dest, const struct setting *pset)
4823 {
4824  if (!dest) {
4825  dest = game.est_connections;
4826  }
4827 
4828 #define PACKET_COMMON_INIT(packet, pset, pconn) \
4829  memset(&packet, 0, sizeof(packet)); \
4830  packet.id = setting_number(pset); \
4831  packet.is_visible = setting_is_visible(pset, pconn); \
4832  packet.is_changeable = setting_is_changeable(pset, pconn, nullptr, 0); \
4833  packet.initial_setting = game.info.is_new_game; \
4834  packet.setdef = setting_get_setdef(pset);
4835 
4836  switch (setting_type(pset)) {
4837  case SST_BOOL: {
4838  struct packet_server_setting_bool packet;
4839 
4840  conn_list_iterate(dest, pconn)
4841  {
4842  PACKET_COMMON_INIT(packet, pset, pconn);
4843  if (packet.is_visible) {
4844  packet.val = *pset->boolean.pvalue;
4845  packet.default_val = pset->boolean.default_value;
4846  }
4847  send_packet_server_setting_bool(pconn, &packet);
4848  }
4850  } break;
4851  case SST_INT: {
4852  struct packet_server_setting_int packet;
4853 
4854  conn_list_iterate(dest, pconn)
4855  {
4856  PACKET_COMMON_INIT(packet, pset, pconn);
4857  if (packet.is_visible) {
4858  packet.val = *pset->integer.pvalue;
4859  packet.default_val = pset->integer.default_value;
4860  packet.min_val = pset->integer.min_value;
4861  packet.max_val = pset->integer.max_value;
4862  }
4863  send_packet_server_setting_int(pconn, &packet);
4864  }
4866  } break;
4867  case SST_STRING: {
4868  struct packet_server_setting_str packet;
4869 
4870  conn_list_iterate(dest, pconn)
4871  {
4872  PACKET_COMMON_INIT(packet, pset, pconn);
4873  if (packet.is_visible) {
4874  sz_strlcpy(packet.val, pset->string.value);
4875  sz_strlcpy(packet.default_val, pset->string.default_value);
4876  }
4877  send_packet_server_setting_str(pconn, &packet);
4878  }
4880  } break;
4881  case SST_ENUM: {
4882  struct packet_server_setting_enum packet;
4883  const struct sset_val_name *val_name;
4884  int i;
4885 
4886  conn_list_iterate(dest, pconn)
4887  {
4888  PACKET_COMMON_INIT(packet, pset, pconn);
4889  if (packet.is_visible) {
4890  packet.val = read_enum_value(pset);
4891  packet.default_val = pset->enumerator.default_value;
4892  for (i = 0; (val_name = pset->enumerator.name(i)); i++) {
4893  sz_strlcpy(packet.support_names[i], val_name->support);
4894  // Send untranslated string
4895  sz_strlcpy(packet.pretty_names[i], val_name->pretty);
4896  }
4897  packet.values_num = i;
4898  fc_assert(i <= ARRAY_SIZE(packet.support_names));
4899  fc_assert(i <= ARRAY_SIZE(packet.pretty_names));
4900  }
4901  send_packet_server_setting_enum(pconn, &packet);
4902  }
4904  } break;
4905  case SST_BITWISE: {
4906  struct packet_server_setting_bitwise packet;
4907  const struct sset_val_name *val_name;
4908  int i;
4909 
4910  conn_list_iterate(dest, pconn)
4911  {
4912  PACKET_COMMON_INIT(packet, pset, pconn);
4913  if (packet.is_visible) {
4914  packet.val = *pset->bitwise.pvalue;
4915  packet.default_val = pset->bitwise.default_value;
4916  for (i = 0; (val_name = pset->bitwise.name(i)); i++) {
4917  sz_strlcpy(packet.support_names[i], val_name->support);
4918  // Send untranslated string
4919  sz_strlcpy(packet.pretty_names[i], val_name->pretty);
4920  }
4921  packet.bits_num = i;
4922  fc_assert(i <= ARRAY_SIZE(packet.support_names));
4923  fc_assert(i <= ARRAY_SIZE(packet.pretty_names));
4924  }
4925  send_packet_server_setting_bitwise(pconn, &packet);
4926  }
4928  } break;
4929 
4930  case SST_COUNT:
4931  fc_assert(setting_type(pset) != SST_COUNT);
4932  break;
4933  }
4934 
4935 #undef PACKET_INIT
4936 }
4937 
4941 void send_server_settings(struct conn_list *dest)
4942 {
4943  settings_iterate(SSET_ALL, pset) { send_server_setting(dest, pset); }
4945 }
4946 
4952 void send_server_access_level_settings(struct conn_list *dest,
4953  enum cmdlevel old_level,
4954  enum cmdlevel new_level)
4955 {
4956  enum cmdlevel min_level;
4957  enum cmdlevel max_level;
4958 
4959  if (old_level == new_level) {
4960  return;
4961  }
4962 
4963  if (old_level < new_level) {
4964  min_level = old_level;
4965  max_level = new_level;
4966  } else {
4967  min_level = new_level;
4968  max_level = old_level;
4969  }
4970 
4971  settings_iterate(SSET_ALL, pset)
4972  {
4973  if ((pset->access_level_read >= min_level
4974  && pset->access_level_read <= max_level)
4975  || (pset->access_level_write >= min_level
4976  && pset->access_level_write <= max_level)) {
4977  send_server_setting(dest, pset);
4978  }
4979  }
4981 }
4982 
4987 {
4988  struct packet_server_setting_control control;
4989  struct packet_server_setting_const setting;
4990  int i;
4991 
4992  control.settings_num = SETTINGS_NUM;
4993 
4994  // Fill in the category strings.
4995  fc_assert(SSET_NUM_CATEGORIES <= ARRAY_SIZE(control.category_names));
4996  control.categories_num = SSET_NUM_CATEGORIES;
4997  for (i = 0; i < SSET_NUM_CATEGORIES; i++) {
4998  // Send untranslated name
4999  sz_strlcpy(control.category_names[i],
5000  sset_category_name(sset_category(i)));
5001  }
5002 
5003  // Send off the control packet.
5004  send_packet_server_setting_control(pconn, &control);
5005 
5006  // Send the constant and common part of the settings.
5007  settings_iterate(SSET_ALL, pset)
5008  {
5009  setting.id = setting_number(pset);
5011  // Send untranslated strings to client
5014  setting.category = pset->scategory;
5015 
5016  send_packet_server_setting_const(pconn, &setting);
5017  }
5019 }
5020 
5024 static void settings_list_init()
5025 {
5026  struct setting *pset;
5027  int i;
5028 
5029  fc_assert_ret(setting_sorted.init == false);
5030 
5031  // Do it for all values of enum sset_level.
5032  for (i = 0; i < OLEVELS_NUM; i++) {
5033  setting_sorted.level[i] = setting_list_new();
5034  }
5035 
5036  for (i = 0; (pset = setting_by_number(i)); i++) {
5037  // Add the setting to the list of all settings.
5038  setting_list_append(setting_sorted.level[SSET_ALL], pset);
5039 
5040  switch (setting_level(pset)) {
5041  case SSET_NONE:
5042  // No setting should be in this level.
5043  fc_assert_msg(setting_level(pset) != SSET_NONE,
5044  "No setting level defined for '%s'.",
5045  setting_name(pset));
5046  break;
5047  case SSET_ALL:
5048  // Done above - list of all settings.
5049  break;
5050  case SSET_VITAL:
5051  setting_list_append(setting_sorted.level[SSET_VITAL], pset);
5052  break;
5053  case SSET_SITUATIONAL:
5054  setting_list_append(setting_sorted.level[SSET_SITUATIONAL], pset);
5055  break;
5056  case SSET_RARE:
5057  setting_list_append(setting_sorted.level[SSET_RARE], pset);
5058  break;
5059  case SSET_CHANGED:
5060  case SSET_LOCKED:
5061  // This is done in settings_list_update.
5062  break;
5063  case OLEVELS_NUM:
5064  // No setting should be in this level.
5065  fc_assert_msg(setting_level(pset) != OLEVELS_NUM,
5066  "Invalid setting level for '%s' (%s).",
5067  setting_name(pset),
5068  sset_level_name(setting_level(pset)));
5069  break;
5070  }
5071  }
5072 
5073  // Sort the lists.
5074  for (i = 0; i < OLEVELS_NUM; i++) {
5075  setting_list_sort(setting_sorted.level[i], settings_list_cmp);
5076  }
5077 
5078  setting_sorted.init = true;
5079 }
5080 
5085 {
5086  struct setting *pset;
5087  int i;
5088 
5089  fc_assert_ret(setting_sorted.init == true);
5090 
5091  // Clear the lists for changed and locked values.
5092  setting_list_clear(setting_sorted.level[SSET_CHANGED]);
5093  setting_list_clear(setting_sorted.level[SSET_LOCKED]);
5094 
5095  // Refill them.
5096  for (i = 0; (pset = setting_by_number(i)); i++) {
5097  if (setting_non_default(pset)) {
5098  setting_list_append(setting_sorted.level[SSET_CHANGED], pset);
5099  }
5100  if (setting_locked(pset)) {
5101  setting_list_append(setting_sorted.level[SSET_LOCKED], pset);
5102  }
5103  }
5104 
5105  // Sort them.
5106  setting_list_sort(setting_sorted.level[SSET_CHANGED], settings_list_cmp);
5107  setting_list_sort(setting_sorted.level[SSET_LOCKED], settings_list_cmp);
5108 }
5109 
5113 int settings_list_cmp(const struct setting *const *ppset1,
5114  const struct setting *const *ppset2)
5115 {
5116  const struct setting *pset1 = *ppset1;
5117  const struct setting *pset2 = *ppset2;
5118 
5119  return fc_strcasecmp(setting_name(pset1), setting_name(pset2));
5120 }
5121 
5126 struct setting_list *settings_list_get(enum sset_level level)
5127 {
5128  fc_assert_ret_val(setting_sorted.init == true, nullptr);
5129  fc_assert_ret_val(setting_sorted.level[level] != nullptr, nullptr);
5130  fc_assert_ret_val(sset_level_is_valid(level), nullptr);
5131 
5132  return setting_sorted.level[level];
5133 }
5134 
5138 static void settings_list_free()
5139 {
5140  int i;
5141 
5142  fc_assert_ret(setting_sorted.init == true);
5143 
5144  // Free the lists.
5145  for (i = 0; i < OLEVELS_NUM; i++) {
5146  setting_list_destroy(setting_sorted.level[i]);
5147  }
5148 
5149  setting_sorted.init = false;
5150 }
5151 
5155 void setting_changed(struct setting *pset) { pset->setdef = SETDEF_CHANGED; }
5156 
5160 enum setting_default_level setting_get_setdef(const struct setting *pset)
5161 {
5162  return pset->setdef;
5163 }
QString strvec_to_and_list(const QVector< QString > &psv)
Definition: astring.cpp:43
bool BV_ISSET(const BV &bv, int bit)
Definition: bitvector.h:37
#define conn_list_iterate(connlist, pconn)
Definition: connection.h:99
#define conn_list_iterate_end
Definition: connection.h:101
@ TDM_FIXED
Definition: fc_types.h:869
@ TDM_EVEN
Definition: fc_types.h:869
@ DIPLO_NO_MIXED
Definition: fc_types.h:877
@ DIPLO_FOR_TEAMS
Definition: fc_types.h:878
@ DIPLO_NO_AIS
Definition: fc_types.h:876
@ DIPLO_FOR_HUMANS
Definition: fc_types.h:874
@ DIPLO_FOR_ALL
Definition: fc_types.h:873
@ DIPLO_FOR_AIS
Definition: fc_types.h:875
@ DIPLO_DISABLED
Definition: fc_types.h:879
setting_default_level
Definition: fc_types.h:1147
@ SETDEF_RULESET
Definition: fc_types.h:1149
@ SETDEF_INTERNAL
Definition: fc_types.h:1148
@ SETDEF_CHANGED
Definition: fc_types.h:1150
@ REVOLEN_RANDOM
Definition: fc_types.h:1089
@ REVOLEN_RANDQUICK
Definition: fc_types.h:1091
@ REVOLEN_FIXED
Definition: fc_types.h:1088
@ REVOLEN_QUICKENING
Definition: fc_types.h:1090
int Unit_Class_id
Definition: fc_types.h:333
@ HB_ALLIANCE
Definition: fc_types.h:1094
@ HB_DISABLED
Definition: fc_types.h:1094
@ HB_NATIONAL
Definition: fc_types.h:1094
@ VC_SPACERACE
Definition: fc_types.h:1083
@ VC_CULTURE
Definition: fc_types.h:1083
@ VC_ALLIED
Definition: fc_types.h:1083
@ BORDERS_ENABLED
Definition: fc_types.h:864
@ BORDERS_DISABLED
Definition: fc_types.h:863
@ BORDERS_SEE_INSIDE
Definition: fc_types.h:865
@ BORDERS_EXPAND
Definition: fc_types.h:866
#define Q_(String)
Definition: fcintl.h:53
#define _(String)
Definition: fcintl.h:50
#define N_(String)
Definition: fcintl.h:52
const struct ft_color ftc_server
struct civ_game game
Definition: game.cpp:47
struct world wld
Definition: game.cpp:48
int generate_save_name(const char *format, char *buf, int buflen, const char *reason)
Generate a default save file name and place it in the provided buffer.
Definition: game.cpp:756
#define GAME_DEFAULT_TECHPENALTY
Definition: game.h:513
#define GAME_MAX_RAPTUREDELAY
Definition: game.h:465
#define GAME_DEFAULT_START_CITY
Definition: game.h:342
#define GAME_DEFAULT_KILLSTACK
Definition: game.h:506
@ BARBS_HUTS_ONLY
Definition: game.h:33
@ BARBS_FREQUENT
Definition: game.h:35
@ BARBS_NORMAL
Definition: game.h:34
@ BARBS_DISABLED
Definition: game.h:32
@ BARBS_HORDES
Definition: game.h:36
#define GAME_MAX_DIPLCHANCE
Definition: game.h:424
#define GAME_MAX_SCIENCEBOX
Definition: game.h:382
#define GAME_MAX_EVENT_CACHE_MAX_SIZE
Definition: game.h:659
#define GAME_DEFAULT_REVOLENTYPE
Definition: game.h:675
#define GAME_DEFAULT_AUTO_AI_TOGGLE
Definition: game.h:553
#define GAME_MIN_RAZECHANCE
Definition: game.h:529
#define GAME_MIN_GLOBAL_WARMING_PERCENT
Definition: game.h:407
#define GAME_DEFAULT_CARAVAN_BONUS_STYLE
Definition: game.h:610
#define GAME_MIN_SEED
Definition: game.h:334
#define GAME_MAX_TECHLOSSFG
Definition: game.h:436
#define GAME_DEFAULT_EVENT_CACHE_INFO
Definition: game.h:663
#define GAME_DEFAULT_MGR_FOODNEEDED
Definition: game.h:485
#define GAME_DEFAULT_TECHLOST_DONOR
Definition: game.h:521
#define GAME_DEFAULT_ALLOWED_CITY_NAMES
Definition: game.h:671
#define GAME_MIN_TRADEWORLDRELPCT
Definition: game.h:599
#define GAME_DEFAULT_SCORELOG
Definition: game.h:534
#define GAME_MAX_KILLUNHOMED
Definition: game.h:511
#define GAME_MIN_TECHLOST_RECV
Definition: game.h:518
#define GAME_MIN_FREECOST
Definition: game.h:427
#define GAME_MAX_CONTACTTURNS
Definition: game.h:459
#define GAME_MIN_SPACESHIP_TRAVEL_TIME
Definition: game.h:548
#define GAME_MAX_TECHLOST_RECV
Definition: game.h:519
#define GAME_DEFAULT_OCCUPYCHANCE
Definition: game.h:624
#define GAME_DEFAULT_USER_META_MESSAGE
Definition: game.h:644
#define GAME_MAX_FOODBOX
Definition: game.h:374
#define GAME_DEFAULT_GLOBAL_WARMING_PERCENT
Definition: game.h:406
#define GAME_DEFAULT_TRADING_TECH
Definition: game.h:606
#define GAME_MIN_SCIENCEBOX
Definition: game.h:381
#define GAME_MAX_PINGTIMEOUT
Definition: game.h:592
#define GAME_MAX_SAVEFREQUENCY
Definition: game.h:637
#define GAME_MIN_REVOLUTION_LENGTH
Definition: game.h:677
#define GAME_MAX_MGR_TURNINTERVAL
Definition: game.h:483
#define GAME_DEFAULT_SAVETURNS
Definition: game.h:632
#define GAME_DEFAULT_BORDERS
Definition: game.h:416
#define GAME_DEFAULT_AIRLIFTINGSTYLE
Definition: game.h:682
#define GAME_MAX_CONQUERCOST
Definition: game.h:432
#define GAME_MAX_AQUEDUCTLOSS
Definition: game.h:504
#define GAME_DEFAULT_KILLUNHOMED
Definition: game.h:509
#define GAME_DEFAULT_SCIENCEBOX
Definition: game.h:380
#define GAME_MIN_DIPLGOLDCOST
Definition: game.h:389
#define GAME_DEFAULT_MGR_WORLDCHANCE
Definition: game.h:498
#define GAME_MIN_PINGTIME
Definition: game.h:587
#define GAME_DEFAULT_ONSETBARBARIAN
Definition: game.h:620
#define GAME_MIN_ONSETBARBARIAN
Definition: game.h:621
#define GAME_MAX_TECHLOSSREST
Definition: game.h:440
#define GAME_DEFAULT_KILLCITIZEN
Definition: game.h:507
#define GAME_MIN_INCITE_GOLD_LOSS_CHANCE
Definition: game.h:393
#define GAME_MIN_MGR_NATIONCHANCE
Definition: game.h:495
#define GAME_DEFAULT_NATIONSET
Definition: game.h:370
#define GAME_DEFAULT_SHIELDBOX
Definition: game.h:376
#define GAME_MIN_NOTRADESIZE
Definition: game.h:595
#define GAME_MIN_GOLD
Definition: game.h:338
#define GAME_MAX_OCCUPYCHANCE
Definition: game.h:626
#define GAME_DEFAULT_MAXCONNECTIONSPERHOST
Definition: game.h:564
#define GAME_DEFAULT_INCITE_GOLD_CAPT_CHANCE
Definition: game.h:396
#define GAME_DEFAULT_DEMOGRAPHY
Definition: game.h:650
#define GAME_MIN_MAXCONNECTIONSPERHOST
Definition: game.h:565
#define GAME_DEFAULT_FULLTRADESIZE
Definition: game.h:602
#define GAME_MAX_DISPERSION
Definition: game.h:346
#define GAME_MIN_TECHLOST_DONOR
Definition: game.h:522
#define GAME_DEFAULT_RAPTUREDELAY
Definition: game.h:463
#define GAME_MIN_MGR_TURNINTERVAL
Definition: game.h:482
#define GAME_DEFAULT_REVOLUTION_LENGTH
Definition: game.h:676
#define GAME_DEFAULT_MGR_TURNINTERVAL
Definition: game.h:481
#define GAME_DEFAULT_START_UNITS
Definition: game.h:341
#define GAME_MAX_SPACESHIP_TRAVEL_TIME
Definition: game.h:549
#define GAME_DEFAULT_ALLOW_TAKE
Definition: game.h:651
#define GAME_DEFAULT_THREADED_SAVE
Definition: game.h:642
#define GAME_MAX_TRADEWORLDRELPCT
Definition: game.h:600
#define GAME_DEFAULT_MIN_PLAYERS
Definition: game.h:358
#define GAME_MIN_CONQUERCOST
Definition: game.h:431
#define GAME_MAX_MGR_DISTANCE
Definition: game.h:492
#define GAME_DEFAULT_SPACESHIP_TRAVEL_TIME
Definition: game.h:547
#define GAME_MIN_TECHLOSSREST
Definition: game.h:439
#define GAME_DEFAULT_AUTOATTACK
Definition: game.h:628
#define GAME_DEFAULT_SAVEFREQUENCY
Definition: game.h:635
#define GAME_MAX_GOLD
Definition: game.h:339
#define GAME_DEFAULT_REVEALMAP
Definition: game.h:532
#define GAME_DEFAULT_SCOREFILE
Definition: game.h:536
#define GAME_MAX_FIRST_TIMEOUT
Definition: game.h:571
#define GAME_MIN_MGR_DISTANCE
Definition: game.h:491
#define GAME_MIN_DISPERSION
Definition: game.h:345
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
Definition: game.h:525
#define GAME_DEFAULT_SEED
Definition: game.h:333
#define GAME_DEFAULT_HOMECAUGHTUNITS
Definition: game.h:475
#define GAME_MAX_GLOBAL_WARMING_PERCENT
Definition: game.h:408
#define GAME_MAX_MAXCONNECTIONSPERHOST
Definition: game.h:566
#define GAME_DEFAULT_NETWAIT
Definition: game.h:582
#define GAME_MIN_PINGTIMEOUT
Definition: game.h:591
#define GAME_MIN_TECHPENALTY
Definition: game.h:514
#define GAME_MIN_CONTACTTURNS
Definition: game.h:458
#define GAME_MAX_INCITE_GOLD_LOSS_CHANCE
Definition: game.h:394
#define GAME_DEFAULT_UNITWAITTIME_STYLE
Definition: game.h:578
#define GAME_DEFAULT_KICK_TIME
Definition: game.h:687
#define GAME_DEFAULT_PLRCOLORMODE
Definition: game.h:673
#define GAME_MAX_CITYMINDIST
Definition: game.h:448
#define GAME_DEFAULT_DIPLCHANCE
Definition: game.h:422
#define GAME_MAX_NUCLEAR_WINTER_PERCENT
Definition: game.h:414
#define GAME_MIN_END_TURN
Definition: game.h:355
#define GAME_DEFAULT_UNRPROTECTS
Definition: game.h:455
#define GAME_MIN_MGR_WORLDCHANCE
Definition: game.h:499
#define GAME_DEFAULT_RAZECHANCE
Definition: game.h:528
#define GAME_MIN_SHIELDBOX
Definition: game.h:377
#define GAME_MIN_FIRST_TIMEOUT
Definition: game.h:570
#define GAME_MAX_RAZECHANCE
Definition: game.h:530
#define GAME_MIN_TIMEOUT
Definition: game.h:568
#define GAME_MAX_ONSETBARBARIAN
Definition: game.h:622
#define GAME_MIN_FOODBOX
Definition: game.h:373
#define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE
Definition: game.h:392
#define GAME_MAX_MAX_PLAYERS
Definition: game.h:364
#define GAME_DEFAULT_TRADING_CITY
Definition: game.h:608
#define GAME_DEFAULT_FOODBOX
Definition: game.h:372
#define GAME_DEFAULT_COMPRESS_TYPE
Definition: game.h:668
#define GAME_MAX_TIMEOUT
Definition: game.h:569
#define GAME_DEFAULT_PINGTIMEOUT
Definition: game.h:590
#define GAME_DEFAULT_TRADE_REVENUE_STYLE
Definition: game.h:616
scoreQtMsgType
Definition: game.h:62
@ SL_HUMANS
Definition: game.h:62
@ SL_ALL
Definition: game.h:62
#define GAME_DEFAULT_SAVEPALACE
Definition: game.h:473
#define GAME_MIN_EVENT_CACHE_TURNS
Definition: game.h:654
#define GAME_DEFAULT_GLOBAL_WARMING
Definition: game.h:404
#define GAME_MAX_SEED
Definition: game.h:335
#define GAME_MAX_DIPLGOLDCOST
Definition: game.h:390
#define GAME_DEFAULT_TECHLOST_RECV
Definition: game.h:517
#define GAME_DEFAULT_NOTRADESIZE
Definition: game.h:594
#define GAME_MAX_TECHLOST_DONOR
Definition: game.h:523
#define GAME_MIN_SAVETURNS
Definition: game.h:633
#define GAME_MAX_UNITWAITTIME
Definition: game.h:574
#define GAME_DEFAULT_FIRST_TIMEOUT
Definition: game.h:556
#define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT
Definition: game.h:412
#define GAME_MIN_CIVILWARSIZE
Definition: game.h:451
#define GAME_DEFAULT_TRADING_GOLD
Definition: game.h:607
#define GAME_MIN_TECHLEAK
Definition: game.h:443
#define GAME_DEFAULT_TRAIT_DIST_MODE
Definition: game.h:471
#define GAME_DEFAULT_NUCLEAR_WINTER
Definition: game.h:410
#define GAME_MIN_DISASTERS
Definition: game.h:468
#define GAME_MIN_OCCUPYCHANCE
Definition: game.h:625
#define GAME_DEFAULT_FREECOST
Definition: game.h:426
#define GAME_MIN_KICK_TIME
Definition: game.h:688
#define GAME_DEFAULT_MAX_PLAYERS
Definition: game.h:362
#define GAME_DEFAULT_CITYMINDIST
Definition: game.h:446
#define GAME_MIN_NUCLEAR_WINTER_PERCENT
Definition: game.h:413
#define GAME_DEFAULT_PHASE_MODE
Definition: game.h:580
#define GAME_DEFAULT_AIFILL
Definition: game.h:366
#define GAME_DEFAULT_TRADEWORLDRELPCT
Definition: game.h:598
#define GAME_DEFAULT_MULTIRESEARCH
Definition: game.h:526
#define GAME_DEFAULT_CONQUERCOST
Definition: game.h:430
#define GAME_MAX_TECHPENALTY
Definition: game.h:515
#define GAME_DEFAULT_TIMEOUT
Definition: game.h:555
#define GAME_MAX_DISASTERS
Definition: game.h:469
#define GAME_MIN_INCITE_GOLD_CAPT_CHANCE
Definition: game.h:397
#define GAME_MIN_TECHLOSSFG
Definition: game.h:435
#define GAME_MAX_END_TURN
Definition: game.h:356
#define GAME_DEFAULT_TECHLOSSREST
Definition: game.h:438
#define GAME_MIN_KILLUNHOMED
Definition: game.h:510
#define GAME_MAX_NOTRADESIZE
Definition: game.h:596
#define GAME_DEFAULT_CONTACTTURNS
Definition: game.h:457
#define GAME_DEFAULT_SCORELOGLEVEL
Definition: game.h:535
#define GAME_DEFAULT_TECHLOSSFG
Definition: game.h:434
#define GAME_DEFAULT_TECHLEVEL
Definition: game.h:348
#define GAME_MIN_MAX_PLAYERS
Definition: game.h:363
compress_type
Definition: game.h:40
@ COMPRESS_ZLIB
Definition: game.h:42
@ COMPRESS_PLAIN
Definition: game.h:41
#define GAME_DEFAULT_DISASTERS
Definition: game.h:467
#define GAME_MAX_FREECOST
Definition: game.h:428
#define GAME_MAX_REVOLUTION_LENGTH
Definition: game.h:678
#define GAME_MAX_AIFILL
Definition: game.h:368
#define GAME_DEFAULT_GOLD
Definition: game.h:337
#define GAME_MIN_AQUEDUCTLOSS
Definition: game.h:503
#define GAME_MIN_DIPLBULBCOST
Definition: game.h:385
#define GAME_DEFAULT_MIGRATION
Definition: game.h:479
@ AS_INTERRUPT
Definition: game.h:58
@ AS_GAME_OVER
Definition: game.h:56
@ AS_QUITIDLE
Definition: game.h:57
@ AS_TIMER
Definition: game.h:59
@ AS_TURN
Definition: game.h:55
#define GAME_MIN_EVENT_CACHE_MAX_SIZE
Definition: game.h:658
#define GAME_MIN_CITYMINDIST
Definition: game.h:447
#define GAME_MIN_AIFILL
Definition: game.h:367
#define GAME_MIN_SAVEFREQUENCY
Definition: game.h:636
#define GAME_DEFAULT_NATURALCITYNAMES
Definition: game.h:477
#define GAME_DEFAULT_EVENT_CACHE_TURNS
Definition: game.h:653
#define GAME_DEFAULT_VICTORY_CONDITIONS
Definition: game.h:543
#define GAME_MIN_UNITWAITTIME
Definition: game.h:573
#define GAME_DEFAULT_FOGGEDBORDERS
Definition: game.h:402
#define GAME_DEFAULT_UNITWAITTIME
Definition: game.h:575
#define GAME_DEFAULT_TIMEOUTADDEMOVE
Definition: game.h:561
#define GAME_DEFAULT_DISPERSION
Definition: game.h:344
#define GAME_MAX_CIVILWARSIZE
Definition: game.h:452
#define GAME_DEFAULT_AUTOSAVES
Definition: game.h:639
#define GAME_DEFAULT_EVENT_CACHE_CHAT
Definition: game.h:661
#define GAME_DEFAULT_DIPLOMACY
Definition: game.h:420
#define GAME_DEFAULT_MGR_DISTANCE
Definition: game.h:490
#define GAME_MIN_DIPLCHANCE
Definition: game.h:423
#define GAME_DEFAULT_TURNBLOCK
Definition: game.h:551
#define GAME_MAX_SAVETURNS
Definition: game.h:634
#define GAME_MAX_PINGTIME
Definition: game.h:588
#define GAME_DEFAULT_PINGTIME
Definition: game.h:586
#define GAME_DEFAULT_UNITWAITTIME_EXTENDED
Definition: game.h:576
@ CNM_PLAYER_UNIQUE
Definition: game.h:26
@ CNM_GLOBAL_UNIQUE
Definition: game.h:27
@ CNM_NO_RESTRICTIONS
Definition: game.h:25
@ CNM_NO_STEALING
Definition: game.h:28
#define GAME_DEFAULT_AQUEDUCTLOSS
Definition: game.h:502
#define GAME_DEFAULT_TRADEMINDIST
Definition: game.h:612
#define GAME_DEFAULT_BARBARIANRATE
Definition: game.h:618
#define GAME_DEFAULT_HAPPYBORDERS
Definition: game.h:418
#define GAME_MAX_FULLTRADESIZE
Definition: game.h:604
#define GAME_MAX_TECHLEAK
Definition: game.h:444
#define GAME_MAX_MGR_NATIONCHANCE
Definition: game.h:496
#define GAME_MAX_TECHLEVEL
Definition: game.h:350
#define GAME_MAX_MGR_WORLDCHANCE
Definition: game.h:500
#define GAME_MIN_MIN_PLAYERS
Definition: game.h:359
#define GAME_MAX_TRADEMINDIST
Definition: game.h:614
#define GAME_DEFAULT_END_TURN
Definition: game.h:354
#define GAME_MAX_EVENT_CACHE_TURNS
Definition: game.h:655
#define GAME_MAX_DIPLBULBCOST
Definition: game.h:386
#define GAME_DEFAULT_DIPLGOLDCOST
Definition: game.h:388
#define GAME_MAX_SHIELDBOX
Definition: game.h:378
#define GAME_DEFAULT_TECHLEAK
Definition: game.h:442
#define GAME_MAX_MIN_PLAYERS
Definition: game.h:360
#define GAME_MAX_NETWAIT
Definition: game.h:584
#define GAME_DEFAULT_END_SPACESHIP
Definition: game.h:545
#define GAME_MIN_RAPTUREDELAY
Definition: game.h:464
#define GAME_MIN_NETWAIT
Definition: game.h:583
#define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
Definition: game.h:657
#define GAME_DEFAULT_SAVE_NAME
Definition: game.h:631
#define GAME_MIN_TRADEMINDIST
Definition: game.h:613
#define GAME_DEFAULT_MGR_NATIONCHANCE
Definition: game.h:494
#define GAME_MIN_TECHLEVEL
Definition: game.h:349
#define GAME_MAX_INCITE_GOLD_CAPT_CHANCE
Definition: game.h:398
#define GAME_DEFAULT_FOGOFWAR
Definition: game.h:400
#define GAME_DEFAULT_PERSISTENTREADY
Definition: game.h:683
#define GAME_MIN_FULLTRADESIZE
Definition: game.h:603
#define GAME_DEFAULT_DIPLBULBCOST
Definition: game.h:384
#define GAME_DEFAULT_RESTRICTINFRA
Definition: game.h:454
#define GAME_MAX_KICK_TIME
Definition: game.h:689
#define GAME_DEFAULT_CIVILWARSIZE
Definition: game.h:450
void send_game_info(struct conn_list *dest)
Send game_info packet; some server options and various stuff...
Definition: gamehand.cpp:905
enum unit_role_id crole_to_role_id(char crole)
Get role_id for given role character.
Definition: gamehand.cpp:77
const char * name
Definition: inputfile.cpp:118
#define fc_assert_msg(condition, message,...)
Definition: log.h:96
#define fc_assert_ret(condition)
Definition: log.h:112
#define fc_assert(condition)
Definition: log.h:89
#define fc_assert_ret_val(condition, val)
Definition: log.h:114
#define log_debug(message,...)
Definition: log.h:65
bool map_is_empty()
Returns TRUE if we are at a stage of the game where the map has not yet been generated/loaded.
Definition: map.cpp:124
int map_startpos_count()
Is there start positions set for map.
Definition: map.cpp:1518
#define MAP_MAX_SIZE
Definition: map.h:517
#define MAP_MIN_HUTS
Definition: map.h:503
#define MAP_MIN_STEEPNESS
Definition: map.h:554
#define MAP_MIN_LANDMASS
Definition: map.h:546
#define MAP_DEFAULT_SIZE
Definition: map.h:515
#define MAP_MAX_LINEAR_SIZE
Definition: map.h:530
#define MAP_MAX_TILESPERPLAYER
Definition: map.h:526
#define MAP_DEFAULT_HUTS
Definition: map.h:502
#define MAP_MAX_FLATPOLES
Definition: map.h:575
#define MAP_MIN_TILESPERPLAYER
Definition: map.h:525
#define MAP_DEFAULT_LINEAR_SIZE
Definition: map.h:529
#define MAP_DEFAULT_STARTPOS
Definition: map.h:563
#define MAP_DEFAULT_ANIMALS
Definition: map.h:506
#define MAP_MIN_WETNESS
Definition: map.h:558
#define MAP_MAX_SEED
Definition: map.h:543
#define MAP_DEFAULT_TEAM_PLACEMENT
Definition: map.h:589
#define MAP_DEFAULT_TOPO
Definition: map.h:539
#define MAP_DEFAULT_SEED
Definition: map.h:541
#define MAP_IS_ISOMETRIC
Definition: map.h:32
#define MAP_MIN_TEMPERATURE
Definition: map.h:586
#define MAP_DEFAULT_MAPSIZE
Definition: map.h:510
#define MAP_MIN_LINEAR_SIZE
Definition: map.h:531
#define MAP_MAX_STEEPNESS
Definition: map.h:555
#define MAP_DEFAULT_LANDMASS
Definition: map.h:545
#define MAP_MIN_FLATPOLES
Definition: map.h:574
#define MAP_MAX_LANDMASS
Definition: map.h:547
#define MAP_MIN_SEED
Definition: map.h:542
#define MAP_MAX_ANIMALS
Definition: map.h:508
#define MAP_MAX_TEMPERATURE
Definition: map.h:587
#define MAP_MIN_SIZE
Definition: map.h:516
#define MAP_DEFAULT_SINGLE_POLE
Definition: map.h:577
#define MAP_MIN_RICHES
Definition: map.h:550
#define MAP_MIN_ANIMALS
Definition: map.h:507
#define MAP_DEFAULT_SEPARATE_POLES
Definition: map.h:569
#define MAP_DEFAULT_RICHES
Definition: map.h:549
#define MAP_DEFAULT_TINYISLES
Definition: map.h:565
#define MAP_DEFAULT_TILESPERPLAYER
Definition: map.h:524
#define MAP_DEFAULT_TEMPERATURE
Definition: map.h:585
#define MAP_DEFAULT_ALLTEMPERATE
Definition: map.h:581
#define MAP_MAX_RICHES
Definition: map.h:551
#define MAP_DEFAULT_GENERATOR
Definition: map.h:561
#define MAP_MAX_HUTS
Definition: map.h:504
#define MAP_DEFAULT_FLATPOLES
Definition: map.h:573
#define MAP_DEFAULT_WETNESS
Definition: map.h:557
#define MAP_MAX_WETNESS
Definition: map.h:559
#define MAP_DEFAULT_STEEPNESS
Definition: map.h:553
@ MAPSIZE_FULLSIZE
Definition: map_types.h:35
@ MAPSIZE_PLAYER
Definition: map_types.h:36
@ MAPSIZE_XYSIZE
Definition: map_types.h:39
@ MAPGEN_SCENARIO
Definition: map_types.h:43
@ MAPGEN_FRACTURE
Definition: map_types.h:48
@ MAPGEN_ISLAND
Definition: map_types.h:46
@ MAPGEN_FAIR
Definition: map_types.h:47
@ MAPGEN_FRACTAL
Definition: map_types.h:45
@ MAPGEN_RANDOM
Definition: map_types.h:44
@ MAPSTARTPOS_VARIABLE
Definition: map_types.h:56
@ MAPSTARTPOS_2or3
Definition: map_types.h:54
@ MAPSTARTPOS_ALL
Definition: map_types.h:55
@ MAPSTARTPOS_DEFAULT
Definition: map_types.h:52
@ MAPSTARTPOS_SINGLE
Definition: map_types.h:53
bool is_metaserver_open()
Are we sending info to the metaserver?
Definition: meta.cpp:464
bool send_server_info_to_metaserver(enum meta_flag flag)
Control when we send info to the metaserver.
Definition: meta.cpp:469
void set_user_meta_message_string(const char *string)
Set user defined metaserver message string.
Definition: meta.cpp:148
@ META_INFO
Definition: meta.h:25
std::vector< nation_type > nations
Definition: nation.cpp:38
const struct rgbcolor * nation_color(const struct nation_type *pnation)
Returns nation's player color preference, or nullptr if none.
Definition: nation.cpp:568
struct nation_set * nation_set_by_rule_name(const char *name)
Return the nation set that has the given (untranslated) rule name.
Definition: nation.cpp:652
#define NO_NATION_SELECTED
Definition: nation.h:21
void notify_conn(struct conn_list *dest, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
See notify_conn_packet - this is just the "non-v" version, with varargs.
Definition: notify.cpp:235
int len
Definition: packhand.cpp:127
int player_count()
Return the number of players.
Definition: player.cpp:739
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Set the player's nation to the given nation (may be nullptr).
Definition: player.cpp:780
#define players_iterate_end
Definition: player.h:520
#define players_iterate(_pplayer)
Definition: player.h:514
plrcolor_mode
Definition: player.h:33
@ PLRCOL_PLR_RANDOM
Definition: player.h:35
@ PLRCOL_PLR_SET
Definition: player.h:36
@ PLRCOL_NATION_ORDER
Definition: player.h:38
@ PLRCOL_TEAM_ORDER
Definition: player.h:37
@ PLRCOL_PLR_ORDER
Definition: player.h:34
#define is_human(plr)
Definition: player.h:226
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Tell clients which nations can be picked given current server settings.
Definition: plrhand.cpp:2574
void count_playable_nations()
Update the server's cached number of playable nations.
Definition: plrhand.cpp:2529
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
Definition: plrhand.cpp:1706
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
Definition: plrhand.cpp:1048
int normal_player_count()
Return the number of non-barbarian players.
Definition: plrhand.cpp:3140
bool nation_is_in_current_set(const struct nation_type *pnation)
Is the nation in the currently selected nationset? If not, it's not allowed to appear in the game.
Definition: plrhand.cpp:2520
const char * secfile_error()
Returns the last error which occurred in a string.
bool secfile_lookup_int(const struct section_file *secfile, int *ival, const char *path,...)
Lookup a integer value in the secfile.
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,...)
Lookup a value saved as string in the secfile.
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,...)
Lookup a value saved as string in the secfile.
const char * secfile_lookup_str(const struct section_file *secfile, const char *path,...)
Lookup a string value in the secfile.
const char * secfile_name(const struct section_file *secfile)
Return the filename the section file was loaded as, or "(anonymous)" if this sectionfile was created ...
struct section * secfile_section_by_name(const struct section_file *secfile, const QString &name)
Returns the first section matching the name.
bool secfile_lookup_bool_default(const struct section_file *secfile, bool def, const char *path,...)
Lookup a boolean value in the secfile.
const char * secfile_lookup_str_default(const struct section_file *secfile, const char *def, const char *path,...)
Lookup a string value in the secfile.
int secfile_lookup_int_default(const struct section_file *secfile, int def, const char *path,...)
Lookup a integer value in the secfile.
bool secfile_lookup_bool(const struct section_file *secfile, bool *bval, const char *path,...)
Lookup a boolean value in the secfile.
#define secfile_insert_int(secfile, value, path,...)
Definition: registry_ini.h:116
#define secfile_insert_str(secfile, string, path,...)
Definition: registry_ini.h:167
#define secfile_insert_bool(secfile, value, path,...)
Definition: registry_ini.h:79
#define secfile_insert_enum_data(secfile, value, bitwise, name_fn, data, path,...)
Definition: registry_ini.h:318
const void * secfile_data_t
Definition: registry_ini.h:28
void log_civ_score_init()
Initialize score logging system.
Definition: report.cpp:1450
bool is_valid_demography(const char *demography, int *error)
Verify that a given demography string is valid.
Definition: report.cpp:1128
void log_civ_score_free()
Free resources allocated for score logging system.
Definition: report.cpp:1474
bool autolock_settings()
Set and lock settings that must have certain value.
Definition: rssanity.cpp:1481
bool setting_int_validate(const struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3477
static const struct sset_val_name * teamplacement_name(int team_placement)
Team placement setting names accessor.
Definition: settings.cpp:296
static void metamessage_action(const struct setting *pset)
Update metaserver message string from changed user meta server message string.
Definition: settings.cpp:786
void settings_init(bool act)
Initialize stuff related to this code module.
Definition: settings.cpp:4761
static enum m_pre_result setting_match_prefix_base(const val_name_func_t name_fn, const char *prefix, int *ind_result, QVector< QString > &matches, size_t max_matches, size_t *pnum_matches)
Convert the string prefix to an integer representation.
Definition: settings.cpp:3241
static const char * setting_int_to_str(const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
Compute the string representation of the value for this integer setting.
Definition: settings.cpp:3428
static bool savename_validate(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify the selected savename definition.
Definition: settings.cpp:806
#define PACKET_COMMON_INIT(packet, pset, pconn)
static bool endturn_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify that a given endturn is valid.
Definition: settings.cpp:1005
void setting_action(const struct setting *pset)
Execute the action callback if needed.
Definition: settings.cpp:4048
void settings_reset()
Reset all settings iff they are changeable.
Definition: settings.cpp:4782
static const struct sset_val_name * trait_dist_name(int trait_dist)
Trait distribution setting names accessor.
Definition: settings.cpp:373
bool(* bitwise_validate_func_t)(unsigned value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition: settings.cpp:69
#define GEN_BOOL(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
Definition: settings.cpp:1283
static const char * setting_bool_secfile_str(secfile_data_t data, int val)
Convert the integer to the long support string representation of a boolean setting.
Definition: settings.cpp:3417
int setting_int_get(struct setting *pset)
Get value of integer setting.
Definition: settings.cpp:3502
static const struct sset_val_name * scoreloglevel_name(enum scoreQtMsgType sl_level)
Scorelog level names accessor.
Definition: settings.cpp:523
static void nationset_action(const struct setting *pset)
Restrict to the selected nation set.
Definition: settings.cpp:657
void settings_game_start()
Save setting values at the start of the game.
Definition: settings.cpp:4404
bool setting_enum_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3749
static const struct sset_val_name * bool_name(int enable)
Names accessor for boolean settings (disable/enable).
Definition: settings.cpp:557
void setting_set_to_default(struct setting *pset)
Update the setting to the default value.
Definition: settings.cpp:4018
static void timeout_action(const struct setting *pset)
Enact a change in the 'timeout' server setting immediately, if the game is afoot.
Definition: settings.cpp:724
void settings_game_load(struct section_file *file, const char *section)
Restore all settings from a savegame.
Definition: settings.cpp:4487
static bool setting_match_prefix(const val_name_func_t name_fn, const char *prefix, int *pvalue, char *reject_msg, size_t reject_msg_len)
Convert the string prefix to an integer representation.
Definition: settings.cpp:3285
void settings_free()
Deinitialize stuff related to this code module.
Definition: settings.cpp:4805
int setting_number(const struct setting *pset)
Returns the id to the given setting.
Definition: settings.cpp:3056
bool setting_int_set(struct setting *pset, int val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
Definition: settings.cpp:3457
enum sset_category setting_category(const struct setting *pset)
Access function for the setting category.
Definition: settings.cpp:3108
int settings_list_cmp(const struct setting *const *pset1, const struct setting *const *pset2)
Update sorted settings (changed and locked values).
Definition: settings.cpp:5113
static const struct sset_val_name * mapsize_name(int mapsize)
Map size definition setting names accessor.
Definition: settings.cpp:223
static const struct sset_val_name * unitwaittime_name(int bit)
Unitwaittime style names accessor.
Definition: settings.cpp:569
bool setting_is_visible(const struct setting *pset, struct connection *caller)
Returns whether the specified server setting (option) can be seen by the caller.
Definition: settings.cpp:3227
static bool first_timeout_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Validate the 'first_timeout' server setting.
Definition: settings.cpp:1106
bool setting_locked(const struct setting *pset)
Returns if the setting is locked by the ruleset.
Definition: settings.cpp:4283
bool setting_non_default(const struct setting *pset)
Returns whether the setting has non-default value.
Definition: settings.cpp:4257
static bool xsize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
xsize setting validation callback.
Definition: settings.cpp:1170
static const char * setting_enum_to_str(const struct setting *pset, int value, bool pretty, char *buf, size_t buf_len)
Compute the string representation of the value for this enumerator setting.
Definition: settings.cpp:3615
static const struct sset_val_name * borders_name(int borders)
Borders setting names accessor.
Definition: settings.cpp:357
static const struct sset_val_name * victory_conditions_name(int condition_bit)
Victory conditions setting names accessor.
Definition: settings.cpp:327
enum sset_type setting_type(const struct setting *pset)
Access function for the setting type.
Definition: settings.cpp:3092
static const char * setting_bool_to_str(const struct setting *pset, bool value, bool pretty, char *buf, size_t buf_len)
Compute the string representation of the value for this boolean setting.
Definition: settings.cpp:3322
static const struct sset_val_name * autosaves_name(int autosaves_bit)
Autosaves setting names accessor.
Definition: settings.cpp:341
bool setting_str_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
Definition: settings.cpp:3528
#define GEN_STRING(name, value, sclass, scateg, slevel, al_read, al_write, short_help, extra_help, func_validate, func_action, _default)
Definition: settings.cpp:1304
struct setting * setting_by_number(int id)
Returns the setting to the given id.
Definition: settings.cpp:3031
bool init
Definition: settings.cpp:166
int setting_int_max(const struct setting *pset)
Returns the maximal integer value for this setting.
Definition: settings.cpp:3447
void setting_lock_set(struct setting *pset, bool lock)
Set the value for the lock of a setting.
Definition: settings.cpp:4288
bool settings_game_reset()
Reset all settings to the values at game start.
Definition: settings.cpp:4745
enum sset_level setting_level(const struct setting *pset)
Access function for the setting level (used by the /show command).
Definition: settings.cpp:3100
static struct setting settings[]
Definition: settings.cpp:1338
const char * setting_enum_val(const struct setting *pset, int val, bool pretty)
Convert the integer to the string representation of an enumerator.
Definition: settings.cpp:3595
static void first_timeout_action(const struct setting *pset)
Enact a change in the 'first_timeout' server setting immediately, if the game is afoot.
Definition: settings.cpp:741
static bool allowtake_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify that a given allowtake string is valid.
Definition: settings.cpp:912
struct setting_list * settings_list_get(enum sset_level level)
Get a settings list of a certain level.
Definition: settings.cpp:5126
static const struct sset_val_name * airliftingstyle_name(int bit)
Airlifting style setting names accessor.
Definition: settings.cpp:490
static bool setting_ruleset_one(struct section_file *file, const char *name, const char *path)
Set one setting from the game.ruleset file.
Definition: settings.cpp:4108
static const struct sset_val_name * citynames_name(int citynames)
City names setting names accessor.
Definition: settings.cpp:433
bool setting_bitwise_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
Definition: settings.cpp:3902
static void topology_action(const struct setting *pset)
Topology setting changed.
Definition: settings.cpp:769
void settings_game_save(struct section_file *file, const char *section)
Save game settings.
Definition: settings.cpp:4416
bool setting_str_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3548
bool(* string_validate_func_t)(const char *value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition: settings.cpp:62
#define NAME_CASE(_val, _support, _pretty)
Definition: settings.cpp:199
bool settings_ruleset(struct section_file *file, const char *section, bool act)
Load game settings from ruleset file 'game.ruleset'.
Definition: settings.cpp:4058
static bool setting_is_free_to_change(const struct setting *pset, char *reject_msg, size_t reject_msg_len)
Returns whether the specified server setting (option) can currently be changed without breaking data ...
Definition: settings.cpp:3118
static const struct sset_val_name * persistentready_name(int persistent_ready)
Persistentready setting names accessor.
Definition: settings.cpp:313
static const struct sset_val_name * traderevenuestyle_name(int revenue_style)
Trade revenue style setting names accessor.
Definition: settings.cpp:250
struct setting * setting_by_name(const char *name)
Returns the setting to the given name.
Definition: settings.cpp:3039
struct setting_list * level[OLEVELS_NUM]
Definition: settings.cpp:167
static const struct sset_val_name * plrcol_name(int plrcol)
Player colors configuration setting names accessor.
Definition: settings.cpp:385
static bool compresstype_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Warn about deprecated compresstype selection.
Definition: settings.cpp:1248
void setting_changed(struct setting *pset)
Mark setting changed.
Definition: settings.cpp:5155
#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.cpp:1315
static bool startunits_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify that a given startunits string is valid.
Definition: settings.cpp:955
static void huts_action(const struct setting *pset)
Clean out absolute number of huts when relative setting set.
Definition: settings.cpp:761
const char * setting_name(const struct setting *pset)
Access function for the setting name.
Definition: settings.cpp:3065
static const struct sset_val_name * barbarians_name(int barbarians)
Barbarian setting names accessor.
Definition: settings.cpp:447
static bool nationset_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Validate the 'nationset' server setting.
Definition: settings.cpp:1047
enum setting_default_level setting_get_setdef(const struct setting *pset)
Is the setting in changed state, or the default.
Definition: settings.cpp:5160
static bool mapsize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Mapsize setting validation callback.
Definition: settings.cpp:1151
static const struct sset_val_name * caravanbonusstyle_name(int caravanbonus)
Caravan bonus style setting names accessor.
Definition: settings.cpp:208
static void settings_list_free()
Free sorted settings.
Definition: settings.cpp:5138
const char * setting_value_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Compute the name of the current value of the setting.
Definition: settings.cpp:3946
static const struct sset_val_name * revolentype_name(int revolentype)
Revolution length type setting names accessor.
Definition: settings.cpp:462
static bool setting_bool_validate_base(const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3343
static const struct sset_val_name * compresstype_name(enum compress_type compresstype)
Savegame compress type names accessor.
Definition: settings.cpp:536
static bool demography_callback(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify that a given demography string is valid.
Definition: settings.cpp:869
static const char * setting_str_to_str(const struct setting *pset, const char *value, bool pretty, char *buf, size_t buf_len)
Compute the string representation of the value for this string setting.
Definition: settings.cpp:3512
static const struct sset_val_name * topology_name(int topology_bit)
Topology setting names accessor.
Definition: settings.cpp:236
void settings_turn()
Update stuff every turn that is related to this code module.
Definition: settings.cpp:4798
bool(* enum_validate_func_t)(int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition: settings.cpp:66
bool setting_enum_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
Definition: settings.cpp:3720
void send_server_setting_control(struct connection *pconn)
Tell the client about all server settings.
Definition: settings.cpp:4986
static bool plrcol_validate(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Validate that the player color mode can be used.
Definition: settings.cpp:1264
static struct @108 setting_sorted
const char * setting_bitwise_secfile_str(secfile_data_t data, int bit)
Convert the integer to the long support string representation of an enumerator.
Definition: settings.cpp:3763
static bool autosaves_callback(unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Autosaves setting callback.
Definition: settings.cpp:888
static bool maxplayers_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify that a given maxplayers is valid.
Definition: settings.cpp:1020
int setting_int_min(const struct setting *pset)
Returns the minimal integer value for this setting.
Definition: settings.cpp:3438
bool(* bool_validate_func_t)(bool value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition: settings.cpp:57
static bool setting_enum_validate_base(const struct setting *pset, const char *val, int *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3637
static void autotoggle_action(const struct setting *pset)
Toggle player AI status.
Definition: settings.cpp:706
bool setting_bitwise_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3923
const char * setting_short_help(const struct setting *pset)
Access function for the short help (not translated yet) of the setting.
Definition: settings.cpp:3070
static const char * huts_help(const struct setting *pset)
Help about huts setting.
Definition: settings.cpp:605
const char * setting_extra_help(const struct setting *pset, bool constant)
Access function for the long (extra) help of the setting.
Definition: settings.cpp:3080
static const struct sset_val_name * happyborders_name(int happyborders)
Happyborders setting names accessor.
Definition: settings.cpp:401
#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.cpp:1293
static const struct sset_val_name * startpos_name(int startpos)
Start position setting names accessor.
Definition: settings.cpp:278
bool setting_bool_validate(const struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3403
void settings_list_update()
Update sorted settings (changed and locked values).
Definition: settings.cpp:5084
bool setting_is_changeable(const struct setting *pset, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns whether the specified server setting (option) can currently be changed by the caller.
Definition: settings.cpp:3191
const struct sset_val_name *(* val_name_func_t)(int value)
Definition: settings.cpp:76
static bool setting_bitwise_validate_base(const struct setting *pset, const char *val, unsigned *pint_val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Returns TRUE if 'val' is a valid value for this setting.
Definition: settings.cpp:3854
char * setting_str_get(struct setting *pset)
Get value of string setting.
Definition: settings.cpp:3572
static void settings_list_init()
Initialise sorted settings.
Definition: settings.cpp:5024
static const char * phasemode_help(const struct setting *pset)
Help about phasemode setting.
Definition: settings.cpp:587
static const int SETTINGS_NUM
Definition: settings.cpp:3026
static bool ysize_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
ysize setting validation callback.
Definition: settings.cpp:1195
static void scorelog_action(const struct setting *pset)
(De)initialze the score log.
Definition: settings.cpp:632
const char * setting_bitwise_bit(const struct setting *pset, int bit, bool pretty)
Convert the bit number to its string representation.
Definition: settings.cpp:3775
int setting_bitwise_get(struct setting *pset)
Get value of bitwise setting.
Definition: settings.cpp:3936
static bool timeout_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Validate the 'timeout' server setting.
Definition: settings.cpp:1067
int settings_number()
Returns the total number of settings.
Definition: settings.cpp:4816
sset_class
Definition: settings.cpp:45
@ SSET_RULES
Definition: settings.cpp:51
@ SSET_PLAYERS
Definition: settings.cpp:49
@ SSET_GAME_INIT
Definition: settings.cpp:50
@ SSET_MAP_GEN
Definition: settings.cpp:47
@ SSET_RULES_FLEXIBLE
Definition: settings.cpp:53
@ SSET_META
Definition: settings.cpp:54
@ SSET_MAP_ADD
Definition: settings.cpp:48
@ SSET_MAP_SIZE
Definition: settings.cpp:46
@ SSET_RULES_SCENARIO
Definition: settings.cpp:52
static bool generator_validate(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify the value of the generator option (notably the MAPGEN_SCENARIO case).
Definition: settings.cpp:828
const char * setting_default_name(const struct setting *pset, bool pretty, char *buf, size_t buf_len)
Compute the name of the default value of the setting.
Definition: settings.cpp:3982
void(* action_callback_func_t)(const struct setting *pset)
Definition: settings.cpp:74
static const char * setting_bitwise_to_str(const struct setting *pset, unsigned value, bool pretty, char *buf, size_t buf_len)
Compute the string representation of the value for this bitwise setting.
Definition: settings.cpp:3794
#define settings_snprintf(_buf, _buf_len, format,...)
Definition: settings.cpp:181
bool setting_bool_get(struct setting *pset)
Get value of boolean setting.
Definition: settings.cpp:3391
static bool set_enum_value(struct setting *pset, int val)
Helper function to write value to enumerator setting.
Definition: settings.cpp:3664
static void setting_game_set(struct setting *pset, bool init)
Save the setting value of the current game.
Definition: settings.cpp:4296
static void setting_game_free(struct setting *pset)
Free the memory used for the settings at game start.
Definition: settings.cpp:4332
static bool scorefile_validate(const char *value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Verify the name for the score log file.
Definition: settings.cpp:853
static const struct sset_val_name * diplomacy_name(int diplomacy)
Diplomacy setting names accessor.
Definition: settings.cpp:414
static void aifill_action(const struct setting *pset)
Create the selected number of AI's.
Definition: settings.cpp:644
bool setting_is_visible_at_level(const struct setting *pset, enum cmdlevel plevel)
Returns whether the specified server setting (option) can be seen by a caller with the specified acce...
Definition: settings.cpp:3217
bool setting_bool_set(struct setting *pset, const char *val, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Set the setting to 'val'.
Definition: settings.cpp:3372
void send_server_setting(struct conn_list *dest, const struct setting *pset)
Tell the client about just one server setting.
Definition: settings.cpp:4822
void send_server_settings(struct conn_list *dest)
Tell the client about all server settings.
Definition: settings.cpp:4941
#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.cpp:1326
static void plrcol_action(const struct setting *pset)
Clear any user-set player colors in modes other than PLRCOL_PLR_SET.
Definition: settings.cpp:691
const char *(* help_callback_func_t)(const struct setting *pset)
Definition: settings.cpp:75
void send_server_access_level_settings(struct conn_list *dest, enum cmdlevel old_level, enum cmdlevel new_level)
Send the server settings that got a different visibility or changability after a connection access le...
Definition: settings.cpp:4952
static const struct sset_val_name * revealmap_name(int bit)
Revealmap setting names accessor.
Definition: settings.cpp:478
static void setting_game_restore(struct setting *pset)
Restore the setting to the value used at the start of the current game.
Definition: settings.cpp:4343
int read_enum_value(const struct setting *pset)
Helper function to read value from enumerator setting.
Definition: settings.cpp:3692
static const struct sset_val_name * phasemode_name(int phasemode)
Phase mode names accessor.
Definition: settings.cpp:508
bool(* int_validate_func_t)(int value, struct connection *pconn, char *reject_msg, size_t reject_msg_len)
Definition: settings.cpp:60
static bool unitwaittime_callback(int value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Check 'timeout' setting if 'unitwaittime' is changed.
Definition: settings.cpp:1124
static bool topology_callback(unsigned value, struct connection *caller, char *reject_msg, size_t reject_msg_len)
Topology setting validation callback.
Definition: settings.cpp:1228
static const struct sset_val_name * generator_name(int generator)
Generator setting names accessor.
Definition: settings.cpp:262
const char * setting_enum_secfile_str(secfile_data_t data, int val)
Convert the integer to the long support string representation of an enumerator.
Definition: settings.cpp:3583
#define settings_iterate(_level, _pset)
Definition: settings.h:168
#define settings_iterate_end
Definition: settings.h:175
bool is_safe_filename(const QString &name)
Check if the name is safe security-wise.
Definition: shared.cpp:210
void remove_leading_trailing_spaces(char *s)
Removes leading and trailing spaces in string pointed to by 's'.
Definition: shared.cpp:353
#define ARRAY_SIZE(x)
Definition: shared.h:79
#define MIN(x, y)
Definition: shared.h:49
#define MAX_LEN_PATH
Definition: shared.h:28
m_pre_result
Definition: shared.h:152
@ M_PRE_EXACT
Definition: shared.h:153
@ M_PRE_ONLY
Definition: shared.h:154
@ M_PRE_LAST
Definition: shared.h:159
@ M_PRE_LONG
Definition: shared.h:157
@ M_PRE_AMBIGUOUS
Definition: shared.h:155
@ M_PRE_EMPTY
Definition: shared.h:156
@ M_PRE_FAIL
Definition: shared.h:158
size_t size
Definition: specvec.h:64
const char * aifill(int amount)
Fill or remove players to meet the given aifill.
Definition: srv_main.cpp:2440
bool game_was_started()
Returns iff the game was started once upon a time.
Definition: srv_main.cpp:251
enum server_states server_state()
Return current server state.
Definition: srv_main.cpp:238
void toggle_ai_player_direct(struct connection *caller, struct player *pplayer)
Handle ai player ai toggling.
Definition: stdinhand.cpp:676
struct civ_game::@28::@32 server
struct conn_list * est_connections
Definition: game.h:88
struct packet_game_info info
Definition: game.h:80
struct packet_scenario_info scenario
Definition: game.h:78
struct packet_timeout_info tinfo
Definition: game.h:82
int xsize
Definition: map_types.h:73
int ysize
Definition: map_types.h:73
int topology_id
Definition: map_types.h:68
struct civ_map::@39::@41 server
enum cmdlevel access_level
Definition: connection.h:164
Definition: servers.h:55
struct setting::@109::@113 string
enum cmdlevel access_level_read
Definition: settings.cpp:83
char * game_value
Definition: settings.cpp:134
enum setting_default_level setdef
Definition: settings.cpp:162
const char *const default_value
Definition: settings.cpp:131
bool game_value
Definition: settings.cpp:117
const int_validate_func_t validate
Definition: settings.cpp:125
enum sset_class sclass
Definition: settings.cpp:80
const int default_value
Definition: settings.cpp:122
enum cmdlevel access_level_write
Definition: settings.cpp:84
int *const pvalue
Definition: settings.cpp:121
const val_name_func_t name
Definition: settings.cpp:116
const int max_value
Definition: settings.cpp:124
struct setting::@109::@111 boolean
int game_value
Definition: settings.cpp:126
unsigned game_value
Definition: settings.cpp:151
char *const value
Definition: settings.cpp:130
const help_callback_func_t help_func
Definition: settings.cpp:99
const char * name
Definition: settings.cpp:79
bool *const pvalue
Definition: settings.cpp:113
const enum_validate_func_t validate
Definition: settings.cpp:141
const char * extra_help
Definition: settings.cpp:96
const char * short_help
Definition: settings.cpp:89
const int store_size
Definition: settings.cpp:139
bool locked
Definition: settings.cpp:159
struct setting::@109::@115 bitwise
struct setting::@109::@112 integer
const action_callback_func_t action
Definition: settings.cpp:156
void *const pvalue
Definition: settings.cpp:138
const int min_value
Definition: settings.cpp:123
enum sset_type stype
Definition: settings.cpp:101
const bool_validate_func_t validate
Definition: settings.cpp:115
const string_validate_func_t validate
Definition: settings.cpp:133
const size_t value_size
Definition: settings.cpp:132
const bitwise_validate_func_t validate
Definition: settings.cpp:149
const unsigned default_value
Definition: settings.cpp:148
const bool default_value
Definition: settings.cpp:114
struct setting::@109::@114 enumerator
unsigned *const pvalue
Definition: settings.cpp:147
enum sset_level slevel
Definition: settings.cpp:103
enum sset_category scategory
Definition: settings.cpp:102
const char * support
Definition: settings.h:21
const char * pretty
Definition: settings.h:23
struct civ_map map
Definition: world_object.h:21
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
Definition: support.cpp:537
size_t fc_strlcpy(char *dest, const char *src, size_t n)
fc_strlcpy() provides utf-8 version of (non-standard) function strlcpy() It is intended as more user-...
Definition: support.cpp:412
int fc_strcasecmp(const char *str0, const char *str1)
Compare strings like strcmp(), but ignoring case.
Definition: support.cpp:89
size_t fc_strlcat(char *dest, const char *src, size_t n)
fc_strlcat() provides utf-8 version of (non-standard) function strlcat() It is intended as more user-...
Definition: support.cpp:448
int fc_strncasecmp(const char *str0, const char *str1, size_t n)
Compare strings like strncmp(), but ignoring case.
Definition: support.cpp:100
#define sz_strlcpy(dest, src)
Definition: support.h:140
#define fc__fallthrough
Definition: support.h:49
#define terrain_type_iterate(_p)
Definition: terrain.h:331
#define terrain_type_iterate_end
Definition: terrain.h:337
#define terrain_has_flag(terr, flag)
Definition: terrain.h:260
void timer_destroy(civtimer *t)
Deletes timer.
Definition: timing.cpp:66
void timer_start(civtimer *t)
Start timing, adding to previous accumulated time if timer has not been cleared.
Definition: timing.cpp:95
civtimer * timer_renew(civtimer *t, enum timer_timetype type, enum timer_use use)
Allocate a new timer, or reuse t, with specified "type" and "use".
Definition: timing.cpp:51
void timer_stop(civtimer *t)
Stop timing, and accumulate time so far.
Definition: timing.cpp:116
@ TIMER_ACTIVE
Definition: timing.h:25
@ TIMER_USER
Definition: timing.h:21
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.
Definition: unittype.cpp:1900
#define utype_class(_t_)
Definition: unittype.h:691
#define uclass_index(_c_)
Definition: unittype.h:684