39 const struct player *plr2);
42 const struct player *plr2);
45 const struct player *plr2);
65 *player_intel_slot =
nullptr;
75 if (aplayer != pplayer) {
115 if (aplayer != pplayer) {
182 if (check_pl == pplayer || check_pl == aplayer
228 "No target city for spy action");
230 if (punit->goto_tile !=
nullptr) {
233 if (pcity !=
nullptr) {
252 if (aplayer == pplayer) {
313 #if defined(FREECIV_DEBUG) || IS_DEVEL_VERSION
317 if (caller_closes !=
nullptr) {
318 *caller_closes =
false;
331 log_debug(
"%s ai data phase closed when dai_plr_data_get() called",
334 if (caller_closes !=
nullptr) {
335 *caller_closes =
true;
343 *caller_closes =
true;
354 const struct player *plr2)
368 *player_intel_slot = player_intel;
375 const struct player *plr1,
376 const struct player *plr2)
398 const struct player *plr1,
399 const struct player *plr2)
410 return const_cast<struct
ai_dip_intel *
>(*player_intel_slot);
417 const struct player *plr1,
418 const struct player *plr2)
427 if (*player_intel_slot !=
nullptr) {
431 *player_intel_slot =
nullptr;
439 bool needs_back_rearrange =
false;
450 bool better_found =
false;
459 if (mp_val > ppol->start) {
462 pplayer->
multipliers[pidx] =
MAX(mp_val - ppol->step, ppol->start);
476 if (new_value > orig_value) {
480 needs_back_rearrange =
false;
486 if (!better_found && mp_val < ppol->stop) {
489 pplayer->
multipliers[pidx] =
MIN(mp_val + ppol->step, ppol->stop);
503 if (new_value > orig_value) {
507 needs_back_rearrange =
false;
515 needs_back_rearrange =
true;
521 if (needs_back_rearrange) {
538 int revolution_turns;
540 .kind = VUT_GOVERNMENT};
547 if (city_list_size(pplayer->
cities) == 0) {
579 if (VUT_GOVERNMENT == preq->source.kind
580 && preq->source.value.govern == gov) {
581 present = preq->present;
584 if (!
is_req_active(pplayer,
nullptr, pcity,
nullptr,
nullptr,
585 nullptr,
nullptr,
nullptr,
nullptr,
nullptr, preq,
597 peffect, 1, nplayers);
612 if (revolution_turns > 0) {
613 bonus -= int(6 / revolution_turns);
616 *val += (*val * bonus) / 100;
622 if (VUT_ADVANCE == preq->source.kind) {
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
void adv_data_phase_done(struct player *pplayer)
Clean up our mess.
bool aia_utype_is_considered_spy_vs_city(const struct unit_type *putype)
Returns TRUE if the specified unit type is able to perform diplomatic actions against cities.
bool is_ai_data_phase_open(struct ai_type *ait, struct player *pplayer)
Return whether data phase is currently open.
void dai_gov_value(struct ai_type *ait, struct player *pplayer, struct government *gov, adv_want *val, bool *override)
Set value of the government.
struct ai_dip_intel * dai_diplomacy_get(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
static void dai_diplomacy_destroy(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Free resources allocated for diplomacy information between two players.
void dai_adjust_policies(struct ai_type *ait, struct player *pplayer)
Adjust multiplier values.
static void dai_diplomacy_new(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Allocate new ai diplomacy slot.
void dai_data_init(struct ai_type *ait, struct player *pplayer)
Initialize ai data structure.
void dai_data_phase_begin(struct ai_type *ait, struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
static void dai_diplomacy_defaults(struct ai_type *ait, const struct player *plr1, const struct player *plr2)
Set diplomacy data between two players to its default values.
void dai_data_phase_finished(struct ai_type *ait, struct player *pplayer)
Clean up ai data after phase finished.
struct ai_plr * dai_plr_data_get(struct ai_type *ait, struct player *pplayer, bool *caller_closes)
Get current default ai data related to player.
void dai_data_close(struct ai_type *ait, struct player *pplayer)
Deinitialize ai data structure.
void aiferry_init_stats(struct ai_type *ait, struct player *pplayer)
Call to initialize the ferryboat statistics.
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
static struct unit_ai * def_ai_unit_data(const struct unit *punit, struct ai_type *deftype)
void dai_auto_settler_init(struct ai_plr *ai)
Initialize ai settler engine.
void dai_auto_settler_free(struct ai_plr *ai)
Deinitialize ai settler engine.
bool is_capital(const struct city *pcity)
Return TRUE iff this city is its nation's capital.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
void auto_arrange_workers(struct city *pcity)
Call sync_cities() to send the affected cities to the clients.
adv_want dai_city_want(struct player *pplayer, struct city *acity, struct adv_data *adv, struct impr_type *pimprove)
Calculates city want from some input values.
void dai_diplomacy_begin_new_phase(struct ai_type *ait, struct player *pplayer)
Calculate our diplomatic predispositions here.
adv_want dai_effect_value(struct player *pplayer, struct government *gov, const struct adv_data *adv, const struct city *pcity, const bool capital, int turns, const struct effect *peffect, const int c, const int nplayers)
How desirable is a particular effect for a particular city, given the number of cities in range (c).
struct effect_list * get_req_source_effects(struct universal *psource)
Get a list of effects with this requirement source.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define effect_list_iterate_end
#define effect_list_iterate(effect_list, peffect)
#define MAX_NUM_PLAYER_SLOTS
#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,...)
bool multiplier_can_be_changed(struct multiplier *pmul, struct player *pplayer)
Can player change multiplier value.
Multiplier_type_id multiplier_index(const struct multiplier *pmul)
Returns multiplier index.
#define multipliers_iterate(_mul_)
#define multipliers_iterate_end
int player_multiplier_value(const struct player *pplayer, const struct multiplier *pmul)
Return the multiplier value currently in effect for pplayer (in display units).
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
int player_index(const struct player *pplayer)
Return the player index.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
#define players_iterate_end
#define players_iterate(_pplayer)
static bool is_barbarian(const struct player *pplayer)
#define player_slots_iterate(_pslot)
#define players_iterate_alive_end
#define player_slots_iterate_end
#define players_iterate_alive(_pplayer)
void check_player_max_rates(struct player *pplayer)
The following checks that government rates are acceptable for the present form of government.
int normal_player_count()
Return the number of non-barbarian players.
bool is_req_active(const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel)
Checks the requirement to see if it is active on the given target.
#define requirement_vector_iterate_end
#define requirement_vector_iterate(req_vec, preq)
int research_goal_unknown_techs(const struct research *presearch, Tech_type_id goal)
Returns the number of technologies the player need to research to get the goal technology.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
struct player * at_war_with_ally
signed char asked_about_alliance
enum war_reason war_reason
signed char asked_about_peace
struct player * is_allied_with_ally
signed char warned_about_space
signed char ally_patience
struct player * is_allied_with_enemy
signed char asked_about_ceasefire
struct ai_plr::@156 diplomacy
struct ai_settler * settler
int req_love_for_alliance
QSet< int > diplomat_reservations
const struct ai_dip_intel ** player_intel_slots
struct ai_plr::@155 stats
enum winning_strategy strategy
struct requirement_vector reqs
struct city_list * cities
struct government * government
int multipliers[MAX_NUM_MULTIPLIERS]
int multipliers_target[MAX_NUM_MULTIPLIERS]
struct tile * prev_struct
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
#define is_ocean_tile(ptile)
struct city * tile_city(const struct tile *ptile)
Return the city on this tile (or nullptr), checking for city center.
#define tile_continent(_tile)
struct government * govern
#define unit_list_iterate(unitlist, punit)
#define unit_list_iterate_end
const struct unit_type * unit_type_get(const struct unit *punit)
Return the unit type for this unit.
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.