Freeciv21
Develop your civilization from humble roots to a global empire
climisc.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 // common
16 #include "events.h"
17 #include "fc_types.h"
18 
19 struct Clause;
20 struct nation_type;
21 struct nation_set;
22 
23 typedef int cid;
24 
25 void client_remove_city(struct city *pcity);
26 void client_remove_unit(struct unit *punit);
27 
28 const char *get_embassy_status(const struct player *me,
29  const struct player *them);
30 const char *get_vision_status(const struct player *me,
31  const struct player *them);
32 void client_diplomacy_clause_string(char *buf, int bufsiz,
33  struct Clause *pclause);
34 
35 void global_warming_scaled(int *chance, int *rate, int max);
36 void nuclear_winter_scaled(int *chance, int *rate, int max);
37 
38 const QPixmap *client_research_sprite();
39 const QPixmap *client_warming_sprite();
40 const QPixmap *client_cooling_sprite();
41 const QPixmap *client_government_sprite();
42 
43 void center_on_something();
44 
45 /*
46  * A compound id (cid) can hold all objects a city can build:
47  * improvements (with wonders) and units. This is achieved by
48  * seperation the value set: a cid < B_LAST denotes a improvement
49  * (including wonders). A cid >= B_LAST denotes a unit with the
50  * unit_type_id of (cid - B_LAST).
51  */
52 
53 cid cid_encode(struct universal target);
54 cid cid_encode_unit(const struct unit_type *punittype);
55 cid cid_encode_building(const struct impr_type *pimprove);
56 
57 struct universal cid_decode(cid cid);
58 
59 bool city_unit_supported(const struct city *pcity,
60  const struct universal *target);
61 bool city_unit_present(const struct city *pcity,
62  const struct universal *target);
63 bool city_building_present(const struct city *pcity,
64  const struct universal *target);
65 
66 struct item {
67  struct universal item;
68  char descr[MAX_LEN_NAME + 40];
69 };
70 
71 typedef bool (*TestCityFunc)(const struct city *, const struct universal *);
72 
73 #define MAX_NUM_PRODUCTION_TARGETS (U_LAST + B_LAST)
74 void name_and_sort_items(struct universal *targets, int num_items,
75  struct item *items, bool show_cost,
76  struct city *pcity);
77 int collect_production_targets(struct universal *targets,
78  struct city **selected_cities,
79  int num_selected_cities, bool append_units,
80  bool append_wonders, bool change_prod,
83  struct city *pcity,
84  bool advanced_tech);
85 int collect_already_built_targets(struct universal *targets,
86  struct city *pcity);
87 
88 void handle_event(const char *featured_text, struct tile *ptile,
89  enum event_type event, int turn, int phase, int conn_id);
90 void create_event(struct tile *ptile, enum event_type event,
91  const struct ft_color color, const char *format, ...)
92  fc__attribute((__format__(__printf__, 4, 5)));
93 
94 struct city *get_nearest_city(const struct unit *punit, int *sq_dist);
95 
96 void cityrep_buy(struct city *pcity);
97 
98 bool can_units_do_connect(const std::vector<unit *> &units,
99  enum unit_activity activity,
100  struct extra_type *tgt);
101 
102 void client_unit_init_act_prob_cache(struct unit *punit);
103 
104 void unit_focus_set_status(struct player *pplayer);
105 
106 void client_player_init(struct player *pplayer);
107 
109 
110 bool mapimg_client_define();
111 
113 
114 enum ai_level server_ai_level();
const char * get_vision_status(const struct player *me, const struct player *them)
Return a string indicating one nation's shaed vision status with another.
Definition: climisc.cpp:194
int collect_eventually_buildable_targets(struct universal *targets, struct city *pcity, bool advanced_tech)
Collect the cids of all targets which can be build by this city or in general.
Definition: climisc.cpp:701
void client_player_maps_reset()
Reset the private maps of all players.
Definition: climisc.cpp:1104
bool city_unit_supported(const struct city *pcity, const struct universal *target)
Return TRUE if the city supports at least one unit of the given production type (returns FALSE if the...
Definition: climisc.cpp:497
cid cid_encode_building(const struct impr_type *pimprove)
Encode a CID for the target building.
Definition: climisc.cpp:467
struct universal cid_decode(cid cid)
Decode the CID into a city_production structure.
Definition: climisc.cpp:478
void client_player_init(struct player *pplayer)
Initialize a player on the client side.
Definition: climisc.cpp:1092
const QPixmap * client_government_sprite()
Return the sprite for the government indicator.
Definition: climisc.cpp:374
void client_remove_city(struct city *pcity)
Remove city, client end version.
Definition: climisc.cpp:134
void client_unit_init_act_prob_cache(struct unit *punit)
Initialize the action probability cache.
Definition: climisc.cpp:1069
void nuclear_winter_scaled(int *chance, int *rate, int max)
Return nuclear winter chance and rate of change, scaled to max.
Definition: climisc.cpp:308
bool mapimg_client_define()
Create a map image definition on the client.
Definition: climisc.cpp:1133
void struct city * get_nearest_city(const struct unit *punit, int *sq_dist)
Find city nearest to given unit and optionally return squared city distance Parameter sq_dist may be ...
Definition: climisc.cpp:980
void name_and_sort_items(struct universal *targets, int num_items, struct item *items, bool show_cost, struct city *pcity)
Takes an array of compound ids (cids).
Definition: climisc.cpp:596
const QPixmap * client_research_sprite()
Return the sprite for the research indicator.
Definition: climisc.cpp:317
int cid
Definition: climisc.h:21
void cityrep_buy(struct city *pcity)
Called when the "Buy" button is pressed in the city report for every selected city.
Definition: climisc.cpp:1019
void global_warming_scaled(int *chance, int *rate, int max)
Return global warming chance and rate of change, scaled to max.
Definition: climisc.cpp:299
struct nation_set * client_current_nation_set()
Returns the nation set in use.
Definition: climisc.cpp:1190
bool(* TestCityFunc)(const struct city *, const struct universal *)
Definition: climisc.h:71
void create_event(struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...) fc__attribute((__format__(__printf__
cid cid_encode(struct universal target)
Encode a CID for the target production.
Definition: climisc.cpp:446
void client_remove_unit(struct unit *punit)
Remove unit, client end version.
Definition: climisc.cpp:69
bool can_units_do_connect(const std::vector< unit * > &units, enum unit_activity activity, struct extra_type *tgt)
Returns TRUE if any of the units can do the connect activity.
Definition: climisc.cpp:1056
bool city_building_present(const struct city *pcity, const struct universal *target)
A TestCityFunc to tell whether the item is a building and is present.
Definition: climisc.cpp:538
int collect_already_built_targets(struct universal *targets, struct city *pcity)
Collect the cids of all improvements which are built in the given city.
Definition: climisc.cpp:806
void center_on_something()
Find something sensible to display.
Definition: climisc.cpp:392
enum ai_level server_ai_level()
Returns the current AI skill level on the server, if the same level is currently used for all current...
Definition: climisc.cpp:1211
void unit_focus_set_status(struct player *pplayer)
Set focus status of all player units to FOCUS_AVAIL.
Definition: climisc.cpp:1080
void handle_event(const char *featured_text, struct tile *ptile, enum event_type event, int turn, int phase, int conn_id)
Handles a chat or event message.
Definition: climisc.cpp:827
cid cid_encode_unit(const struct unit_type *punittype)
Encode a CID for the target unit type.
Definition: climisc.cpp:456
void client_diplomacy_clause_string(char *buf, int bufsiz, struct Clause *pclause)
Copy a string that describes the given clause into the return buffer.
Definition: climisc.cpp:213
const QPixmap * client_warming_sprite()
Return the sprite for the global-warming indicator.
Definition: climisc.cpp:340
const QPixmap * client_cooling_sprite()
Return the sprite for the global-cooling indicator.
Definition: climisc.cpp:357
bool city_unit_present(const struct city *pcity, const struct universal *target)
Return TRUE if the city has present at least one unit of the given production type (returns FALSE if ...
Definition: climisc.cpp:518
const char * get_embassy_status(const struct player *me, const struct player *them)
Return a string indicating one nation's embassy status with another.
Definition: climisc.cpp:169
int collect_production_targets(struct universal *targets, struct city **selected_cities, int num_selected_cities, bool append_units, bool append_wonders, bool change_prod, TestCityFunc test_func)
Return possible production targets for the current player's cities.
Definition: climisc.cpp:648
enum event_type event
Definition: events.cpp:68
#define MAX_LEN_NAME
Definition: fc_types.h:61
Definition: city.h:291
Definition: climisc.h:66
char descr[MAX_LEN_NAME+40]
Definition: climisc.h:68
Functions for handling the nations.
Definition: nation.cpp:33
Definition: player.h:231
Definition: tile.h:42
Definition: unit.h:134
int fc__attribute((nonnull(1, 3)))