Freeciv-3.1
Loading...
Searching...
No Matches
game.c
Go to the documentation of this file.
1/***********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12***********************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "fcintl.h"
20#include "ioz.h"
21#include "log.h"
22#include "mem.h"
23#include "shared.h"
24#include "support.h"
25
26/* aicore */
27#include "cm.h"
28
29/* common */
30#include "ai.h"
31#include "achievements.h"
32#include "actions.h"
33#include "city.h"
34#include "connection.h"
35#include "disaster.h"
36#include "extras.h"
37#include "government.h"
38#include "idex.h"
39#include "map.h"
40#include "multipliers.h"
41#include "nation.h"
42#include "packets.h"
43#include "player.h"
44#include "research.h"
45#include "spaceship.h"
46#include "specialist.h"
47#include "style.h"
48#include "tech.h"
49#include "terrain.h"
50#include "traderoutes.h"
51#include "unit.h"
52#include "unitlist.h"
53#include "victory.h"
54
55#include "game.h"
56
58struct world wld;
59
61
63
64static void game_defaults(bool keep_ruleset_value);
65
66/**********************************************************************/
69int civ_population(const struct player *pplayer)
70{
71 int ppl = 0;
72
73 city_list_iterate(pplayer->cities, pcity) {
74 ppl += city_population(pcity);
76
77 return ppl;
78}
79
80/**********************************************************************/
83struct city *game_city_by_name(const char *name)
84{
85 players_iterate(pplayer) {
86 struct city *pcity = city_list_find_name(pplayer->cities, name);
87
88 if (pcity) {
89 return pcity;
90 }
92
93 return NULL;
94}
95
96
97/**********************************************************************/
103{
104 return idex_lookup_city(&wld, id);
105}
106
107/**********************************************************************/
112{
113 return idex_lookup_unit(&wld, id);
114}
115
116/**********************************************************************/
119void game_remove_unit(struct world *gworld, struct unit *punit)
120{
121 struct city *pcity;
122
123 /* It's possible that during city transfer homecity/unit owner
124 * information is inconsistent, and client then tries to remove
125 * now unseen unit so that homecity is not in the list of cities
126 * of the player (seemingly) owning the unit.
127 * Thus cannot use player_city_by_number() here, but have to
128 * consider cities of all players. */
130 if (pcity) {
131 unit_list_remove(pcity->units_supported, punit);
132
133 log_debug("game_remove_unit()"
134 " at (%d,%d) unit %d, %s %s home (%d,%d) city %d, %s %s",
136 punit->id,
139 TILE_XY(pcity->tile),
142 city_name_get(pcity));
143 } else if (IDENTITY_NUMBER_ZERO == punit->homecity) {
144 log_debug("game_remove_unit() at (%d,%d) unit %d, %s %s home %d",
146 punit->id,
149 punit->homecity);
150 } else {
151 log_error("game_remove_unit() at (%d,%d) unit %d, %s %s home %d invalid",
153 punit->id,
156 punit->homecity);
157 }
158
159 unit_list_remove(unit_tile(punit)->units, punit);
160 unit_list_remove(unit_owner(punit)->units, punit);
161
163
166 }
168}
169
170/**********************************************************************/
173void game_remove_city(struct world *gworld, struct city *pcity)
174{
175 struct tile *pcenter = city_tile(pcity);
176 struct player *powner = city_owner(pcity);
177 const struct civ_map *nmap = &(wld.map);
178
179 if (NULL != powner) {
180 /* Always unlink before clearing data */
181 city_list_remove(powner->cities, pcity);
182 }
183
184 if (NULL == pcenter) {
185 log_debug("game_remove_city() virtual city %d, %s",
186 pcity->id,
187 city_name_get(pcity));
188 } else {
189 log_debug("game_remove_city() at (%d,%d) city %d, %s %s",
190 TILE_XY(pcenter),
191 pcity->id,
193 city_name_get(pcity));
194
195 city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
196 if (tile_worked(ptile) == pcity) {
197 tile_set_worked(ptile, NULL);
198 }
200 }
201
202 idex_unregister_city(gworld, pcity);
204}
205
206/**********************************************************************/
209static void game_defaults(bool keep_ruleset_value)
210{
211 int i;
212
213 /* The control packet. */
235
236 game.ruleset_summary = NULL;
239
240 /* The info packet. */
249 game.info.cooling = 0;
250 game.info.coolinglevel = 0; /* set later */
256 for (i = 0; i < A_LAST; i++) {
257 /* game.num_tech_types = 0 here */
259 }
260 for (i = 0; i < B_LAST; i++) {
261 /* game.num_impr_types = 0 here */
263 }
272 game.info.heating = 0;
297 game.info.turn = 0;
298 game.info.warminglevel = 0; /* set later */
302
303 /* The scenario packets. */
305 game.scenario.name[0] = '\0';
306 game.scenario.authors[0] = '\0';
316
318
319 /* Veteran system. */
320 game.veteran = NULL;
321
322 /* player colors */
323 game.plr_bg_color = NULL;
324
325 if (is_server()) {
326 /* All settings only used by the server (./server/ and ./ai/ */
334 game.server.connectmsg[0] = '\0';
337 for (i = 0; i < DEBUG_LAST; i++) {
338 game.server.debug[i] = FALSE;
339 }
365 /* Do not clear meta_info.type here as it's already set to correct value */
388 if (!keep_ruleset_value) {
390 }
418 game.server.plr_colors = NULL;
419 } else {
420 /* Client side takes care of itself in client_main() */
421 }
422}
423
424/**********************************************************************/
429void game_init(bool keep_ruleset_value)
430{
431 game_defaults(keep_ruleset_value);
436 idex_init(&wld);
437 cm_init();
440}
441
442/**********************************************************************/
447{
448 /* FIXME: it's not clear where these values should be initialized. It
449 * can't be done in game_init because the map isn't created yet. Maybe it
450 * should be done in the mapgen code or in the maphand code. It should
451 * surely be called when the map is generated. */
452 game.info.warminglevel = (map_num_tiles() + 499) / 500;
453 game.info.coolinglevel = (map_num_tiles() + 499) / 500;
454}
455
456/**********************************************************************/
459void game_free(void)
460{
464 idex_free(&wld);
468 cm_free();
469}
470
471/**********************************************************************/
475void game_reset(void)
476{
477 if (is_server()) {
478 game_free();
480 } else {
481 /* Reset the players infos. */
482 players_iterate(pplayer) {
483 player_clear(pplayer, FALSE);
485
488 idex_free(&wld);
489
491 idex_init(&wld);
493 }
494}
495
496/**********************************************************************/
540
541/**********************************************************************/
545{
546 int i;
547
548 CALL_FUNC_EACH_AI(units_ruleset_close);
549
550 /* Clear main structures which can points to the ruleset dependent
551 * structures. */
552 players_iterate(pplayer) {
553 player_ruleset_close(pplayer);
556
559 techs_free();
561 nations_free();
567 goods_free();
568 extras_free();
571 styles_free();
572 actions_free();
583
584 /* Destroy the default veteran system. */
586 game.veteran = NULL;
587
588 /* Player colors. */
589 if (game.plr_bg_color != NULL) {
591 game.plr_bg_color = NULL;
592 }
593
594 if (is_server()) {
595 if (game.server.luadata != NULL) {
597 }
598 if (game.server.ruledit.description_file != NULL) {
601 }
602 if (game.server.ruledit.nationlist != NULL) {
605 }
606 if (game.server.ruledit.embedded_nations != NULL) {
607 for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
609 }
613 if (game.server.ruledit.allowed_govs != NULL) {
614 for (i = 0; i < game.server.ruledit.ag_count; i++) {
615 free(game.server.ruledit.nc_agovs[i]);
616 }
620 }
621 if (game.server.ruledit.allowed_terrains != NULL) {
622 for (i = 0; i < game.server.ruledit.at_count; i++) {
623 free(game.server.ruledit.nc_aterrs[i]);
624 }
628 }
629 if (game.server.ruledit.allowed_styles != NULL) {
630 for (i = 0; i < game.server.ruledit.as_count; i++) {
631 free(game.server.ruledit.nc_astyles[i]);
632 }
636 }
637 }
638 }
639
640 for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
642 }
643
644 if (game.ruleset_summary != NULL) {
645 free(game.ruleset_summary);
646 game.ruleset_summary = NULL;
647 }
648
649 if (game.ruleset_description != NULL) {
652 }
653
654 if (game.ruleset_capabilities != NULL) {
657 }
658}
659
660/**********************************************************************/
664{
665 players_iterate(pplayer) {
666 city_list_iterate(pplayer->cities, pcity) {
667 city_built_iterate(pcity, pimprove) {
668 if (is_wonder(pimprove)) {
669 if (is_great_wonder(pimprove)) {
671 player_number(pplayer);
672 }
673 pplayer->wonders[improvement_index(pimprove)] = pcity->id;
674 }
678}
679
680/**********************************************************************/
687bool is_player_phase(const struct player *pplayer, int phase)
688{
689 switch (game.info.phase_mode) {
690 case PMT_CONCURRENT:
691 return TRUE;
692 break;
693 case PMT_PLAYERS_ALTERNATE:
694 return player_number(pplayer) == phase;
695 break;
696 case PMT_TEAMS_ALTERNATE:
697 fc_assert_ret_val(NULL != pplayer->team, FALSE);
698 return team_number(pplayer->team) == phase;
699 break;
700 default:
701 break;
702 }
703
704 fc_assert_msg(FALSE, "Unrecognized phase mode %d in is_player_phase().",
705 phase);
706 return TRUE;
707}
708
709/**********************************************************************/
714const char *population_to_text(int thousand_citizen)
715{
716 /* big_int_to_text can't handle negative values, and in any case we'd
717 * better not have a negative population. */
718 fc_assert_ret_val(thousand_citizen >= 0, NULL);
719 return big_int_to_text(thousand_citizen, game.info.pop_report_zeroes - 1);
720}
721
722/**********************************************************************/
725static char *year_suffix(void)
726{
727 static char buf[MAX_LEN_NAME];
728 const char *suffix;
729 char safe_year_suffix[MAX_LEN_NAME];
730 const char *max = safe_year_suffix + MAX_LEN_NAME - 1;
731 char *c = safe_year_suffix;
732
733 if (game.info.year < 0) {
735 } else {
737 }
738
739 /* Remove all non alphanumeric characters from the year suffix. */
740 for (; '\0' != *suffix && c < max; suffix++) {
741 if (fc_isalnum(*suffix)) {
742 *c++ = *suffix;
743 }
744 }
745 *c = '\0';
746
747 fc_snprintf(buf, sizeof(buf), "%s", safe_year_suffix);
748
749 return buf;
750}
751
752/**********************************************************************/
771int generate_save_name(const char *format, char *buf, int buflen,
772 const char *reason)
773{
774 struct cf_sequence sequences[5] = {
775 cf_str_seq('R', (reason == NULL) ? "auto" : reason),
776 cf_str_seq('S', year_suffix()),
777 { 0 }, { 0 }, /* Works for both gcc and tcc */
778 cf_end()
779 };
780
781 cf_int_seq('T', game.info.turn, &sequences[2]);
782 cf_int_seq('Y', game.info.year, &sequences[3]);
783
784 fc_vsnprintcf(buf, buflen, format, sequences, -1);
785
786 if (0 == strcmp(format, buf)) {
787 /* Use the default savename if 'format' does not contain
788 * printf information. */
789 char savename[512];
790
791 fc_snprintf(savename, sizeof(savename), "%s-T%%04T-Y%%05Y-%%R",
792 format);
793 fc_vsnprintcf(buf, buflen, savename, sequences, -1);
794 }
795
796 log_debug("save name generated from '%s': %s", format, buf);
797
798 return strlen(buf);
799}
800
801/**********************************************************************/
804void user_flag_init(struct user_flag *flag)
805{
806 flag->name = NULL;
807 flag->helptxt = NULL;
808}
809
810/**********************************************************************/
813void user_flag_free(struct user_flag *flag)
814{
815 if (flag->name != NULL) {
816 FC_FREE(flag->name);
817 flag->name = NULL;
818 }
819 if (flag->helptxt != NULL) {
820 FC_FREE(flag->helptxt);
821 flag->helptxt = NULL;
822 }
823}
824
825/**********************************************************************/
829{
830 if (game.info.turn == 1 && game.info.first_timeout != -1) {
831 return game.info.first_timeout;
832 } else {
833 return game.info.timeout;
834 }
835}
void achievements_free(void)
void achievements_init(void)
void actions_free(void)
Definition actions.c:1530
void actions_init(void)
Definition actions.c:1460
#define CALL_FUNC_EACH_AI(_func,...)
Definition ai.h:384
#define BV_CLR_ALL(bv)
Definition bitvector.h:95
void city_styles_free(void)
Definition city.c:3324
const char * city_name_get(const struct city *pcity)
Definition city.c:1115
int city_population(const struct city *pcity)
Definition city.c:1169
void free_city_map_index(void)
Definition city.c:604
int city_map_radius_sq_get(const struct city *pcity)
Definition city.c:132
void destroy_city_virtual(struct city *pcity)
Definition city.c:3419
struct city * city_list_find_name(struct city_list *This, const char *name)
Definition city.c:1668
#define city_list_iterate(citylist, pcity)
Definition city.h:488
#define city_tile(_pcity_)
Definition city.h:544
#define city_owner(_pcity_)
Definition city.h:543
#define city_list_iterate_end
Definition city.h:490
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile)
Definition city.h:222
#define city_tile_iterate_end
Definition city.h:230
#define city_built_iterate(_pcity, _p)
Definition city.h:810
#define city_built_iterate_end
Definition city.h:816
void cm_init(void)
Definition cm.c:293
void cm_free(void)
Definition cm.c:328
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
Definition dialogs_g.h:73
void clause_infos_init(void)
Definition diptreaty.c:245
void clause_infos_free(void)
Definition diptreaty.c:260
void disaster_types_init(void)
Definition disaster.c:33
void disaster_types_free(void)
Definition disaster.c:46
void ruleset_cache_free(void)
Definition effects.c:271
void ruleset_cache_init(void)
Definition effects.c:245
void user_extra_flags_init(void)
Definition extras.c:858
void extras_free(void)
Definition extras.c:80
void extra_flags_free(void)
Definition extras.c:870
void extras_init(void)
Definition extras.c:43
static bool is_server(void)
#define MAX_CALENDAR_FRAGMENTS
Definition fc_types.h:62
#define MAX_LEN_NAME
Definition fc_types.h:66
#define IDENTITY_NUMBER_ZERO
Definition fc_types.h:82
const char * population_to_text(int thousand_citizen)
Definition game.c:714
void game_reset(void)
Definition game.c:475
void user_flag_init(struct user_flag *flag)
Definition game.c:804
void user_flag_free(struct user_flag *flag)
Definition game.c:813
struct civ_game game
Definition game.c:57
void game_ruleset_init(void)
Definition game.c:499
bool is_player_phase(const struct player *pplayer, int phase)
Definition game.c:687
static void game_defaults(bool keep_ruleset_value)
Definition game.c:209
static char * year_suffix(void)
Definition game.c:725
int current_turn_timeout(void)
Definition game.c:828
struct city * game_city_by_name(const char *name)
Definition game.c:83
void game_ruleset_free(void)
Definition game.c:544
void game_init(bool keep_ruleset_value)
Definition game.c:429
struct world wld
Definition game.c:58
bool _ruleset_compat_mode
Definition game.c:62
void game_remove_unit(struct world *gworld, struct unit *punit)
Definition game.c:119
struct unit * game_unit_by_number(int id)
Definition game.c:111
int civ_population(const struct player *pplayer)
Definition game.c:69
void game_remove_city(struct world *gworld, struct city *pcity)
Definition game.c:173
void game_free(void)
Definition game.c:459
void game_map_init(void)
Definition game.c:446
void initialize_globals(void)
Definition game.c:663
int generate_save_name(const char *format, char *buf, int buflen, const char *reason)
Definition game.c:771
bool am_i_server
Definition game.c:60
struct city * game_city_by_number(int id)
Definition game.c:102
#define GAME_DEFAULT_TECHPENALTY
Definition game.h:532
#define GAME_DEFAULT_SKILL_LEVEL
Definition game.h:675
#define GAME_DEFAULT_KILLSTACK
Definition game.h:525
#define GAME_DEFAULT_INFRA
Definition game.h:356
#define GAME_DEFAULT_REVOLENTYPE
Definition game.h:710
#define GAME_DEFAULT_AUTO_AI_TOGGLE
Definition game.h:571
#define GAME_DEFAULT_CARAVAN_BONUS_STYLE
Definition game.h:631
#define GAME_DEFAULT_TIMEOUTINTINC
Definition game.h:576
#define GAME_DEFAULT_SCORETURN
Definition game.h:560
#define GAME_DEFAULT_TCPTIMEOUT
Definition game.h:597
#define GAME_DEFAULT_EVENT_CACHE_INFO
Definition game.h:692
#define GAME_DEFAULT_MGR_FOODNEEDED
Definition game.h:504
#define GAME_DEFAULT_TECHLOST_DONOR
Definition game.h:540
#define GAME_DEFAULT_TIMEOUTINT
Definition game.h:575
#define GAME_DEFAULT_ALLOWED_CITY_NAMES
Definition game.h:706
#define GAME_DEFAULT_SCORELOG
Definition game.h:553
#define GAME_DEFAULT_OCCUPYCHANCE
Definition game.h:645
#define GAME_DEFAULT_GLOBAL_WARMING_PERCENT
Definition game.h:425
#define GAME_DEFAULT_TRADING_TECH
Definition game.h:627
#define GAME_DEFAULT_SAVETURNS
Definition game.h:658
#define GAME_DEFAULT_BORDERS
Definition game.h:435
#define GAME_DEFAULT_AIRLIFTINGSTYLE
Definition game.h:717
#define GAME_DEFAULT_KILLUNHOMED
Definition game.h:528
#define GAME_DEFAULT_SCIENCEBOX
Definition game.h:399
#define GAME_DEFAULT_MGR_WORLDCHANCE
Definition game.h:517
#define GAME_DEFAULT_ONSETBARBARIAN
Definition game.h:641
#define GAME_DEFAULT_KILLCITIZEN
Definition game.h:526
#define GAME_DEFAULT_SHIELDBOX
Definition game.h:395
@ DEBUG_LAST
Definition game.h:41
#define GAME_DEFAULT_MAXCONNECTIONSPERHOST
Definition game.h:582
#define GAME_DEFAULT_INCITE_GOLD_CAPT_CHANCE
Definition game.h:415
#define GAME_DEFAULT_DEMOGRAPHY
Definition game.h:679
#define GAME_DEFAULT_FULLTRADESIZE
Definition game.h:623
#define GAME_DEFAULT_TIMEOUTINCMULT
Definition game.h:578
#define GAME_DEFAULT_CELEBRATESIZE
Definition game.h:480
#define GAME_DEFAULT_RAPTUREDELAY
Definition game.h:482
#define GAME_DEFAULT_REVOLUTION_LENGTH
Definition game.h:711
#define GAME_DEFAULT_MGR_TURNINTERVAL
Definition game.h:500
#define GAME_DEFAULT_TIMEOUTINC
Definition game.h:577
#define GAME_DEFAULT_START_UNITS
Definition game.h:360
#define GAME_DEFAULT_ALLOW_TAKE
Definition game.h:680
#define GAME_DEFAULT_MIN_PLAYERS
Definition game.h:377
#define GAME_DEFAULT_SPACESHIP_TRAVEL_TIME
Definition game.h:565
#define GAME_DEFAULT_RULESETDIR
Definition game.h:654
#define GAME_DEFAULT_AUTOATTACK
Definition game.h:649
#define GAME_DEFAULT_REVEALMAP
Definition game.h:551
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
Definition game.h:544
#define GAME_DEFAULT_SEED
Definition game.h:348
#define GAME_DEFAULT_HOMECAUGHTUNITS
Definition game.h:494
#define GAME_DEFAULT_NETWAIT
Definition game.h:601
#define GAME_DEFAULT_KICK_TIME
Definition game.h:722
#define GAME_DEFAULT_PLRCOLORMODE
Definition game.h:708
#define GAME_DEFAULT_DIPLCHANCE
Definition game.h:441
#define GAME_DEFAULT_RAZECHANCE
Definition game.h:547
#define GAME_DEFAULT_START_YEAR
Definition game.h:715
#define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE
Definition game.h:411
#define GAME_DEFAULT_TIMEOUTCOUNTER
Definition game.h:580
#define GAME_DEFAULT_TRADING_CITY
Definition game.h:629
#define GAME_DEFAULT_FOODBOX
Definition game.h:391
#define GAME_DEFAULT_COMPRESS_TYPE
Definition game.h:703
#define GAME_DEFAULT_PINGTIMEOUT
Definition game.h:609
#define GAME_DEFAULT_TRADE_REVENUE_STYLE
Definition game.h:637
#define GAME_DEFAULT_SAVEPALACE
Definition game.h:492
#define GAME_DEFAULT_GLOBAL_WARMING
Definition game.h:423
#define GAME_DEFAULT_TECHLOST_RECV
Definition game.h:536
#define GAME_DEFAULT_NOTRADESIZE
Definition game.h:615
#define GAME_DEFAULT_COMPRESS_LEVEL
Definition game.h:694
#define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT
Definition game.h:431
#define GAME_DEFAULT_TRADING_GOLD
Definition game.h:628
#define GAME_DEFAULT_TRAIT_DIST_MODE
Definition game.h:490
#define GAME_DEFAULT_NUCLEAR_WINTER
Definition game.h:429
#define GAME_DEFAULT_FREECOST
Definition game.h:445
#define GAME_DEFAULT_MAX_PLAYERS
Definition game.h:381
#define GAME_DEFAULT_CITYMINDIST
Definition game.h:465
#define GAME_DEFAULT_PHASE_MODE
Definition game.h:595
#define GAME_DEFAULT_AIFILL
Definition game.h:385
#define GAME_DEFAULT_MULTIRESEARCH
Definition game.h:545
#define GAME_DEFAULT_CONQUERCOST
Definition game.h:449
#define GAME_DEFAULT_TIMEOUT
Definition game.h:573
#define GAME_DEFAULT_CONTACTTURNS
Definition game.h:476
#define GAME_DEFAULT_SCORELOGLEVEL
Definition game.h:554
#define GAME_DEFAULT_TECHLEVEL
Definition game.h:367
#define GAME_DEFAULT_DISASTERS
Definition game.h:486
#define GAME_DEFAULT_GOLD
Definition game.h:352
#define GAME_DEFAULT_MIGRATION
Definition game.h:498
#define GAME_DEFAULT_NATURALCITYNAMES
Definition game.h:496
#define GAME_DEFAULT_EVENT_CACHE_TURNS
Definition game.h:682
#define GAME_DEFAULT_VICTORY_CONDITIONS
Definition game.h:562
#define GAME_DEFAULT_FOGGEDBORDERS
Definition game.h:421
#define GAME_DEFAULT_UNITWAITTIME
Definition game.h:593
#define GAME_DEFAULT_TIMEOUTADDEMOVE
Definition game.h:579
#define GAME_DEFAULT_DISPERSION
Definition game.h:363
#define GAME_DEFAULT_EVENT_CACHE_CHAT
Definition game.h:690
#define GAME_DEFAULT_DIPLOMACY
Definition game.h:439
#define GAME_DEFAULT_MGR_DISTANCE
Definition game.h:509
#define GAME_DEFAULT_TURNBLOCK
Definition game.h:569
#define GAME_DEFAULT_PINGTIME
Definition game.h:605
#define GAME_DEFAULT_AQUEDUCTLOSS
Definition game.h:521
#define GAME_DEFAULT_TRADEMINDIST
Definition game.h:633
#define GAME_DEFAULT_ANGRYCITIZEN
Definition game.h:371
#define GAME_DEFAULT_BARBARIANRATE
Definition game.h:639
#define GAME_DEFAULT_HAPPYBORDERS
Definition game.h:437
#define GAME_DEFAULT_END_TURN
Definition game.h:373
#define GAME_DEFAULT_DIPLGOLDCOST
Definition game.h:407
#define GAME_DEFAULT_END_SPACESHIP
Definition game.h:563
#define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
Definition game.h:686
#define GAME_DEFAULT_SAVE_NAME
Definition game.h:657
#define GAME_DEFAULT_MGR_NATIONCHANCE
Definition game.h:513
#define GAME_DEFAULT_FOGOFWAR
Definition game.h:419
#define GAME_DEFAULT_DIPLBULBCOST
Definition game.h:403
#define GAME_DEFAULT_RESTRICTINFRA
Definition game.h:473
#define GAME_DEFAULT_CIVILWARSIZE
Definition game.h:469
void governments_free(void)
Definition government.c:544
#define G_LAST
Definition government.h:48
void idex_free(struct world *iworld)
Definition idex.c:53
struct city * idex_lookup_city(struct world *iworld, int id)
Definition idex.c:132
void idex_unregister_city(struct world *iworld, struct city *pcity)
Definition idex.c:96
void idex_init(struct world *iworld)
Definition idex.c:44
struct unit * idex_lookup_unit(struct world *iworld, int id)
Definition idex.c:145
void idex_unregister_unit(struct world *iworld, struct unit *punit)
Definition idex.c:114
void improvements_init(void)
Definition improvement.c:46
Impr_type_id improvement_index(const struct impr_type *pimprove)
bool is_wonder(const struct impr_type *pimprove)
bool is_great_wonder(const struct impr_type *pimprove)
void improvements_free(void)
Definition improvement.c:80
#define WONDER_NOT_OWNED
#define B_LAST
Definition improvement.h:42
const char * name
Definition inputfile.c:127
#define fc_assert_msg(condition, message,...)
Definition log.h:181
#define fc_assert_ret_val(condition, val)
Definition log.h:194
#define log_debug(message,...)
Definition log.h:115
#define log_error(message,...)
Definition log.h:103
void main_map_free(void)
Definition map.c:552
int map_num_tiles(void)
Definition map.c:1012
void map_init(struct civ_map *imap, bool server_side)
Definition map.c:157
#define FC_FREE(ptr)
Definition mem.h:41
void multipliers_free(void)
Definition multipliers.c:43
void multipliers_init(void)
Definition multipliers.c:28
void nations_free(void)
Definition nation.c:636
const char * nation_rule_name(const struct nation_type *pnation)
Definition nation.c:137
struct nation_type * nation_of_unit(const struct unit *punit)
Definition nation.c:462
struct nation_type * nation_of_player(const struct player *pplayer)
Definition nation.c:443
struct nation_type * nation_of_city(const struct city *pcity)
Definition nation.c:453
void nation_sets_groups_free(void)
Definition nation.c:1177
void nation_sets_groups_init(void)
Definition nation.c:1169
int player_number(const struct player *pplayer)
Definition player.c:828
void player_slots_free(void)
Definition player.c:379
void player_ruleset_close(struct player *pplayer)
Definition player.c:736
void player_clear(struct player *pplayer, bool full)
Definition player.c:660
void player_slots_init(void)
Definition player.c:353
#define players_iterate_end
Definition player.h:535
#define players_iterate(_pplayer)
Definition player.h:530
void secfile_destroy(struct section_file *secfile)
void universal_found_functions_init(void)
void researches_init(void)
Definition research.c:62
void researches_free(void)
Definition research.c:98
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Definition rgbcolor.c:74
int fc_vsnprintcf(char *buf, size_t buf_len, const char *format, const struct cf_sequence *sequences, size_t sequences_num)
Definition shared.c:2193
const char * big_int_to_text(unsigned int mantissa, unsigned int exponent)
Definition shared.c:159
static struct cf_sequence cf_end(void)
Definition shared.h:425
static void cf_int_seq(char letter, int value, struct cf_sequence *out)
Definition shared.h:359
static struct cf_sequence cf_str_seq(char letter, const char *value)
Definition shared.h:411
void specialists_free(void)
Definition specialist.c:53
void specialists_init(void)
Definition specialist.c:36
Definition city.h:309
int id
Definition city.h:315
struct tile * tile
Definition city.h:311
struct unit_list * units_supported
Definition city.h:391
int diplgoldcost
Definition game.h:139
int contactturns
Definition game.h:136
struct civ_game::@30::@34::@36 save_options
enum city_names_mode allowed_city_names
Definition game.h:126
int unitwaittime
Definition game.h:197
bool multiresearch
Definition game.h:162
int incite_gold_capt_chance
Definition game.h:141
char * nationlist
Definition game.h:274
size_t as_count
Definition game.h:285
int mgr_worldchance
Definition game.h:161
struct rgbcolor_list * plr_colors
Definition game.h:242
int kick_time
Definition game.h:152
const char ** allowed_govs
Definition game.h:277
bool chat
Definition game.h:249
void(* unit_deallocate)(int unit_id)
Definition game.h:293
enum barbarians_rate barbarianrate
Definition game.h:132
bool last_updated_year
Definition game.h:234
int dispersion
Definition game.h:142
int max_size
Definition game.h:248
int save_compress_level
Definition game.h:180
struct rgbcolor * plr_bg_color
Definition game.h:102
int tcptimeout
Definition game.h:194
struct civ_game::@30::@34 server
char start_units[MAX_LEN_STARTUNIT]
Definition game.h:188
int save_nturns
Definition game.h:182
bool debug[DEBUG_LAST]
Definition game.h:201
struct packet_scenario_description scenario_desc
Definition game.h:88
char * description_file
Definition game.h:273
int mgr_nationchance
Definition game.h:159
char connectmsg[MAX_LEN_MSG]
Definition game.h:218
bool save_private_map
Definition game.h:258
int techlost_recv
Definition game.h:193
struct packet_ruleset_control control
Definition game.h:83
char * ruleset_summary
Definition game.h:84
bool mgr_foodneeded
Definition game.h:158
struct civ_game::@30::@34::@35 event_cache
int diplchance
Definition game.h:137
int netwait
Definition game.h:167
char ** nc_agovs
Definition game.h:278
struct civ_game::@32 callbacks
bool fogofwar_old
Definition game.h:232
int incite_gold_loss_chance
Definition game.h:140
int end_turn
Definition game.h:143
enum plrcolor_mode plrcolormode
Definition game.h:127
int onsetbarbarian
Definition game.h:170
int spaceship_travel_time
Definition game.h:178
char demography[MAX_LEN_DEMOGRAPHY]
Definition game.h:237
struct packet_game_info info
Definition game.h:89
int mgr_turninterval
Definition game.h:160
char user_message[256]
Definition game.h:262
int min_players
Definition game.h:165
int timeoutcounter
Definition game.h:206
bool endspaceship
Definition game.h:144
time_t last_ping
Definition game.h:209
enum scorelog_level scoreloglevel
Definition game.h:221
char rulesetdir[MAX_LEN_NAME]
Definition game.h:236
int start_year
Definition game.h:190
bool migration
Definition game.h:163
int additional_phase_seconds
Definition game.h:211
struct section_file * luadata
Definition game.h:244
int diplbulbcost
Definition game.h:138
int scoreturn
Definition game.h:223
struct civ_game::@30::@34::@37 meta_info
randseed seed
Definition game.h:225
bool natural_city_names
Definition game.h:166
char ** embedded_nations
Definition game.h:275
struct civ_game::@30::@34::@39 ruledit
int maxconnectionsperhost
Definition game.h:154
struct packet_scenario_info scenario
Definition game.h:87
int timeoutint
Definition game.h:202
int pingtimeout
Definition game.h:172
char ** nc_astyles
Definition game.h:284
int occupychance
Definition game.h:169
int killunhomed
Definition game.h:153
int nuclear_winter_percent
Definition game.h:230
int conquercost
Definition game.h:135
unsigned revealmap
Definition game.h:176
int pingtime
Definition game.h:171
const char ** allowed_terrains
Definition game.h:280
char * ruleset_description
Definition game.h:85
int civilwarsize
Definition game.h:134
bool save_known
Definition game.h:255
size_t ag_count
Definition game.h:279
bool savepalace
Definition game.h:186
int freecost
Definition game.h:147
const char ** allowed_styles
Definition game.h:283
int aqueductloss
Definition game.h:128
char save_name[MAX_LEN_NAME]
Definition game.h:219
enum fz_method save_compress_type
Definition game.h:181
enum trait_dist_mode trait_dist
Definition game.h:164
bool foggedborders
Definition game.h:146
char ** nc_aterrs
Definition game.h:281
size_t embedded_nations_count
Definition game.h:276
char * ruleset_capabilities
Definition game.h:86
int timeoutincmult
Definition game.h:204
bool homecaughtunits
Definition game.h:187
size_t at_count
Definition game.h:282
int timeoutinc
Definition game.h:203
char allow_take[MAX_LEN_ALLOW_TAKE]
Definition game.h:238
bool autoattack
Definition game.h:130
int phase_mode_stored
Definition game.h:215
int max_players
Definition game.h:155
int revolution_length
Definition game.h:177
int turns
Definition game.h:247
bool save_starts
Definition game.h:257
bool auto_ai_toggle
Definition game.h:129
struct veteran_system * veteran
Definition game.h:100
int mgr_distance
Definition game.h:157
int global_warming_percent
Definition game.h:228
struct packet_calendar_info calendar
Definition game.h:90
struct government * government_during_revolution
Definition game.h:94
int timeoutintinc
Definition game.h:205
int techlost_donor
Definition game.h:192
int timeoutaddenemymove
Definition game.h:207
bool scorelog
Definition game.h:220
int techpenalty
Definition game.h:195
int razechance
Definition game.h:175
bool turnblock
Definition game.h:196
char positive_year_label[MAX_LEN_NAME]
char negative_year_label[MAX_LEN_NAME]
char calendar_fragment_name[MAX_CALENDAR_FRAGMENTS][MAX_LEN_NAME]
enum borders_mode borders
enum happyborders_type happyborders
Government_type_id government_during_revolution_id
enum diplomacy_mode diplomacy
enum trade_revenue_style trade_revenue_style
int great_wonder_owners[B_LAST]
bool global_advances[A_LAST]
enum airlifting_style airlifting_style
enum ai_level skill_level
enum revolen_type revolentype
enum phase_mode_type phase_mode
enum caravan_bonus_style caravan_bonus_style
bv_actions diplchance_initial_odds
enum victory_condition_type victory_conditions
Government_type_id default_government_id
char preferred_soundset[MAX_LEN_NAME]
char preferred_tileset[MAX_LEN_NAME]
char preferred_musicset[MAX_LEN_NAME]
char description[MAX_LEN_CONTENT]
char authors[MAX_LEN_PACKET/3]
struct city_list * cities
Definition player.h:281
struct team * team
Definition player.h:261
Definition tile.h:49
Definition unit.h:138
int id
Definition unit.h:145
int homecity
Definition unit.h:146
char * name
Definition game.h:74
char * helptxt
Definition game.h:75
struct civ_map map
void styles_free(void)
Definition style.c:51
void music_styles_free(void)
Definition style.c:148
int fc_snprintf(char *str, size_t n, const char *format,...)
Definition support.c:969
bool fc_isalnum(char c)
Definition support.c:1205
#define sz_strlcpy(dest, src)
Definition support.h:167
#define TRUE
Definition support.h:46
#define FALSE
Definition support.h:47
void team_slots_free(void)
Definition team.c:85
int team_number(const struct team *pteam)
Definition team.c:391
void team_slots_init(void)
Definition team.c:53
void tech_classes_init(void)
Definition tech.c:307
void techs_init(void)
Definition tech.c:459
void techs_free(void)
Definition tech.c:510
void user_tech_flags_init(void)
Definition tech.c:370
void user_tech_flags_free(void)
Definition tech.c:382
#define A_LAST
Definition tech.h:45
void user_terrain_flags_init(void)
Definition terrain.c:752
void terrains_free(void)
Definition terrain.c:59
void terrains_init(void)
Definition terrain.c:42
void user_terrain_flags_free(void)
Definition terrain.c:764
void tile_set_worked(struct tile *ptile, struct city *pcity)
Definition tile.c:106
#define tile_worked(_tile)
Definition tile.h:113
#define TILE_XY(ptile)
Definition tile.h:42
void trade_route_types_init(void)
void goods_init(void)
void goods_free(void)
void unit_virtual_destroy(struct unit *punit)
Definition unit.c:1713
#define unit_tile(_pu)
Definition unit.h:395
#define unit_owner(_pu)
Definition unit.h:394
void unit_types_init(void)
Definition unittype.c:2395
void user_unit_type_flags_init(void)
Definition unittype.c:1916
void unit_class_flags_free(void)
Definition unittype.c:2460
const char * unit_rule_name(const struct unit *punit)
Definition unittype.c:1639
void unit_types_free(void)
Definition unittype.c:2434
void veteran_system_destroy(struct veteran_system *vsystem)
Definition unittype.c:2720
void unit_classes_free(void)
Definition unittype.c:2577
void unit_type_flags_free(void)
Definition unittype.c:2448
void user_unit_class_flags_init(void)
Definition unittype.c:1852
void unit_classes_init(void)
Definition unittype.c:2555
void role_unit_precalcs_free(void)
Definition unittype.c:2208