Freeciv-3.2
Loading...
Searching...
No Matches
Macros | Functions
citytools.h File Reference
#include "events.h"
#include "packets.h"
#include "unitlist.h"
#include "speclist.h"

Go to the source code of this file.

Macros

#define LOG_BUILD_TARGET   LOG_DEBUG
 
#define SPECLIST_TAG   trade_route_packet
 
#define SPECLIST_TYPE   struct packet_trade_route_info
 
#define trade_route_packet_list_iterate(ptrlist, ptr)    TYPED_LIST_ITERATE(struct packet_trade_route_info, ptrlist, ptr)
 
#define trade_route_packet_list_iterate_end   LIST_ITERATE_END
 

Functions

int build_points_left (struct city *pcity)
 
void transfer_city_units (struct player *pplayer, struct player *pvictim, struct unit_list *units, struct city *pcity, struct city *exclude_city, int kill_outside, bool verbose)
 
bool transfer_city (struct player *ptaker, struct city *pcity, int kill_outside, bool transfer_unit_verbose, bool resolve_stack, bool raze, bool build_free)
 
struct cityfind_closest_city (const struct tile *ptile, const struct city *pexclcity, const struct player *pplayer, bool only_ocean, bool only_continent, bool only_known, bool only_player, bool only_enemy, const struct unit_class *pclass)
 
bool unit_conquer_city (struct unit *punit, struct city *pcity)
 
bool send_city_suppression (bool now)
 
void send_city_info (struct player *dest, struct city *pcity)
 
void send_city_info_at_tile (struct player *pviewer, struct conn_list *dest, struct city *pcity, struct tile *ptile)
 
void send_all_known_cities (struct conn_list *dest)
 
void send_player_cities (struct player *pplayer)
 
void broadcast_city_info (struct city *pcity)
 
void package_city (struct city *pcity, struct packet_city_info *packet, struct packet_city_nationalities *nat_packet, struct packet_city_rally_point *rally_packet, struct packet_web_city_info_addition *web_packet, struct trade_route_packet_list *routes, bool dipl_invest)
 
void reality_check_city (struct player *pplayer, struct tile *ptile)
 
bool update_dumb_city (struct player *pplayer, struct city *pcity)
 
void refresh_dumb_city (struct city *pcity)
 
void remove_dumb_city (struct player *pplayer, struct tile *ptile)
 
void city_build_free_buildings (struct city *pcity)
 
void create_city (struct player *pplayer, struct tile *ptile, const char *name, struct player *nationality)
 
bool create_city_for_player (struct player *pplayer, struct tile *ptile, const char *name)
 
void remove_city (struct city *pcity)
 
struct trade_routeremove_trade_route (struct city *pc1, struct trade_route *proute, bool announce, bool source_gone)
 
bool city_illness_strike (struct city *pcity)
 
void do_sell_building (struct player *pplayer, struct city *pcity, struct impr_type *pimprove, const char *reason)
 
struct citybuild_or_move_building (struct city *pcity, struct impr_type *pimprove, struct player **oldcity_owner)
 
bool building_removed (struct city *pcity, const struct impr_type *pimprove, const char *reason, struct unit *destroyer)
 
void building_lost (struct city *pcity, const struct impr_type *pimprove, const char *reason, struct unit *destroyer)
 
void update_unit_upkeep (struct unit *punit, int free_uk[O_LAST])
 
void city_units_upkeep (const struct city *pcity)
 
bool is_production_equal (const struct universal *one, const struct universal *two)
 
void change_build_target (struct player *pplayer, struct city *pcity, struct universal *target, enum event_type event)
 
bool is_allowed_city_name (struct player *pplayer, const char *cityname, char *error_buf, size_t bufsz)
 
const charcity_name_suggestion (struct player *pplayer, struct tile *ptile)
 
void city_freeze_workers (struct city *pcity)
 
void city_thaw_workers (struct city *pcity)
 
void city_freeze_workers_queue (struct city *pcity)
 
void city_thaw_workers_queue (void)
 
void city_map_update_empty (struct city *pcity, struct tile *ptile)
 
void city_map_update_worker (struct city *pcity, struct tile *ptile)
 
bool city_map_update_tile_frozen (struct tile *ptile)
 
bool city_map_update_tile_now (struct tile *ptile)
 
void city_map_update_all (struct city *pcity)
 
void city_map_update_all_cities_for_player (struct player *pplayer)
 
bool city_map_update_radius_sq (struct city *pcity)
 
void city_landlocked_sell_coastal_improvements (struct tile *ptile)
 
void city_refresh_vision (struct city *pcity)
 
void refresh_player_cities_vision (struct player *pplayer)
 
void sync_cities (void)
 
void clear_worker_task (struct city *pcity, struct worker_task *ptask)
 
void clear_worker_tasks (struct city *pcity)
 
void package_and_send_worker_tasks (struct city *pcity)
 
int city_production_buy_gold_cost (const struct city *pcity)
 
void city_add_improvement_with_gov_notice (struct city *pcity, const struct impr_type *pimprove, const char *format)
 
int city_original_owner (const struct city *pcity, const struct player *known_for)
 

Macro Definition Documentation

◆ LOG_BUILD_TARGET

#define LOG_BUILD_TARGET   LOG_DEBUG

Definition at line 21 of file citytools.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   trade_route_packet

Definition at line 23 of file citytools.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct packet_trade_route_info

Definition at line 24 of file citytools.h.

◆ trade_route_packet_list_iterate

#define trade_route_packet_list_iterate (   ptrlist,
  ptr 
)     TYPED_LIST_ITERATE(struct packet_trade_route_info, ptrlist, ptr)

Definition at line 26 of file citytools.h.

◆ trade_route_packet_list_iterate_end

#define trade_route_packet_list_iterate_end   LIST_ITERATE_END

Definition at line 28 of file citytools.h.

Function Documentation

◆ broadcast_city_info()

void broadcast_city_info ( struct city pcity)

Broadcast info about a city to all players who observe the tile. If the player can see the city we update the city info first. If not we just use the info from the players private map. See also comments to send_city_info_at_tile(). (Split off from send_city_info_at_tile() because that was getting too difficult for me to understand... –dwp)

Definition at line 2245 of file citytools.c.

Referenced by auto_arrange_workers(), and send_city_info().

◆ build_or_move_building()

struct city * build_or_move_building ( struct city pcity,
struct impr_type pimprove,
struct player **  oldcity_owner 
)

Creates an improvement in a city. If the improvement is a present wonder, moves it from a city it is in now, returns that city. If it is a wonder not present (never built or destroyed), returns pcity. If the wonder is great, also tells its owner. If it is not a wonder (must be a regular improvement), returns NULL. It's up to the caller to update the necessary cities and emit signals. FIXME: If governmental center status of a city is changed, check if other cities of its owner need update. And what's there with trade partners? FIXME: it is not checked if the improvement is obsolete or obsoletes other building, should we?

Definition at line 3019 of file citytools.c.

Referenced by api_edit_create_building(), and handle_edit_city().

◆ build_points_left()

int build_points_left ( struct city pcity)

Calculate the remaining build points

Definition at line 576 of file citytools.c.

Referenced by dai_choose_help_wonder(), and unit_do_help_build().

◆ building_lost()

void building_lost ( struct city pcity,
const struct impr_type pimprove,
const char reason,
struct unit destroyer 
)

Destroy the improvement in the city straight-out. Note that this is different from selling a building.

Definition at line 3068 of file citytools.c.

Referenced by apply_disaster(), diplomat_sabotage(), do_sell_building(), and do_unit_strike_city_building().

◆ building_removed()

bool building_removed ( struct city pcity,
const struct impr_type pimprove,
const char reason,
struct unit destroyer 
)

Remove building from the city. Emits lua signal.

Definition at line 3051 of file citytools.c.

Referenced by building_lost(), raze_city(), remove_city(), and transfer_city().

◆ change_build_target()

void change_build_target ( struct player pplayer,
struct city pcity,
struct universal target,
enum event_type  event 
)

Change the build target.

Definition at line 3179 of file citytools.c.

Referenced by advisor_choose_build(), dai_city_choose_build(), handle_city_change(), and worklist_change_build_target().

◆ city_add_improvement_with_gov_notice()

void city_add_improvement_with_gov_notice ( struct city pcity,
const struct impr_type pimprove,
const char format 
)

Add improvement to the city, notifying all players about the new government forms it enables for them.

Definition at line 3661 of file citytools.c.

Referenced by build_or_move_building(), city_build_building(), city_build_free_buildings(), and transfer_city().

◆ city_build_free_buildings()

void city_build_free_buildings ( struct city pcity)

Give to a new city the free (initial) buildings. Call this when a player has just acquired a city (or batch of cities, e.g. civil war) after having no cities. Doesn't check for building uniqueness! – assumes player has no other cities which might contain unique buildings.

Definition at line 1434 of file citytools.c.

Referenced by civil_war(), create_city(), and transfer_city().

◆ city_freeze_workers()

void city_freeze_workers ( struct city pcity)

Freeze the workers (citizens on tiles) for the city. They will not be auto-arranged until unfreeze_workers() is called.

Long explanation:

Historically auto_arrange_workers was called every time a city changed. If the city grew or shrunk, a new tile became available or was removed, the function would be called. However in at least one place this breaks. In some operations (like transfer_city() ) multiple things may change and the city is not left in a sane state in between. Calling auto_arrange_workers() after each change means it's called with an "insane" city. This can lead at best to a failed sanity check with a wasted call, or at worse to a more major bug. The solution is freeze_workers() and thaw_workers()

Call freeze_workers() to freeze the auto-arranging of citizens. So long as the freeze is in place no arrangement will be done for this city. Any call to auto_arrange_workers() will just queue up an arrangement for later. Later when thaw_workers is called, the freeze is removed and the auto-arrange will be done if there is any arrangement pending.

Freezing may safely be done more than once.

It is thus always safe to call freeze and thaw around any set of city actions. However this is unlikely to be needed in very many places.

Definition at line 137 of file citytools.c.

Referenced by auto_arrange_workers(), city_freeze_workers_queue(), city_map_update_all_cities_for_player(), sg_load_player_city(), sg_load_player_city(), and transfer_city().

◆ city_freeze_workers_queue()

void city_freeze_workers_queue ( struct city pcity)

Queue pending auto_arrange_workers() for later.

Definition at line 161 of file citytools.c.

Referenced by city_map_update_tile_direct(), create_city(), and resolve_city_emergency().

◆ city_illness_strike()

bool city_illness_strike ( struct city pcity)

Give the city a plague.

Definition at line 2971 of file citytools.c.

Referenced by spy_spread_plague(), and update_city_activity().

◆ city_landlocked_sell_coastal_improvements()

void city_landlocked_sell_coastal_improvements ( struct tile ptile)

For each city adjacent to ptile, check all the buildings in the city. Any which have unmet terrain requirements will be sold. This is called after any terrain changes (but this may be tied to the default ruleset).

FIXME: This function isn't very general. It would be better to check each turn to make sure all requirements of all buildings of all cities are met, and sell any buildings that can't be supported. Terrains aren't the only requirement that may disappear.

Definition at line 3395 of file citytools.c.

Referenced by fix_tile_on_terrain_change().

◆ city_map_update_all()

void city_map_update_all ( struct city pcity)

Called by auto_arrange_workers() and below.

Definition at line 3361 of file citytools.c.

Referenced by auto_arrange_workers(), and city_map_update_all_cities_for_player().

◆ city_map_update_all_cities_for_player()

void city_map_update_all_cities_for_player ( struct player pplayer)

Update worked map of all cities of given player

Definition at line 3376 of file citytools.c.

Referenced by handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact(), and update_diplomatics().

◆ city_map_update_empty()

void city_map_update_empty ( struct city pcity,
struct tile ptile 
)

Change city tile from worked to empty. Call sync_cities() to send the affected cities to the clients.

Parameters
pcityCity to change worker status
ptileTile to clear worker from

Definition at line 3268 of file citytools.c.

Referenced by apply_cmresult_to_city(), city_map_update_radius_sq(), city_reduce_workers(), city_tc_effect_refresh(), handle_city_make_specialist(), handle_diplomacy_cancel_pact(), map_change_seen(), resolve_city_emergency(), and tile_change_side_effects().

◆ city_map_update_radius_sq()

bool city_map_update_radius_sq ( struct city pcity)

Updates the squared city radius. Returns if the radius is changed.

Definition at line 3467 of file citytools.c.

Referenced by city_refresh().

◆ city_map_update_tile_frozen()

bool city_map_update_tile_frozen ( struct tile ptile)

Updates the worked status of a tile. Call city_thaw_workers_queue() followed by sync_cities() to send the affected cities to the clients.

Definition at line 3325 of file citytools.c.

Referenced by map_claim_border_ownership(), and really_give_tile_info_from_player_to_player().

◆ city_map_update_tile_now()

bool city_map_update_tile_now ( struct tile ptile)

Updates the worked status of a tile immediately.

Definition at line 3333 of file citytools.c.

Referenced by place_unit(), server_remove_unit_full(), and unit_move_consequences().

◆ city_map_update_worker()

void city_map_update_worker ( struct city pcity,
struct tile ptile 
)

Change city tile from empty to worked. Call sync_cities() to send the affected cities to the clients.

Parameters
pcityCity to change worker status
ptileTile to set worker to

Definition at line 3282 of file citytools.c.

Referenced by apply_cmresult_to_city(), city_map_update_radius_sq(), and handle_city_make_worker().

◆ city_name_suggestion()

const char * city_name_suggestion ( struct player pplayer,
struct tile ptile 
)

Come up with a default name when a new city is about to be built. Handle running out of names etc. gracefully. Maybe we should keeptrack of which names have been rejected by the player, so that we do not suggest them again?

Definition at line 458 of file citytools.c.

Referenced by api_edit_perform_action_unit_vs_tile(), api_edit_perform_action_unit_vs_tile_extra(), create_city_for_player(), dai_do_build_city(), execute_orders(), handle_city_name_suggestion_req(), init_new_game(), and transfer_city().

◆ city_original_owner()

int city_original_owner ( const struct city pcity,
const struct player known_for 
)

Return city's original owner id, as known by specified player. NULL known_for is expected to mean global observer.

Definition at line 3689 of file citytools.c.

Referenced by broadcast_city_info(), diplomat_investigate(), and send_city_info_at_tile().

◆ city_production_buy_gold_cost()

int city_production_buy_gold_cost ( const struct city pcity)

Return the cost (gold) to buy the current city production.

Definition at line 3639 of file citytools.c.

Referenced by dai_spend_gold(), package_city(), and really_handle_city_buy().

◆ city_refresh_vision()

void city_refresh_vision ( struct city pcity)

Refresh the city's vision.

This function has very small overhead and can be called any time effects may have changed the vision range of the city.

Definition at line 3442 of file citytools.c.

Referenced by building_lost(), city_build_building(), city_map_update_radius_sq(), create_city(), do_city_migration(), found_new_tech(), refresh_player_cities_vision(), sg_load_player_cities(), sg_load_player_cities(), and transfer_city().

◆ city_thaw_workers()

void city_thaw_workers ( struct city pcity)

Thaw (unfreeze) the workers (citizens on tiles) for the city. The workers will be auto-arranged if there is an arrangement pending. See explanation in freeze_workers().

Definition at line 147 of file citytools.c.

Referenced by auto_arrange_workers(), city_map_update_all_cities_for_player(), city_thaw_workers_queue(), sg_load_players(), sg_load_players(), and transfer_city().

◆ city_thaw_workers_queue()

void city_thaw_workers_queue ( void  )

◆ city_units_upkeep()

void city_units_upkeep ( const struct city pcity)

Recalculate the upkeep needed for all units supported by the city. It has to be called

If the upkeep for a unit changes, an update is send to the player.

Definition at line 3156 of file citytools.c.

Referenced by city_refresh(), place_unit(), transform_unit(), unit_change_homecity_handling(), unit_change_owner(), and update_city_activities().

◆ clear_worker_task()

void clear_worker_task ( struct city pcity,
struct worker_task ptask 
)

Clear worker task from the city and inform owner

Definition at line 3580 of file citytools.c.

Referenced by auto_settler_findwork(), and clear_worker_tasks().

◆ clear_worker_tasks()

void clear_worker_tasks ( struct city pcity)

Clear all worker tasks from the city and inform owner

Definition at line 3605 of file citytools.c.

Referenced by dai_auto_settler_run(), dai_gained_control(), and transfer_city().

◆ create_city()

void create_city ( struct player pplayer,
struct tile ptile,
const char name,
struct player nationality 
)

Creates real city.

Definition at line 1519 of file citytools.c.

Referenced by city_build(), create_city_for_player(), and init_new_game().

◆ create_city_for_player()

bool create_city_for_player ( struct player pplayer,
struct tile ptile,
const char name 
)

Create city for player, doing necessary checks and adjustments.

Return whether it was legal to create the city. If not, city was not created.

Definition at line 1680 of file citytools.c.

Referenced by api_edit_create_city(), and handle_edit_city_create().

◆ do_sell_building()

void do_sell_building ( struct player pplayer,
struct city pcity,
struct impr_type pimprove,
const char reason 
)

Sell the improvement from the city, and give the player the owner. Not all buildings can be sold.

I guess the player should always be the city owner?

Definition at line 2997 of file citytools.c.

Referenced by city_landlocked_sell_coastal_improvements(), dai_city_sell_noncritical(), really_handle_city_sell(), remove_obsolete_buildings_city(), and sell_random_building().

◆ find_closest_city()

struct city * find_closest_city ( const struct tile ptile,
const struct city pexclcity,
const struct player pplayer,
bool  only_ocean,
bool  only_continent,
bool  only_known,
bool  only_player,
bool  only_enemy,
const struct unit_class pclass 
)

Find the city closest to 'ptile'. Some restrictions can be applied:

'pexclcity' not this city 'pplayer' player to be used by 'only_known', 'only_player' and 'only_enemy'. 'only_ocean' if set the city must be adjacent to ocean. 'only_continent' if set only cities on the same continent as 'ptile' are valid. 'only_known' if set only cities known to 'pplayer' are considered. 'only_player' if set and 'pplayer' is not NULL only cities of this player are returned. 'only_enemy' if set and 'pplayer' is not NULL only cities of players which are at war with 'pplayer' are returned. 'pclass' if set, and 'pclass' is not NULL only cities that have adjacent native terrain for that unit class are returned.

If no city is found NULL is returned.

Definition at line 856 of file citytools.c.

Referenced by dai_manage_diplomat(), dai_military_attack_barbarian(), dai_military_defend(), diplomat_escape_full(), disband_city(), do_city_migration(), handle_edit_unit_create(), try_summon_barbarians(), and try_to_save_unit().

◆ is_allowed_city_name()

bool is_allowed_city_name ( struct player pplayer,
const char cityname,
char error_buf,
size_t  bufsz 
)

Checks, if a city name is allowed for a player. If not, reports a reason for rejection. There's 4 different modes: 0: no restrictions, 1: a city name has to be unique to player 2: a city name has to be globally unique 3: a city name has to be globally unique, and players can't use names that are in another player's default city names. (E.g., Swedish may not call new cities or rename old cities as Helsinki, because it's in Finns' default city names. Duplicated names may be used by either nation.)

Definition at line 374 of file citytools.c.

Referenced by city_build(), handle_city_rename(), handle_edit_city(), and search_for_city_name().

◆ is_production_equal()

bool is_production_equal ( const struct universal one,
const struct universal two 
)

◆ package_and_send_worker_tasks()

void package_and_send_worker_tasks ( struct city pcity)

Send city worker task to owner

Definition at line 3615 of file citytools.c.

Referenced by send_all_info(), and texai_req_worker_task_rcv().

◆ package_city()

void package_city ( struct city pcity,
struct packet_city_info packet,
struct packet_city_nationalities nat_packet,
struct packet_city_rally_point rally_packet,
struct packet_web_city_info_addition web_packet,
struct trade_route_packet_list routes,
bool  dipl_invest 
)

Fill city info packet with information about given city. This can't set 'original', as it depends on who is about to receive the package whether they know true value of that.

Definition at line 2526 of file citytools.c.

Referenced by broadcast_city_info(), diplomat_investigate(), package_city(), and send_city_info_at_tile().

◆ reality_check_city()

void reality_check_city ( struct player pplayer,
struct tile ptile 
)

Removes outdated (nonexistent) cities from a player

Definition at line 2840 of file citytools.c.

Referenced by broadcast_city_info(), map_change_seen(), map_show_tile(), really_give_tile_info_from_player_to_player(), remove_city(), sg_load_player_vision(), and sg_load_player_vision().

◆ refresh_dumb_city()

void refresh_dumb_city ( struct city pcity)

Update plrtile information about the city, and send out information to the clients if it has changed.

Definition at line 2216 of file citytools.c.

Referenced by unit_move().

◆ refresh_player_cities_vision()

void refresh_player_cities_vision ( struct player pplayer)

Refresh the vision of all cities owned by a player, for empire-wide effects.

Definition at line 3457 of file citytools.c.

Referenced by end_phase().

◆ remove_city()

void remove_city ( struct city pcity)

◆ remove_dumb_city()

void remove_dumb_city ( struct player pplayer,
struct tile ptile 
)

Removes a dumb city. Called when the vision changed to unknown.

Definition at line 2861 of file citytools.c.

Referenced by map_hide_tile().

◆ remove_trade_route()

struct trade_route * remove_trade_route ( struct city pc1,
struct trade_route proute,
bool  announce,
bool  source_gone 
)

Remove the trade route between pc1 and pc2 (if one exists). source_gone should be TRUE if the reason for removal is the imminent removal of the source city (pc1) from the game.

Does not free the trade route structures, only removes them from the cities.

Definition at line 2936 of file citytools.c.

Referenced by do_unit_establish_trade(), reestablish_city_trade_routes(), remove_city(), server_remove_player(), and update_city_activities().

◆ send_all_known_cities()

void send_all_known_cities ( struct conn_list dest)

Send to each client information about the cities it knows about. dest may not be NULL

Definition at line 2320 of file citytools.c.

Referenced by send_all_info().

◆ send_city_info()

void send_city_info ( struct player dest,
struct city pcity 
)

◆ send_city_info_at_tile()

void send_city_info_at_tile ( struct player pviewer,
struct conn_list dest,
struct city pcity,
struct tile ptile 
)

Send info about a city, as seen by pviewer, to dest (usually dest will be pviewer->connections). If pplayer can see the city we update the city info first. If not we just use the info from the players private map.

If (pviewer == NULL) this is for observers, who see everything (?) For this function dest may not be NULL. See send_city_info() and broadcast_city_info().

If pcity is non-NULL it should be same as tile_city(x,y); if pcity is NULL, this function calls tile_city(x,y) (it is ok if this returns NULL).

Sometimes a player's map contain a city that doesn't actually exist. Use reality_check_city(pplayer, ptile) to update that. Remember to NOT send info about a city to a player who thinks the tile contains another city. If you want to update the clients info of the tile you must use reality_check_city(pplayer, ptile) first. This is generally taken care of automatically when a tile becomes visible.

Definition at line 2415 of file citytools.c.

Referenced by really_give_tile_info_from_player_to_player(), send_all_known_cities(), and send_city_info().

◆ send_city_suppression()

bool send_city_suppression ( bool  now)

Suppress sending cities during game_load() and end_phase()

Definition at line 2166 of file citytools.c.

Referenced by end_phase(), savegame2_load(), and savegame3_load().

◆ send_player_cities()

void send_player_cities ( struct player pplayer)

Send information about all their cities to player

Definition at line 2343 of file citytools.c.

Referenced by begin_phase(), build_free_small_wonders(), and end_phase().

◆ sync_cities()

void sync_cities ( void  )

◆ transfer_city()

bool transfer_city ( struct player ptaker,
struct city pcity,
int  kill_outside,
bool  transfer_unit_verbose,
bool  resolve_stack,
bool  raze,
bool  build_free 
)

Handles all transactions in relation to transferring a city.

The kill_outside and transfer_unit_verbose arguments are passed to transfer_city_units(), which is called in the middle of the function.

Return TRUE iff the city remains after transferring (the city may be destroyed by a script, notably with bouncing or wiping units).

Definition at line 1076 of file citytools.c.

Referenced by api_edit_transfer_city(), civil_war(), diplomat_incite(), handle_diplomacy_accept_treaty_req(), kill_player(), player_loot_player(), and unit_conquer_city().

◆ transfer_city_units()

void transfer_city_units ( struct player pplayer,
struct player pvictim,
struct unit_list *  units,
struct city pcity,
struct city exclude_city,
int  kill_outside,
bool  verbose 
)

When a city is transferred (bought, incited, disbanded, civil war): Units in a transferred city are transferred to the new owner; units supported by the city, but held in other cities are updated to reflect those cities as their new homecity. Units supported by the transferred city that are not in a city tile may be deleted.

pplayer: The player receiving the units if they are not disbanded and are not in a city pvictim: The owner of the city the units are transferred from. units: A list of units to be transferred, typically a city's unit list. pcity: Default city the units are transferred to. exclude_city: The units cannot be transferred to this city. kill_outside: Units outside this range are deleted. -1 means no units are deleted. verbose: Messages are sent to the involved parties.

Definition at line 721 of file citytools.c.

Referenced by disband_city(), do_city_migration(), and transfer_city().

◆ unit_conquer_city()

bool unit_conquer_city ( struct unit punit,
struct city pcity 
)

Handle unit conquering a city.

  • Can't conquer a city when not at war. (Enters cities peacefully during peace. At the moment this can happen to domestic, allied and team mate cities)
  • A unit can't conquer a city if it is owned by the animal barbarian.
  • A unit can't conquer a city if its unit class is missing the "CanOccupyCity" unit class flag.
  • A unit can't conquer a city if its unit type has the "NonMil" unit type flag.
  • Transported units trying to conquer a city should be unloaded before this function is called.

Returns TRUE iff action could be done, FALSE if it couldn't. Even if this returns TRUE, unit may have died during the action.

Definition at line 1987 of file citytools.c.

Referenced by unit_move_consequences().

◆ update_dumb_city()

bool update_dumb_city ( struct player pplayer,
struct city pcity 
)

Updates a players knowledge about a city. If the player_tile already contains a city, it must be the same city (avoid problems by always calling reality_check_city() first)

Returns TRUE iff anything has changed for the player city (i.e., if the client needs to be updated with a short city packet). This information is only used in refresh_dumb_city(); elsewhere the data is (of necessity) broadcast regardless.

Definition at line 2769 of file citytools.c.

Referenced by broadcast_city_info(), diplomat_investigate(), map_show_tile(), reestablish_city_trade_routes(), refresh_dumb_city(), send_city_info_at_tile(), sg_load_player_vision(), and sg_load_player_vision().

◆ update_unit_upkeep()

void update_unit_upkeep ( struct unit punit,
int  free_uk[O_LAST] 
)

Recalculate the upkeep needed for one unit.

Note that this modifies the free_uk array it gets, if the unit uses some of that free upkeep.

If the upkeep for a unit changes, an update is send to the player.

Definition at line 3105 of file citytools.c.

Referenced by city_units_upkeep().