Freeciv21
Develop your civilization from humble roots to a global empire
game.h
Go to the documentation of this file.
1 /*__ ___ ***************************************
2 / \ / \ Copyright (c) 1996-2020 Freeciv21 and Freeciv
3 \_ \ / __/ contributors. This file is part of Freeciv21.
4  _\ \ / /__ Freeciv21 is free software: you can redistribute it
5  \___ \____/ __/ and/or modify it under the terms of the GNU General
6  \_ _/ Public License as published by the Free Software
7  | @ @ \_ Foundation, either version 3 of the License,
8  | or (at your option) any later version.
9  _/ /\ You should have received a copy of the GNU
10  /o) (o/\ \_ General Public License along with Freeciv21.
11  \_____/ / If not, see https://www.gnu.org/licenses/.
12  \____/ ********************************************************/
13 #pragma once
14 
15 #include <ctime> // time_t
16 
17 // common
18 #include "connection.h" // struct conn_list
19 #include "packets.h"
20 #include "player.h"
21 
23 
29 };
30 
37 };
38 
39 // (Possibly) supported methods (depending on what KArchive supports).
43 #ifdef FREECIV_HAVE_BZ2
44  COMPRESS_BZIP2,
45 #endif
46 #ifdef FREECIV_HAVE_LZMA
47  COMPRESS_XZ,
48 #endif
49 #ifdef FREECIV_HAVE_ZSTD
50  COMPRESS_ZSTD,
51 #endif
52 };
53 
55  AS_TURN = 0,
59  AS_TIMER
60 };
61 
63 
64 struct user_flag {
65  char *name;
66  char *helptxt;
67 };
68 
69 /* The number of turns that the first user needs to be attached to a
70  * player for that user to be ranked as that player */
71 #define TURNS_NEEDED_TO_RANK 10
72 
73 struct civ_game {
74  struct packet_ruleset_control control;
78  struct packet_scenario_info scenario;
79  struct packet_scenario_description scenario_desc;
80  struct packet_game_info info;
81  struct packet_calendar_info calendar;
82  struct packet_timeout_info tinfo;
83 
84  struct government *default_government; // may be overridden by nation
86 
87  struct conn_list *all_connections; // including not yet established
88  struct conn_list *est_connections; // all established client conns
89  struct conn_list *glob_observers; // global observers
90 
91  struct veteran_system *veteran; // veteran system
92 
94 
95  struct {
96  /* Items given to all players at game start.
97  * Client gets this info for help purposes only. */
100  } rgame;
101 
102  union {
103  struct {
104  /* Only used at the client (./client/). */
105 
109 
110  struct {
111  /* Only used in the server (./ai/ and ./server/). */
112 
113  // Defined in the ruleset.
114  diplstate_type initial_diplomatic_state;
115 
116  // Game settings & other data.
117 
135  int end_turn;
139  int freecost;
154  bool migration;
158  int netwait;
162  int pingtime;
166  unsigned revealmap;
173  unsigned
174  autosaves; /* FIXME: char would be enough, but current settings.c
175  code wants to write sizeof(unsigned) bytes */
185  bool turnblock;
186  int unitwaittime; // minimal time between two movements of a unit
187  bool unitwaittime_extended; // UWT applies to built and captured/bribed
188  // units.
192 
194  int timeoutint; // increase timeout every N turns...
195  int timeoutinc; // ... by this amount ...
196  int timeoutincmult; /* ... and multiply timeoutinc by this amount ...
197  */
198  int timeoutintinc; // ... and increase timeoutint by this amount
199  int timeoutcounter; /* timeoutcounter - timeoutint = turns to next inc.
200  */
201  int timeoutaddenemymove; /* minimum timeout after an enemy move is seen
202  */
203 
204  time_t last_ping;
205  civtimer *phase_timer; // Time since seconds_to_phase_done was set.
207  /* The game.info.phase_mode value indicates the phase mode currently in
208  * use. The "stored" value is a value the player can change; it won't
209  * take effect until the next turn. */
215  bool scorelog;
218  int scoreturn; // next make_history_report()
220  int seed;
221 
226 
227  bool fogofwar_old; /* as the fog_of_war bit get changed by setting
228  * the server we need to remember the old setting */
229  bool last_updated_year; /* last_updated is still counted as year in
230  * this game. */
234 
235  bool settings_gamestart_valid; // Valid settings from the game start.
236 
237  struct rgbcolor_list *plr_colors;
238 
240 
241  struct {
242  int turns;
243  int max_size;
244  bool chat;
245  bool info;
247 
248  // used by the map editor to control game_save.
249  struct {
250  bool save_known; /* loading will just reveal the squares around
251  * cities and units */
252  bool save_starts; // start positions will be auto generated
253  bool save_private_map; // FoW map; will be created if not saved
255 
256  struct {
257  char user_message[256];
258  char type[20];
260 
261  struct {
262  QMutex *city_list;
264 
265  struct trait_limits default_traits[TRAIT_COUNT];
266 
267  struct {
269  char *nationlist;
272  const char **allowed_govs;
273  char **nc_agovs;
274  size_t ag_count;
275  const char **allowed_terrains;
276  char **nc_aterrs;
277  size_t at_count;
278  const char **allowed_styles;
279  char **nc_astyles;
280  size_t as_count;
284  };
285 
286  struct {
287  // Function to be called in game_remove_unit when a unit is deleted.
288  void (*unit_deallocate)(int unit_id);
290 };
291 
292 bool is_server();
293 void i_am_server();
294 void i_am_client();
295 static inline void i_am_tool()
296 {
297  i_am_server(); // No difference between a tool and server at the moment
298 }
299 
300 void game_init(bool keep_ruleset_value);
301 void game_map_init();
302 void game_free();
303 void game_reset();
304 
305 void game_ruleset_init();
306 void game_ruleset_free();
307 
308 int civ_population(const struct player *pplayer);
309 struct city *game_city_by_name(const char *name);
310 struct city *game_city_by_number(int id);
311 
312 struct unit *game_unit_by_number(int id);
313 
314 void game_remove_unit(struct world *gworld, struct unit *punit);
315 void game_remove_city(struct world *gworld, struct city *pcity);
316 void initialize_globals();
317 
318 bool is_player_phase(const struct player *pplayer, int phase);
319 
320 const char *population_to_text(int thousand_citizen);
321 
322 int generate_save_name(const char *format, char *buf, int buflen,
323  const char *reason);
324 
325 void user_flag_init(struct user_flag *flag);
326 void user_flag_free(struct user_flag *flag);
327 
329 
330 extern struct civ_game game;
331 extern struct world wld;
332 
333 #define GAME_DEFAULT_SEED 0
334 #define GAME_MIN_SEED 0
335 #define GAME_MAX_SEED (MAX_UINT32 >> 1)
336 
337 #define GAME_DEFAULT_GOLD 50
338 #define GAME_MIN_GOLD 0
339 #define GAME_MAX_GOLD 50000
340 
341 #define GAME_DEFAULT_START_UNITS "ccwwx"
342 #define GAME_DEFAULT_START_CITY false
343 
344 #define GAME_DEFAULT_DISPERSION 0
345 #define GAME_MIN_DISPERSION 0
346 #define GAME_MAX_DISPERSION 10
347 
348 #define GAME_DEFAULT_TECHLEVEL 0
349 #define GAME_MIN_TECHLEVEL 0
350 #define GAME_MAX_TECHLEVEL 100
351 
352 #define GAME_DEFAULT_ANGRYCITIZEN true
353 
354 #define GAME_DEFAULT_END_TURN 5000
355 #define GAME_MIN_END_TURN 1
356 #define GAME_MAX_END_TURN 32767
357 
358 #define GAME_DEFAULT_MIN_PLAYERS 1
359 #define GAME_MIN_MIN_PLAYERS 0
360 #define GAME_MAX_MIN_PLAYERS MAX_NUM_PLAYERS
361 
362 #define GAME_DEFAULT_MAX_PLAYERS MAX_NUM_PLAYERS
363 #define GAME_MIN_MAX_PLAYERS 1
364 #define GAME_MAX_MAX_PLAYERS MAX_NUM_PLAYERS
365 
366 #define GAME_DEFAULT_AIFILL 5
367 #define GAME_MIN_AIFILL 0
368 #define GAME_MAX_AIFILL GAME_MAX_MAX_PLAYERS
369 
370 #define GAME_DEFAULT_NATIONSET ""
371 
372 #define GAME_DEFAULT_FOODBOX 100
373 #define GAME_MIN_FOODBOX 1
374 #define GAME_MAX_FOODBOX 10000
375 
376 #define GAME_DEFAULT_SHIELDBOX 100
377 #define GAME_MIN_SHIELDBOX 1
378 #define GAME_MAX_SHIELDBOX 10000
379 
380 #define GAME_DEFAULT_SCIENCEBOX 100
381 #define GAME_MIN_SCIENCEBOX 1
382 #define GAME_MAX_SCIENCEBOX 10000
383 
384 #define GAME_DEFAULT_DIPLBULBCOST 0
385 #define GAME_MIN_DIPLBULBCOST 0
386 #define GAME_MAX_DIPLBULBCOST 100
387 
388 #define GAME_DEFAULT_DIPLGOLDCOST 0
389 #define GAME_MIN_DIPLGOLDCOST 0
390 #define GAME_MAX_DIPLGOLDCOST 100
391 
392 #define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE 0
393 #define GAME_MIN_INCITE_GOLD_LOSS_CHANCE 0
394 #define GAME_MAX_INCITE_GOLD_LOSS_CHANCE 100
395 
396 #define GAME_DEFAULT_INCITE_GOLD_CAPT_CHANCE 0
397 #define GAME_MIN_INCITE_GOLD_CAPT_CHANCE 0
398 #define GAME_MAX_INCITE_GOLD_CAPT_CHANCE 100
399 
400 #define GAME_DEFAULT_FOGOFWAR true
401 
402 #define GAME_DEFAULT_FOGGEDBORDERS false
403 
404 #define GAME_DEFAULT_GLOBAL_WARMING true
405 
406 #define GAME_DEFAULT_GLOBAL_WARMING_PERCENT 100
407 #define GAME_MIN_GLOBAL_WARMING_PERCENT 1
408 #define GAME_MAX_GLOBAL_WARMING_PERCENT 10000
409 
410 #define GAME_DEFAULT_NUCLEAR_WINTER true
411 
412 #define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT 100
413 #define GAME_MIN_NUCLEAR_WINTER_PERCENT 1
414 #define GAME_MAX_NUCLEAR_WINTER_PERCENT 10000
415 
416 #define GAME_DEFAULT_BORDERS BORDERS_ENABLED
417 
418 #define GAME_DEFAULT_HAPPYBORDERS HB_NATIONAL
419 
420 #define GAME_DEFAULT_DIPLOMACY DIPLO_FOR_ALL
421 
422 #define GAME_DEFAULT_DIPLCHANCE 80
423 #define GAME_MIN_DIPLCHANCE 40
424 #define GAME_MAX_DIPLCHANCE 100
425 
426 #define GAME_DEFAULT_FREECOST 0
427 #define GAME_MIN_FREECOST 0
428 #define GAME_MAX_FREECOST 100
429 
430 #define GAME_DEFAULT_CONQUERCOST 0
431 #define GAME_MIN_CONQUERCOST 0
432 #define GAME_MAX_CONQUERCOST 100
433 
434 #define GAME_DEFAULT_TECHLOSSFG -1
435 #define GAME_MIN_TECHLOSSFG -1
436 #define GAME_MAX_TECHLOSSFG 200
437 
438 #define GAME_DEFAULT_TECHLOSSREST 50
439 #define GAME_MIN_TECHLOSSREST -1
440 #define GAME_MAX_TECHLOSSREST 100
441 
442 #define GAME_DEFAULT_TECHLEAK 100
443 #define GAME_MIN_TECHLEAK 0
444 #define GAME_MAX_TECHLEAK 300
445 
446 #define GAME_DEFAULT_CITYMINDIST 2
447 #define GAME_MIN_CITYMINDIST 1
448 #define GAME_MAX_CITYMINDIST 11
449 
450 #define GAME_DEFAULT_CIVILWARSIZE 10
451 #define GAME_MIN_CIVILWARSIZE 2 // can't split an empire of 1 city
452 #define GAME_MAX_CIVILWARSIZE 1000
453 
454 #define GAME_DEFAULT_RESTRICTINFRA false
455 #define GAME_DEFAULT_UNRPROTECTS true
456 
457 #define GAME_DEFAULT_CONTACTTURNS 20
458 #define GAME_MIN_CONTACTTURNS 0
459 #define GAME_MAX_CONTACTTURNS 100
460 
461 #define GAME_DEFAULT_CELEBRATESIZE 3
462 
463 #define GAME_DEFAULT_RAPTUREDELAY 1
464 #define GAME_MIN_RAPTUREDELAY 1
465 #define GAME_MAX_RAPTUREDELAY 99 // 99 practicaly disables rapturing
466 
467 #define GAME_DEFAULT_DISASTERS 10
468 #define GAME_MIN_DISASTERS 0
469 #define GAME_MAX_DISASTERS 1000
470 
471 #define GAME_DEFAULT_TRAIT_DIST_MODE TDM_FIXED
472 
473 #define GAME_DEFAULT_SAVEPALACE true
474 
475 #define GAME_DEFAULT_HOMECAUGHTUNITS true
476 
477 #define GAME_DEFAULT_NATURALCITYNAMES true
478 
479 #define GAME_DEFAULT_MIGRATION false
480 
481 #define GAME_DEFAULT_MGR_TURNINTERVAL 5
482 #define GAME_MIN_MGR_TURNINTERVAL 1
483 #define GAME_MAX_MGR_TURNINTERVAL 100
484 
485 #define GAME_DEFAULT_MGR_FOODNEEDED true
486 
487 /* definition of the migration distance in relation to the current city
488  * radius; 0 means that migration is possible if the second city is within
489  * the city radius */
490 #define GAME_DEFAULT_MGR_DISTANCE 0
491 #define GAME_MIN_MGR_DISTANCE (0 - CITY_MAP_MAX_RADIUS)
492 #define GAME_MAX_MGR_DISTANCE (1 + CITY_MAP_MAX_RADIUS)
493 
494 #define GAME_DEFAULT_MGR_NATIONCHANCE 50
495 #define GAME_MIN_MGR_NATIONCHANCE 0
496 #define GAME_MAX_MGR_NATIONCHANCE 100
497 
498 #define GAME_DEFAULT_MGR_WORLDCHANCE 10
499 #define GAME_MIN_MGR_WORLDCHANCE 0
500 #define GAME_MAX_MGR_WORLDCHANCE 100
501 
502 #define GAME_DEFAULT_AQUEDUCTLOSS 0
503 #define GAME_MIN_AQUEDUCTLOSS 0
504 #define GAME_MAX_AQUEDUCTLOSS 100
505 
506 #define GAME_DEFAULT_KILLSTACK true
507 #define GAME_DEFAULT_KILLCITIZEN true
508 
509 #define GAME_DEFAULT_KILLUNHOMED 0
510 #define GAME_MIN_KILLUNHOMED 0
511 #define GAME_MAX_KILLUNHOMED 100
512 
513 #define GAME_DEFAULT_TECHPENALTY 100
514 #define GAME_MIN_TECHPENALTY 0
515 #define GAME_MAX_TECHPENALTY 100
516 
517 #define GAME_DEFAULT_TECHLOST_RECV 0
518 #define GAME_MIN_TECHLOST_RECV 0
519 #define GAME_MAX_TECHLOST_RECV 100
520 
521 #define GAME_DEFAULT_TECHLOST_DONOR 0
522 #define GAME_MIN_TECHLOST_DONOR 0
523 #define GAME_MAX_TECHLOST_DONOR 100
524 
525 #define GAME_DEFAULT_TEAM_POOLED_RESEARCH true
526 #define GAME_DEFAULT_MULTIRESEARCH false
527 
528 #define GAME_DEFAULT_RAZECHANCE 20
529 #define GAME_MIN_RAZECHANCE 0
530 #define GAME_MAX_RAZECHANCE 100
531 
532 #define GAME_DEFAULT_REVEALMAP REVEAL_MAP_NONE
533 
534 #define GAME_DEFAULT_SCORELOG false
535 #define GAME_DEFAULT_SCORELOGLEVEL SL_ALL
536 #define GAME_DEFAULT_SCOREFILE "freeciv-score.log"
537 
538 /* Turns between reports is random between SCORETURN and (2 x SCORETURN).
539  * First report is shown at SCORETURN. As report is generated in the end of
540  * the turn, first report is already generated at (SCORETURN - 1) */
541 #define GAME_DEFAULT_SCORETURN 20
542 
543 #define GAME_DEFAULT_VICTORY_CONDITIONS \
544  ((victory_condition_type)(1 << VC_SPACERACE | 1 << VC_ALLIED))
545 #define GAME_DEFAULT_END_SPACESHIP true
546 
547 #define GAME_DEFAULT_SPACESHIP_TRAVEL_TIME 100
548 #define GAME_MIN_SPACESHIP_TRAVEL_TIME 50
549 #define GAME_MAX_SPACESHIP_TRAVEL_TIME 1000
550 
551 #define GAME_DEFAULT_TURNBLOCK true
552 
553 #define GAME_DEFAULT_AUTO_AI_TOGGLE false
554 
555 #define GAME_DEFAULT_TIMEOUT 0
556 #define GAME_DEFAULT_FIRST_TIMEOUT -1
557 #define GAME_DEFAULT_TIMEOUTINT 0
558 #define GAME_DEFAULT_TIMEOUTINTINC 0
559 #define GAME_DEFAULT_TIMEOUTINC 0
560 #define GAME_DEFAULT_TIMEOUTINCMULT 1
561 #define GAME_DEFAULT_TIMEOUTADDEMOVE 0
562 #define GAME_DEFAULT_TIMEOUTCOUNTER 1
563 
564 #define GAME_DEFAULT_MAXCONNECTIONSPERHOST 4
565 #define GAME_MIN_MAXCONNECTIONSPERHOST 0
566 #define GAME_MAX_MAXCONNECTIONSPERHOST MAX_NUM_CONNECTIONS
567 
568 #define GAME_MIN_TIMEOUT -1
569 #define GAME_MAX_TIMEOUT 8639999
570 #define GAME_MIN_FIRST_TIMEOUT -1
571 #define GAME_MAX_FIRST_TIMEOUT GAME_MAX_TIMEOUT
572 
573 #define GAME_MIN_UNITWAITTIME 0
574 #define GAME_MAX_UNITWAITTIME GAME_MAX_TIMEOUT
575 #define GAME_DEFAULT_UNITWAITTIME 0
576 #define GAME_DEFAULT_UNITWAITTIME_EXTENDED false
577 
578 #define GAME_DEFAULT_UNITWAITTIME_STYLE UWT_CLASSICAL
579 
580 #define GAME_DEFAULT_PHASE_MODE 0
581 
582 #define GAME_DEFAULT_NETWAIT 4
583 #define GAME_MIN_NETWAIT 0
584 #define GAME_MAX_NETWAIT 20
585 
586 #define GAME_DEFAULT_PINGTIME 20
587 #define GAME_MIN_PINGTIME 1
588 #define GAME_MAX_PINGTIME 1800
589 
590 #define GAME_DEFAULT_PINGTIMEOUT 60
591 #define GAME_MIN_PINGTIMEOUT 60
592 #define GAME_MAX_PINGTIMEOUT 1800
593 
594 #define GAME_DEFAULT_NOTRADESIZE 0
595 #define GAME_MIN_NOTRADESIZE 0
596 #define GAME_MAX_NOTRADESIZE 49
597 
598 #define GAME_DEFAULT_TRADEWORLDRELPCT 50
599 #define GAME_MIN_TRADEWORLDRELPCT 0
600 #define GAME_MAX_TRADEWORLDRELPCT 100
601 
602 #define GAME_DEFAULT_FULLTRADESIZE 1
603 #define GAME_MIN_FULLTRADESIZE 1
604 #define GAME_MAX_FULLTRADESIZE 50
605 
606 #define GAME_DEFAULT_TRADING_TECH true
607 #define GAME_DEFAULT_TRADING_GOLD true
608 #define GAME_DEFAULT_TRADING_CITY true
609 
610 #define GAME_DEFAULT_CARAVAN_BONUS_STYLE CBS_CLASSIC
611 
612 #define GAME_DEFAULT_TRADEMINDIST 9
613 #define GAME_MIN_TRADEMINDIST 1
614 #define GAME_MAX_TRADEMINDIST 999
615 
616 #define GAME_DEFAULT_TRADE_REVENUE_STYLE TRS_CLASSIC
617 
618 #define GAME_DEFAULT_BARBARIANRATE BARBS_NORMAL
619 
620 #define GAME_DEFAULT_ONSETBARBARIAN 60
621 #define GAME_MIN_ONSETBARBARIAN 1
622 #define GAME_MAX_ONSETBARBARIAN GAME_MAX_END_TURN
623 
624 #define GAME_DEFAULT_OCCUPYCHANCE 0
625 #define GAME_MIN_OCCUPYCHANCE 0
626 #define GAME_MAX_OCCUPYCHANCE 100
627 
628 #define GAME_DEFAULT_AUTOATTACK false
629 
630 #define GAME_DEFAULT_RULESETDIR "classic"
631 #define GAME_DEFAULT_SAVE_NAME "freeciv"
632 #define GAME_DEFAULT_SAVETURNS 1
633 #define GAME_MIN_SAVETURNS 1
634 #define GAME_MAX_SAVETURNS 200
635 #define GAME_DEFAULT_SAVEFREQUENCY 15
636 #define GAME_MIN_SAVEFREQUENCY 2
637 #define GAME_MAX_SAVEFREQUENCY 1440
638 
639 #define GAME_DEFAULT_AUTOSAVES \
640  (1 << AS_TURN | 1 << AS_GAME_OVER | 1 << AS_QUITIDLE | 1 << AS_INTERRUPT)
641 
642 #define GAME_DEFAULT_THREADED_SAVE false
643 
644 #define GAME_DEFAULT_USER_META_MESSAGE ""
645 
646 #define GAME_DEFAULT_SKILL_LEVEL AI_LEVEL_EASY
647 #define GAME_HARDCODED_DEFAULT_SKILL_LEVEL 3 // that was 'easy' in old saves
648 #define GAME_OLD_DEFAULT_SKILL_LEVEL 5 // normal; for oldest save games
649 
650 #define GAME_DEFAULT_DEMOGRAPHY "NASRLPEMOCqrb"
651 #define GAME_DEFAULT_ALLOW_TAKE "HAhadOo"
652 
653 #define GAME_DEFAULT_EVENT_CACHE_TURNS 1
654 #define GAME_MIN_EVENT_CACHE_TURNS 0
655 #define GAME_MAX_EVENT_CACHE_TURNS (GAME_MAX_END_TURN + 1)
656 
657 #define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE 256
658 #define GAME_MIN_EVENT_CACHE_MAX_SIZE 10
659 #define GAME_MAX_EVENT_CACHE_MAX_SIZE 20000
660 
661 #define GAME_DEFAULT_EVENT_CACHE_CHAT true
662 
663 #define GAME_DEFAULT_EVENT_CACHE_INFO false
664 
665 #ifdef FREECIV_HAVE_LZMA
666 #define GAME_DEFAULT_COMPRESS_TYPE COMPRESS_XZ
667 #else
668 #define GAME_DEFAULT_COMPRESS_TYPE COMPRESS_ZLIB
669 #endif
670 
671 #define GAME_DEFAULT_ALLOWED_CITY_NAMES CNM_PLAYER_UNIQUE
672 
673 #define GAME_DEFAULT_PLRCOLORMODE PLRCOL_PLR_ORDER
674 
675 #define GAME_DEFAULT_REVOLENTYPE REVOLEN_RANDOM
676 #define GAME_DEFAULT_REVOLUTION_LENGTH 5
677 #define GAME_MIN_REVOLUTION_LENGTH 1
678 #define GAME_MAX_REVOLUTION_LENGTH 20
679 
680 #define GAME_START_YEAR -4000
681 
682 #define GAME_DEFAULT_AIRLIFTINGSTYLE AIRLIFTING_CLASSICAL
683 #define GAME_DEFAULT_PERSISTENTREADY PERSISTENTR_DISABLED
684 
685 #define GAME_MAX_READ_RECURSION 10 // max recursion for the read command
686 
687 #define GAME_DEFAULT_KICK_TIME 1800 // 1800 seconds = 30 minutes.
688 #define GAME_MIN_KICK_TIME 0 // 0 = disabling.
689 #define GAME_MAX_KICK_TIME 86400 // 86400 seconds = 24 hours.
690 
691 // Max distance from the capital used to calculat the bribe cost.
692 #define GAME_UNIT_BRIBE_DIST_MAX 32
693 
694 // Max number of recursive transports.
695 #define GAME_TRANSPORT_MAX_RECURSIVE 5
696 
697 // ruleset settings
698 
699 #define RS_MAX_VALUE 1000000
700 
701 // TRANS: year label (Anno Domini)
702 #define RS_DEFAULT_POS_YEAR_LABEL N_("AD")
703 // TRANS: year label (Before Christ)
704 #define RS_DEFAULT_NEG_YEAR_LABEL N_("BC")
705 
706 #define RS_DEFAULT_ILLNESS_ON false
707 
708 #define RS_DEFAULT_ILLNESS_BASE_FACTOR 25
709 #define RS_MIN_ILLNESS_BASE_FACTOR 0
710 #define RS_MAX_ILLNESS_BASE_FACTOR RS_MAX_VALUE
711 
712 #define RS_DEFAULT_ILLNESS_MIN_SIZE 3
713 #define RS_MIN_ILLNESS_MIN_SIZE 1
714 #define RS_MAX_ILLNESS_MIN_SIZE 100
715 
716 #define RS_DEFAULT_ILLNESS_TRADE_INFECTION_PCT 50
717 #define RS_MIN_ILLNESS_TRADE_INFECTION_PCT 0
718 #define RS_MAX_ILLNESS_TRADE_INFECTION_PCT 500
719 
720 #define RS_DEFAULT_ILLNESS_POLLUTION_PCT 50
721 #define RS_MIN_ILLNESS_POLLUTION_PCT 0
722 #define RS_MAX_ILLNESS_POLLUTION_PCT 500
723 
724 #define RS_DEFAULT_CALENDAR_SKIP_0 true
725 
726 #define RS_DEFAULT_BORDER_RADIUS_SQ_CITY 17 // city radius 4
727 #define RS_MIN_BORDER_RADIUS_SQ_CITY 0
728 #define RS_MAX_BORDER_RADIUS_SQ_CITY 401 // city radius 20
729 
730 #define RS_DEFAULT_BORDER_SIZE_EFFECT 1
731 #define RS_MIN_BORDER_SIZE_EFFECT 0
732 #define RS_MAX_BORDER_SIZE_EFFECT 100
733 
734 #define RS_DEFAULT_BORDER_RADIUS_SQ_CITY_PERMANENT 0
735 #define RS_MIN_BORDER_RADIUS_SQ_CITY_PERMANENT (-CITY_MAP_MAX_RADIUS_SQ)
736 #define RS_MAX_BORDER_RADIUS_SQ_CITY_PERMANENT 401 // city radius 20
737 
738 #define RS_DEFAULT_INCITE_BASE_COST 1000
739 #define RS_MIN_INCITE_BASE_COST 0
740 #define RS_MAX_INCITE_BASE_COST RS_MAX_VALUE
741 
742 #define RS_DEFAULT_INCITE_IMPROVEMENT_FCT 1
743 #define RS_MIN_INCITE_IMPROVEMENT_FCT 0
744 #define RS_MAX_INCITE_IMPROVEMENT_FCT RS_MAX_VALUE
745 
746 #define RS_DEFAULT_INCITE_UNIT_FCT 2
747 #define RS_MIN_INCITE_UNIT_FCT 0
748 #define RS_MAX_INCITE_UNIT_FCT RS_MAX_VALUE
749 
750 #define RS_DEFAULT_INCITE_TOTAL_FCT 100
751 #define RS_MIN_INCITE_TOTAL_FCT 0
752 #define RS_MAX_INCITE_TOTAL_FCT RS_MAX_VALUE
753 
754 #define RS_DEFAULT_GRANARY_FOOD_INI 20
755 
756 #define RS_DEFAULT_GRANARY_FOOD_INC 10
757 #define RS_MIN_GRANARY_FOOD_INC 0
758 #define RS_MAX_GRANARY_FOOD_INC RS_MAX_VALUE
759 
760 #define RS_DEFAULT_CITY_CENTER_OUTPUT 0
761 #define RS_MIN_CITY_CENTER_OUTPUT 0
762 #define RS_MAX_CITY_CENTER_OUTPUT RS_MAX_VALUE
763 
764 // the constants CITY_MAP_*_RADIUS are defined in city.c
765 #define RS_DEFAULT_CITY_RADIUS_SQ CITY_MAP_DEFAULT_RADIUS_SQ
766 #define RS_MIN_CITY_RADIUS_SQ CITY_MAP_MIN_RADIUS_SQ
767 #define RS_MAX_CITY_RADIUS_SQ CITY_MAP_MAX_RADIUS_SQ
768 
769 #define RS_DEFAULT_VIS_RADIUS_SQ 5 // city radius 2
770 #define RS_MIN_VIS_RADIUS_SQ 0
771 #define RS_MAX_VIS_RADIUS_SQ 401 // city radius 20
772 
773 #define RS_DEFAULT_BASE_POLLUTION -20
774 /* no min / max values as it can be set to high negative values to
775  * deactiveate pollution and high positive values to create much
776  * pollution */
777 
778 #define RS_DEFAULT_HAPPY_COST 2
779 #define RS_MIN_HAPPY_COST 0
780 #define RS_MAX_HAPPY_COST 10000
781 
782 #define RS_DEFAULT_FOOD_COST 2
783 #define RS_MIN_FOOD_COST 0
784 #define RS_MAX_FOOD_COST 10000
785 
786 #define RS_DEFAULT_CIVIL_WAR_CELEB -5
787 #define RS_DEFAULT_CIVIL_WAR_UNHAPPY 5
788 
789 #define RS_DEFAULT_TIRED_ATTACK false
790 #define RS_DEFAULT_ONLY_KILLING_VETERAN false
791 #define RS_DEFAULT_NUKE_POP_LOSS_PCT 50
792 #define RS_MIN_NUKE_POP_LOSS_PCT 0
793 #define RS_MAX_NUKE_POP_LOSS_PCT 100
794 #define RS_DEFAULT_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT 0
795 #define RS_MIN_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT 0
796 #define RS_MAX_NUKE_DEFENDER_SURVIVAL_CHANCE_PCT 100
797 
798 #define RS_DEFAULT_BASE_BRIBE_COST 750
799 #define RS_MIN_BASE_BRIBE_COST 0
800 #define RS_MAX_BASE_BRIBE_COST RS_MAX_VALUE
801 
802 #define RS_DEFAULT_RANSOM_GOLD 100
803 #define RS_MIN_RANSOM_GOLD 0
804 #define RS_MAX_RANSOM_GOLD RS_MAX_VALUE
805 
806 #define RS_DEFAULT_PILLAGE_SELECT true
807 
808 #define RS_DEFAULT_UPGRADE_VETERAN_LOSS 0
809 #define RS_MIN_UPGRADE_VETERAN_LOSS 0
810 #define RS_MAX_UPGRADE_VETERAN_LOSS MAX_VET_LEVELS
811 
812 #define RS_DEFAULT_TECH_UPKEEP_DIVIDER 100
813 #define RS_MIN_TECH_UPKEEP_DIVIDER 1
814 #define RS_MAX_TECH_UPKEEP_DIVIDER 100000
815 
816 #define RS_DEFAULT_BASE_TECH_COST 20
817 #define RS_MIN_BASE_TECH_COST 0
818 #define RS_MAX_BASE_TECH_COST 20000
819 
820 #define RS_DEFAULT_FORCE_TRADE_ROUTE false
821 #define RS_DEFAULT_FORCE_CAPTURE_UNITS false
822 #define RS_DEFAULT_FORCE_BOMBARD false
823 #define RS_DEFAULT_FORCE_EXPLODE_NUCLEAR false
824 
825 #define RS_DEFAULT_POISON_EMPTIES_FOOD_STOCK false
826 #define RS_DEFAULT_STEAL_MAP_REVEALS_CITIES true
827 #define RS_DEFAULT_ACTION_ACTOR_CONSUMING_ALWAYS false
828 #define RS_DEFAULT_USER_ACTION_TARGET_KIND ATK_UNIT
829 #define RS_DEFAULT_ACTION_MIN_RANGE 0
830 #define RS_DEFAULT_ACTION_MAX_RANGE 1
831 #define RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE 0
832 
833 #define RS_ACTION_NO_MAX_DISTANCE "unlimited"
trait_dist_mode
Definition: fc_types.h:869
#define MAX_NUM_BUILDING_LIST
Definition: fc_types.h:38
#define MAX_LEN_ALLOW_TAKE
Definition: fc_types.h:65
#define MAX_LEN_STARTUNIT
Definition: fc_types.h:68
#define MAX_LEN_NAME
Definition: fc_types.h:61
#define MAX_LEN_DEMOGRAPHY
Definition: fc_types.h:64
#define MAX_NUM_TECH_LIST
Definition: fc_types.h:36
barbarians_rate
Definition: game.h:31
@ 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
void game_ruleset_init()
Initialize the objects which will read from a ruleset.
Definition: game.cpp:489
void game_ruleset_free()
Frees all memory which in objects which are read from a ruleset.
Definition: game.cpp:534
void i_am_client()
Set program type to client.
Definition: game.cpp:67
void user_flag_init(struct user_flag *flag)
Initialize user flag.
Definition: game.cpp:788
void game_reset()
Do all changes to change view, and not full game_free()/game_init().
Definition: game.cpp:466
struct unit * game_unit_by_number(int id)
Find unit out of all units in game: now uses fast idex method, instead of looking through all units o...
Definition: game.cpp:112
void user_flag_free(struct user_flag *flag)
Free user flag.
Definition: game.cpp:797
struct civ_game game
Definition: game.cpp:47
bool is_player_phase(const struct player *pplayer, int phase)
Return TRUE if it is this player's phase.
Definition: game.cpp:672
const char * population_to_text(int thousand_citizen)
Return a prettily formatted string containing the population text.
Definition: game.cpp:699
debug_globals
Definition: game.h:22
@ DEBUG_LAST
Definition: game.h:22
@ DEBUG_FERRIES
Definition: game.h:22
void game_map_init()
Initialize map-specific parts of the game structure.
Definition: game.cpp:437
void i_am_server()
Set program type to server.
Definition: game.cpp:62
void game_init(bool keep_ruleset_value)
Initialise all game settings.
Definition: game.cpp:420
bool is_server()
Is program type server?
Definition: game.cpp:57
struct world wld
Definition: game.cpp:48
static void i_am_tool()
Definition: game.h:295
scoreQtMsgType
Definition: game.h:62
@ SL_HUMANS
Definition: game.h:62
@ SL_ALL
Definition: game.h:62
void game_remove_unit(struct world *gworld, struct unit *punit)
In the server call wipe_unit(), and never this function directly.
Definition: game.cpp:120
int civ_population(const struct player *pplayer)
Count the # of thousand citizen in a civilisation.
Definition: game.cpp:72
struct city * game_city_by_name(const char *name)
Find city with given name from any player.
Definition: game.cpp:83
void game_remove_city(struct world *gworld, struct city *pcity)
Remove city from game.
Definition: game.cpp:166
compress_type
Definition: game.h:40
@ COMPRESS_ZLIB
Definition: game.h:42
@ COMPRESS_PLAIN
Definition: game.h:41
void initialize_globals()
Initialize wonder information.
Definition: game.cpp:640
autosave_type
Definition: game.h:54
@ 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
city_names_mode
Definition: game.h:24
@ 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
int current_turn_timeout()
Return timeout value for the current turn.
Definition: game.cpp:808
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
Definition: game.cpp:103
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
void game_free()
Frees all memory of the game.
Definition: game.cpp:450
const char * name
Definition: inputfile.cpp:118
#define MAX_LEN_MSG
Definition: packets.h:37
plrcolor_mode
Definition: player.h:33
Definition: city.h:291
Definition: game.h:73
int diplgoldcost
Definition: game.h:131
int contactturns
Definition: game.h:128
int num_phases
Definition: game.h:159
enum city_names_mode allowed_city_names
Definition: game.h:118
int unitwaittime
Definition: game.h:186
bool multiresearch
Definition: game.h:153
int incite_gold_capt_chance
Definition: game.h:133
char * nationlist
Definition: game.h:269
int named_teams
Definition: game.h:281
size_t as_count
Definition: game.h:280
char type[20]
Definition: game.h:258
bool unitwaittime_extended
Definition: game.h:187
struct civ_game::@28::@32::@34 save_options
int mgr_worldchance
Definition: game.h:152
struct rgbcolor_list * plr_colors
Definition: game.h:237
int kick_time
Definition: game.h:144
const char ** allowed_govs
Definition: game.h:272
int seed_setting
Definition: game.h:219
bool chat
Definition: game.h:244
void(* unit_deallocate)(int unit_id)
Definition: game.h:288
enum barbarians_rate barbarianrate
Definition: game.h:124
struct civ_game::@28::@32 server
diplstate_type initial_diplomatic_state
Definition: game.h:114
bool last_updated_year
Definition: game.h:229
int upgrade_veteran_loss
Definition: game.h:190
int dispersion
Definition: game.h:134
bool threaded_save
Definition: game.h:169
int max_size
Definition: game.h:243
struct rgbcolor * plr_bg_color
Definition: game.h:93
int incite_total_factor
Definition: game.h:141
int init_vis_radius_sq
Definition: game.h:143
civtimer * save_timer
Definition: game.h:211
char start_units[MAX_LEN_STARTUNIT]
Definition: game.h:178
int save_nturns
Definition: game.h:171
bool debug[DEBUG_LAST]
Definition: game.h:193
float turn_change_time
Definition: game.h:212
bool vision_reveal_tiles
Definition: game.h:191
struct packet_scenario_description scenario_desc
Definition: game.h:79
char * description_file
Definition: game.h:268
int mgr_nationchance
Definition: game.h:150
char connectmsg[MAX_LEN_MSG]
Definition: game.h:213
bool fixedlength
Definition: game.h:137
struct conn_list * glob_observers
Definition: game.h:89
bool save_private_map
Definition: game.h:253
int techlost_recv
Definition: game.h:183
struct packet_ruleset_control control
Definition: game.h:74
char * ruleset_summary
Definition: game.h:75
bool mgr_foodneeded
Definition: game.h:149
int diplchance
Definition: game.h:129
int netwait
Definition: game.h:158
char ** nc_agovs
Definition: game.h:273
unsigned unitwaittime_style
Definition: game.h:189
struct civ_game::@28::@31 client
bool fogofwar_old
Definition: game.h:227
int incite_gold_loss_chance
Definition: game.h:132
int end_turn
Definition: game.h:135
bool nuclear_winter
Definition: game.h:224
bool settings_gamestart_valid
Definition: game.h:235
enum plrcolor_mode plrcolormode
Definition: game.h:119
int onsetbarbarian
Definition: game.h:161
int spaceship_travel_time
Definition: game.h:168
struct civ_game::@30 callbacks
int base_incite_cost
Definition: game.h:125
char demography[MAX_LEN_DEMOGRAPHY]
Definition: game.h:232
struct conn_list * est_connections
Definition: game.h:88
int global_init_techs[MAX_NUM_TECH_LIST]
Definition: game.h:98
struct packet_game_info info
Definition: game.h:80
int autoupgrade_veteran_loss
Definition: game.h:123
int mgr_turninterval
Definition: game.h:151
char user_message[256]
Definition: game.h:257
int min_players
Definition: game.h:156
unsigned autosaves
Definition: game.h:174
int timeoutcounter
Definition: game.h:199
bool endspaceship
Definition: game.h:136
time_t last_ping
Definition: game.h:204
char rulesetdir[MAX_LEN_NAME]
Definition: game.h:231
bool ruleset_ready
Definition: game.h:107
civtimer * phase_timer
Definition: game.h:205
int start_year
Definition: game.h:180
bool migration
Definition: game.h:154
int additional_phase_seconds
Definition: game.h:206
struct civ_game::@28::@32::@36 mutexes
int incite_improvement_factor
Definition: game.h:140
struct section_file * luadata
Definition: game.h:239
int diplbulbcost
Definition: game.h:130
int scoreturn
Definition: game.h:218
bool natural_city_names
Definition: game.h:157
struct civ_game::@28::@32::@37 ruledit
char ** embedded_nations
Definition: game.h:270
enum scoreQtMsgType scoreloglevel
Definition: game.h:216
int global_init_buildings[MAX_NUM_BUILDING_LIST]
Definition: game.h:99
int maxconnectionsperhost
Definition: game.h:145
struct packet_scenario_info scenario
Definition: game.h:78
struct trait_limits default_traits[TRAIT_COUNT]
Definition: game.h:265
int timeoutint
Definition: game.h:194
int pingtimeout
Definition: game.h:163
char ** nc_astyles
Definition: game.h:279
int occupychance
Definition: game.h:160
int nuclear_winter_percent
Definition: game.h:225
int conquercost
Definition: game.h:127
unsigned revealmap
Definition: game.h:166
int pingtime
Definition: game.h:162
int techloss_restore
Definition: game.h:181
const char ** allowed_terrains
Definition: game.h:275
char * ruleset_description
Definition: game.h:76
int civilwarsize
Definition: game.h:126
struct conn_list * all_connections
Definition: game.h:87
bool save_known
Definition: game.h:250
size_t ag_count
Definition: game.h:274
bool savepalace
Definition: game.h:176
QMutex * city_list
Definition: game.h:262
int freecost
Definition: game.h:139
char nationset[MAX_LEN_NAME]
Definition: game.h:147
const char ** allowed_styles
Definition: game.h:278
struct civ_game::@28::@32::@33 event_cache
int aqueductloss
Definition: game.h:120
char save_name[MAX_LEN_NAME]
Definition: game.h:214
enum compress_type save_compress_type
Definition: game.h:170
struct civ_game::@27 rgame
enum trait_dist_mode trait_dist
Definition: game.h:155
bool foggedborders
Definition: game.h:138
char ** nc_aterrs
Definition: game.h:276
size_t embedded_nations_count
Definition: game.h:271
bool ruleset_init
Definition: game.h:106
int incite_unit_factor
Definition: game.h:142
char * ruleset_capabilities
Definition: game.h:77
int timeoutincmult
Definition: game.h:196
bool homecaughtunits
Definition: game.h:177
bool global_warming
Definition: game.h:222
int ransom_gold
Definition: game.h:164
int seed
Definition: game.h:220
struct packet_timeout_info tinfo
Definition: game.h:82
size_t at_count
Definition: game.h:277
int timeoutinc
Definition: game.h:195
char allow_take[MAX_LEN_ALLOW_TAKE]
Definition: game.h:233
bool autoattack
Definition: game.h:122
int phase_mode_stored
Definition: game.h:210
bool start_city
Definition: game.h:179
int max_players
Definition: game.h:146
int revolution_length
Definition: game.h:167
int turns
Definition: game.h:242
bool save_starts
Definition: game.h:252
char scorefile[MAX_LEN_NAME]
Definition: game.h:217
bool auto_ai_toggle
Definition: game.h:121
int save_frequency
Definition: game.h:172
struct veteran_system * veteran
Definition: game.h:91
int mgr_distance
Definition: game.h:148
int global_warming_percent
Definition: game.h:223
struct packet_calendar_info calendar
Definition: game.h:81
struct government * default_government
Definition: game.h:84
struct government * government_during_revolution
Definition: game.h:85
int timeoutintinc
Definition: game.h:198
bool info
Definition: game.h:245
int techlost_donor
Definition: game.h:182
int timeoutaddenemymove
Definition: game.h:201
bool scorelog
Definition: game.h:215
int techpenalty
Definition: game.h:184
int razechance
Definition: game.h:165
bool turnblock
Definition: game.h:185
struct civ_game::@28::@32::@35 meta_info
Definition: player.h:231
Definition: unit.h:134
Definition: game.h:64
char * name
Definition: game.h:65
char * helptxt
Definition: game.h:66