57 const struct player *plr2);
59 const struct player *plr2);
61 const struct player *plr2);
81 log_error(
"non-pact diplstate %d in cancel_pact_result", oldstate);
97 if (p1 == p2 || ds == DS_WAR || ds == DS_NO_CONTACT) {
155 enum diplstate_type treaty)
168 || treaty == DS_NO_CONTACT
169 || treaty == DS_ARMISTICE
171 || treaty == DS_LAST) {
174 if (treaty == DS_CEASEFIRE && existing != DS_WAR) {
177 if (treaty == DS_PEACE
178 && (existing != DS_WAR && existing != DS_CEASEFIRE)) {
181 if (treaty == DS_ALLIANCE) {
191 if (treaty == existing) {
203 const struct player *pplayer2)
205 return (pplayer == pplayer2
216 if (tgt_player->
team == pteam) {
235 const struct player *pplayer2)
245 const struct player *pplayer2)
257 return (pcity && pplayer &&
city_owner(pcity) == pplayer);
265 const struct tile *ptile)
270 || ptile_owner == pplayer
279 const struct player *plr2)
291 diplstate =
fc_calloc(1,
sizeof(*diplstate));
292 *diplstate_slot = diplstate;
299 const struct player *plr2)
305 diplstate->
type = DS_NO_CONTACT;
318 const struct player *plr2)
335 const struct player *plr2)
343 if (*diplstate_slot != NULL) {
347 *diplstate_slot = NULL;
450 return NULL != pslot->
player;
503 }
else if (NULL != pslot->
player) {
509 pplayer =
fc_calloc(1,
sizeof(*pplayer));
510 pplayer->
slot = pslot;
519 *diplstate_slot = NULL;
526 if (aplayer != pplayer) {
558 pplayer->
team = NULL;
575 if (aplayer != pplayer) {
582 pplayer->
cities = city_list_new();
583 pplayer->
units = unit_list_new();
613 for (i = 0; i <
B_LAST; i++) {
642 if (pplayer->
rgb != NULL) {
664 if (pplayer == NULL) {
692 pcargo->client.transported_by = -1;
719 owned->nationality =
owner;
726 if (pplayer->
nation != NULL) {
741 pplayer->
style = NULL;
753 pslot = pplayer->
slot;
760 unit_list_destroy(pplayer->
units);
762 city_list_destroy(pplayer->
cities);
771 if (aplayer != pplayer) {
777 if (pcity->original == pplayer) {
780 pcity->original = NULL;
854 if (pplayer->
nation != pnation) {
861 pnation->
player = pplayer;
863 pplayer->
nation = pnation;
891 return pplayer->
name;
959 const struct tile *ptile)
985 const struct tile *ptile)
997 && unit_list_size(ptile->
units) > 0) {
1027 const struct tile *ptile,
1028 bool is_transported)
1043 if (is_transported && !allied) {
1114 const struct city *pcity)
1130 const struct city *pcity)
1132 return (!pplayer || pplayer ==
city_owner(pcity));
1188 if (!pplayer || (
city_owner(pcity) == pplayer)) {
1226 const struct tile *ptile)
1234 && (pplayer == NULL ||
city_owner(pcity) == pplayer)
1250 enum tech_flag_id flag)
1269 income += pcity->surplus[
O_GOLD];
1279 case GOLD_UPKEEP_CITY:
1281 case GOLD_UPKEEP_NATION:
1285 case GOLD_UPKEEP_MIXED:
1293 income += pcity->shield_stock + pcity->surplus[
O_SHIELD];
1305 enum tech_flag_id flag)
1336 return Q_(
"?attitude:Genocidal");
1338 return Q_(
"?attitude:Belligerent");
1340 return Q_(
"?attitude:Hostile");
1342 return Q_(
"?attitude:Uncooperative");
1344 return Q_(
"?attitude:Uneasy");
1346 return Q_(
"?attitude:Neutral");
1348 return Q_(
"?attitude:Respectful");
1350 return Q_(
"?attitude:Helpful");
1352 return Q_(
"?attitude:Enthusiastic");
1354 return Q_(
"?attitude:Admiring");
1357 return Q_(
"?attitude:Worshipful");
1365 const struct player *pplayer2)
1367 enum diplstate_type ds;
1369 if (pplayer == pplayer2) {
1375 return ds == DS_WAR || ds == DS_NO_CONTACT;
1382 const struct player *pplayer2)
1384 enum diplstate_type ds;
1386 if (!pplayer || !pplayer2) {
1390 if (pplayer == pplayer2) {
1396 return (ds == DS_ALLIANCE || ds == DS_TEAM);
1403 const struct player *pplayer2)
1407 if (pplayer == pplayer2) {
1411 return (ds == DS_PEACE || ds == DS_ALLIANCE
1412 || ds == DS_ARMISTICE || ds == DS_TEAM);
1419 const struct player *pplayer2)
1421 if (pplayer1 == pplayer2 || !pplayer1 || !pplayer2) {
1436 const struct player *pplayer2)
1438 enum diplstate_type ds;
1440 if (pplayer == pplayer2) {
1446 return (ds == DS_PEACE || ds == DS_CEASEFIRE || ds == DS_ARMISTICE);
1453 const struct player *pplayer2)
1455 return pplayer1->
team == pplayer2->
team;
1481 const struct player *player2,
1488 if (player1 == player2 && diplrel != DRO_FOREIGN) {
1492 if (diplrel < DS_LAST) {
1497 case DRO_GIVES_SHARED_VISION:
1499 case DRO_RECEIVES_SHARED_VISION:
1501 case DRO_HOSTS_EMBASSY:
1503 case DRO_HAS_EMBASSY:
1505 case DRO_HOSTS_REAL_EMBASSY:
1507 case DRO_HAS_REAL_EMBASSY:
1509 case DRO_HAS_CASUS_BELLI:
1511 case DRO_PROVIDED_CASUS_BELLI:
1514 return player1 != player2;
1531 if (oplayer == pplayer) {
1550 if (diplrel != diplrel_other_invalid()) {
1569 if (diplrel != diplstate_type_invalid()) {
1573 return diplrel_other_invalid();
1581 if (value < DS_LAST) {
1582 return diplstate_type_name(value);
1584 return diplrel_other_name(value);
1593 if (value < DS_LAST) {
1594 return diplstate_type_translated_name(value);
1596 return _(diplrel_other_name(value));
1606 const struct player *tgt_plr,
1607 const enum effect_type outcome,
1608 const struct action *paction,
1609 const struct tile *tgt_tile)
1611 int casus_belli_amount;
1615 casus_belli_amount =
1630 return CBR_INTERNATIONAL_OUTRAGE;
1636 return CBR_VICTIM_ONLY;
1644#define DIPLREL_MESS_SIZE (3 + (DRO_LAST * (5 + 4 + 3 + 2 + 1)))
1657 const enum req_range legal_ranges[] = {
1672 *
sizeof(bv_diplrel_all_reqs));
1727 for (rel = 0; rel < DRO_LAST; rel++) {
1731 for (i = 0; i < 5; i++) {
1732 for (j = i; j < 5; j++) {
1789 int diplrel_req_num;
1790 bv_diplrel_all_reqs *mess;
1791 bv_diplrel_all_reqs known;
1801 || req->
source.
kind == VUT_DIPLREL_UNITANY_O)) {
1807 || req->
source.
kind == VUT_DIPLREL_UNITANY_O);
1822 if (
BV_ISSET(mess[set], diplrel_req_num)) {
1832 BV_CLR(known, diplrel_req_num);
1843 const struct player *pplayer2)
1845 int in_territory = 0;
1864 return in_territory;
1874 return (strlen(
name) > 0
1885 if (
level == AI_LEVEL_AWAY) {
1898 return AI_LEVEL_COUNT - 1;
int ai_type_number(const struct ai_type *ai)
void dbv_free(struct dbv *pdbv)
#define BV_SET_ALL_FROM(vec_to, vec_from)
#define BV_ISSET(bv, bit)
bool city_production_has_flag(const struct city *pcity, enum impr_flag_id flag)
int city_map_radius_sq_get(const struct city *pcity)
int city_total_unit_gold_upkeep(const struct city *pcity)
int city_total_impr_gold_upkeep(const struct city *pcity)
#define city_list_iterate(citylist, pcity)
#define city_tile(_pcity_)
#define CITY_MAP_MAX_RADIUS_SQ
#define city_owner(_pcity_)
#define city_list_iterate_end
#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile)
#define city_tile_iterate_end
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit * punit
struct unit struct city * target_city
int get_target_bonus_effects(struct effect_list *plist, const struct req_context *context, const struct player *other_player, enum effect_type effect_type)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
const struct functions * fc_funcs
static bool is_server(void)
#define CASUS_BELLI_OUTRAGE
#define MAX_NUM_PLAYER_SLOTS
#define CASUS_BELLI_VICTIM
void game_remove_unit(struct world *gworld, struct unit *punit)
void game_remove_city(struct world *gworld, struct city *pcity)
struct city * idex_lookup_city(struct world *iworld, int id)
struct unit * idex_lookup_unit(struct world *iworld, int id)
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define log_error(message,...)
int sq_map_distance(const struct tile *tile0, const struct tile *tile1)
#define fc_calloc(n, esz)
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
#define NO_NATION_SELECTED
bool is_settable_ai_level(enum ai_level level)
bool are_diplstates_equal(const struct player_diplstate *pds1, const struct player_diplstate *pds2)
bool player_can_invade_tile(const struct player *pplayer, const struct tile *ptile)
bool player_knows_techs_with_flag(const struct player *pplayer, enum tech_flag_id flag)
int player_multiplier_effect_value(const struct player *pplayer, const struct multiplier *pmul)
void * player_ai_data(const struct player *pplayer, const struct ai_type *ai)
bool player_slot_is_used(const struct player_slot *pslot)
bv_diplrel_all_reqs diplrel_req_contradicts(const struct requirement *req)
static bv_diplrel_all_reqs * diplrel_mess_get(void)
int num_known_tech_with_flag(const struct player *pplayer, enum tech_flag_id flag)
bool is_valid_username(const char *name)
static void player_diplstate_new(const struct player *plr1, const struct player *plr2)
int player_multiplier_target_value(const struct player *pplayer, const struct multiplier *pmul)
struct unit * player_unit_by_number(const struct player *pplayer, int unit_id)
static bv_diplrel_all_reqs * diplrel_mess
struct player * player_by_name_prefix(const char *name, enum m_pre_result *result)
int diplrel_by_rule_name(const char *value)
struct player * player_new(struct player_slot *pslot)
struct player * player_by_number(const int player_id)
bool player_in_city_map(const struct player *pplayer, const struct tile *ptile)
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
static bv_diplrel_all_reqs * diplrel_mess_gen(void)
bool can_player_see_unit_at(const struct player *pplayer, const struct unit *punit, const struct tile *ptile, bool is_transported)
enum diplstate_type cancel_pact_result(enum diplstate_type oldstate)
int player_slot_count(void)
struct player_slot * player_slot_by_number(int player_id)
int player_multiplier_value(const struct player *pplayer, const struct multiplier *pmul)
int player_get_expected_income(const struct player *pplayer)
int player_number(const struct player *pplayer)
enum dipl_reason pplayer_can_make_treaty(const struct player *p1, const struct player *p2, enum diplstate_type treaty)
const char * player_name(const struct player *pplayer)
static void player_diplstate_defaults(const struct player *plr1, const struct player *plr2)
void player_slots_free(void)
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
int player_slot_max_used_number(void)
static bool is_valid_alliance(const struct player *p1, const struct player *p2)
bool can_player_see_unit(const struct player *pplayer, const struct unit *punit)
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
void player_set_ai_data(struct player *pplayer, const struct ai_type *ai, void *data)
static void player_diplstate_destroy(const struct player *plr1, const struct player *plr2)
void player_ruleset_close(struct player *pplayer)
void player_clear(struct player *pplayer, bool full)
int player_slot_index(const struct player_slot *pslot)
struct player * player_by_name(const char *name)
void player_slots_init(void)
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
bool team_has_embassy(const struct team *pteam, const struct player *tgt_player)
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
struct city * player_city_by_number(const struct player *pplayer, int city_id)
struct city * player_primary_capital(const struct player *pplayer)
int player_index(const struct player *pplayer)
int player_in_territory(const struct player *pplayer, const struct player *pplayer2)
struct player * player_by_user(const char *name)
const char * diplrel_name_translation(int value)
bool is_diplrel_between(const struct player *player1, const struct player *player2, int diplrel)
static struct @68 player_slots
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
#define DIPLREL_MESS_SIZE
bool player_can_see_city_externals(const struct player *pow_player, const struct city *target_city)
int player_age(const struct player *pplayer)
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
int number_of_ai_levels(void)
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
static void player_defaults(struct player *pplayer)
bool can_player_see_hypotetic_units_at(const struct player *pplayer, const struct tile *ptile)
struct player_slot * slots
bool player_has_embassy_from_effect(const struct player *pplayer, const struct player *pplayer2)
void diplrel_mess_close(void)
bool players_non_invade(const struct player *pplayer1, const struct player *pplayer2)
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
bool can_player_see_units_in_city(const struct player *pplayer, const struct city *pcity)
struct player * player_slot_get_player(const struct player_slot *pslot)
static const char * player_name_by_number(int i)
bool can_player_see_city_internals(const struct player *pplayer, const struct city *pcity)
struct player_slot * player_slot_next(struct player_slot *pslot)
bool player_can_trust_tile_has_no_units(const struct player *pplayer, const struct tile *ptile)
bool player_slots_initialised(void)
const char * love_text(const int love)
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
enum casus_belli_range casus_belli_range_for(const struct player *offender, const struct unit_type *off_ut, const struct player *tgt_plr, const enum effect_type outcome, const struct action *paction, const struct tile *tgt_tile)
const char * diplrel_rule_name(int value)
bool gives_shared_vision(const struct player *me, const struct player *them)
bool player_owns_city(const struct player *pplayer, const struct city *pcity)
struct player_slot * player_slot_first(void)
void player_destroy(struct player *pplayer)
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
#define players_iterate_end
@ DIPL_ALLIANCE_PROBLEM_THEM
@ DIPL_ALLIANCE_PROBLEM_US
#define players_iterate(_pplayer)
#define player_list_iterate(playerlist, pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define player_list_iterate_end
#define PLAYER_DEFAULT_SCIENCE_RATE
#define set_as_human(plr)
#define players_iterate_alive_end
#define player_slots_iterate_end
#define PLAYER_DEFAULT_TAX_RATE
#define PLAYER_DEFAULT_LUXURY_RATE
#define players_iterate_alive(_pplayer)
#define requirement_diplrel_ereq(_id_, _range_, _present_)
struct research * research_get(const struct player *pplayer)
void rgbcolor_destroy(struct rgbcolor *prgbcolor)
struct rgbcolor * rgbcolor_copy(const struct rgbcolor *prgbcolor)
struct setting_list * level[OLEVELS_NUM]
enum m_pre_result match_prefix(m_pre_accessor_fn_t accessor_fn, size_t n_names, size_t max_len_name, m_pre_strncmp_fn_t cmp_fn, m_strlen_fn_t len_fn, const char *prefix, int *ind_result)
bool is_ascii_name(const char *name)
void spaceship_init(struct player_spaceship *ship)
enum capital_type capital
struct packet_game_info info
bool(* player_tile_vision_get)(const struct tile *ptile, const struct player *pplayer, enum vision_layer vision)
void(* destroy_city)(struct city *pcity)
enum gold_upkeep_style gold_upkeep_style
enum ai_level skill_level
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
enum diplstate_type max_state
char has_reason_to_cancel
struct city_list * cities
struct player_ai ai_common
struct dbv tile_vision[V_COUNT]
const struct player_diplstate ** diplstates
struct government * target_government
char username[MAX_LEN_NAME]
struct player::@69::@72 client
void * ais[FREECIV_AI_MOD_LAST]
struct government * government
struct connection * current_conn
char * savegame_ai_type_name
const struct ai_type * ai
char ranked_username[MAX_LEN_NAME]
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct attribute_block_s attribute_block
bv_player gives_shared_vision
struct attribute_block_s attribute_block_buffer
struct multiplier_value multipliers[MAX_NUM_MULTIPLIERS]
struct nation_type * nation
struct nation_style * style
struct player_slot * slot
struct player::@69::@71 server
int num_known_tech_with_flag[TF_COUNT]
struct player * extras_owner
struct unit_class::@85 cache
struct extra_type_list * hiding_extras
struct unit_list * transporting
struct unit::@80::@82 client
int fc_strcasecmp(const char *str0, const char *str1)
int fc_strncasequotecmp(const char *str0, const char *str1, size_t n)
size_t effectivestrlenquote(const char *str)
#define sz_strlcpy(dest, src)
const struct player_list * team_members(const struct team *pteam)
void team_remove_player(struct player *pplayer)
bool tile_is_seen(const struct tile *target_tile, const struct player *pow_player)
enum known_type tile_get_known(const struct tile *ptile, const struct player *pplayer)
struct city * tile_city(const struct tile *ptile)
#define tile_has_extra(ptile, pextra)
#define tile_owner(_tile)
#define trade_partners_iterate_end
#define trade_partners_iterate(c, p)
bool is_hiding_unit(const struct unit *punit)
struct player * unit_nationality(const struct unit *punit)
bool unit_transport_unload(struct unit *pcargo)
bool unit_transported(const struct unit *pcargo)
struct unit_list * unit_transport_cargo(const struct unit *ptrans)
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
struct unit_class * unit_class_get(const struct unit *punit)
#define vision_layer_iterate(v)
#define vision_layer_iterate_end