Freeciv21
Develop your civilization from humble roots to a global empire
game.cpp
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 
14 // utility
15 #include "log.h"
16 #include "shared.h"
17 #include "support.h"
18 
19 // aicore
20 #include "cm.h"
21 
22 // common
23 #include "achievements.h"
24 #include "actions.h"
25 #include "ai.h"
26 #include "city.h"
27 #include "disaster.h"
28 #include "effects.h"
29 #include "extras.h"
30 #include "government.h"
31 #include "idex.h"
32 #include "map.h"
33 #include "multipliers.h"
34 #include "nation.h"
35 #include "packets.h"
36 #include "player.h"
37 #include "research.h"
38 #include "specialist.h"
39 #include "style.h"
40 #include "tech.h"
41 #include "terrain.h"
42 #include "traderoutes.h"
43 #include "unit.h"
44 
45 #include "game.h"
46 
47 struct civ_game game;
48 struct world wld;
49 
50 bool am_i_server = false;
51 
52 static void game_defaults(bool keep_ruleset_value);
53 
57 bool is_server() { return am_i_server; }
58 
62 void i_am_server() { am_i_server = true; }
63 
67 void i_am_client() { am_i_server = false; }
68 
72 int civ_population(const struct player *pplayer)
73 {
74  int ppl = 0;
75  city_list_iterate(pplayer->cities, pcity) ppl += city_population(pcity);
77  return ppl;
78 }
79 
83 struct city *game_city_by_name(const char *name)
84 {
85  players_iterate(pplayer)
86  {
87  struct city *pcity = city_list_find_name(pplayer->cities, name);
88 
89  if (pcity) {
90  return pcity;
91  }
92  }
94 
95  return nullptr;
96 }
97 
103 struct city *game_city_by_number(int id)
104 {
105  return idex_lookup_city(&wld, id);
106 }
107 
112 struct unit *game_unit_by_number(int id)
113 {
114  return idex_lookup_unit(&wld, id);
115 }
116 
120 void game_remove_unit(struct world *gworld, struct unit *punit)
121 {
122  struct city *pcity;
123 
124  /* It's possible that during city transfer homecity/unit owner
125  * information is inconsistent, and client then tries to remove
126  * now unseen unit so that homecity is not in the list of cities
127  * of the player (seemingly) owning the unit.
128  * Thus cannot use player_city_by_number() here, but have to
129  * consider cities of all players. */
130  pcity = game_city_by_number(punit->homecity);
131  if (pcity) {
132  unit_list_remove(pcity->units_supported, punit);
133 
134  log_debug("game_remove_unit()"
135  " at (%d,%d) unit %d, %s %s home (%d,%d) city %d, %s %s",
136  TILE_XY(unit_tile(punit)), punit->id,
138  TILE_XY(pcity->tile), punit->homecity,
140  } else if (IDENTITY_NUMBER_ZERO == punit->homecity) {
141  log_debug("game_remove_unit() at (%d,%d) unit %d, %s %s home %d",
142  TILE_XY(unit_tile(punit)), punit->id,
144  punit->homecity);
145  } else {
146  qCritical("game_remove_unit() at (%d,%d) unit %d, %s %s home %d invalid",
147  TILE_XY(unit_tile(punit)), punit->id,
149  punit->homecity);
150  }
151 
152  unit_list_remove(unit_tile(punit)->units, punit);
153  unit_list_remove(unit_owner(punit)->units, punit);
154 
155  idex_unregister_unit(gworld, punit);
156 
158  (game.callbacks.unit_deallocate)(punit->id);
159  }
160  unit_virtual_destroy(punit);
161 }
162 
166 void game_remove_city(struct world *gworld, struct city *pcity)
167 {
168  struct tile *pcenter = city_tile(pcity);
169  struct player *powner = city_owner(pcity);
170 
171  if (nullptr != powner) {
172  // always unlink before clearing data
173  city_list_remove(powner->cities, pcity);
174  }
175 
176  if (nullptr == pcenter) {
177  log_debug("game_remove_city() virtual city %d, %s", pcity->id,
178  city_name_get(pcity));
179  } else {
180  log_debug("game_remove_city() at (%d,%d) city %d, %s %s",
181  TILE_XY(pcenter), pcity->id,
183  city_name_get(pcity));
184 
185  city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile)
186  {
187  if (tile_worked(ptile) == pcity) {
188  tile_set_worked(ptile, nullptr);
189  }
190  }
192  }
193 
194  idex_unregister_city(gworld, pcity);
195  destroy_city_virtual(pcity);
196 }
197 
201 static void game_defaults(bool keep_ruleset_value)
202 {
203  int i;
204 
205  // The control packet.
206  game.control.government_count = 0;
207  game.control.nation_count = 0;
208  game.control.num_base_types = 0;
209  game.control.num_road_types = 0;
210  game.control.num_resource_types = 0;
211  game.control.num_impr_types = 0;
212  game.control.num_specialist_types = 0;
213  game.control.num_tech_types = 0;
214  game.control.num_unit_classes = 0;
215  game.control.num_unit_types = 0;
216  game.control.num_disaster_types = 0;
217  game.control.num_achievement_types = 0;
218  game.control.num_styles = 0;
219  game.control.num_music_styles = 0;
220  game.control.preferred_tileset[0] = '\0';
221  game.control.preferred_soundset[0] = '\0';
222  game.control.preferred_musicset[0] = '\0';
223  game.control.styles_count = 0;
224  game.control.terrain_count = 0;
225 
226  game.ruleset_summary = nullptr;
227  game.ruleset_description = nullptr;
228  game.ruleset_capabilities = nullptr;
229 
230  // The info packet.
231  game.info.aifill = GAME_DEFAULT_AIFILL;
232  game.info.airlifting_style = GAME_DEFAULT_AIRLIFTINGSTYLE;
233  game.info.angrycitizen = GAME_DEFAULT_ANGRYCITIZEN;
234  game.info.borders = GAME_DEFAULT_BORDERS;
235  game.calendar.calendar_skip_0 = false;
236  game.info.caravan_bonus_style = GAME_DEFAULT_CARAVAN_BONUS_STYLE;
237  game.info.celebratesize = GAME_DEFAULT_CELEBRATESIZE;
238  game.info.citymindist = GAME_DEFAULT_CITYMINDIST;
239  game.info.cooling = 0;
240  game.info.coolinglevel = 0; // set later
241  game.info.diplomacy = GAME_DEFAULT_DIPLOMACY;
242  game.info.fogofwar = GAME_DEFAULT_FOGOFWAR;
243  game.info.foodbox = GAME_DEFAULT_FOODBOX;
244  game.info.fulltradesize = GAME_DEFAULT_FULLTRADESIZE;
245  game.info.global_advance_count = 0;
246  for (i = 0; i < A_LAST; i++) {
247  // game.num_tech_types = 0 here
248  game.info.global_advances[i] = false;
249  }
250  for (i = 0; i < B_LAST; i++) {
251  // game.num_impr_types = 0 here
252  game.info.great_wonder_owners[i] = WONDER_NOT_OWNED;
253  }
254  game.info.globalwarming = 0;
255  game.info.global_warming = GAME_DEFAULT_GLOBAL_WARMING;
256  game.info.gold = GAME_DEFAULT_GOLD;
257  game.info._unused = 0;
258  game.info.revolentype = GAME_DEFAULT_REVOLENTYPE;
259  game.info.default_government_id = G_LAST;
260  game.info.government_during_revolution_id = G_LAST;
261  game.info.happyborders = GAME_DEFAULT_HAPPYBORDERS;
262  game.info.heating = 0;
263  game.info.is_edit_mode = false;
264  game.info.is_new_game = true;
265  game.info.killstack = GAME_DEFAULT_KILLSTACK;
266  game.info.killcitizen = GAME_DEFAULT_KILLCITIZEN;
267  game.calendar.negative_year_label[0] = '\0';
268  game.info.notradesize = GAME_DEFAULT_NOTRADESIZE;
269  game.info.nuclearwinter = 0;
270  game.info.nuclear_winter = GAME_DEFAULT_NUCLEAR_WINTER;
271  game.calendar.positive_year_label[0] = '\0';
272  game.info.rapturedelay = GAME_DEFAULT_RAPTUREDELAY;
273  game.info.disasters = GAME_DEFAULT_DISASTERS;
274  game.info.restrictinfra = GAME_DEFAULT_RESTRICTINFRA;
275  game.info.sciencebox = GAME_DEFAULT_SCIENCEBOX;
276  game.info.shieldbox = GAME_DEFAULT_SHIELDBOX;
277  game.info.skill_level = GAME_DEFAULT_SKILL_LEVEL;
278  game.info.victory_conditions = GAME_DEFAULT_VICTORY_CONDITIONS;
279  game.info.team_pooled_research = GAME_DEFAULT_TEAM_POOLED_RESEARCH;
281  game.info.timeout = GAME_DEFAULT_TIMEOUT;
282  game.info.trademindist = GAME_DEFAULT_TRADEMINDIST;
283  game.info.trade_revenue_style = GAME_DEFAULT_TRADE_REVENUE_STYLE;
284  game.info.trading_city = GAME_DEFAULT_TRADING_CITY;
285  game.info.trading_gold = GAME_DEFAULT_TRADING_GOLD;
286  game.info.trading_tech = GAME_DEFAULT_TRADING_TECH;
287  game.info.turn = 0;
288  game.info.warminglevel = 0; // set later
289  game.info.year_0_hack = false;
290  game.info.year = GAME_START_YEAR;
291  game.info.killunhomed = GAME_DEFAULT_KILLUNHOMED;
292 
293  // The scenario packets.
294  game.scenario.is_scenario = false;
295  game.scenario.name[0] = '\0';
296  game.scenario.authors[0] = '\0';
297  game.scenario.players = true;
298  game.scenario.startpos_nations = false;
299  game.scenario.handmade = false;
300  game.scenario.prevent_new_cities = false;
301  game.scenario.lake_flooding = true;
302  game.scenario.have_resources = true;
303  game.scenario.ruleset_locked = true;
304  game.scenario.save_random = false;
305  game.scenario.allow_ai_type_fallback = true;
306 
307  game.scenario_desc.description[0] = '\0';
308 
309  // Veteran system.
310  game.veteran = nullptr;
311 
312  // player colors
313  game.plr_bg_color = nullptr;
314 
315  if (is_server()) {
316  /* All settings only used by the server (./server/ and ./ai/ */
318  game.server.allowed_city_names = GAME_DEFAULT_ALLOWED_CITY_NAMES;
319  game.server.aqueductloss = GAME_DEFAULT_AQUEDUCTLOSS;
320  game.server.auto_ai_toggle = GAME_DEFAULT_AUTO_AI_TOGGLE;
321  game.server.autoattack = GAME_DEFAULT_AUTOATTACK;
322  game.server.barbarianrate = GAME_DEFAULT_BARBARIANRATE;
323  game.server.civilwarsize = GAME_DEFAULT_CIVILWARSIZE;
324  game.server.connectmsg[0] = '\0';
325  game.server.conquercost = GAME_DEFAULT_CONQUERCOST;
326  game.server.contactturns = GAME_DEFAULT_CONTACTTURNS;
327  for (i = 0; i < DEBUG_LAST; i++) {
328  game.server.debug[i] = false;
329  }
331  game.server.diplchance = GAME_DEFAULT_DIPLCHANCE;
332  game.server.diplbulbcost = GAME_DEFAULT_DIPLBULBCOST;
333  game.server.diplgoldcost = GAME_DEFAULT_DIPLGOLDCOST;
334  game.server.incite_gold_loss_chance =
336  game.server.incite_gold_capt_chance =
338  game.server.dispersion = GAME_DEFAULT_DISPERSION;
339  game.server.endspaceship = GAME_DEFAULT_END_SPACESHIP;
340  game.server.end_turn = GAME_DEFAULT_END_TURN;
341  game.server.event_cache.chat = GAME_DEFAULT_EVENT_CACHE_CHAT;
342  game.server.event_cache.info = GAME_DEFAULT_EVENT_CACHE_INFO;
343  game.server.event_cache.max_size = GAME_DEFAULT_EVENT_CACHE_MAX_SIZE;
344  game.server.event_cache.turns = GAME_DEFAULT_EVENT_CACHE_TURNS;
345  game.server.foggedborders = GAME_DEFAULT_FOGGEDBORDERS;
346  game.server.fogofwar_old = game.info.fogofwar;
347  game.server.last_updated_year = false;
348  game.server.freecost = GAME_DEFAULT_FREECOST;
349  game.server.global_warming_percent = GAME_DEFAULT_GLOBAL_WARMING_PERCENT;
350  game.server.homecaughtunits = GAME_DEFAULT_HOMECAUGHTUNITS;
351  game.server.kick_time = GAME_DEFAULT_KICK_TIME;
352  game.server.maxconnectionsperhost = GAME_DEFAULT_MAXCONNECTIONSPERHOST;
353  game.server.last_ping = 0;
354  game.server.max_players = GAME_DEFAULT_MAX_PLAYERS;
355  game.server.meta_info.user_message[0] = '\0';
356  /* Do not clear meta_info.type here as it's already set to correct value
357  */
358  game.server.mgr_distance = GAME_DEFAULT_MGR_DISTANCE;
359  game.server.mgr_foodneeded = GAME_DEFAULT_MGR_FOODNEEDED;
360  game.server.mgr_nationchance = GAME_DEFAULT_MGR_NATIONCHANCE;
361  game.server.mgr_turninterval = GAME_DEFAULT_MGR_TURNINTERVAL;
362  game.server.mgr_worldchance = GAME_DEFAULT_MGR_WORLDCHANCE;
363  game.server.multiresearch = GAME_DEFAULT_MULTIRESEARCH;
364  game.server.migration = GAME_DEFAULT_MIGRATION;
366  game.server.min_players = GAME_DEFAULT_MIN_PLAYERS;
367  game.server.natural_city_names = GAME_DEFAULT_NATURALCITYNAMES;
368  game.server.nuclear_winter_percent = GAME_DEFAULT_NUCLEAR_WINTER_PERCENT;
369  game.server.plrcolormode = GAME_DEFAULT_PLRCOLORMODE;
370  game.server.netwait = GAME_DEFAULT_NETWAIT;
371  game.server.occupychance = GAME_DEFAULT_OCCUPYCHANCE;
372  game.server.onsetbarbarian = GAME_DEFAULT_ONSETBARBARIAN;
373  game.server.additional_phase_seconds = 0;
374  game.server.phase_mode_stored = GAME_DEFAULT_PHASE_MODE;
375  game.server.pingtime = GAME_DEFAULT_PINGTIME;
376  game.server.pingtimeout = GAME_DEFAULT_PINGTIMEOUT;
377  game.server.razechance = GAME_DEFAULT_RAZECHANCE;
378  game.server.revealmap = GAME_DEFAULT_REVEALMAP;
379  game.server.revolution_length = GAME_DEFAULT_REVOLUTION_LENGTH;
380  if (!keep_ruleset_value) {
382  }
383  game.server.save_compress_type = GAME_DEFAULT_COMPRESS_TYPE;
385  game.server.save_nturns = GAME_DEFAULT_SAVETURNS;
386  game.server.save_options.save_known = true;
387  game.server.save_options.save_private_map = true;
388  game.server.save_options.save_starts = true;
389  game.server.savepalace = GAME_DEFAULT_SAVEPALACE;
390  game.server.scorelog = GAME_DEFAULT_SCORELOG;
391  game.server.scoreloglevel = GAME_DEFAULT_SCORELOGLEVEL;
392  game.server.scoreturn = GAME_DEFAULT_SCORETURN - 1;
395  game.server.spaceship_travel_time = GAME_DEFAULT_SPACESHIP_TRAVEL_TIME;
396  game.server.start_year = GAME_START_YEAR;
397  game.server.techlost_donor = GAME_DEFAULT_TECHLOST_DONOR;
398  game.server.techlost_recv = GAME_DEFAULT_TECHLOST_RECV;
399  game.server.techpenalty = GAME_DEFAULT_TECHPENALTY;
400  game.server.timeoutaddenemymove = GAME_DEFAULT_TIMEOUTADDEMOVE;
401  game.server.timeoutcounter = GAME_DEFAULT_TIMEOUTCOUNTER;
402  game.server.timeoutinc = GAME_DEFAULT_TIMEOUTINC;
403  game.server.timeoutincmult = GAME_DEFAULT_TIMEOUTINCMULT;
404  game.server.timeoutint = GAME_DEFAULT_TIMEOUTINT;
405  game.server.timeoutintinc = GAME_DEFAULT_TIMEOUTINTINC;
406  game.server.turnblock = GAME_DEFAULT_TURNBLOCK;
407  game.server.unitwaittime = GAME_DEFAULT_UNITWAITTIME;
408  game.server.unitwaittime_extended = GAME_DEFAULT_UNITWAITTIME_EXTENDED;
409  game.server.plr_colors = nullptr;
410  } else {
411  // Client side takes care of itself in client_main()
412  }
413 }
414 
420 void game_init(bool keep_ruleset_value)
421 {
422  game_defaults(keep_ruleset_value);
424  map_init(&wld.map, is_server());
425  team_slots_init();
427  idex_init(&wld);
428  cm_init();
429  researches_init();
431 }
432 
438 {
439  /* FIXME: it's not clear where these values should be initialized. It
440  * can't be done in game_init because the map isn't created yet. Maybe it
441  * should be done in the mapgen code or in the maphand code. It should
442  * surely be called when the map is generated. */
443  game.info.warminglevel = (map_num_tiles() + 499) / 500;
444  game.info.coolinglevel = (map_num_tiles() + 499) / 500;
445 }
446 
450 void game_free()
451 {
453  main_map_free();
455  idex_free(&wld);
456  team_slots_free();
458  researches_free();
459  cm_free();
460 }
461 
467 {
468  if (is_server()) {
469  game_free();
470  game_init(false);
471  } else {
472  // Reset the players infos.
473  players_iterate(pplayer) { player_clear(pplayer, false); }
475 
476  main_map_free();
478  idex_free(&wld);
479 
480  map_init(&wld.map, false);
481  idex_init(&wld);
482  researches_init();
483  }
484 }
485 
490 {
495  actions_init();
497  terrains_init();
498  extras_init();
499  goods_init();
501  techs_init();
503  unit_types_init();
513 
514  if (is_server()) {
515  game.server.luadata = nullptr;
516  game.server.ruledit.nationlist = nullptr;
517  game.server.ruledit.embedded_nations = nullptr;
518  game.server.ruledit.embedded_nations_count = 0;
519  game.server.ruledit.allowed_govs = nullptr;
520  game.server.ruledit.allowed_terrains = nullptr;
521  game.server.ruledit.allowed_styles = nullptr;
522  game.server.ruledit.nc_agovs = nullptr;
523  game.server.ruledit.nc_aterrs = nullptr;
524  game.server.ruledit.nc_astyles = nullptr;
525  game.server.ruledit.ag_count = 0;
526  game.server.ruledit.at_count = 0;
527  game.server.ruledit.as_count = 0;
528  }
529 }
530 
535 {
536  int i;
537 
538  CALL_FUNC_EACH_AI(units_ruleset_close);
539 
540  /* Clear main structures which can points to the ruleset dependent
541  * structures. */
542  players_iterate(pplayer) { player_ruleset_close(pplayer); }
545 
548  techs_free();
550  nations_free();
551  unit_types_free();
556  goods_free();
557  extras_free();
560  styles_free();
561  actions_free();
564  terrains_free();
572 
573  // Destroy the default veteran system.
575  game.veteran = nullptr;
576 
577  // Player colors.
578  if (game.plr_bg_color != nullptr) {
580  game.plr_bg_color = nullptr;
581  }
582 
583  if (is_server()) {
584  if (game.server.luadata != nullptr) {
585  secfile_destroy(game.server.luadata);
586  }
587  delete[] game.server.ruledit.description_file;
588  game.server.ruledit.description_file = nullptr;
589  delete[] game.server.ruledit.nationlist;
590  game.server.ruledit.nationlist = nullptr;
591  if (game.server.ruledit.embedded_nations != nullptr) {
592  for (i = 0; i < game.server.ruledit.embedded_nations_count; i++) {
593  delete[] game.server.ruledit.embedded_nations[i];
594  }
595  delete[] game.server.ruledit.embedded_nations;
596  game.server.ruledit.embedded_nations = nullptr;
597  game.server.ruledit.embedded_nations_count = 0;
598  if (game.server.ruledit.allowed_govs != nullptr) {
599  for (i = 0; i < game.server.ruledit.ag_count; i++) {
600  delete[] game.server.ruledit.nc_agovs[i];
601  }
602  delete[] game.server.ruledit.allowed_govs;
603  game.server.ruledit.allowed_govs = nullptr;
604  game.server.ruledit.nc_agovs = nullptr;
605  }
606  if (game.server.ruledit.allowed_terrains != nullptr) {
607  for (i = 0; i < game.server.ruledit.at_count; i++) {
608  delete[] game.server.ruledit.nc_aterrs[i];
609  }
610  delete[] game.server.ruledit.allowed_terrains;
611  game.server.ruledit.allowed_terrains = nullptr;
612  game.server.ruledit.nc_aterrs = nullptr;
613  }
614  if (game.server.ruledit.allowed_styles != nullptr) {
615  for (i = 0; i < game.server.ruledit.as_count; i++) {
616  delete[] game.server.ruledit.nc_astyles[i];
617  }
618  delete[] game.server.ruledit.allowed_styles;
619  game.server.ruledit.allowed_styles = nullptr;
620  game.server.ruledit.nc_astyles = nullptr;
621  }
622  }
623  }
624 
625  for (i = 0; i < MAX_CALENDAR_FRAGMENTS; i++) {
626  game.calendar.calendar_fragment_name[i][0] = '\0';
627  }
628 
629  delete[] game.ruleset_summary;
630  delete[] game.ruleset_description;
631  delete[] game.ruleset_capabilities;
632  game.ruleset_summary = nullptr;
633  game.ruleset_description = nullptr;
634  game.ruleset_capabilities = nullptr;
635 }
636 
641 {
642  players_iterate(pplayer)
643  {
644  city_list_iterate(pplayer->cities, pcity)
645  {
646  city_built_iterate(pcity, pimprove)
647  {
648  if (is_wonder(pimprove)) {
649  if (is_great_wonder(pimprove)) {
650  game.info.great_wonder_owners[improvement_index(pimprove)] =
651  player_number(pplayer);
652  }
653  if (get_building_bonus(pcity, pimprove, EFT_WONDER_VISIBLE) > 0) {
654  pplayer->wonders[improvement_index(pimprove)] = pcity->id;
655  }
656  }
657  }
659  }
661  }
663 }
664 
672 bool is_player_phase(const struct player *pplayer, int phase)
673 {
674  switch (game.info.phase_mode) {
675  case PMT_CONCURRENT:
676  return true;
677  break;
678  case PMT_PLAYERS_ALTERNATE:
679  return player_number(pplayer) == phase;
680  break;
681  case PMT_TEAMS_ALTERNATE:
682  fc_assert_ret_val(nullptr != pplayer->team, false);
683  return team_number(pplayer->team) == phase;
684  break;
685  default:
686  break;
687  }
688 
689  fc_assert_msg(false, "Unrecognized phase mode %d in is_player_phase().",
690  phase);
691  return true;
692 }
693 
699 const char *population_to_text(int thousand_citizen)
700 {
701  /* big_int_to_text can't handle negative values, and in any case we'd
702  * better not have a negative population. */
703  fc_assert_ret_val(thousand_citizen >= 0, nullptr);
704  return big_int_to_text(thousand_citizen, game.info.pop_report_zeroes - 1);
705 }
706 
710 static char *year_suffix()
711 {
712  static char buf[MAX_LEN_NAME];
713  const char *suffix;
714  char safe_year_suffix[MAX_LEN_NAME];
715  const char *max = safe_year_suffix + MAX_LEN_NAME - 1;
716  char *c = safe_year_suffix;
717 
718  if (game.info.year < 0) {
719  suffix = game.calendar.negative_year_label;
720  } else {
721  suffix = game.calendar.positive_year_label;
722  }
723 
724  // Remove all non alphanumeric characters from the year suffix.
725  for (; '\0' != *suffix && c < max; suffix++) {
726  if (QChar::isLetterOrNumber(*suffix)) {
727  *c++ = *suffix;
728  }
729  }
730  *c = '\0';
731 
732  fc_snprintf(buf, sizeof(buf), "%s", safe_year_suffix);
733 
734  return buf;
735 }
736 
756 int generate_save_name(const char *format, char *buf, int buflen,
757  const char *reason)
758 {
759  struct cf_sequence sequences[5] = {
760  cf_str_seq('R', (reason == nullptr) ? "auto" : reason),
761  cf_str_seq('S', year_suffix()),
762  {cf_type(0)},
763  {cf_type(0)},
764  cf_end()};
765 
766  cf_int_seq('T', game.info.turn, &sequences[2]);
767  cf_int_seq('Y', game.info.year, &sequences[3]);
768 
769  fc_vsnprintcf(buf, buflen, format, sequences, -1);
770 
771  if (0 == strcmp(format, buf)) {
772  /* Use the default savename if 'format' does not contain
773  * printf information. */
774  char savename[512];
775 
776  fc_snprintf(savename, sizeof(savename), "%s-T%%04T-Y%%05Y-%%R", format);
777  fc_vsnprintcf(buf, buflen, savename, sequences, -1);
778  }
779 
780  log_debug("save name generated from '%s': %s", format, buf);
781 
782  return qstrlen(buf);
783 }
784 
788 void user_flag_init(struct user_flag *flag)
789 {
790  flag->name = nullptr;
791  flag->helptxt = nullptr;
792 }
793 
797 void user_flag_free(struct user_flag *flag)
798 {
799  delete[] flag->name;
800  delete[] flag->helptxt;
801  flag->name = nullptr;
802  flag->helptxt = nullptr;
803 }
804 
809 {
810  if (game.info.turn == 1 && game.info.first_timeout != -1) {
811  return game.info.first_timeout;
812  } else {
813  return game.info.timeout;
814  }
815 }
void achievements_init()
Initialize achievements.
void achievements_free()
Free the memory associated with achievements.
void actions_init()
Initialize the actions and the action enablers.
Definition: actions.cpp:934
void actions_free()
Free the actions and the action enablers.
Definition: actions.cpp:994
#define CALL_FUNC_EACH_AI(_func,...)
Definition: ai.h:393
void city_styles_free()
De-allocate the memory used by the city styles.
Definition: city.cpp:3327
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
Definition: city.cpp:1083
int city_population(const struct city *pcity)
Returns how many thousand citizen live in this city.
Definition: city.cpp:1137
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
Definition: city.cpp:1095
const char * city_name_get(const struct city *pcity)
Return the name of the city.
Definition: city.cpp:1077
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
Definition: city.cpp:130
void destroy_city_virtual(struct city *pcity)
Removes the virtual skeleton of a city.
Definition: city.cpp:3421
struct city * city_list_find_name(struct city_list *This, const char *name)
Find city with given name from list.
Definition: city.cpp:1616
void free_city_map_index()
Free memory allocated by generate_citymap_index.
Definition: city.cpp:581
#define city_list_iterate(citylist, pcity)
Definition: city.h:482
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
Definition: city.h:202
#define city_list_iterate_end
Definition: city.h:484
#define city_tile_iterate_end
Definition: city.h:209
#define city_built_iterate(_pcity, _p)
Definition: city.h:752
#define city_built_iterate_end
Definition: city.h:759
void cm_init()
Initialize the CM data at the start of each game.
Definition: cm.cpp:288
void cm_free()
Called at the end of a game to free any CM data.
Definition: cm.cpp:315
void clause_infos_free()
Free memory associated with clause infos.
Definition: diptreaty.cpp:244
void clause_infos_init()
Initialize clause info structures.
Definition: diptreaty.cpp:229
void disaster_types_init()
Initialize disaster_type structures.
Definition: disaster.cpp:27
void disaster_types_free()
Free the memory associated with disaster types.
Definition: disaster.cpp:40
void ruleset_cache_init()
Initialize the ruleset cache.
Definition: effects.cpp:219
void ruleset_cache_free()
Free the ruleset cache.
Definition: effects.cpp:245
int get_building_bonus(const struct city *pcity, const struct impr_type *building, enum effect_type effect_type)
Returns the effect bonus at a building.
Definition: effects.cpp:819
void extra_flags_free()
Frees the memory associated with all extra flags.
Definition: extras.cpp:847
void extras_init()
Initialize extras structures.
Definition: extras.cpp:36
void extras_free()
Free the memory associated with extras.
Definition: extras.cpp:71
void user_extra_flags_init()
Initialize user extra flags.
Definition: extras.cpp:835
#define MAX_CALENDAR_FRAGMENTS
Definition: fc_types.h:57
#define MAX_LEN_NAME
Definition: fc_types.h:61
#define IDENTITY_NUMBER_ZERO
Definition: fc_types.h:76
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
static char * year_suffix()
Return a string containing the save year.
Definition: game.cpp:710
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
static void game_defaults(bool keep_ruleset_value)
Set default game values.
Definition: game.cpp:201
const char * population_to_text(int thousand_citizen)
Return a prettily formatted string containing the population text.
Definition: game.cpp:699
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
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
void initialize_globals()
Initialize wonder information.
Definition: game.cpp:640
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
bool am_i_server
Definition: game.cpp:50
void game_free()
Frees all memory of the game.
Definition: game.cpp:450
#define GAME_DEFAULT_TECHPENALTY
Definition: game.h:513
#define GAME_DEFAULT_SKILL_LEVEL
Definition: game.h:646
#define GAME_DEFAULT_KILLSTACK
Definition: game.h:506
#define GAME_DEFAULT_REVOLENTYPE
Definition: game.h:675
#define GAME_DEFAULT_AUTO_AI_TOGGLE
Definition: game.h:553
#define GAME_DEFAULT_CARAVAN_BONUS_STYLE
Definition: game.h:610
#define GAME_DEFAULT_TIMEOUTINTINC
Definition: game.h:558
#define GAME_DEFAULT_SCORETURN
Definition: game.h:541
#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_TIMEOUTINT
Definition: game.h:557
#define GAME_DEFAULT_ALLOWED_CITY_NAMES
Definition: game.h:671
#define GAME_DEFAULT_SCORELOG
Definition: game.h:534
#define GAME_DEFAULT_OCCUPYCHANCE
Definition: game.h:624
#define GAME_DEFAULT_GLOBAL_WARMING_PERCENT
Definition: game.h:406
#define GAME_DEFAULT_TRADING_TECH
Definition: game.h:606
#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_DEFAULT_KILLUNHOMED
Definition: game.h:509
#define GAME_DEFAULT_SCIENCEBOX
Definition: game.h:380
#define GAME_DEFAULT_MGR_WORLDCHANCE
Definition: game.h:498
#define GAME_DEFAULT_ONSETBARBARIAN
Definition: game.h:620
#define GAME_DEFAULT_KILLCITIZEN
Definition: game.h:507
#define GAME_DEFAULT_SHIELDBOX
Definition: game.h:376
@ DEBUG_LAST
Definition: game.h:22
#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_DEFAULT_FULLTRADESIZE
Definition: game.h:602
#define GAME_DEFAULT_TIMEOUTINCMULT
Definition: game.h:560
#define GAME_DEFAULT_CELEBRATESIZE
Definition: game.h:461
#define GAME_DEFAULT_RAPTUREDELAY
Definition: game.h:463
#define GAME_DEFAULT_REVOLUTION_LENGTH
Definition: game.h:676
#define GAME_DEFAULT_MGR_TURNINTERVAL
Definition: game.h:481
#define GAME_DEFAULT_TIMEOUTINC
Definition: game.h:559
#define GAME_DEFAULT_START_UNITS
Definition: game.h:341
#define GAME_DEFAULT_ALLOW_TAKE
Definition: game.h:651
#define GAME_DEFAULT_MIN_PLAYERS
Definition: game.h:358
#define GAME_DEFAULT_SPACESHIP_TRAVEL_TIME
Definition: game.h:547
#define GAME_DEFAULT_RULESETDIR
Definition: game.h:630
#define GAME_DEFAULT_AUTOATTACK
Definition: game.h:628
#define GAME_DEFAULT_REVEALMAP
Definition: game.h:532
#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_DEFAULT_NETWAIT
Definition: game.h:582
#define GAME_DEFAULT_KICK_TIME
Definition: game.h:687
#define GAME_DEFAULT_PLRCOLORMODE
Definition: game.h:673
#define GAME_DEFAULT_DIPLCHANCE
Definition: game.h:422
#define GAME_DEFAULT_RAZECHANCE
Definition: game.h:528
#define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE
Definition: game.h:392
#define GAME_DEFAULT_TIMEOUTCOUNTER
Definition: game.h:562
#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_DEFAULT_PINGTIMEOUT
Definition: game.h:590
#define GAME_DEFAULT_TRADE_REVENUE_STYLE
Definition: game.h:616
#define GAME_DEFAULT_SAVEPALACE
Definition: game.h:473
#define GAME_DEFAULT_GLOBAL_WARMING
Definition: game.h:404
#define GAME_DEFAULT_TECHLOST_RECV
Definition: game.h:517
#define GAME_DEFAULT_NOTRADESIZE
Definition: game.h:594
#define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT
Definition: game.h:412
#define GAME_DEFAULT_TRADING_GOLD
Definition: game.h:607
#define GAME_START_YEAR
Definition: game.h:680
#define GAME_DEFAULT_TRAIT_DIST_MODE
Definition: game.h:471
#define GAME_DEFAULT_NUCLEAR_WINTER
Definition: game.h:410
#define GAME_DEFAULT_FREECOST
Definition: game.h:426
#define GAME_DEFAULT_MAX_PLAYERS
Definition: game.h:362
#define GAME_DEFAULT_CITYMINDIST
Definition: game.h:446
#define GAME_DEFAULT_PHASE_MODE
Definition: game.h:580
#define GAME_DEFAULT_AIFILL
Definition: game.h:366
#define GAME_DEFAULT_MULTIRESEARCH
Definition: game.h:526
#define GAME_DEFAULT_CONQUERCOST
Definition: game.h:430
#define GAME_DEFAULT_TIMEOUT
Definition: game.h:555
#define GAME_DEFAULT_CONTACTTURNS
Definition: game.h:457
#define GAME_DEFAULT_SCORELOGLEVEL
Definition: game.h:535
#define GAME_DEFAULT_TECHLEVEL
Definition: game.h:348
#define GAME_DEFAULT_DISASTERS
Definition: game.h:467
#define GAME_DEFAULT_GOLD
Definition: game.h:337
#define GAME_DEFAULT_MIGRATION
Definition: game.h:479
#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_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_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_DEFAULT_TURNBLOCK
Definition: game.h:551
#define GAME_DEFAULT_PINGTIME
Definition: game.h:586
#define GAME_DEFAULT_UNITWAITTIME_EXTENDED
Definition: game.h:576
#define GAME_DEFAULT_AQUEDUCTLOSS
Definition: game.h:502
#define GAME_DEFAULT_TRADEMINDIST
Definition: game.h:612
#define GAME_DEFAULT_ANGRYCITIZEN
Definition: game.h:352
#define GAME_DEFAULT_BARBARIANRATE
Definition: game.h:618
#define GAME_DEFAULT_HAPPYBORDERS
Definition: game.h:418
#define GAME_DEFAULT_END_TURN
Definition: game.h:354
#define GAME_DEFAULT_DIPLGOLDCOST
Definition: game.h:388
#define GAME_DEFAULT_END_SPACESHIP
Definition: game.h:545
#define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
Definition: game.h:657
#define GAME_DEFAULT_SAVE_NAME
Definition: game.h:631
#define GAME_DEFAULT_MGR_NATIONCHANCE
Definition: game.h:494
#define GAME_DEFAULT_FOGOFWAR
Definition: game.h:400
#define GAME_DEFAULT_DIPLBULBCOST
Definition: game.h:384
#define GAME_DEFAULT_RESTRICTINFRA
Definition: game.h:454
#define GAME_DEFAULT_CIVILWARSIZE
Definition: game.h:450
void governments_free()
De-allocate the currently allocated governments.
Definition: government.cpp:452
#define G_LAST
Definition: government.h:31
void idex_free(struct world *iworld)
Free the hashs.
Definition: idex.cpp:49
struct unit * idex_lookup_unit(struct world *iworld, int id)
Lookup unit with given id.
Definition: idex.cpp:152
void idex_unregister_city(struct world *iworld, struct city *pcity)
Remove a city from idex, with current pcity->id.
Definition: idex.cpp:97
void idex_init(struct world *iworld)
idex = ident index: a lookup table for quick mapping of unit and city id values to unit and city poin...
Definition: idex.cpp:40
struct city * idex_lookup_city(struct world *iworld, int id)
Lookup city with given id.
Definition: idex.cpp:139
void idex_unregister_unit(struct world *iworld, struct unit *punit)
Remove a unit from idex, with current punit->id.
Definition: idex.cpp:118
void improvements_free()
Frees the memory associated with all improvements.
Definition: improvement.cpp:68
void improvements_init()
Initialize building structures.
Definition: improvement.cpp:38
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
bool is_wonder(const struct impr_type *pimprove)
Returns whether improvement is some kind of wonder.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
#define WONDER_NOT_OWNED
Definition: improvement.h:138
#define B_LAST
Definition: improvement.h:33
const char * name
Definition: inputfile.cpp:118
#define fc_assert_msg(condition, message,...)
Definition: log.h:96
#define fc_assert_ret_val(condition, val)
Definition: log.h:114
#define log_debug(message,...)
Definition: log.h:65
void main_map_free()
Free main map and related global structures.
Definition: map.cpp:525
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
Definition: map.cpp:954
void map_init(struct civ_map *imap, bool server_side)
Put some sensible values into the map structure.
Definition: map.cpp:129
void multipliers_free()
Free all multipliers.
Definition: multipliers.cpp:40
void multipliers_init()
Initialize all multipliers.
Definition: multipliers.cpp:25
void nation_sets_groups_init()
Definition: nation.cpp:1035
void nation_sets_groups_free()
Frees and resets all nation set/group data.
Definition: nation.cpp:1040
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
Definition: nation.cpp:429
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
Definition: nation.cpp:115
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
Definition: nation.cpp:438
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
Definition: nation.cpp:419
void nations_free()
De-allocate the currently allocated nations.
Definition: nation.cpp:533
int player_number(const struct player *pplayer)
Return the player index/number/id.
Definition: player.cpp:756
void player_ruleset_close(struct player *pplayer)
Clear the ruleset dependent pointers of the player structure.
Definition: player.cpp:673
void player_clear(struct player *pplayer, bool full)
Clear all player data.
Definition: player.cpp:615
void player_slots_free()
Remove all player slots.
Definition: player.cpp:346
void player_slots_init()
Initialise all player slots (= pointer to player pointers).
Definition: player.cpp:324
#define players_iterate_end
Definition: player.h:520
#define players_iterate(_pplayer)
Definition: player.h:514
void secfile_destroy(struct section_file *secfile)
Free a section file.
void universal_found_functions_init()
Initialise universal_found_function array.
void researches_init()
Initializes all player research structure.
Definition: research.cpp:50
void researches_free()
Free all resources allocated for the research system.
Definition: research.cpp:82
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
Definition: rgbcolor.cpp:65
int fc_vsnprintcf(char *buf, size_t buf_len, const char *format, const struct cf_sequence *sequences, size_t sequences_num)
Print a string with a custom format.
Definition: shared.cpp:1421
const char * big_int_to_text(unsigned int mantissa, unsigned int exponent)
Returns a statically allocated string containing a nicely-formatted version of the given number accor...
Definition: shared.cpp:117
int static void cf_int_seq(char letter, int value, struct cf_sequence *out)
Definition: shared.h:241
static struct cf_sequence cf_str_seq(char letter, const char *value)
Definition: shared.h:252
cf_type
Definition: shared.h:212
static struct cf_sequence cf_end()
Definition: shared.h:266
void specialists_free()
Free data for specialists.
Definition: specialist.cpp:47
void specialists_init()
Initialize data for specialists.
Definition: specialist.cpp:30
Definition: city.h:291
int id
Definition: city.h:296
struct tile * tile
Definition: city.h:293
struct unit_list * units_supported
Definition: city.h:377
Definition: game.h:73
void(* unit_deallocate)(int unit_id)
Definition: game.h:288
struct civ_game::@28::@32 server
struct rgbcolor * plr_bg_color
Definition: game.h:93
struct packet_scenario_description scenario_desc
Definition: game.h:79
struct packet_ruleset_control control
Definition: game.h:74
char * ruleset_summary
Definition: game.h:75
struct civ_game::@30 callbacks
struct packet_game_info info
Definition: game.h:80
struct packet_scenario_info scenario
Definition: game.h:78
char * ruleset_description
Definition: game.h:76
char * ruleset_capabilities
Definition: game.h:77
struct veteran_system * veteran
Definition: game.h:91
struct packet_calendar_info calendar
Definition: game.h:81
struct government * government_during_revolution
Definition: game.h:85
Definition: player.h:231
struct city_list * cities
Definition: player.h:263
struct team * team
Definition: player.h:243
Definition: tile.h:42
Definition: unit.h:134
int id
Definition: unit.h:141
int homecity
Definition: unit.h:142
Definition: game.h:64
char * name
Definition: game.h:65
char * helptxt
Definition: game.h:66
struct civ_map map
Definition: world_object.h:21
void music_styles_free()
Free the memory associated with music styles.
Definition: style.cpp:136
void styles_free()
Free the memory associated with styles.
Definition: style.cpp:45
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
#define sz_strlcpy(dest, src)
Definition: support.h:140
int team_number(const struct team *pteam)
Return the team index/number/id.
Definition: team.cpp:364
void team_slots_init()
Initialise all team slots.
Definition: team.cpp:48
void team_slots_free()
Remove all team slots.
Definition: team.cpp:77
void tech_classes_init()
Initialize tech classes.
Definition: tech.cpp:291
void user_tech_flags_init()
Initialize user tech flags.
Definition: tech.cpp:354
void techs_free()
De-allocate resources of all techs.
Definition: tech.cpp:481
void techs_init()
Initialize tech structures.
Definition: tech.cpp:437
void user_tech_flags_free()
Frees the memory associated with all user tech flags.
Definition: tech.cpp:366
#define A_LAST
Definition: tech.h:38
void user_terrain_flags_init()
Initialize user terrain type flags.
Definition: terrain.cpp:649
void terrains_free()
Free memory which is associated with terrain types.
Definition: terrain.cpp:50
void user_terrain_flags_free()
Frees the memory associated with all user terrain flags.
Definition: terrain.cpp:661
void terrains_init()
Initialize terrain and resource structures.
Definition: terrain.cpp:34
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
Definition: tile.cpp:96
#define tile_worked(_tile)
Definition: tile.h:97
#define TILE_XY(ptile)
Definition: tile.h:36
void trade_route_types_init()
Initialize trade route types.
void goods_init()
Initialize goods structures.
void goods_free()
Free the memory associated with goods.
void unit_virtual_destroy(struct unit *punit)
Free the memory used by virtual unit.
Definition: unit.cpp:1588
#define unit_tile(_pu)
Definition: unit.h:371
#define unit_owner(_pu)
Definition: unit.h:370
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
Definition: unittype.cpp:1283
void unit_classes_init()
Initialize unit_class structures.
Definition: unittype.cpp:2159
void unit_class_flags_free()
Frees the memory associated with all unit class flags.
Definition: unittype.cpp:2067
void user_unit_class_flags_init()
Initialize user unit class flags.
Definition: unittype.cpp:1481
void unit_classes_free()
Free resources allocated for unit classes.
Definition: unittype.cpp:2179
void unit_type_flags_free()
Frees the memory associated with all unit type flags.
Definition: unittype.cpp:2055
void role_unit_precalcs_free()
Free memory allocated by role_unit_precalcs().
Definition: unittype.cpp:1823
void veteran_system_destroy(struct veteran_system *vsystem)
Free veteran system.
Definition: unittype.cpp:2298
void unit_types_init()
Inialize unit-type structures.
Definition: unittype.cpp:2001
void user_unit_type_flags_init()
Initialize user unit type flags.
Definition: unittype.cpp:1544
void unit_types_free()
Frees the memory associated with all unit types.
Definition: unittype.cpp:2041