Freeciv21
Develop your civilization from humble roots to a global empire
maphand.h
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 #pragma once
14 
15 #include "fc_types.h"
16 
17 #include "map.h"
18 #include "packets.h"
19 #include "terrain.h"
20 #include "vision.h"
21 
22 #include "hand_gen.h"
23 
24 struct section_file;
25 struct conn_list;
26 
27 struct player_tile {
28  std::unique_ptr<vision_site> site; // nullptr for no vision site
29  struct extra_type *resource; // nullptr for no resource
30  struct terrain *terrain; // nullptr for unknown tiles
31  struct player *owner; // nullptr for unowned
33  bv_extras extras;
34 
35  /* If you build a city with an unknown square within city radius
36  the square stays unknown. However, we still have to keep count
37  of the seen points, so they are kept in here. When the tile
38  then becomes known they are moved to seen. */
41  short last_updated;
42 };
43 
44 void global_warming(int effect);
45 void nuclear_winter(int effect);
46 void climate_change(bool warming, int effect);
47 bool upgrade_city_extras(struct city *pcity, struct extra_type **gained);
48 void upgrade_all_city_extras(struct player *pplayer, bool discovery);
49 
50 void give_map_from_player_to_player(struct player *pfrom,
51  struct player *pdest);
52 void give_seamap_from_player_to_player(struct player *pfrom,
53  struct player *pdest);
54 void give_citymap_from_player_to_player(struct city *pcity,
55  struct player *pfrom,
56  struct player *pdest);
57 void send_all_known_tiles(struct conn_list *dest);
58 
59 bool send_tile_suppression(bool now);
60 void send_tile_info(struct conn_list *dest, struct tile *ptile,
61  bool send_unknown);
62 
63 void send_map_info(struct conn_list *dest);
64 
65 void map_show_tile(struct player *pplayer, struct tile *ptile);
66 void map_hide_tile(struct player *pplayer, struct tile *ptile);
67 void map_show_circle(struct player *pplayer, struct tile *ptile,
68  int radius_sq);
69 void map_vision_update(struct player *pplayer, struct tile *ptile,
70  const v_radius_t old_radius_sq,
71  const v_radius_t new_radius_sq,
72  bool can_reveal_tiles);
73 void map_set_border_vision(struct player *pplayer, const bool is_enabled);
74 void map_show_all(struct player *pplayer);
75 
76 bool map_is_known_and_seen(const struct tile *ptile,
77  const struct player *pplayer,
78  enum vision_layer vlayer);
79 bool map_is_known(const struct tile *ptile, const struct player *pplayer);
80 void map_set_known(struct tile *ptile, struct player *pplayer);
81 void map_clear_known(struct tile *ptile, struct player *pplayer);
82 void map_know_and_see_all(struct player *pplayer);
83 void show_map_to_all();
84 
85 void player_map_init(struct player *pplayer);
86 void player_map_free(struct player *pplayer);
87 void remove_player_from_maps(struct player *pplayer);
88 
89 struct vision_site *map_get_player_city(const struct tile *ptile,
90  const struct player *pplayer);
91 struct vision_site *map_get_player_site(const struct tile *ptile,
92  const struct player *pplayer);
93 struct player_tile *map_get_player_tile(const struct tile *ptile,
94  const struct player *pplayer);
95 bool update_player_tile_knowledge(struct player *pplayer,
96  struct tile *ptile);
97 void update_tile_knowledge(struct tile *ptile);
98 void update_player_tile_last_seen(struct player *pplayer,
99  struct tile *ptile);
100 
101 void give_shared_vision(struct player *pfrom, struct player *pto);
102 void remove_shared_vision(struct player *pfrom, struct player *pto);
103 bool really_gives_vision(struct player *me, struct player *them);
104 
105 void enable_fog_of_war();
106 void disable_fog_of_war();
107 void enable_fog_of_war_player(struct player *pplayer);
108 void disable_fog_of_war_player(struct player *pplayer);
109 
110 void map_calculate_borders();
111 void map_claim_border(struct tile *ptile, struct player *powner,
112  int radius_sq);
113 void map_claim_ownership(struct tile *ptile, struct player *powner,
114  struct tile *psource, bool claim_bases);
115 void map_clear_border(struct tile *ptile);
116 void map_update_border(struct tile *ptile, struct player *owner,
117  int old_radius_sq, int new_radius_sq);
118 
119 void tile_claim_bases(struct tile *ptile, struct player *powner);
120 void map_claim_base(struct tile *ptile, const extra_type *pextra,
121  struct player *powner, struct player *ploser);
122 
123 void terrain_changed(struct tile *ptile);
124 void check_terrain_change(struct tile *ptile, struct terrain *oldter);
125 void fix_tile_on_terrain_change(struct tile *ptile, struct terrain *oldter,
126  bool extend_rivers);
127 bool need_to_reassign_continents(const struct terrain *oldter,
128  const struct terrain *newter);
129 void bounce_units_on_terrain_change(struct tile *ptile);
130 
131 void vision_change_sight(struct vision *vision, const v_radius_t radius_sq);
132 void vision_clear_sight(struct vision *vision);
133 
134 void change_playertile_site(struct player_tile *ptile,
135  struct vision_site *new_site);
136 
137 void create_extra(struct tile *ptile, const extra_type *pextra,
138  struct player *pplayer);
139 void destroy_extra(struct tile *ptile, struct extra_type *pextra);
140 
141 void give_distorted_map(struct player *pfrom, struct player *pto, int prob,
142  bool reveal_cities);
void disable_fog_of_war()
Turns FoW off for everyone.
Definition: maphand.cpp:1736
void player_map_init(struct player *pplayer)
Allocate space for map, and initialise the tiles.
Definition: maphand.cpp:1177
void update_player_tile_last_seen(struct player *pplayer, struct tile *ptile)
Remember that tile was last seen this year.
Definition: maphand.cpp:1427
void vision_clear_sight(struct vision *vision)
Clear all sight points from this vision source.
Definition: maphand.cpp:2395
void map_calculate_borders()
Update borders for all sources.
Definition: maphand.cpp:2244
void map_show_tile(struct player *pplayer, struct tile *ptile)
Shows the area to the player.
Definition: maphand.cpp:743
void map_set_border_vision(struct player *pplayer, const bool is_enabled)
Turn a players ability to see inside his borders on or off.
Definition: maphand.cpp:714
void map_claim_ownership(struct tile *ptile, struct player *powner, struct tile *psource, bool claim_bases)
Claim ownership of a single tile.
Definition: maphand.cpp:2070
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
Definition: maphand.cpp:884
void send_map_info(struct conn_list *dest)
Send basic map information: map size, topology, and is_earth.
Definition: maphand.cpp:617
bool send_tile_suppression(bool now)
Suppress send_tile_info() during game_load()
Definition: maphand.cpp:469
void destroy_extra(struct tile *ptile, struct extra_type *pextra)
Remove extra from tile.
Definition: maphand.cpp:2478
void map_claim_base(struct tile *ptile, const extra_type *pextra, struct player *powner, struct player *ploser)
Claim base to player's ownership.
Definition: maphand.cpp:2273
bool really_gives_vision(struct player *me, struct player *them)
Return TRUE iff the player me really gives shared vision to player them.
Definition: maphand.cpp:325
void map_know_and_see_all(struct player *pplayer)
Call this function to unfog all tiles.
Definition: maphand.cpp:1151
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.
Definition: maphand.cpp:485
bool update_player_tile_knowledge(struct player *pplayer, struct tile *ptile)
Give pplayer the correct knowledge about tile; return TRUE iff knowledge changed.
Definition: maphand.cpp:1357
void give_map_from_player_to_player(struct player *pfrom, struct player *pdest)
Give information about whole map (all tiles) from player to player.
Definition: maphand.cpp:368
void send_all_known_tiles(struct conn_list *dest)
Send all tiles known to specified clients.
Definition: maphand.cpp:436
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,...
Definition: maphand.cpp:1802
void give_seamap_from_player_to_player(struct player *pfrom, struct player *pdest)
Give information about all oceanic tiles from player to player.
Definition: maphand.cpp:387
void remove_shared_vision(struct player *pfrom, struct player *pto)
Removes shared vision from between two players.
Definition: maphand.cpp:1634
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 co...
Definition: maphand.cpp:1819
void 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.
Definition: maphand.cpp:2558
void show_map_to_all()
Unfogs all tiles for all players.
Definition: maphand.cpp:1167
void tile_claim_bases(struct tile *ptile, struct player *powner)
Claim ownership of bases on single tile.
Definition: maphand.cpp:2083
void disable_fog_of_war_player(struct player *pplayer)
Turns FoW off for player.
Definition: maphand.cpp:1720
void climate_change(bool warming, int effect)
Do a climate change.
Definition: maphand.cpp:123
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.
Definition: maphand.cpp:251
void map_update_border(struct tile *ptile, struct player *owner, int old_radius_sq, int new_radius_sq)
Update borders for this source.
Definition: maphand.cpp:2121
void map_set_known(struct tile *ptile, struct player *pplayer)
Set known status of the tile.
Definition: maphand.cpp:1133
void enable_fog_of_war()
Turns FoW on for everyone.
Definition: maphand.cpp:1711
void map_show_all(struct player *pplayer)
Shows the area to the player.
Definition: maphand.cpp:870
void map_hide_tile(struct player *pplayer, struct tile *ptile)
Hides the area to the player.
Definition: maphand.cpp:802
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: maphand.cpp:408
void nuclear_winter(int effect)
Wrapper for climate_change().
Definition: maphand.cpp:109
void create_extra(struct tile *ptile, const extra_type *pextra, struct player *pplayer)
Create extra to tile.
Definition: maphand.cpp:2405
void terrain_changed(struct tile *ptile)
Handle local side effects for a terrain change.
Definition: maphand.cpp:1837
void player_map_free(struct player *pplayer)
Free a player's private map.
Definition: maphand.cpp:1191
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: maphand.cpp:894
void change_playertile_site(struct player_tile *ptile, struct vision_site *new_site)
Changes site information for player tile.
Definition: maphand.cpp:1122
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).
Definition: maphand.cpp:1856
void enable_fog_of_war_player(struct player *pplayer)
Turns FoW on for player.
Definition: maphand.cpp:1695
void map_show_circle(struct player *pplayer, struct tile *ptile, int radius_sq)
Shows the area to the player.
Definition: maphand.cpp:852
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: maphand.cpp:652
void update_tile_knowledge(struct tile *ptile)
Update playermap knowledge for everybody who sees the tile, and send a packet to everyone whose info ...
Definition: maphand.cpp:1395
void map_claim_border(struct tile *ptile, struct player *powner, int radius_sq)
Update borders for this source.
Definition: maphand.cpp:2155
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 c...
Definition: maphand.cpp:1210
void give_shared_vision(struct player *pfrom, struct player *pto)
Starts shared vision between two players.
Definition: maphand.cpp:1568
void check_terrain_change(struct tile *ptile, struct terrain *oldter)
Handles local and global side effects for a terrain change for a single tile.
Definition: maphand.cpp:1875
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 cli...
Definition: maphand.cpp:1341
struct vision_site * map_get_player_site(const struct tile *ptile, const struct player *pplayer)
Returns site located at given tile from player map.
Definition: maphand.cpp:1330
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: maphand.cpp:1317
void global_warming(int effect)
Wrapper for climate_change().
Definition: maphand.cpp:96
bool upgrade_city_extras(struct city *pcity, struct extra_type **gained)
Check city for extra upgrade.
Definition: maphand.cpp:214
void map_clear_border(struct tile *ptile)
Remove border for this source.
Definition: maphand.cpp:2102
void map_clear_known(struct tile *ptile, struct player *pplayer)
Clear known status of the tile.
Definition: maphand.cpp:1141
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.
Definition: maphand.cpp:2383
Definition: city.h:291
bv_extras extras
Definition: maphand.h:33
struct player * extras_owner
Definition: maphand.h:32
v_radius_t seen_count
Definition: maphand.h:40
v_radius_t own_seen
Definition: maphand.h:39
struct terrain * terrain
Definition: maphand.h:30
std::unique_ptr< vision_site > site
Definition: maphand.h:28
short last_updated
Definition: maphand.h:41
struct player * owner
Definition: maphand.h:31
struct extra_type * resource
Definition: maphand.h:29
Definition: player.h:231
Definition: tile.h:42
Definition: vision.h:83
short int v_radius_t[V_COUNT]
Definition: vision.h:81