Freeciv-3.3: /fast/freeciv/nightly/main/server/maphand.c File Reference

Freeciv-3.3

Loading...
Searching...
No Matches
Macros | Functions | Variables
maphand.c File Reference
`#include "bitvector.h"`
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "rand.h"`
`#include "support.h"`
`#include "ai.h"`
`#include "base.h"`
`#include "borders.h"`
`#include "events.h"`
`#include "game.h"`
`#include "map.h"`
`#include "movement.h"`
`#include "nation.h"`
`#include "packets.h"`
`#include "player.h"`
`#include "road.h"`
`#include "specialist.h"`
`#include "unit.h"`
`#include "unitlist.h"`
`#include "vision.h"`
`#include "citytools.h"`
`#include "cityturn.h"`
`#include "notify.h"`
`#include "plrhand.h"`
`#include "sanitycheck.h"`
`#include "sernet.h"`
`#include "srv_main.h"`
`#include "unithand.h"`
`#include "unittools.h"`
`#include "advdata.h"`
`#include "mapgen_utils.h"`
`#include "maphand.h"`

Go to the source code of this file.

## Macros

#define | MAXIMUM_CLAIMED_OCEAN_SIZE (20)

## Functions

static void | player_tile_init (struct tile *ptile, struct player *pplayer)
static void | player_tile_free (struct tile *ptile, struct player *pplayer)
static bool | give_tile_info_from_player_to_player (struct player *pfrom, struct player *pdest, struct tile *ptile)
static void | shared_vision_change_seen (struct player *pplayer, struct tile *ptile, const v_radius_t change, bool can_reveal_tiles)
static void | map_change_seen (struct player *pplayer, struct tile *ptile, const v_radius_t change, bool can_reveal_tiles)
static void | map_change_own_seen (struct player *pplayer, struct tile *ptile, const v_radius_t change)
static int | map_get_seen (const struct player *pplayer, const struct tile *ptile, enum vision_layer vlayer)
static bool | map_is_also_seen (const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
static bool | is_claimable_ocean (struct tile *ptile, struct tile *source, struct player *pplayer)
static bool | is_terrain_ecologically_wet (struct tile *ptile)
void | global_warming (int effect)
void | nuclear_winter (int effect)
void | climate_change (bool warming, int effect)
bool | upgrade_city_extras (struct city *pcity, struct extra_type **gained)
void | upgrade_all_city_extras (struct player *pplayer, bool discovery)
bool | really_gives_vision (struct player *me, struct player *them)
static void | buffer_shared_vision (struct player *pplayer)
static void | unbuffer_shared_vision (struct player *pplayer)
void | give_map_from_player_to_player (struct player *pfrom, struct player *pdest)
void | give_seamap_from_player_to_player (struct player *pfrom, struct player *pdest)
void | give_citymap_from_player_to_player (struct city *pcity, struct player *pfrom, struct player *pdest)
void | send_all_known_tiles (struct conn_list *dest)
bool | send_tile_suppression (bool now)
void | send_tile_info (struct conn_list *dest, struct tile *ptile, bool send_unknown)
static bool | unit_is_on_layer (const struct unit *punit, enum vision_layer vlayer)
void | send_map_info (struct conn_list *dest)
void | map_vision_update (struct player *pplayer, struct tile *ptile, const v_radius_t old_radius_sq, const v_radius_t new_radius_sq, bool can_reveal_tiles)
void | map_set_border_vision (struct player *pplayer, const bool is_enabled)
void | map_show_tile (struct player *src_player, struct tile *ptile)
void | map_hide_tile (struct player *src_player, struct tile *ptile)
void | map_show_circle (struct player *pplayer, struct tile *ptile, int radius_sq)
void | map_show_all (struct player *pplayer)
bool | map_is_known (const struct tile *ptile, const struct player *pplayer)
bool | map_is_known_and_seen (const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
static int | player_tile_own_seen (const struct player_tile *plrtile, enum vision_layer vlayer)
void | change_playertile_site (struct player_tile *ptile, struct vision_site *new_site)
void | map_set_known (struct tile *ptile, struct player *pplayer)
void | map_clear_known (struct tile *ptile, struct player *pplayer)
void | map_know_and_see_all (struct player *pplayer)
void | show_map_to_all (void)
void | player_map_init (struct player *pplayer)
void | player_map_free (struct player *pplayer)
void | remove_player_from_maps (struct player *pplayer)
struct vision_site * | map_get_player_city (const struct tile *ptile, const struct player *pplayer)
struct player_tile * | map_get_player_tile (const struct tile *ptile, const struct player *pplayer)
bool | update_player_tile_knowledge (struct player *pplayer, struct tile *ptile)
void | update_tile_knowledge (struct tile *ptile)
void | update_player_tile_last_seen (struct player *pplayer, struct tile *ptile)
static bool | really_give_tile_info_from_player_to_player (struct player *pfrom, struct player *pdest, struct tile *ptile)
static void | really_give_map_from_player_to_player (struct player *pfrom, struct player *pdest)
static void | create_vision_dependencies (void)
void | give_shared_vision (struct player *pfrom, struct player *pto)
void | remove_shared_vision (struct player *pfrom, struct player *pto)
void | enable_fog_of_war_player (struct player *pplayer)
void | enable_fog_of_war (void)
void | disable_fog_of_war_player (struct player *pplayer)
void | disable_fog_of_war (void)
static void | ocean_to_land_fix_rivers (struct tile *ptile)
static void | terrain_change_bounce_single_unit (struct unit *punit, struct tile *from)
static void | check_units_single_tile (struct tile *ptile)
void | bounce_units_on_terrain_change (struct tile *ptile)
bool | need_to_reassign_continents (const struct terrain *oldter, const struct terrain *newter)
void | terrain_changed (struct tile *ptile)
void | fix_tile_on_terrain_change (struct tile *ptile, struct terrain *oldter, bool extend_rivers)
void | check_terrain_change (struct tile *ptile, struct terrain *oldter)
static void | map_unit_homecity_enqueue (struct tile *ptile)
static void | map_claim_border_ownership (struct tile *ptile, struct player *powner, struct tile *psource)
void | map_claim_ownership (struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
void | tile_claim_bases (struct tile *ptile, struct player *powner)
void | map_clear_border (struct tile *ptile)
void | map_update_border (struct tile *ptile, struct player *owner, int old_radius_sq, int new_radius_sq)
void | map_claim_border (struct tile *ptile, struct player *owner, int radius_sq)
void | map_calculate_borders (void)
void | map_claim_base (struct tile *ptile, struct extra_type *pextra, struct player *powner, struct player *ploser)
void | vision_change_sight (struct vision *vision, const v_radius_t radius_sq)
void | vision_clear_sight (struct vision *vision)
void | create_extra (struct tile *ptile, struct extra_type *pextra, struct player *pplayer)
void | destroy_extra (struct tile *ptile, struct extra_type *pextra)
bool | give_distorted_map (struct player *pfrom, struct player *pto, int prob, bool reveal_cities)
void | tile_change_side_effects (struct tile *ptile, bool refresh_city)

## Variables

static bool | send_tile_suppressed = FALSE

## Macro Definition Documentation

## ◆ MAXIMUM_CLAIMED_OCEAN_SIZE

#define MAXIMUM_CLAIMED_OCEAN_SIZE (20)

Definition at line 62 of file maphand.c.

## Function Documentation

## ◆ bounce_units_on_terrain_change()

void bounce_units_on_terrain_change | ( | struct tile * | ptile | ) |

Check ptile and nearby tiles to see if all units can remain at their current locations, and move or disband any that cannot. Call this after terrain or specials change on ptile.

Definition at line 1915 of file maphand.c.

Referenced by create_extra(), terrain_changed(), and update_unit_activity().

## ◆ buffer_shared_vision()

static void buffer_shared_vision | ( | struct player * | pplayer | ) |

static

Start buffering shared vision

Definition at line 353 of file maphand.c.

Referenced by disable_fog_of_war_player(), enable_fog_of_war_player(), give_citymap_from_player_to_player(), give_distorted_map(), give_map_from_player_to_player(), give_seamap_from_player_to_player(), give_shared_vision(), map_know_and_see_all(), map_show_all(), map_show_circle(), map_vision_update(), and remove_shared_vision().

## ◆ change_playertile_site()

void change_playertile_site | ( | struct player_tile * | ptile,
|  | struct vision_site * | new_site
| ) |  |

Changes site information for player tile.

Definition at line 1163 of file maphand.c.

Referenced by remove_player_from_maps(), sg_load_player_vision(), sg_load_player_vision(), and update_dumb_city().

## ◆ check_terrain_change()

void check_terrain_change | ( | struct tile * | ptile,
|  | struct terrain * | oldter
| ) |  |

Handles local and global side effects for a terrain change for a single tile. Call this in the server immediately after calling tile_change_terrain(). Assumes an in-game terrain change (e.g., by workers/engineers).

Definition at line 1988 of file maphand.c.

Referenced by check_terrain_change(), climate_change(), and update_unit_activity().

## ◆ check_units_single_tile()

static void check_units_single_tile | ( | struct tile * | ptile | ) |

static

Helper function for bounce_units_on_terrain_change() that checks units on a single tile.

Definition at line 1885 of file maphand.c.

Referenced by bounce_units_on_terrain_change().

## ◆ climate_change()

void climate_change | ( | bool | warming,
|  | int | effect
| ) |  |

Do a climate change. Global warming occurred if 'warming' is TRUE, else there is a nuclear winter.

Definition at line 133 of file maphand.c.

Referenced by api_edit_climate_change(), global_warming(), and nuclear_winter().

## ◆ create_extra()

void create_extra | ( | struct tile * | ptile,
|  | struct extra_type * | pextra,
|  | struct player * | pplayer
| ) |  |

Create extra to tile.

Definition at line 2530 of file maphand.c.

Referenced by api_edit_create_owned_extra(), begin_phase(), fc_interface_init_server(), and update_unit_activity().

## ◆ create_vision_dependencies()

static void create_vision_dependencies | ( | void |  | ) |

static

This updates all players' really_gives_vision field. If p1 gives p2 shared vision and p2 gives p3 shared vision p1 should also give p3 shared vision.

Definition at line 1602 of file maphand.c.

Referenced by give_shared_vision(), and remove_shared_vision().

## ◆ destroy_extra()

void destroy_extra | ( | struct tile * | ptile,
|  | struct extra_type * | pextra
| ) |  |

Remove extra from tile.

Definition at line 2595 of file maphand.c.

Referenced by create_city(), create_extra(), fc_interface_init_server(), unit_enter_hut(), and update_unit_activity().

## ◆ disable_fog_of_war()

void disable_fog_of_war | ( | void |  | ) |

Turns FoW off for everyone

Definition at line 1789 of file maphand.c.

Referenced by begin_turn().

## ◆ disable_fog_of_war_player()

void disable_fog_of_war_player | ( | struct player * | pplayer | ) |

Turns FoW off for player

Definition at line 1775 of file maphand.c.

Referenced by check_leaving_edit_mode(), disable_fog_of_war(), and handle_edit_toggle_fogofwar().

## ◆ enable_fog_of_war()

void enable_fog_of_war | ( | void |  | ) |

Turns FoW on for everyone.

Definition at line 1765 of file maphand.c.

Referenced by begin_turn().

## ◆ enable_fog_of_war_player()

void enable_fog_of_war_player | ( | struct player * | pplayer | ) |

Turns FoW on for player

Definition at line 1751 of file maphand.c.

Referenced by check_leaving_edit_mode(), enable_fog_of_war(), and handle_edit_toggle_fogofwar().

## ◆ fix_tile_on_terrain_change()

void fix_tile_on_terrain_change | ( | struct tile * | ptile,
|  | struct terrain * | oldter,
|  | bool | extend_rivers
| ) |  |

Handles local side effects for a terrain change (tile and its surroundings). Does not handle global side effects (such as reassigning continents). For in-game terrain changes 'extend_rivers' should be TRUE; for edits it should be FALSE.

Definition at line 1968 of file maphand.c.

Referenced by api_edit_change_terrain(), check_terrain_change(), and edit_tile_terrain_handling().

## ◆ give_citymap_from_player_to_player()

void give_citymap_from_player_to_player | ( | struct city * | pcity,
|  | struct player * | pfrom,
|  | struct player * | pdest
| ) |  |

Give information about tiles within city radius from player to player

Definition at line 418 of file maphand.c.

Referenced by handle_diplomacy_create_clause_req(), and transfer_city().

## ◆ give_distorted_map()

bool give_distorted_map | ( | struct player * | pfrom,
|  | struct player * | pto,
|  | int | prob,
|  | bool | reveal_cities
| ) |  |

Transfer (random parts of) player pfrom's world map to pto.

Parameters

  pfrom | player that is the source of the map
  pto | player that receives the map
  prob | probability for the transfer each known tile
  reveal_cities | if the map of all known cities should be transferred

Returns
  Whether there any new info was given

Definition at line 2670 of file maphand.c.

Referenced by player_loot_player(), and spy_steal_some_maps().

## ◆ give_map_from_player_to_player()

void give_map_from_player_to_player | ( | struct player * | pfrom,
|  | struct player * | pdest
| ) |  |

Give information about whole map (all tiles) from player to player. Takes care of shared vision chains.

Definition at line 384 of file maphand.c.

Referenced by handle_diplomacy_accept_treaty_req(), and split_player().

## ◆ give_seamap_from_player_to_player()

void give_seamap_from_player_to_player | ( | struct player * | pfrom,
|  | struct player * | pdest
| ) |  |

Give information about all oceanic tiles from player to player

Definition at line 400 of file maphand.c.

Referenced by handle_diplomacy_accept_treaty_req().

## ◆ give_shared_vision()

void give_shared_vision | ( | struct player * | pfrom,
|  | struct player * | pto
| ) |  |

Starts shared vision between two players.

Definition at line 1636 of file maphand.c.

Referenced by handle_diplomacy_accept_treaty_req(), sg_load_players(), sg_load_players(), and srv_ready().

## ◆ give_tile_info_from_player_to_player()

static bool give_tile_info_from_player_to_player | ( | struct player * | pfrom,
|  | struct player * | pdest,
|  | struct tile * | ptile
| ) |  |

static

Give tile information from player to player. Handles chains of shared vision so that receiver may give information forward.

Parameters

  pfrom | Who gives the information
  pdest | Who receives the information
  ptile | Tile to give info about

Returns
  Whether there was any new info to give

Definition at line 1582 of file maphand.c.

Referenced by give_citymap_from_player_to_player(), give_distorted_map(), give_map_from_player_to_player(), and give_seamap_from_player_to_player().

## ◆ global_warming()

void global_warming | ( | int | effect | ) |

Wrapper for climate_change().

Definition at line 106 of file maphand.c.

Referenced by end_turn(), and receive_packet_game_info_100().

## ◆ is_claimable_ocean()

static bool is_claimable_ocean | ( | struct tile * | ptile,
|  | struct tile * | source,
|  | struct player * | pplayer
| ) |  |

static

Ocean tile can be claimed iff one of the following conditions stands: a) it is an inland lake not larger than MAXIMUM_OCEAN_SIZE b) it is adjacent to only one continent and not more than two ocean tiles c) It is one tile away from a border source d) Player knows tech with Claim_Ocean flag e) Source itself is Oceanic tile and player knows tech with Claim_Ocean_Limited flag The source which claims the ocean has to be placed on the correct continent. in case a) The continent which surrounds the inland lake in case b) The only continent which is adjacent to the tile

Definition at line 2080 of file maphand.c.

Referenced by check_terrain_change(), and map_claim_border().

## ◆ is_terrain_ecologically_wet()

static bool is_terrain_ecologically_wet | ( | struct tile * | ptile | ) |

static

Used only in global_warming() and nuclear_winter() below.

Definition at line 96 of file maphand.c.

Referenced by climate_change().

## ◆ map_calculate_borders()

void map_calculate_borders | ( | void |  | ) |

Update borders for all sources. Call this on turn end.

Definition at line 2360 of file maphand.c.

Referenced by end_turn(), handle_edit_recalculate_borders(), server_remove_player(), sg_load_players(), and sg_load_players().

## ◆ map_change_own_seen()

static void map_change_own_seen | ( | struct player * | pplayer,
|  | struct tile * | ptile,
|  | const v_radius_t | change
| ) |  |

static

Changes the own seen count of a tile for a player.

Definition at line 1149 of file maphand.c.

Referenced by shared_vision_change_seen().

## ◆ map_change_seen()

void map_change_seen | ( | struct player * | pplayer,
|  | struct tile * | ptile,
|  | const v_radius_t | change,
|  | bool | can_reveal_tiles
| ) |  |

static

This function changes the seen state of one player for all vision layers of a tile. It reveals the tiles if needed and controls the fog of war.

See also map_change_own_seen(), shared_vision_change_seen().

Definition at line 954 of file maphand.c.

Referenced by disable_fog_of_war_player(), enable_fog_of_war_player(), give_shared_vision(), map_know_and_see_all(), remove_shared_vision(), and shared_vision_change_seen().

## ◆ map_claim_base()

void map_claim_base | ( | struct tile * | ptile,
|  | struct extra_type * | pextra,
|  | struct player * | powner,
|  | struct player * | ploser
| ) |  |

Claim base to player's ownership.

Definition at line 2387 of file maphand.c.

Referenced by create_extra(), maybe_claim_base(), and tile_claim_bases().

## ◆ map_claim_border()

void map_claim_border | ( | struct tile * | ptile,
|  | struct player * | owner,
|  | int | radius_sq
| ) |  |

Update borders for this source. Call this for each new source.

If radius_sq is -1, get value from the border source on tile.

Definition at line 2273 of file maphand.c.

Referenced by city_change_size(), city_populate(), create_city(), map_calculate_borders(), map_claim_base(), map_update_border(), and transfer_city().

## ◆ map_claim_border_ownership()

static void map_claim_border_ownership | ( | struct tile * | ptile,
|  | struct player * | powner,
|  | struct tile * | psource
| ) |  |

static

Claim ownership of a single tile.

Definition at line 2149 of file maphand.c.

Referenced by map_claim_base(), and map_claim_ownership().

## ◆ map_claim_ownership()

void map_claim_ownership | ( | struct tile * | ptile,
|  | struct player * | powner,
|  | struct tile * | psource,
|  | bool | claim_bases
| ) |  |

Claim ownership of a single tile.

Definition at line 2194 of file maphand.c.

Referenced by create_city(), kill_player(), map_claim_border(), map_clear_border(), map_update_border(), sg_load_map_owner(), sg_load_map_owner(), sg_load_player_cities(), sg_load_player_cities(), and transfer_city().

## ◆ map_clear_border()

void map_clear_border | ( | struct tile * | ptile | ) |

Remove border for this source.

Definition at line 2224 of file maphand.c.

Referenced by check_terrain_change(), destroy_extra(), map_claim_base(), map_claim_border(), remove_city(), and transfer_city().

## ◆ map_clear_known()

void map_clear_known | ( | struct tile * | ptile,
|  | struct player * | pplayer
| ) |  |

Clear known status of the tile.

Definition at line 1190 of file maphand.c.

Referenced by create_barbarian_player(), map_hide_tile(), and remove_player_from_maps().

## ◆ map_get_player_city()

struct vision_site * map_get_player_city | ( | const struct tile * | ptile,
|  | const struct player * | pplayer
| ) |  |

Returns city located at given tile from player map.

Definition at line 1371 of file maphand.c.

Referenced by mapimg_server_tile_city(), package_dumb_city(), reality_check_city(), remove_dumb_city(), sg_save_player_vision(), spy_send_sabotage_list(), and update_dumb_city().

## ◆ map_get_player_tile()

struct player_tile * map_get_player_tile | ( | const struct tile * | ptile,
|  | const struct player * | pplayer
| ) |  |

Players' information of tiles is tracked so that fogged area can be kept consistent even when the client disconnects. This function returns the player tile information for the given tile and player.

Definition at line 1386 of file maphand.c.

Referenced by do_paradrop(), give_shared_vision(), handle_unit_get_actions(), is_refuel_tile(), map_change_own_seen(), map_change_seen(), map_get_seen(), mapimg_server_tile_owner(), mapimg_server_tile_terrain(), player_tile_free(), player_tile_init(), reality_check_city(), really_give_tile_info_from_player_to_player(), remove_dumb_city(), remove_player_from_maps(), remove_shared_vision(), send_tile_info(), server_plr_tile_city_id_get(), sg_load_player_vision(), sg_load_player_vision(), sg_save_player_vision(), update_dumb_city(), update_player_tile_knowledge(), and update_player_tile_last_seen().

## ◆ map_get_seen()

static int map_get_seen | ( | const struct player * | pplayer,
|  | const struct tile * | ptile,
|  | enum vision_layer | vlayer
| ) |  |

inlinestatic

Return whether the player can see the tile. Seeing a tile means you have vision of it now (as opposed to knowing a tile which means you've seen it before). Note that a tile can be seen but not known (currently this only happens when a city is founded with some unknown tiles in its radius); in this case the tile is unknown (but map_get_seen() will still return TRUE).

Definition at line 941 of file maphand.c.

Referenced by map_hide_tile(), map_is_also_seen(), and map_show_tile().

## ◆ map_hide_tile()

void map_hide_tile | ( | struct player * | src_player,
|  | struct tile * | ptile
| ) |  |

Hides the area to the player.

Callers may wish to buffer_shared_vision() before calling this function.

Definition at line 827 of file maphand.c.

Referenced by handle_edit_player_vision().

## ◆ map_is_also_seen()

static bool map_is_also_seen | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | enum vision_layer | vlayer
| ) |  |

inlinestatic

Returns whether the layer 'vlayer' of the tile 'ptile' is seen by the player 'pplayer'. Only call this when you already know the tile to be known.

Definition at line 916 of file maphand.c.

Referenced by map_is_known_and_seen(), and send_tile_info().

## ◆ map_is_known()

bool map_is_known | ( | const struct tile * | ptile,
|  | const struct player * | pplayer
| ) |  |

Return whether the player knows the tile. Knowing a tile means you've seen it once (as opposed to seeing a tile which means you can see it now).

Definition at line 901 of file maphand.c.

Referenced by adv_data_phase_init(), calculate_want_for_paratrooper(), city_desirability(), cityresult_fill(), expl_act_not_enabl(), explorer_desirable(), find_best_tile_to_paradrop_to(), find_closest_city(), find_something_to_bomb(), find_something_to_kill(), give_shared_vision(), likely_native(), manage_auto_explorer(), map_change_seen(), map_claim_border(), map_hide_tile(), map_is_known_and_seen(), notify_conn_packet(), really_give_tile_info_from_player_to_player(), send_city_info_at_tile(), send_tile_info(), sg_load_player_vision(), sg_load_player_vision(), sg_save_map_known(), try_summon_barbarians(), and update_dumb_city().

## ◆ map_is_known_and_seen()

bool map_is_known_and_seen | ( | const struct tile * | ptile,
|  | const struct player * | pplayer,
|  | enum vision_layer | vlayer
| ) |  |

Returns whether the layer 'vlayer' of the tile 'ptile' is known and seen by the player 'pplayer'.

Definition at line 927 of file maphand.c.

Referenced by adv_danger_at(), api_edit_tile_hide(), construct_move_data_list(), create_city(), dai_consider_tile_dangerous(), destroy_extra(), do_paradrop(), expl_act_not_enabl(), fc_interface_init_server(), find_best_tile_to_paradrop_to(), find_rampage_target(), find_something_to_bomb(), found_new_tech(), handle_diplomacy_create_clause_req(), handle_player_place_infra(), is_city_surrounded_by_our_spies(), map_show_tile(), need_war_player_hlp(), really_give_tile_info_from_player_to_player(), remove_allied_visibility(), remove_city(), see_combat(), send_city_info_at_tile(), send_combat(), sg_load_player_vision(), sg_load_player_vision(), try_summon_barbarians(), and update_tile_knowledge().

## ◆ map_know_and_see_all()

void map_know_and_see_all | ( | struct player * | pplayer | ) |

Call this function to unfog all tiles. This should only be called when a player dies or at the end of the game as it will result in permanent vision of the whole map.

Definition at line 1200 of file maphand.c.

Referenced by kill_player(), sg_load_player_vision(), sg_load_player_vision(), and show_map_to_all().

## ◆ map_set_border_vision()

void map_set_border_vision | ( | struct player * | pplayer,
|  | const bool | is_enabled
| ) |  |

Turn a player's ability to see inside their borders on or off.

It is safe to set the current value.

Definition at line 747 of file maphand.c.

Referenced by do_border_vision_effect().

## ◆ map_set_known()

void map_set_known | ( | struct tile * | ptile,
|  | struct player * | pplayer
| ) |  |

Set known status of the tile.

Definition at line 1182 of file maphand.c.

Referenced by map_change_seen(), map_show_tile(), really_give_tile_info_from_player_to_player(), sg_load_map_known(), and sg_load_map_known().

## ◆ map_show_all()

void map_show_all | ( | struct player * | pplayer | ) |

Shows the area to the player. Unless the tile is "seen", it will remain fogged and units will be hidden.

Definition at line 886 of file maphand.c.

Referenced by do_reveal_effects(), and srv_ready().

## ◆ map_show_circle()

void map_show_circle | ( | struct player * | pplayer,
|  | struct tile * | ptile,
|  | int | radius_sq
| ) |  |

Shows the area to the player. Unless the tile is "seen", it will remain fogged and units will be hidden.

Definition at line 871 of file maphand.c.

Referenced by do_paradrop(), handle_edit_unit_create(), illegal_action_pay_price(), init_new_game(), place_starting_unit(), try_summon_barbarians(), and unleash_barbarians().

## ◆ map_show_tile()

void map_show_tile | ( | struct player * | src_player,
|  | struct tile * | ptile
| ) |  |

Shows the area to the player. Unless the tile is "seen", it will remain fogged and units will be hidden.

Callers may wish to buffer_shared_vision() before calling this function.

Definition at line 775 of file maphand.c.

Referenced by api_edit_tile_show(), create_city_for_player(), do_reveal_effects(), do_unit_establish_trade(), handle_edit_player_vision(), map_show_all(), map_show_circle(), reestablish_city_trade_routes(), and remove_city().

## ◆ map_unit_homecity_enqueue()

static void map_unit_homecity_enqueue | ( | struct tile * | ptile | ) |

static

For each unit at the tile, queue any unique home city.

Definition at line 2133 of file maphand.c.

Referenced by map_claim_border_ownership().

## ◆ map_update_border()

void map_update_border | ( | struct tile * | ptile,
|  | struct player * | owner,
|  | int | old_radius_sq,
|  | int | new_radius_sq
| ) |  |

Update borders for this source. Changes the radius without temporary clearing.

Definition at line 2241 of file maphand.c.

Referenced by city_reduce_size().

## ◆ map_vision_update()

void map_vision_update | ( | struct player * | pplayer,
|  | struct tile * | ptile,
|  | const v_radius_t | old_radius_sq,
|  | const v_radius_t | new_radius_sq,
|  | bool | can_reveal_tiles
| ) |  |

There doesn't have to be a city.

Definition at line 692 of file maphand.c.

Referenced by destroy_extra(), map_claim_base(), and vision_change_sight().

## ◆ need_to_reassign_continents()

bool need_to_reassign_continents | ( | const struct terrain * | oldter,
|  | const struct terrain * | newter
| ) |  |

Returns TRUE if the terrain change from 'oldter' to 'newter' may require expensive reassignment of continents.

Definition at line 1930 of file maphand.c.

Referenced by api_edit_change_terrain(), check_terrain_change(), and edit_tile_terrain_handling().

## ◆ nuclear_winter()

void nuclear_winter | ( | int | effect | ) |

Wrapper for climate_change().

Definition at line 119 of file maphand.c.

Referenced by end_turn(), and receive_packet_game_info_100().

## ◆ ocean_to_land_fix_rivers()

static void ocean_to_land_fix_rivers | ( | struct tile * | ptile | ) |

static

Set the tile to be a river if required. It's required if one of the tiles nearby would otherwise be part of a river to nowhere. (Note that rivers-to-nowhere can still occur if a single-tile lake is transformed away, but this is relatively unlikely.) For simplicity, I'm assuming that this is the only exit of the river, so I don't need to trace it across the continent. –CJM

Definition at line 1805 of file maphand.c.

Referenced by fix_tile_on_terrain_change().

## ◆ player_map_free()

void player_map_free | ( | struct player * | pplayer | ) |

Free a player's private map.

Definition at line 1241 of file maphand.c.

Referenced by server_player_init(), and server_remove_player().

## ◆ player_map_init()

void player_map_init | ( | struct player * | pplayer | ) |

Allocate space for map, and initialise the tiles. Uses current map.xsize and map.ysize.

Definition at line 1225 of file maphand.c.

Referenced by server_player_init(), sg_load_map_known(), sg_load_map_known(), and srv_ready().

## ◆ player_tile_free()

static void player_tile_free | ( | struct tile * | ptile,
|  | struct player * | pplayer
| ) |  |

static

Free the memory stored into the player tile.

Definition at line 1357 of file maphand.c.

Referenced by player_map_free().

## ◆ player_tile_init()

static void player_tile_init | ( | struct tile * | ptile,
|  | struct player * | pplayer
| ) |  |

static

We need to use fogofwar_old here, so the player's tiles get in the same state as the other players' tiles.

Definition at line 1332 of file maphand.c.

Referenced by player_map_init().

## ◆ player_tile_own_seen()

static int player_tile_own_seen | ( | const struct player_tile * | plrtile,
|  | enum vision_layer | vlayer
| ) |  |

inlinestatic

Get own seen count from player tile. Doesn't count shared vision.

Parameters

  plrtile | Player tile to check own seen count from
  vlayer | Vision layer which we want the count for

Returns
  Own seen count

Definition at line 1140 of file maphand.c.

Referenced by give_shared_vision(), and remove_shared_vision().

## ◆ really_give_map_from_player_to_player()

static void really_give_map_from_player_to_player | ( | struct player * | pfrom,
|  | struct player * | pdest
| ) |  |

static

Give information about whole map (all tiles) from player to player. Does not take care of shared vision; caller is assumed to do that.

Definition at line 1562 of file maphand.c.

Referenced by give_shared_vision().

## ◆ really_give_tile_info_from_player_to_player()

static bool really_give_tile_info_from_player_to_player | ( | struct player * | pfrom,
|  | struct player * | pdest,
|  | struct tile * | ptile
| ) |  |

static

Give tile information from one player to one player.

Parameters

  pfrom | Who gives the information
  pdest | Who receives the information
  ptile | Tile to give info about

Returns
  Whether there was any new info to give

Definition at line 1489 of file maphand.c.

Referenced by give_tile_info_from_player_to_player(), and really_give_map_from_player_to_player().

## ◆ really_gives_vision()

bool really_gives_vision | ( | struct player * | me,
|  | struct player * | them
| ) |  |

Return TRUE iff the player me really gives shared vision to player them.

Definition at line 345 of file maphand.c.

Referenced by api_edit_tile_hide(), buffer_shared_vision(), create_vision_dependencies(), give_shared_vision(), give_tile_info_from_player_to_player(), handle_edit_player_vision(), map_hide_tile(), map_show_tile(), remove_shared_vision(), sg_load_players(), sg_load_players(), shared_vision_change_seen(), and unbuffer_shared_vision().

## ◆ remove_player_from_maps()

void remove_player_from_maps | ( | struct player * | pplayer | ) |

Remove all knowledge of a player from main map and other players' private maps, and send updates to connected clients. Frees all vision_sites associated with that player.

Definition at line 1262 of file maphand.c.

Referenced by server_remove_player().

## ◆ remove_shared_vision()

void remove_shared_vision | ( | struct player * | pfrom,
|  | struct player * | pto
| ) |  |

Removes shared vision from between two players.

Definition at line 1697 of file maphand.c.

Referenced by dai_diplomacy_actions(), dai_go_to_war(), handle_diplomacy_cancel_pact(), kill_player(), and server_remove_player().

## ◆ send_all_known_tiles()

void send_all_known_tiles | ( | struct conn_list * | dest | ) |

Send all tiles known to specified clients. If dest is NULL means game.est_connections.

Note for multiple connections this may change "sent" multiple times for single player. This is ok, because "sent" data is just optimised calculations, so it will be correct before this, for each connection during this, and at end.

Definition at line 444 of file maphand.c.

Referenced by api_edit_change_terrain(), check_edited_tile_terrains(), check_terrain_change(), and send_all_info().

## ◆ send_map_info()

void send_map_info | ( | struct conn_list * | dest | ) |

Send basic map information: map size, topology, and is_earth.

Definition at line 655 of file maphand.c.

Referenced by send_all_info().

## ◆ send_tile_info()

void send_tile_info | ( | struct conn_list * | dest,
|  | struct tile * | ptile,
|  | bool | send_unknown
| ) |  |

Send tile information to all the clients in dest which know and see the tile. If dest is NULL, sends to all clients (game.est_connections) which know and see tile.

Note that this function does not update the playermap. For that call update_tile_knowledge().

Definition at line 491 of file maphand.c.

Referenced by api_edit_tile_hide(), api_edit_tile_set_label(), city_map_update_empty(), city_map_update_tile_direct(), city_map_update_worker(), destroy_extra(), found_new_tech(), handle_edit_tile(), handle_player_place_infra(), map_change_seen(), map_claim_border_ownership(), map_hide_tile(), map_show_tile(), really_give_tile_info_from_player_to_player(), remove_city(), remove_player_from_maps(), send_all_known_tiles(), and update_tile_knowledge().

## ◆ send_tile_suppression()

bool send_tile_suppression | ( | bool | now | ) |

Suppress send_tile_info() during game_load()

Definition at line 475 of file maphand.c.

Referenced by savegame2_load(), and savegame3_load().

## ◆ shared_vision_change_seen()

static void shared_vision_change_seen | ( | struct player * | pplayer,
|  | struct tile * | ptile,
|  | const v_radius_t | change,
|  | bool | can_reveal_tiles
| ) |  |

static

Change the seen count of a tile for a pplayer. It will automatically handle the shared visions.

Definition at line 674 of file maphand.c.

Referenced by map_claim_border_ownership(), map_set_border_vision(), and map_vision_update().

## ◆ show_map_to_all()

void show_map_to_all | ( | void |  | ) |

Unfogs all tiles for all players. See map_know_and_see_all.

Definition at line 1214 of file maphand.c.

Referenced by srv_scores().

## ◆ terrain_change_bounce_single_unit()

static void terrain_change_bounce_single_unit | ( | struct unit * | punit,
|  | struct tile * | from
| ) |  |

static

Bounce one unit from tile on terrain change.

Definition at line 1831 of file maphand.c.

Referenced by check_units_single_tile(), and terrain_change_bounce_single_unit().

## ◆ terrain_changed()

void terrain_changed | ( | struct tile * | ptile | ) |

Handle local side effects for a terrain change.

Definition at line 1949 of file maphand.c.

Referenced by edit_tile_extra_handling(), and fix_tile_on_terrain_change().

## ◆ tile_change_side_effects()

void tile_change_side_effects | ( | struct tile * | ptile,
|  | bool | refresh_city
| ) |  |

Handle various side effects of the change on tile. If a city was working the tile, that city might need refresh after this call.

Parameters

  ptile | tile that has changed
  refresh_city | whether city working the tile should be refreshed

Definition at line 2698 of file maphand.c.

Referenced by api_edit_change_terrain(), api_edit_create_owned_extra(), api_edit_remove_extra(), climate_change(), edit_tile_extra_handling(), edit_tile_terrain_handling(), end_turn(), handle_edit_tile(), remove_city(), and update_unit_activity().

## ◆ tile_claim_bases()

void tile_claim_bases | ( | struct tile * | ptile,
|  | struct player * | powner
| ) |  |

Claim ownership of bases on single tile.

Definition at line 2207 of file maphand.c.

Referenced by map_claim_ownership(), sg_load_map_owner(), sg_load_map_owner(), sg_load_player_units(), and unit_move().

## ◆ unbuffer_shared_vision()

static void unbuffer_shared_vision | ( | struct player * | pplayer | ) |

static

Stop buffering shared vision

Definition at line 368 of file maphand.c.

Referenced by disable_fog_of_war_player(), enable_fog_of_war_player(), give_citymap_from_player_to_player(), give_distorted_map(), give_map_from_player_to_player(), give_seamap_from_player_to_player(), give_shared_vision(), map_know_and_see_all(), map_show_all(), map_show_circle(), map_vision_update(), and remove_shared_vision().

## ◆ unit_is_on_layer()

static bool unit_is_on_layer | ( | const struct unit * | punit,
|  | enum vision_layer | vlayer
| ) |  |

static

Return whether unit is on this particular layer. Callers assume that each unit is in just one layer, i.e., though all units can be seen on V_MAIN, this returns FALSE for layer V_MAIN for units that are visible ALSO in other layers.

Definition at line 646 of file maphand.c.

Referenced by map_change_seen(), map_hide_tile(), and map_show_tile().

## ◆ update_player_tile_knowledge()

bool update_player_tile_knowledge | ( | struct player * | pplayer,
|  | struct tile * | ptile
| ) |  |

Give pplayer the correct knowledge about tile; return TRUE iff knowledge changed.

Note that unlike update_tile_knowledge, this function will not send any packets to the client. Callers may want to call send_tile_info() if this function returns TRUE.

Definition at line 1402 of file maphand.c.

Referenced by destroy_extra(), found_new_tech(), map_change_seen(), map_show_tile(), sg_load_player_vision(), sg_load_player_vision(), and update_tile_knowledge().

## ◆ update_player_tile_last_seen()

void update_player_tile_last_seen | ( | struct player * | pplayer,
|  | struct tile * | ptile
| ) |  |

Remember that tile was last seen this year.

Definition at line 1471 of file maphand.c.

Referenced by map_change_seen(), map_hide_tile(), map_show_tile(), sg_load_player_vision(), and sg_load_player_vision().

## ◆ update_tile_knowledge()

void update_tile_knowledge | ( | struct tile * | ptile | ) |

Update playermap knowledge for everybody who sees the tile, and send a packet to everyone whose info is changed.

Note this only checks for changing of the terrain, special, or resource for the tile, since these are the only values held in the playermap.

A tile's owner always can see terrain changes in their territory.

Definition at line 1443 of file maphand.c.

Referenced by api_edit_change_terrain(), api_edit_create_owned_extra(), api_edit_remove_extra(), begin_phase(), check_terrain_change(), climate_change(), create_city(), do_nuke_tile(), edit_tile_extra_handling(), edit_tile_terrain_handling(), end_turn(), handle_edit_tile(), map_claim_border_ownership(), place_pollution(), place_starting_unit(), transfer_city(), try_summon_barbarians(), unit_enter_hut(), update_unit_activity(), and upgrade_all_city_extras().

## ◆ upgrade_all_city_extras()

void upgrade_all_city_extras | ( | struct player * | pplayer,
|  | bool | discovery
| ) |  |

To be called when a player gains some better extra building tech for the first time. Sends a message, and upgrades all city squares to new extras. "discovery" just affects the message: set to 1 if the tech is a "discovery", 0 if otherwise acquired (conquer/trade/GLib). –dwp

Definition at line 276 of file maphand.c.

Referenced by found_new_tech().

## ◆ upgrade_city_extras()

bool upgrade_city_extras | ( | struct city * | pcity,
|  | struct extra_type ** | gained
| ) |  |

Check city for extra upgrade. Returns whether anything was done. gained will be set if there's exactly one kind of extra added.

Definition at line 241 of file maphand.c.

Referenced by create_city(), result_defense_bonus(), terrain_changed(), transfer_city(), and upgrade_all_city_extras().

## ◆ vision_change_sight()

void vision_change_sight | ( | struct vision * | vision,
|  | const v_radius_t | radius_sq
| ) |  |

Change the sight points for the vision source, fogging or unfogging tiles as needed.

See documentation in vision.h.

Definition at line 2508 of file maphand.c.

Referenced by city_refresh_vision(), transfer_city(), unit_move_by_data(), unit_refresh_vision(), and vision_clear_sight().

## ◆ vision_clear_sight()

void vision_clear_sight | ( | struct vision * | vision | ) |

Clear all sight points from this vision source.

See documentation in vision.h.

Definition at line 2520 of file maphand.c.

Referenced by remove_city(), server_remove_unit_full(), transfer_city(), unit_change_homecity_handling(), and unit_move().

## Variable Documentation

## ◆ send_tile_suppressed

bool send_tile_suppressed = FALSE

static

Definition at line 65 of file maphand.c.

Referenced by send_tile_info(), and send_tile_suppression().