49 const struct player *plr2);
51 const struct player *plr2);
53 const struct player *plr2);
68 memset(count, 0,
sizeof(count));
73 .kind = VUT_IMPROVEMENT};
80 switch (peffect->type) {
83 case EFT_FORCE_CONTENT:
84 case EFT_FORCE_CONTENT_PCT:
85 case EFT_MAKE_CONTENT:
86 case EFT_MAKE_CONTENT_MIL:
87 case EFT_MAKE_CONTENT_MIL_PER:
88 case EFT_MAKE_CONTENT_PCT:
91 case EFT_CAPITAL_CITY:
92 case EFT_POLLU_POP_PCT:
93 case EFT_POLLU_POP_PCT_2:
94 case EFT_POLLU_PROD_PCT:
95 case EFT_OUTPUT_BONUS:
96 case EFT_OUTPUT_BONUS_2:
97 case EFT_OUTPUT_WASTE_PCT:
101 if (VUT_IMPROVEMENT == preq->source.kind
102 && preq->source.value.building == pimprove) {
115 case EFT_OUTPUT_ADD_TILE:
116 case EFT_OUTPUT_PER_TILE:
117 case EFT_OUTPUT_INC_TILE:
120 if (VUT_IMPROVEMENT == preq->source.kind
121 && preq->source.value.building == pimprove) {
148 struct research *presearch, *aresearch;
151 if (players_needed == 0) {
161 game.
info.tech_parasite_allow_holes)
170 if (aplayer == pplayer) {
178 if (players_having >= players_needed) {
219 adv->stats.units.coast_strict++;
222 adv->stats.units.suicide_attackers++;
225 adv->stats.units.paratroopers++;
228 adv->stats.units.airliftable++;
231 adv->stats.units.upgradeable++;
253 bool danger_of_nukes;
276 danger_of_nukes =
false;
312 adv->threats.igwall =
true;
320 adv->threats.invasions =
true;
328 adv->threats.invasions =
true;
341 adv->threats.ocean[-continent] =
true;
348 adv->threats.ocean[-continent] =
true;
360 adv->threats.suicide_attack =
true;
367 danger_of_nukes =
true;
385 adv->threats.nuclear = 1;
394 if (danger_of_nukes) {
395 adv->threats.nuclear++;
400 adv->explore.land_done =
true;
401 adv->explore.sea_done =
true;
402 adv->explore.continent =
new bool[
adv->num_continents + 1]();
403 adv->explore.ocean =
new bool[
adv->num_oceans + 1]();
413 adv->explore.sea_done =
false;
414 adv->explore.ocean[-continent] =
true;
426 adv->explore.land_done =
false;
427 adv->explore.continent[continent] =
true;
432 adv->explore.land_done =
false;
433 adv->explore.continent[continent] =
true;
440 adv->stats.cities =
new int[
adv->num_continents + 1]();
441 adv->stats.ocean_cities =
new int[
adv->num_oceans + 1]();
442 adv->stats.average_production = 0;
447 if (continent >= 0) {
448 adv->stats.cities[continent]++;
450 adv->stats.ocean_cities[-continent]++;
452 adv->stats.average_production += pcity->surplus[
O_SHIELD];
455 adv->stats.average_production /=
MAX(1, city_list_size(pplayer->
cities));
522 bool found_human =
false;
526 if (aplayer == pplayer ||
is_ai(aplayer)) {
634 #if defined(FREECIV_DEBUG) || defined(IS_DEVEL_VERSION)
638 if (caller_closes !=
nullptr) {
639 *caller_closes =
false;
663 log_debug(
"%s advisor data phase closed when adv_data_get() called",
666 if (caller_closes !=
nullptr) {
667 *caller_closes =
true;
675 *caller_closes =
true;
689 if (pplayer->
server.adv ==
nullptr) {
692 adv = pplayer->
server.adv;
708 if (aplayer != pplayer) {
752 if (aplayer != pplayer) {
762 pplayer->
server.adv =
nullptr;
769 const struct player *plr2)
781 const struct player *plr2)
786 if (*dip_slot !=
nullptr) {
796 const struct player *plr2)
836 bool override =
false;
851 int revolution_turns;
884 switch (paction->
result) {
886 case ACTRES_SPY_INCITE_CITY:
887 case ACTRES_CONQUER_CITY:
890 case ACTRES_SPY_BRIBE_UNIT:
893 case ACTRES_TRANSFORM_TERRAIN:
896 case ACTRES_CULTIVATE:
903 case ACTRES_SPY_INVESTIGATE_CITY:
904 case ACTRES_SPY_POISON:
905 case ACTRES_SPY_SPREAD_PLAGUE:
906 case ACTRES_SPY_STEAL_GOLD:
907 case ACTRES_SPY_SABOTAGE_CITY:
908 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
909 case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
910 case ACTRES_SPY_STEAL_TECH:
911 case ACTRES_SPY_TARGETED_STEAL_TECH:
912 case ACTRES_SPY_SABOTAGE_UNIT:
913 case ACTRES_CAPTURE_UNITS:
914 case ACTRES_STEAL_MAPS:
916 case ACTRES_SPY_NUKE:
918 case ACTRES_NUKE_CITY:
919 case ACTRES_NUKE_UNITS:
920 case ACTRES_DESTROY_CITY:
921 case ACTRES_EXPEL_UNIT:
922 case ACTRES_STRIKE_BUILDING:
923 case ACTRES_STRIKE_PRODUCTION:
924 case ACTRES_SPY_ATTACK:
930 case ACTRES_MARKETPLACE:
931 case ACTRES_FOUND_CITY:
932 case ACTRES_DISBAND_UNIT:
933 case ACTRES_PARADROP:
944 case ACTRES_ESTABLISH_EMBASSY:
945 case ACTRES_TRADE_ROUTE:
946 case ACTRES_JOIN_CITY:
947 case ACTRES_HELP_WONDER:
948 case ACTRES_RECYCLE_UNIT:
949 case ACTRES_HOME_CITY:
950 case ACTRES_UPGRADE_UNIT:
952 case ACTRES_HEAL_UNIT:
957 case ACTRES_IRRIGATE:
958 case ACTRES_CLEAN_POLLUTION:
959 case ACTRES_CLEAN_FALLOUT:
960 case ACTRES_TRANSPORT_ALIGHT:
961 case ACTRES_TRANSPORT_UNLOAD:
962 case ACTRES_TRANSPORT_DISEMBARK:
963 case ACTRES_TRANSPORT_BOARD:
964 case ACTRES_TRANSPORT_EMBARK:
982 if (revolution_turns > 0) {
983 bonus -= int(6 / revolution_turns);
986 val += (val * bonus) / 100;
992 if (VUT_ADVANCE == preq->source.kind) {
1035 if (VUT_ADVANCE == preq->source.kind) {
1065 enum diplstate_type ds;
1068 if (
is_ai(pplayer)) {
1082 if (pplayer == aplayer) {
1089 if (ds == DS_WAR || ds == DS_CEASEFIRE) {
void action_list_end(action_id *act_list, int size)
Terminate an action list of the specified size.
bool action_immune_government(struct government *gov, action_id act)
Will a player with the government gov be immune to the action act?
void action_list_add_all_by_result(action_id *act_list, int *position, enum action_result result)
Add all actions with the specified result to the specified action list starting at the specified posi...
struct action * action_by_number(action_id act_id)
Return the action with the given id.
#define action_list_iterate_end
#define action_list_iterate(_act_list_, _act_id_)
#define action_id_get_role(act_id)
#define action_iterate_end
#define action_iterate(_act_)
#define POLLUTION_WEIGHTING
int adv_eval_calc_city(struct city *pcity, struct adv_data *adv)
This calculates the usefulness of pcity to us.
static void adv_data_city_impr_calc(struct player *pplayer, struct adv_data *adv)
Precalculates some important data about the improvements in the game that we use later in ai/aicity....
void adv_data_analyze_rulesets(struct player *pplayer)
Analyze rulesets.
void adv_data_close(struct player *pplayer)
Free memory for advisor data.
void adv_data_init(struct player *pplayer)
Allocate memory for advisor data.
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
static void adv_dipl_free(const struct player *plr1, const struct player *plr2)
Free resources allocated for diplomacy information between two players.
bool adv_wants_science(struct player *pplayer)
Return whether science would help us at all.
bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
Make and cache lots of calculations needed for other functions.
void adv_data_phase_done(struct player *pplayer)
Clean up our mess.
bool adv_is_player_dangerous(struct player *pplayer, struct player *aplayer)
There are some signs that a player might be dangerous: We are at war with him, he has done lots of ig...
static void adv_dipl_new(const struct player *plr1, const struct player *plr2)
Allocate new advisor diplomacy slot.
static void count_my_units(struct player *pplayer)
This function is called each turn to initialize pplayer->ai.stats.units.
static struct adv_dipl * adv_dipl_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
static bool player_has_really_useful_tech_parasite(struct player *pplayer)
Check if the player still takes advantage of EFT_TECH_PARASITE.
void adv_best_government(struct player *pplayer)
Find best government to aim for.
void adv_data_default(struct player *pplayer)
Initialize with sane values.
@ ADV_IMPR_CALCULATE_FULL
#define CALL_PLR_AI_FUNC(_func, _player,...)
struct player * player_leading_spacerace()
Find who is leading the space race.
#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.
static void nuke_units(QVariant data1, QVariant data2)
Action "Nuke Units" for choice dialog.
static void nuke(QVariant data1, QVariant data2)
Action "Explode Nuclear" for choice dialog.
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
signed short Continent_id
struct government * government_of_player(const struct player *pplayer)
Return the government of a player.
Government_type_id government_count()
Return the number of governments.
std::vector< government > governments
bool can_change_to_government(struct player *pplayer, const struct government *gov)
Can change to government if appropriate tech exists, and one of:
Government_type_id government_index(const struct government *pgovern)
Return the government index.
bool has_handicap(const struct player *pplayer, enum handicap_type htype)
AI players may have handicaps - allowing them to cheat or preventing them from using certain algorith...
Impr_type_id improvement_index(const struct impr_type *pimprove)
Return the improvement index.
#define improvement_iterate_end
#define improvement_iterate(_p)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_debug(message,...)
#define adjc_iterate(nmap, center_tile, itr_tile)
#define whole_map_iterate(_map, _tile)
#define whole_map_iterate_end
bool map_is_known(const struct tile *ptile, const struct player *pplayer)
Return whether the player knows the tile.
bool can_unit_type_transport(const struct unit_type *transporter, const struct unit_class *transported)
Return TRUE iff transporter type has ability to transport transported class.
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)
#define player_slots_iterate(_pslot)
#define players_iterate_alive_end
#define player_slots_iterate_end
static bool player_is_cpuhog(const struct player *pplayer)
#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.
#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.
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
Returns state of the tech for current research.
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
Returns TRUE iff the given tech can be given to the players sharing the research immediately.
#define CLIP(lower, current, upper)
#define TIMING_LOG(timer, activity)
enum action_result result
struct adv_data::@85 threats
struct government * revolution
struct adv_dipl ** adv_dipl_slots
struct adv_data::@87 stats
struct player * production_leader
struct adv_data::@89 goal
struct adv_data::@88 dipl
struct adv_data::@89::@91 govt
struct adv_data::@87::@90 units
enum adv_improvement_status impr_calc[B_LAST]
bool phase_is_initialized
std::vector< adv_want > government_want
enum req_range impr_range[B_LAST]
struct adv_data::@86 explore
struct player * spacerace_leader
struct packet_game_info info
struct government * government_during_revolution
int love[MAX_NUM_PLAYER_SLOTS]
struct city_list * cities
struct player_ai ai_common
struct player::@65::@67 server
struct government * government
const struct ai_type * ai
struct player_score score
struct unit_class::@80 adv
struct unit_type::@82 adv
bool is_future_tech(Tech_type_id tech)
Is the given tech a future tech.
Tech_type_id advance_number(const struct advance *padvance)
Return the advance index.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
#define is_ocean_tile(ptile)
#define tile_continent(_tile)
const struct impr_type * building
bool unit_can_do_action(const struct unit *punit, const action_id act_id)
Return TRUE iff this unit can do the specified generalized (ruleset defined) action enabler controlle...
int get_transporter_capacity(const struct unit *punit)
Return the number of units the transporter can hold (or 0).
#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.
const struct unit_type * can_upgrade_unittype(const struct player *pplayer, const struct unit_type *punittype)
Return whether this player can upgrade this unit type (to any other unit type).
int num_role_units(int role)
How many unit types have specified role/flag.
struct unit_class * unit_class_get(const struct unit *punit)
Returns unit class pointer for a unit.
bool can_player_build_unit_direct(const struct player *p, const struct unit_type *punittype)
Whether player can build given unit somewhere, ignoring whether unit is obsolete and assuming the pla...
bool unit_has_type_flag(const struct unit *punit, enum unit_type_flag_id flag)
Return whether the unit has the given flag.
struct unit_type * get_role_unit(int role, int role_index)
Return index-th unit with specified role/flag.
bool utype_can_do_action(const struct unit_type *putype, const action_id act_id)
Return TRUE iff units of the given type can do the specified generalized (ruleset defined) action ena...
static bool uclass_has_flag(const struct unit_class *punitclass, enum unit_class_flag_id flag)
#define unit_class_iterate(_p)
#define uclass_index(_c_)
#define unit_class_iterate_end