59 #define LOG_DIPL2 LOG_DEBUG
63 #define BIG_NUMBER 100000
69 #define TURNS_BEFORE_TARGET 15
73 const struct player *violator,
74 const struct player *victim,
75 enum casus_belli_range scope,
int how_bad);
77 const struct player *violator,
78 const struct player *victim);
80 const struct player *violator,
81 const struct player *victim);
83 const struct player *violator,
84 const struct player *victim);
97 struct packet_chat_msg packet;
104 lsend_packet_chat_msg(dest, &packet);
116 if (missing_love > 0) {
129 static enum diplstate_type
133 case CLAUSE_ALLIANCE:
137 case CLAUSE_CEASEFIRE:
140 qCritical(
"Invalid diplomatic clause %d.", type);
151 int bulbs, tech_want, worth;
156 if (TECH_KNOWN == state
158 game.
info.tech_trade_allow_holes)) {
164 if (TECH_PREREQS_KNOWN == state) {
182 if (eplayer == pplayer || eplayer == aplayer) {
188 if (ds != DS_NO_CONTACT && ds != DS_ALLIANCE) {
218 struct player *taker,
int tech_id,
225 *is_dangerous =
false;
243 if (eplayer == giver || eplayer == taker
252 *is_dangerous =
true;
269 static const struct player *
271 const struct player *them)
293 struct Clause *pclause,
bool verbose,
294 enum diplstate_type ds_after)
299 bool give = (pplayer == pclause->
from);
301 const struct player *penemy;
311 giver = pclause->
from;
313 switch (pclause->
type) {
327 if (
game.
info.tech_upkeep_style != TECH_UPKEEP_NONE) {
336 if (pplayer->
server.bulbs_last_turn < limit) {
341 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"%s clause worth %d",
345 case CLAUSE_ALLIANCE:
347 case CLAUSE_CEASEFIRE:
351 aplayer,
_(
"*%s (AI)* In away mode AI can't sign such a treaty."),
360 if (penemy && pclause->
type != CLAUSE_CEASEFIRE) {
362 aplayer,
_(
"*%s (AI)* First break alliance with %s, %s."),
371 _(
"*%s (AI)* I would like to see you keep your "
372 "distance from %s for some time, %s."),
381 if (pclause->
type == CLAUSE_PEACE) {
387 _(
"*%s (AI)* Let us first cease hostilities, %s."),
392 _(
"*%s (AI)* I wish to see you keep the current "
393 "ceasefire for a bit longer first, %s."),
402 }
else if (pclause->
type == CLAUSE_ALLIANCE) {
416 _(
"*%s (AI)* I simply do not trust you with an "
417 "alliance yet, %s."),
421 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"ally clause worth %d",
436 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
437 "ceasefire worth=%d love=%d "
451 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"treaty clause worth %d",
457 worth -= pclause->
value;
464 if (!give || ds_after == DS_ALLIANCE) {
471 worth -= 15 * city_list_size(aplayer->
cities);
479 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"seamap clause worth %d",
484 if (!give || ds_after == DS_ALLIANCE) {
490 worth -= 40 *
MAX(city_list_size(pplayer->
cities), 1);
503 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"landmap clause worth %d",
514 _(
"*%s (AI)* I do not know the city you mention."),
518 "city destroyed during negotiations");
534 if (offer !=
nullptr) {
543 if (ds_after == DS_ALLIANCE) {
546 _(
"*%s (AI)* Sorry, sharing vision with you "
564 if (ds_after == DS_ALLIANCE) {
566 }
else if (ds_after == DS_PEACE) {
573 }
else if (
game.
info.tech_leakage == TECH_LEAKAGE_EMBASSIES) {
574 worth =
game.
info.tech_leak_pct / 10;
578 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"embassy clause worth %d",
601 int total_balance = 0;
602 bool only_gifts =
true;
603 enum diplstate_type ds_after =
605 int given_cities = 0;
612 if (pclause->type == CLAUSE_CITY && pclause->from == pplayer) {
626 if (pclause->type != CLAUSE_GOLD && pclause->type != CLAUSE_MAP
627 && pclause->type != CLAUSE_SEAMAP && pclause->type != CLAUSE_VISION
628 && (pclause->type != CLAUSE_ADVANCE
629 ||
game.
info.tech_cost_style != TECH_COST_CIV1CIV2
645 if (ds_after == DS_WAR && !only_gifts) {
647 "no peace offered, must refuse");
652 && city_list_size(pplayer->
cities) - given_cities <= 2) {
659 if (total_balance >= 0) {
666 if (pplayer != ptreaty->
plr0) {
668 aplayer,
_(
"*%s (AI)* This deal was not very good for us, %s!"),
685 switch (pclause->
type) {
686 case CLAUSE_ALLIANCE:
692 _(
"*%s (AI)* Yes, may we forever stand united, %s."),
695 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"become allies");
700 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"sign peace treaty");
702 case CLAUSE_CEASEFIRE:
704 _(
"*%s (AI)* Agreed. No more hostilities, %s."),
706 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"sign ceasefire");
725 int total_balance = 0;
727 enum diplstate_type ds_after =
748 total_balance += balance;
749 gift = (gift && (balance >= 0));
754 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
"countdown nullified");
763 if (total_balance > 0 && gift) {
764 int i = total_balance / ((city_list_size(pplayer->
cities) * 10) + 1);
789 int want = 0, fear = 0, distance = 0, settlers = 0,
cities = 0;
796 want += pcity->surplus[
O_SHIELD] * 8;
797 want += pcity->surplus[
O_TRADE] * 6;
846 if (VUT_UTYPE == pcity->production.kind
858 want -= abs(want) /
MAX(
cities - settlers, 1);
878 if (
adv->dipl.spacerace_leader == target) {
892 if (eplayer == pplayer) {
898 if (ds == DS_ARMISTICE) {
899 want -= abs(want) / 10;
900 }
else if (ds == DS_CEASEFIRE) {
901 want -= abs(want) / 7;
902 }
else if (ds == DS_PEACE) {
903 want -= abs(want) / 5;
904 }
else if (ds == DS_ALLIANCE) {
905 want -= abs(want) / 3;
929 return (want - fear);
939 enum clause_type what,
bool to_pplayer,
960 bool wants_ceasefire =
false;
970 wants_ceasefire =
true;
974 clause.
from = pplayer;
976 clause.
type = CLAUSE_CEASEFIRE;
981 wants_ceasefire =
true;
986 if (wants_ceasefire) {
988 _(
"*%s (AI)* Greetings %s! May we suggest a ceasefire "
989 "while we get to know each other better?"),
995 _(
"*%s (AI)* I found you %s! Now make it worth my "
996 "letting you live, or be crushed."),
1016 int best_desire = 0;
1017 struct player *best_target =
nullptr;
1025 memset(war_desire, 0,
sizeof(war_desire));
1031 if (aplayer == pplayer ||
NEVER_MET(pplayer, aplayer)
1039 best_target = aplayer;
1051 if (pplayer == aplayer) {
1068 if (
WAR(eplayer, aplayer) &&
WAR(pplayer, eplayer)) {
1076 }
else if (
WAR(pplayer, aplayer)) {
1112 "%d love lost due to units inside "
1141 if (aplayer == best_target && best_desire > 0) {
1146 "Wants war, reducing "
1179 game.
info.tech_trade_allow_holes)) {
1192 game.
info.tech_trade_allow_holes)) {
1208 if (worth[tech] <= 0) {
1215 if (worth[tech2] >= 0) {
1219 diff = worth[tech] + worth[tech2];
1221 || (diff < 0 && player2->economic.gold >= -diff) || diff == 0) {
1227 }
else if (diff < 0) {
1245 if (old_treaty !=
nullptr) {
1249 dlsend_packet_diplomacy_remove_clause(
1251 player_number(pclause->from), pclause->type, pclause->value);
1255 clause_list_destroy(old_treaty->
clauses);
1256 old_treaty->
clauses = clause_list_new();
1279 game.
info.tech_trade_allow_holes)) {
1284 aresearch, idx,
game.
info.tech_trade_allow_holes)) {
1295 gives_vision =
true;
1320 struct player *target,
enum war_reason reason)
1333 case DAI_WR_BEHAVIOUR:
1335 _(
"*%s (AI)* I have tolerated your vicious antics "
1336 "long enough! To war!"),
1348 _(
"*%s (AI)* Finally I get around to you! Did "
1349 "you really think you could get away with your crimes?"),
1355 _(
"*%s (AI)* Your covert hostilities brought "
1356 "this war upon you!"),
1360 case DAI_WR_ALLIANCE:
1363 _(
"*%s (AI)* Your aggression against %s was "
1364 "your last mistake!"),
1370 DIPLO_LOG(ait, LOG_DIPL, pplayer, target,
1371 "Wanted to declare war "
1372 "for his war against an ally, but can no longer find "
1373 "this ally! War declaration aborted.");
1389 pplayer,
game.
info.government_during_revolution_id);
1396 "Wanted to cancel treaty but "
1401 clause_type_invalid());
1411 DIPLO_LOG(ait, LOG_DIPL, pplayer, target,
"war declared");
1432 DIPLO_LOG(ait, LOG_DIPL, pplayer, target,
"countdown to war in %d",
1451 PL_(
"*%s (AI)* We will be launching an all-out war "
1452 "against %s in %d turn to stop the spaceship "
1454 "*%s (AI)* We will be launching an all-out war "
1455 "against %s in %d turns to stop the spaceship "
1461 _(
"*%s (AI)* Your aid in this matter will be expected. "
1462 "Long live our glorious alliance!"),
1465 case DAI_WR_BEHAVIOUR:
1469 PL_(
"*%s (AI)* %s has grossly violated his treaties "
1470 "with us for own gain. We will answer in force in "
1471 "%d turn and expect you to honor your alliance "
1472 "with us and do likewise!",
1473 "*%s (AI)* %s has grossly violated his treaties "
1474 "with us for own gain. We will answer in force in "
1475 "%d turns and expect you to honor your alliance "
1476 "with us and do likewise!",
1483 PL_(
"*%s (AI)* We intend to pillage and plunder the rich "
1484 "civilization of %s. We declare war in %d turn.",
1485 "*%s (AI)* We intend to pillage and plunder the rich "
1486 "civilization of %s. We declare war in %d turns.",
1490 _(
"*%s (AI)* If you want a piece of the loot, feel "
1491 "free to join in the action!"),
1497 PL_(
"*%s (AI)* We have had it with %s. Let us tear this "
1498 "pathetic civilization apart. We declare war in "
1500 "*%s (AI)* We have had it with %s. Let us tear this "
1501 "pathetic civilization apart. We declare war in "
1506 _(
"*%s (AI)* As our glorious allies, we expect your "
1507 "help in this war."),
1510 case DAI_WR_ALLIANCE:
1511 if (
WAR(ally, target)) {
1514 PL_(
"*%s (AI)* We will honor our alliance and declare "
1515 "war on %s in %d turn. Hold on - we are coming!",
1516 "*%s (AI)* We will honor our alliance and declare "
1517 "war on %s in %d turns. Hold on - we are coming!",
1523 PL_(
"*%s (AI)* We will honor our alliance with %s and "
1524 "declare war on %s in %d turns. We expect you to "
1526 "*%s (AI)* We will honor our alliance with %s and "
1527 "declare war on %s in %d turns. We expect you to "
1550 bool need_targets =
true;
1551 struct player *target =
nullptr;
1593 if (aplayer == pplayer
1607 _(
"*%s (AI)* Your attempt to conquer space for "
1608 "yourself alone betrays your true intentions, and I "
1609 "will have no more of our alliance!"),
1623 _(
"*%s (AI)* Your attempt to unilaterally "
1624 "dominate outer space is highly offensive."),
1627 _(
"*%s (AI)* If you do not stop constructing your "
1628 "spaceship, I may be forced to take action!"),
1635 DIPLO_LOG(ait, LOG_DIPL, pplayer, aplayer,
1636 "plans war due to spaceship");
1655 if (
WAR(pplayer, aplayer)) {
1656 need_targets =
false;
1667 aggr_sr = sqrt(aggr);
1672 if (need_targets && target && most_hatred < war_threshold
1674 enum war_reason war_reason;
1678 "Plans war against an ally!");
1682 war_reason = DAI_WR_EXCUSE;
1685 war_reason = DAI_WR_HATRED;
1688 war_reason = DAI_WR_NONE;
1705 "plans war to help ally %s",
1719 if (!aplayer->is_alive) {
1726 if (!
WAR(pplayer, aplayer)) {
1748 clause.
from = pplayer;
1758 _(
"*%s (AI)* Sorry, sharing vision with you "
1759 "is no longer safe."),
1767 || aplayer == target
1787 if (adip->
spam <= 0) {
1821 if (!target || !target->
is_alive) {
1826 if (adip->
spam <= 0) {
1832 _(
"*%s (AI)* Greetings our most trustworthy "
1833 "ally. We call upon you to destroy our enemy, %s."),
1840 _(
"*%s (AI)* Greetings ally, I see you have not yet "
1841 "made war with our enemy, %s. Why do I need to remind "
1842 "you of your promises?"),
1850 _(
"*%s (AI)* Dishonored one, we made a pact of "
1851 "alliance, and yet you remain at peace with our mortal "
1852 "enemy, %s! This is unacceptable; our alliance is no "
1856 "breaking useless alliance");
1872 clause.
type = CLAUSE_ALLIANCE;
1884 _(
"*%s (AI)* Greetings friend, may we suggest "
1885 "making a common cause and join in an alliance?"),
1890 clause.
type = CLAUSE_PEACE;
1902 _(
"*%s (AI)* Greetings neighbor, may we suggest "
1903 "more peaceful relations?"),
1909 clause.
type = CLAUSE_CEASEFIRE;
1921 _(
"*%s (AI)* We grow weary of this constant "
1922 "bloodshed. May we suggest a cessation of hostilities?"),
1959 enum casus_belli_range scope,
const struct action *paction,
1963 if (!
is_ai(receiver) || violator == receiver) {
1969 || scope == CBR_INTERNATIONAL_OUTRAGE);
1975 switch (paction->
result) {
1976 case ACTRES_SPY_NUKE:
1978 case ACTRES_NUKE_CITY:
1979 case ACTRES_NUKE_UNITS:
1980 if (receiver == victim) {
1983 }
else if (violator == victim) {
1989 case ACTRES_ESTABLISH_EMBASSY:
1990 case ACTRES_SPY_INVESTIGATE_CITY:
1994 case ACTRES_SPY_STEAL_GOLD:
1995 case ACTRES_SPY_STEAL_TECH:
1996 case ACTRES_SPY_TARGETED_STEAL_TECH:
1997 case ACTRES_STEAL_MAPS:
2001 case ACTRES_EXPEL_UNIT:
2005 case ACTRES_SPY_SABOTAGE_UNIT:
2009 case ACTRES_SPY_BRIBE_UNIT:
2010 case ACTRES_CAPTURE_UNITS:
2011 case ACTRES_BOMBARD:
2013 case ACTRES_SPY_ATTACK:
2017 case ACTRES_SPY_INCITE_CITY:
2018 case ACTRES_DESTROY_CITY:
2019 case ACTRES_CONQUER_CITY:
2023 case ACTRES_SPY_SABOTAGE_CITY:
2024 case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
2025 case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
2026 case ACTRES_STRIKE_BUILDING:
2027 case ACTRES_STRIKE_PRODUCTION:
2031 case ACTRES_SPY_POISON:
2032 case ACTRES_SPY_SPREAD_PLAGUE:
2036 case ACTRES_FOUND_CITY:
2040 case ACTRES_PILLAGE:
2044 case ACTRES_TRADE_ROUTE:
2045 case ACTRES_MARKETPLACE:
2046 case ACTRES_HELP_WONDER:
2047 case ACTRES_JOIN_CITY:
2048 case ACTRES_RECYCLE_UNIT:
2049 case ACTRES_DISBAND_UNIT:
2050 case ACTRES_HOME_CITY:
2051 case ACTRES_UPGRADE_UNIT:
2052 case ACTRES_PARADROP:
2053 case ACTRES_AIRLIFT:
2054 case ACTRES_HEAL_UNIT:
2055 case ACTRES_TRANSFORM_TERRAIN:
2056 case ACTRES_CULTIVATE:
2058 case ACTRES_CLEAN_POLLUTION:
2059 case ACTRES_CLEAN_FALLOUT:
2060 case ACTRES_FORTIFY:
2062 case ACTRES_CONVERT:
2065 case ACTRES_IRRIGATE:
2066 case ACTRES_TRANSPORT_ALIGHT:
2067 case ACTRES_TRANSPORT_UNLOAD:
2068 case ACTRES_TRANSPORT_DISEMBARK:
2069 case ACTRES_TRANSPORT_BOARD:
2070 case ACTRES_TRANSPORT_EMBARK:
2078 if (receiver == victim) {
2093 const struct player *violator,
2094 const struct player *victim)
2098 if (violator == victim) {
2109 const struct player *violator,
2110 const struct player *victim)
2121 const struct player *violator,
2122 const struct player *victim)
2143 const struct player *violator,
2144 const struct player *victim,
2145 enum casus_belli_range scope,
int how_bad)
2148 if (victim == receiver) {
2149 if (scope == CBR_INTERNATIONAL_OUTRAGE) {
2152 displeasure = displeasure * 2;
2155 }
else if (violator == victim) {
2174 if (!
is_ai(pplayer)) {
2178 if (pplayer != violator) {
2189 if (victim == pplayer) {
2202 _(
"*%s (AI)* We have been savagely attacked by "
2203 "%s, and we need your help! Honor our glorious "
2204 "alliance and your name will never be forgotten!"),
struct adv_data * adv_data_get(struct player *pplayer, bool *caller_closes)
Return a pointer to our data.
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...
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.
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.
#define DIPLO_LOG(ait, loglevel, pplayer, aplayer, msg,...)
static struct ai_plr * def_ai_player_data(const struct player *pplayer, struct ai_type *deftype)
int player_distance_to_player(struct player *pplayer, struct player *target)
Calculate average distances to other players.
int city_gold_worth(struct city *pcity)
Rough calculation of the worth of pcity in gold.
int ai_trait_get_value(enum trait tr, struct player *pplayer)
Get current value of player trait.
#define NEVER_MET(plr1, plr2)
#define ATTACK_POWER(ptype)
struct city * city_list_find_number(struct city_list *This, int id)
Find city with given id from list.
struct player * city_owner(const struct city *pcity)
Return the owner of the city.
bool is_capital(const struct city *pcity)
Return TRUE iff this city is its nation's capital.
const char * city_name_get(const struct city *pcity)
Return the name of the city.
citizens city_size_get(const struct city *pcity)
Get the city size.
#define city_list_iterate(citylist, pcity)
#define city_list_iterate_end
#define city_built_iterate(_pcity, _p)
#define city_built_iterate_end
void dai_treaty_accepted(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
This function is called when a treaty has been concluded, to deal with followup issues like comments ...
static void dai_incident_nuclear_not_target(struct player *receiver, const struct player *violator, const struct player *victim)
Nuclear strike against someone else.
void dai_incident(struct ai_type *ait, enum incident_type type, enum casus_belli_range scope, const struct action *paction, struct player *receiver, struct player *violator, struct player *victim)
Handle incident caused by violator.
bool dai_on_war_footing(struct ai_type *ait, struct player *pplayer)
Are we going to be declaring war in a few turns time? If so, go on a war footing, and try to buy out ...
void dai_diplomacy_actions(struct ai_type *ait, struct player *pplayer)
Do diplomatic actions.
static int dai_goldequiv_clause(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Clause *pclause, bool verbose, enum diplstate_type ds_after)
Evaluate gold worth of a single clause in a treaty.
static void dai_incident_simple(struct player *receiver, const struct player *violator, const struct player *victim, enum casus_belli_range scope, int how_bad)
Called when someone caused an incident to make the receiver lose AI love.
static void dai_incident_nuclear_self(struct player *receiver, const struct player *violator, const struct player *victim)
Somebody else than victim did nuclear strike against self.
void dai_diplomacy_begin_new_phase(struct ai_type *ait, struct player *pplayer)
Calculate our diplomatic predispositions here.
static void suggest_tech_exchange(struct ai_type *ait, struct player *player1, struct player *player2)
Find two techs that can be exchanged and suggest that.
void dai_treaty_evaluate(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
pplayer is AI player, aplayer is the other player involved, treaty is the treaty being considered.
static const struct player * get_allied_with_enemy_player(const struct player *us, const struct player *them)
Returns an enemy player to 'us' allied with 'them' if there is one.
static int greed(int missing_love)
This is your typical human reaction.
static bool dai_players_can_agree_on_ceasefire(struct ai_type *ait, struct player *player1, struct player *player2)
Checks if player1 can agree on ceasefire with player2 This function should only be used for ai player...
static void dai_go_to_war(struct ai_type *ait, struct player *pplayer, struct player *target, enum war_reason reason)
Go to war.
static int dai_goldequiv_tech(struct ai_type *ait, struct player *pplayer, Tech_type_id tech)
How much is a tech worth to player measured in gold.
static enum diplstate_type pact_clause_to_diplstate_type(enum clause_type type)
Convert clause into diplomatic state.
static void dai_diplomacy_suggest(struct player *pplayer, struct player *aplayer, enum clause_type what, bool to_pplayer, int value)
Suggest a treaty.
static void dai_treaty_react(struct ai_type *ait, struct player *pplayer, struct player *aplayer, struct Clause *pclause)
Comments to player from AI on clauses being agreed on.
static int compute_tech_sell_price(struct ai_type *ait, struct player *giver, struct player *taker, int tech_id, bool *is_dangerous)
Calculate a price of a tech.
static void clear_old_treaty(struct player *pplayer, struct player *aplayer)
Clear old clauses from the treaty between players.
static void dai_diplo_notify(struct player *pplayer, const char *text,...)
Send a diplomatic message.
static void dai_incident_nuclear(struct player *receiver, const struct player *violator, const struct player *victim)
Nuclear strike against victim.
static void dai_incident_war(struct player *violator, struct player *victim)
War declared against a player.
static void war_countdown(struct ai_type *ait, struct player *pplayer, struct player *target, int countdown, enum war_reason reason)
Do diplomatic actions.
static void dai_share(struct ai_type *ait, struct player *pplayer, struct player *aplayer)
Offer techs and stuff to other player and ask for techs we need.
static bool shared_vision_is_safe(struct player *pplayer, struct player *aplayer)
Avoid giving pplayer's vision to non-allied player through aplayer (shared vision is transitive).
static int dai_war_desire(struct ai_type *ait, struct player *pplayer, struct player *target)
Calculate our desire to go to war against aplayer.
#define TURNS_BEFORE_TARGET
static bool diplomacy_verbose
void dai_diplomacy_first_contact(struct ai_type *ait, struct player *pplayer, struct player *aplayer)
What to do when we first meet.
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
Find currently active treaty between two players.
void handle_diplomacy_create_clause_req(struct player *pplayer, int counterpart, int giver, enum clause_type type, int value)
Handle request to add clause to treaty between two players.
void handle_diplomacy_init_meeting_req(struct player *pplayer, int counterpart)
Handle meeting opening request.
void handle_diplomacy_accept_treaty_req(struct player *pplayer, int counterpart)
pplayer clicked the accept button.
bool diplomacy_possible(const struct player *pplayer1, const struct player *pplayer2)
Returns TRUE iff pplayer could do diplomancy in the game at all.
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
Returns TRUE iff pplayer could do diplomatic meetings with aplayer.
#define clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define is_pact_clause(x)
int get_city_bonus(const struct city *pcity, enum effect_type effect_type, enum vision_layer vlayer)
Returns the effect bonus at a city.
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
Returns the effect bonus for a player.
#define MAX_NUM_PLAYER_SLOTS
#define PL_(String1, String2, n)
const struct ft_color ftc_chat_private
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...
int impr_build_shield_cost(const struct city *pcity, const struct impr_type *pimprove)
Returns the number of shields it takes to build this improvement.
bool is_great_wonder(const struct impr_type *pimprove)
Is this building a great wonder?
bool improvement_obsolete(const struct player *pplayer, const struct impr_type *pimprove, const struct city *pcity)
Returns TRUE if the improvement or wonder is obsolete.
bool is_small_wonder(const struct impr_type *pimprove)
Is this building a small wonder?
#define fc_assert_msg(condition, message,...)
#define fc_assert_ret(condition)
#define fc_assert(condition)
#define fc_assert_ret_val(condition, val)
#define log_base(level, message,...)
#define map_size_checked()
void remove_shared_vision(struct player *pfrom, struct player *pto)
Removes shared vision from between two players.
void vpackage_event(struct packet_chat_msg *packet, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format, va_list vargs)
Fill a packet_chat_msg structure for common server event.
void event_cache_add_for_player(const struct packet_chat_msg *packet, const struct player *pplayer)
Add an event to the cache for one player.
struct city_list * cities
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
int player_number(const struct player *pplayer)
Return the player index/number/id.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
int player_index(const struct player *pplayer)
Return the player index.
int player_in_territory(const struct player *pplayer, const struct player *pplayer2)
Return the number of pplayer2's visible units in pplayer's territory, from the point of view of pplay...
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
enum dipl_reason pplayer_can_cancel_treaty(const struct player *p1, const struct player *p2)
The senate may not allow you to break the treaty.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players have peace, cease-fire, or armistice.
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Check if pplayer has an embassy with pplayer2.
bool gives_shared_vision(const struct player *me, const struct player *them)
Return TRUE iff the player me gives shared vision to player them.
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied or at peace.
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 players_iterate_alive_end
#define players_iterate_alive(_pplayer)
void handle_player_change_government(struct player *pplayer, Government_type_id government)
Called by the client or AI to change government.
void handle_diplomacy_cancel_pact(struct player *pplayer, int other_player_id, enum clause_type clause)
Handles a player cancelling a "pact" with another player.
bool research_goal_tech_req(const struct research *presearch, Tech_type_id goal, Tech_type_id tech)
Returns if the given tech has to be researched to reach the goal.
int player_tech_upkeep(const struct player *pplayer)
Calculate the bulb upkeep needed for all techs of a player.
struct research * research_get(const struct player *pplayer)
Returns the research structure associated with the player.
int research_goal_bulbs_required(const struct research *presearch, Tech_type_id goal)
Function to determine cost (in bulbs) of reaching goal technology.
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.
struct clause_list * clauses
enum action_result result
struct adv_data::@88 dipl
struct player * spacerace_leader
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
adv_want tech_want[A_LAST+1]
int req_love_for_alliance
enum winning_strategy strategy
struct civ_game::@28::@32 server
struct packet_game_info info
int love[MAX_NUM_PLAYER_SLOTS]
enum spaceship_state state
struct city_list * cities
struct player_ai ai_common
struct player::@65::@67 server
const struct ai_type * ai
struct conn_list * connections
struct player_economic economic
struct player_spaceship spaceship
struct unit_type::@82 adv
const char * advance_rule_name(const struct advance *padvance)
Return the (untranslated) rule name of the advance/technology.
struct advance * advance_by_number(const Tech_type_id atype)
Return the advance for the given advance index.
Tech_type_id advance_count()
Return the number of advances/technologies.
#define advance_index_iterate_end
#define advance_index_iterate(_start, _index)
#define TRAIT_MAX_VALUE_SR
bool unit_is_cityfounder(const struct unit *punit)
Is a cityfounder unit?
#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 utype_is_cityfounder(const struct unit_type *utype)
Is cityfounder type.