135 " at (%d,%d) unit %d, %s %s home (%d,%d) city %d, %s %s",
141 log_debug(
"game_remove_unit() at (%d,%d) unit %d, %s %s home %d",
146 qCritical(
"game_remove_unit() at (%d,%d) unit %d, %s %s home %d invalid",
152 unit_list_remove(
unit_tile(punit)->units, punit);
153 unit_list_remove(
unit_owner(punit)->units, punit);
171 if (
nullptr != powner) {
173 city_list_remove(powner->
cities, pcity);
176 if (
nullptr == pcenter) {
177 log_debug(
"game_remove_city() virtual city %d, %s", pcity->
id,
180 log_debug(
"game_remove_city() at (%d,%d) city %d, %s %s",
246 for (i = 0; i <
A_LAST; i++) {
248 game.
info.global_advances[i] =
false;
250 for (i = 0; i <
B_LAST; i++) {
380 if (!keep_ruleset_value) {
387 game.
server.save_options.save_private_map =
true;
517 game.
server.ruledit.embedded_nations =
nullptr;
518 game.
server.ruledit.embedded_nations_count = 0;
520 game.
server.ruledit.allowed_terrains =
nullptr;
587 delete[]
game.
server.ruledit.description_file;
588 game.
server.ruledit.description_file =
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];
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++) {
606 if (
game.
server.ruledit.allowed_terrains !=
nullptr) {
607 for (i = 0; i <
game.
server.ruledit.at_count; i++) {
610 delete[]
game.
server.ruledit.allowed_terrains;
611 game.
server.ruledit.allowed_terrains =
nullptr;
614 if (
game.
server.ruledit.allowed_styles !=
nullptr) {
615 for (i = 0; i <
game.
server.ruledit.as_count; i++) {
678 case PMT_PLAYERS_ALTERNATE:
681 case PMT_TEAMS_ALTERNATE:
689 fc_assert_msg(
false,
"Unrecognized phase mode %d in is_player_phase().",
716 char *c = safe_year_suffix;
725 for (;
'\0' != *suffix && c < max; suffix++) {
726 if (QChar::isLetterOrNumber(*suffix)) {
732 fc_snprintf(buf,
sizeof(buf),
"%s", safe_year_suffix);
760 cf_str_seq(
'R', (reason ==
nullptr) ?
"auto" : reason),
771 if (0 == strcmp(format, buf)) {
776 fc_snprintf(savename,
sizeof(savename),
"%s-T%%04T-Y%%05Y-%%R", format);
780 log_debug(
"save name generated from '%s': %s", format, buf);
790 flag->
name =
nullptr;
801 flag->
name =
nullptr;
void achievements_init()
Initialize achievements.
void achievements_free()
Free the memory associated with achievements.
void actions_init()
Initialize the actions and the action enablers.
void actions_free()
Free the actions and the action enablers.
#define CALL_FUNC_EACH_AI(_func,...)
void city_styles_free()
De-allocate the memory used by the city styles.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
int city_population(const struct city *pcity)
Returns how many thousand citizen live in this city.
struct tile * city_tile(const struct city *pcity)
Return the tile location of the city.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
int city_map_radius_sq_get(const struct city *pcity)
Returns the current squared radius of the city.
void destroy_city_virtual(struct city *pcity)
Removes the virtual skeleton of a city.
struct city * city_list_find_name(struct city_list *This, const char *name)
Find city with given name from list.
void free_city_map_index()
Free memory allocated by generate_citymap_index.
#define city_list_iterate(citylist, pcity)
#define city_tile_iterate(_radius_sq, _city_tile, _tile)
#define city_list_iterate_end
#define city_tile_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
void cm_init()
Initialize the CM data at the start of each game.
void cm_free()
Called at the end of a game to free any CM data.
void clause_infos_free()
Free memory associated with clause infos.
void clause_infos_init()
Initialize clause info structures.
void disaster_types_init()
Initialize disaster_type structures.
void disaster_types_free()
Free the memory associated with disaster types.
void ruleset_cache_init()
Initialize the ruleset cache.
void ruleset_cache_free()
Free the ruleset cache.
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.
#define MAX_CALENDAR_FRAGMENTS
#define IDENTITY_NUMBER_ZERO
void game_ruleset_init()
Initialize the objects which will read from a ruleset.
void game_ruleset_free()
Frees all memory which in objects which are read from a ruleset.
void i_am_client()
Set program type to client.
void user_flag_init(struct user_flag *flag)
Initialize user flag.
void game_reset()
Do all changes to change view, and not full game_free()/game_init().
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...
static char * year_suffix()
Return a string containing the save year.
void user_flag_free(struct user_flag *flag)
Free user flag.
bool is_player_phase(const struct player *pplayer, int phase)
Return TRUE if it is this player's phase.
static void game_defaults(bool keep_ruleset_value)
Set default game values.
const char * population_to_text(int thousand_citizen)
Return a prettily formatted string containing the population text.
void game_map_init()
Initialize map-specific parts of the game structure.
void i_am_server()
Set program type to server.
void game_init(bool keep_ruleset_value)
Initialise all game settings.
bool is_server()
Is program type server?
void game_remove_unit(struct world *gworld, struct unit *punit)
In the server call wipe_unit(), and never this function directly.
int civ_population(const struct player *pplayer)
Count the # of thousand citizen in a civilisation.
struct city * game_city_by_name(const char *name)
Find city with given name from any player.
void game_remove_city(struct world *gworld, struct city *pcity)
Remove city from game.
void initialize_globals()
Initialize wonder information.
int current_turn_timeout()
Return timeout value for the current turn.
struct city * game_city_by_number(int id)
Often used function to get a city pointer from a city ID.
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.
void game_free()
Frees all memory of the game.
#define GAME_DEFAULT_TECHPENALTY
#define GAME_DEFAULT_SKILL_LEVEL
#define GAME_DEFAULT_KILLSTACK
#define GAME_DEFAULT_REVOLENTYPE
#define GAME_DEFAULT_AUTO_AI_TOGGLE
#define GAME_DEFAULT_CARAVAN_BONUS_STYLE
#define GAME_DEFAULT_TIMEOUTINTINC
#define GAME_DEFAULT_SCORETURN
#define GAME_DEFAULT_EVENT_CACHE_INFO
#define GAME_DEFAULT_MGR_FOODNEEDED
#define GAME_DEFAULT_TECHLOST_DONOR
#define GAME_DEFAULT_TIMEOUTINT
#define GAME_DEFAULT_ALLOWED_CITY_NAMES
#define GAME_DEFAULT_SCORELOG
#define GAME_DEFAULT_OCCUPYCHANCE
#define GAME_DEFAULT_GLOBAL_WARMING_PERCENT
#define GAME_DEFAULT_TRADING_TECH
#define GAME_DEFAULT_SAVETURNS
#define GAME_DEFAULT_BORDERS
#define GAME_DEFAULT_AIRLIFTINGSTYLE
#define GAME_DEFAULT_KILLUNHOMED
#define GAME_DEFAULT_SCIENCEBOX
#define GAME_DEFAULT_MGR_WORLDCHANCE
#define GAME_DEFAULT_ONSETBARBARIAN
#define GAME_DEFAULT_KILLCITIZEN
#define GAME_DEFAULT_SHIELDBOX
#define GAME_DEFAULT_MAXCONNECTIONSPERHOST
#define GAME_DEFAULT_INCITE_GOLD_CAPT_CHANCE
#define GAME_DEFAULT_DEMOGRAPHY
#define GAME_DEFAULT_FULLTRADESIZE
#define GAME_DEFAULT_TIMEOUTINCMULT
#define GAME_DEFAULT_CELEBRATESIZE
#define GAME_DEFAULT_RAPTUREDELAY
#define GAME_DEFAULT_REVOLUTION_LENGTH
#define GAME_DEFAULT_MGR_TURNINTERVAL
#define GAME_DEFAULT_TIMEOUTINC
#define GAME_DEFAULT_START_UNITS
#define GAME_DEFAULT_ALLOW_TAKE
#define GAME_DEFAULT_MIN_PLAYERS
#define GAME_DEFAULT_SPACESHIP_TRAVEL_TIME
#define GAME_DEFAULT_RULESETDIR
#define GAME_DEFAULT_AUTOATTACK
#define GAME_DEFAULT_REVEALMAP
#define GAME_DEFAULT_TEAM_POOLED_RESEARCH
#define GAME_DEFAULT_SEED
#define GAME_DEFAULT_HOMECAUGHTUNITS
#define GAME_DEFAULT_NETWAIT
#define GAME_DEFAULT_KICK_TIME
#define GAME_DEFAULT_PLRCOLORMODE
#define GAME_DEFAULT_DIPLCHANCE
#define GAME_DEFAULT_RAZECHANCE
#define GAME_DEFAULT_INCITE_GOLD_LOSS_CHANCE
#define GAME_DEFAULT_TIMEOUTCOUNTER
#define GAME_DEFAULT_TRADING_CITY
#define GAME_DEFAULT_FOODBOX
#define GAME_DEFAULT_COMPRESS_TYPE
#define GAME_DEFAULT_PINGTIMEOUT
#define GAME_DEFAULT_TRADE_REVENUE_STYLE
#define GAME_DEFAULT_SAVEPALACE
#define GAME_DEFAULT_GLOBAL_WARMING
#define GAME_DEFAULT_TECHLOST_RECV
#define GAME_DEFAULT_NOTRADESIZE
#define GAME_DEFAULT_NUCLEAR_WINTER_PERCENT
#define GAME_DEFAULT_TRADING_GOLD
#define GAME_DEFAULT_TRAIT_DIST_MODE
#define GAME_DEFAULT_NUCLEAR_WINTER
#define GAME_DEFAULT_FREECOST
#define GAME_DEFAULT_MAX_PLAYERS
#define GAME_DEFAULT_CITYMINDIST
#define GAME_DEFAULT_PHASE_MODE
#define GAME_DEFAULT_AIFILL
#define GAME_DEFAULT_MULTIRESEARCH
#define GAME_DEFAULT_CONQUERCOST
#define GAME_DEFAULT_TIMEOUT
#define GAME_DEFAULT_CONTACTTURNS
#define GAME_DEFAULT_SCORELOGLEVEL
#define GAME_DEFAULT_TECHLEVEL
#define GAME_DEFAULT_DISASTERS
#define GAME_DEFAULT_GOLD
#define GAME_DEFAULT_MIGRATION
#define GAME_DEFAULT_NATURALCITYNAMES
#define GAME_DEFAULT_EVENT_CACHE_TURNS
#define GAME_DEFAULT_VICTORY_CONDITIONS
#define GAME_DEFAULT_FOGGEDBORDERS
#define GAME_DEFAULT_UNITWAITTIME
#define GAME_DEFAULT_TIMEOUTADDEMOVE
#define GAME_DEFAULT_DISPERSION
#define GAME_DEFAULT_EVENT_CACHE_CHAT
#define GAME_DEFAULT_DIPLOMACY
#define GAME_DEFAULT_MGR_DISTANCE
#define GAME_DEFAULT_TURNBLOCK
#define GAME_DEFAULT_PINGTIME
#define GAME_DEFAULT_UNITWAITTIME_EXTENDED
#define GAME_DEFAULT_AQUEDUCTLOSS
#define GAME_DEFAULT_TRADEMINDIST
#define GAME_DEFAULT_ANGRYCITIZEN
#define GAME_DEFAULT_BARBARIANRATE
#define GAME_DEFAULT_HAPPYBORDERS
#define GAME_DEFAULT_END_TURN
#define GAME_DEFAULT_DIPLGOLDCOST
#define GAME_DEFAULT_END_SPACESHIP
#define GAME_DEFAULT_EVENT_CACHE_MAX_SIZE
#define GAME_DEFAULT_SAVE_NAME
#define GAME_DEFAULT_MGR_NATIONCHANCE
#define GAME_DEFAULT_FOGOFWAR
#define GAME_DEFAULT_DIPLBULBCOST
#define GAME_DEFAULT_RESTRICTINFRA
#define GAME_DEFAULT_CIVILWARSIZE
void governments_free()
De-allocate the currently allocated governments.
void idex_free(struct world *iworld)
Free the hashs.
struct unit * idex_lookup_unit(struct world *iworld, int id)
Lookup unit with given id.
void idex_unregister_city(struct world *iworld, struct city *pcity)
Remove a city from idex, with current pcity->id.
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...
struct city * idex_lookup_city(struct world *iworld, int id)
Lookup city with given id.
void idex_unregister_unit(struct world *iworld, struct unit *punit)
Remove a unit from idex, with current punit->id.
void improvements_free()
Frees the memory associated with all improvements.
void improvements_init()
Initialize building structures.
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 fc_assert_msg(condition, message,...)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
void main_map_free()
Free main map and related global structures.
int map_num_tiles()
Returns the total number of (real) positions (or tiles) on the map.
void map_init(struct civ_map *imap, bool server_side)
Put some sensible values into the map structure.
void multipliers_free()
Free all multipliers.
void multipliers_init()
Initialize all multipliers.
void nation_sets_groups_init()
void nation_sets_groups_free()
Frees and resets all nation set/group data.
struct nation_type * nation_of_city(const struct city *pcity)
Return the nation of the player who owns the city.
const char * nation_rule_name(const struct nation_type *pnation)
Return the (untranslated) rule name of the nation (adjective form).
struct nation_type * nation_of_unit(const struct unit *punit)
Return the nation of the player who owns the unit.
struct nation_type * nation_of_player(const struct player *pplayer)
Return the nation of a player.
void nations_free()
De-allocate the currently allocated nations.
int player_number(const struct player *pplayer)
Return the player index/number/id.
void player_ruleset_close(struct player *pplayer)
Clear the ruleset dependent pointers of the player structure.
void player_clear(struct player *pplayer, bool full)
Clear all player data.
void player_slots_free()
Remove all player slots.
void player_slots_init()
Initialise all player slots (= pointer to player pointers).
#define players_iterate_end
#define players_iterate(_pplayer)
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.
void researches_free()
Free all resources allocated for the research system.
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
Free rgbcolor structure.
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.
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...
int static void cf_int_seq(char letter, int value, struct cf_sequence *out)
static struct cf_sequence cf_str_seq(char letter, const char *value)
static struct cf_sequence cf_end()
void specialists_free()
Free data for specialists.
void specialists_init()
Initialize data for specialists.
struct unit_list * units_supported
void(* unit_deallocate)(int unit_id)
struct civ_game::@28::@32 server
struct rgbcolor * plr_bg_color
struct packet_scenario_description scenario_desc
struct packet_ruleset_control control
struct civ_game::@30 callbacks
struct packet_game_info info
struct packet_scenario_info scenario
char * ruleset_description
char * ruleset_capabilities
struct veteran_system * veteran
struct packet_calendar_info calendar
struct government * government_during_revolution
struct city_list * cities
void music_styles_free()
Free the memory associated with music styles.
void styles_free()
Free the memory associated with styles.
int fc_snprintf(char *str, size_t n, const char *format,...)
See also fc_utf8_snprintf_trunc(), fc_utf8_snprintf_rep().
#define sz_strlcpy(dest, src)
int team_number(const struct team *pteam)
Return the team index/number/id.
void team_slots_init()
Initialise all team slots.
void team_slots_free()
Remove all team slots.
void tech_classes_init()
Initialize tech classes.
void user_tech_flags_init()
Initialize user tech flags.
void techs_free()
De-allocate resources of all techs.
void techs_init()
Initialize tech structures.
void user_tech_flags_free()
Frees the memory associated with all user tech flags.
void user_terrain_flags_init()
Initialize user terrain type flags.
void terrains_free()
Free memory which is associated with terrain types.
void user_terrain_flags_free()
Frees the memory associated with all user terrain flags.
void terrains_init()
Initialize terrain and resource structures.
void tile_set_worked(struct tile *ptile, struct city *pcity)
Set the city/worker on the tile (may be nullptr).
#define tile_worked(_tile)
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.
const char * unit_rule_name(const struct unit *punit)
Return the (untranslated) rule name of the unit.
void unit_classes_init()
Initialize unit_class structures.
void unit_class_flags_free()
Frees the memory associated with all unit class flags.
void user_unit_class_flags_init()
Initialize user unit class flags.
void unit_classes_free()
Free resources allocated for unit classes.
void unit_type_flags_free()
Frees the memory associated with all unit type flags.
void role_unit_precalcs_free()
Free memory allocated by role_unit_precalcs().
void veteran_system_destroy(struct veteran_system *vsystem)
Free veteran system.
void unit_types_init()
Inialize unit-type structures.
void user_unit_type_flags_init()
Initialize user unit type flags.
void unit_types_free()
Frees the memory associated with all unit types.