124 if ((ptreaty->plr0 ==
plr0 && ptreaty->plr1 ==
plr1)
125 || (ptreaty->plr0 ==
plr1 && ptreaty->plr1 ==
plr0)) {
137 enum diplstate_type b)
139 static const int how_close[DS_LAST] = {
149 if (how_close[a] < how_close[b]) {
161 enum diplstate_type
type)
163 enum diplstate_type max;
165 if (
type == DS_ARMISTICE) {
188 bool *player_accept, *other_accept;
190 bool worker_refresh_required =
FALSE;
196 if (NULL == pother || pplayer == pother) {
206 if (ptreaty->
plr0 == pplayer) {
207 player_accept = &ptreaty->
accept0;
208 other_accept = &ptreaty->
accept1;
210 player_accept = &ptreaty->
accept1;
211 other_accept = &ptreaty->
accept0;
214 if (!*player_accept) {
219 struct city *pcity = NULL;
221 if (pclause->from == pplayer) {
228 log_error(
"Requirements of a clause between %s and %s not fulfilled",
235 switch (pclause->type) {
238 log_error(
"%s tried to give embassy to %s, who already "
249 log_error(
"Treaty: %s can't have tech %s",
253 _(
"The %s can't accept %s."),
261 log_error(
"Nation %s try to give unknown tech %s to nation %s.",
266 _(
"You don't have tech %s, you can't accept treaty."),
276 _(
"City you are trying to give no longer exists, "
277 "you can't accept treaty."));
282 _(
"You are not owner of %s, you can't accept treaty."),
288 _(
"Your capital (%s) is requested, "
289 "you can't accept treaty."),
294 case CLAUSE_CEASEFIRE:
306 case CLAUSE_ALLIANCE:
310 _(
"You cannot form an alliance because you are "
311 "at war with an ally of %s."),
315 _(
"You cannot form an alliance because %s is "
316 "at war with an ally of yours."),
326 _(
"You don't have enough gold, "
327 "you can't accept treaty."));
338 *player_accept = ! *player_accept;
348 int nclauses = clause_list_size(ptreaty->
clauses);
358 PL_(
"A treaty containing %d clause was agreed upon.",
359 "A treaty containing %d clauses was agreed upon.",
363 PL_(
"A treaty containing %d clause was agreed upon.",
364 "A treaty containing %d clauses was agreed upon.",
374 if (pclause->from == pother) {
382 _(
"Clause requirements are no longer fulfilled. "
383 "Treaty with %s canceled!"),
386 _(
"Clause requirements are no longer fulfilled. "
387 "Treaty with %s canceled!"),
393 if (pclause->from == pother) {
394 switch (pclause->type) {
399 _(
"One of the cities the %s are giving away"
400 " is destroyed! Treaty canceled!"),
403 _(
"One of the cities the %s are giving away"
404 " is destroyed! Treaty canceled!"),
410 _(
"The %s no longer control %s! "
415 _(
"The %s no longer control %s! "
423 _(
"Your capital (%s) is requested, "
424 "you can't accept treaty."),
430 case CLAUSE_ALLIANCE:
444 case CLAUSE_CEASEFIRE:
453 _(
"The %s don't have the promised amount "
454 "of gold! Treaty canceled!"),
457 _(
"The %s don't have the promised amount "
458 "of gold! Treaty canceled!"),
473 struct player *pgiver = pclause->from;
474 struct player *pdest = (pplayer == pgiver) ? pother : pplayer;
479 enum diplstate_type old_diplstate = ds_giverdest->
type;
483 switch (pclause->type) {
487 _(
"You gave an embassy to %s."),
490 _(
"%s allowed you to create an embassy!"),
499 const char *advance_name;
504 "that %s want to give them.",
513 _(
"You are taught the knowledge of %s."),
520 sizeof(research_name));
522 _(
"You have acquired %s thanks to the %s "
523 "treaty with the %s."),
528 (presearch, pgiver, E_TECH_EMBASSY,
ftc_server,
530 Q_(
"?fromplr:The %s have acquired %s from the %s."),
545 int received = pclause->value
550 PL_(
"You get %d gold.",
551 "You get %d gold.", received), received);
558 _(
"You receive the %s worldmap."),
561 worker_refresh_required =
TRUE;
567 _(
"You receive the %s seamap."),
570 worker_refresh_required =
TRUE;
577 log_error(
"Treaty city id %d not found - skipping clause.",
583 _(
"You receive the city of %s from %s."),
587 _(
"You give the city of %s to %s."),
597 case CLAUSE_CEASEFIRE:
598 if (old_diplstate == DS_ALLIANCE) {
602 ds_giverdest->
type = DS_CEASEFIRE;
604 ds_destgiver->
type = DS_CEASEFIRE;
607 _(
"You agree on a cease-fire with %s."),
610 _(
"You agree on a cease-fire with %s."),
612 if (old_diplstate == DS_ALLIANCE) {
616 unit_list_destroy(pgiver_seen_units);
617 unit_list_destroy(pdest_seen_units);
620 worker_refresh_required =
TRUE;
623 if (old_diplstate == DS_ALLIANCE) {
632 PL_(
"You agree on an armistice with the %s. In %d turn, "
633 "it will become a peace treaty. Move your "
634 "military units out of %s territory to avoid them "
636 "You agree on an armistice with the %s. In %d turns, "
637 "it will become a peace treaty. Move any "
638 "military units out of %s territory to avoid them "
646 PL_(
"You agree on an armistice with the %s. In %d turn, "
647 "it will become a peace treaty. Move your "
648 "military units out of %s territory to avoid them "
650 "You agree on an armistice with the %s. In %d turns, "
651 "it will become a peace treaty. Move any "
652 "military units out of %s territory to avoid them "
658 if (old_diplstate == DS_ALLIANCE) {
662 unit_list_destroy(pgiver_seen_units);
663 unit_list_destroy(pdest_seen_units);
666 worker_refresh_required =
TRUE;
668 case CLAUSE_ALLIANCE:
671 _(
"You agree on an alliance with %s."),
674 _(
"You agree on an alliance with %s."),
679 worker_refresh_required =
TRUE;
684 _(
"You give shared vision to %s."),
687 _(
"%s gives you shared vision."),
692 worker_refresh_required =
TRUE;
695 fc_assert(pclause->type != CLAUSE_COUNT);
706 if (worker_refresh_required) {
713 treaty_list_remove(
treaties, ptreaty);
748 enum clause_type
type,
int value)
754 if (NULL == pother || pplayer == pother || NULL == pgiver) {
758 if (pgiver != pplayer && pgiver != pother) {
781 enum clause_type
type,
int value)
787 if (NULL == pother || pplayer == pother || NULL == pgiver) {
791 if (pgiver != pplayer && pgiver != pother) {
807 if (
type == CLAUSE_CITY) {
839 _(
"%s canceled the meeting!"),
846 _(
"Meeting with %s canceled."),
848 treaty_list_remove(
treaties, ptreaty);
862 if (NULL == pother || pplayer == pother) {
877 if (NULL == pother || pplayer == pother) {
888 _(
"Your diplomatic envoy was decapitated!"));
897 treaty_list_prepend(
treaties, ptreaty);
934 if (ptreaty->
plr0 == pplayer) {
#define CALL_PLR_AI_FUNC(_func, _player,...)
bool is_capital(const struct city *pcity)
#define city_tile(_pcity_)
#define city_owner(_pcity_)
static struct treaty_list * treaties
void establish_embassy(struct player *pplayer, struct player *aplayer)
void send_diplomatic_meetings(struct connection *dest)
void handle_diplomacy_remove_clause_req(struct player *pplayer, int counterpart, int giver, enum clause_type type, int value)
struct treaty_list * get_all_treaties(void)
void handle_diplomacy_create_clause_req(struct player *pplayer, int counterpart, int giver, enum clause_type type, int value)
static void call_treaty_accepted(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
void reject_all_treaties(struct player *pplayer)
void set_diplstate_type(struct player_diplstate *state1, struct player_diplstate *state2, enum diplstate_type type)
void handle_diplomacy_init_meeting_req(struct player *pplayer, int counterpart)
void cancel_all_meetings(struct player *pplayer)
void handle_diplomacy_cancel_meeting_req(struct player *pplayer, int counterpart)
static void call_treaty_evaluate(struct player *pplayer, struct player *aplayer, struct Treaty *ptreaty)
static enum diplstate_type dst_closest(enum diplstate_type a, enum diplstate_type b)
struct Treaty * find_treaty(struct player *plr0, struct player *plr1)
static void really_diplomacy_cancel_meeting(struct player *pplayer, struct player *pother)
void handle_diplomacy_accept_treaty_req(struct player *pplayer, int counterpart)
#define treaty_list_iterate(list, p)
#define treaty_list_iterate_end
int int initiated_from int int giver
void clear_treaty(struct Treaty *ptreaty)
void init_treaty(struct Treaty *ptreaty, struct player *plr0, struct player *plr1)
bool add_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val, struct player *client_player)
bool remove_clause(struct Treaty *ptreaty, struct player *pfrom, enum clause_type type, int val)
struct clause_info * clause_info_get(enum clause_type type)
bool could_meet_with_player(const struct player *pplayer, const struct player *aplayer)
#define clause_list_iterate_end
#define clause_list_iterate(clauselist, pclause)
#define is_pact_clause(x)
int get_player_bonus(const struct player *pplayer, enum effect_type effect_type)
#define PL_(String1, String2, n)
const struct ft_color ftc_server
const char * city_link(const struct city *pcity)
struct city * game_city_by_number(int id)
#define log_verbose(message,...)
#define fc_assert(condition)
#define fc_assert_action(condition, action)
#define log_error(message,...)
void give_map_from_player_to_player(struct player *pfrom, struct player *pdest)
void give_seamap_from_player_to_player(struct player *pfrom, struct player *pdest)
void give_citymap_from_player_to_player(struct city *pcity, struct player *pfrom, struct player *pdest)
bool map_is_known_and_seen(const struct tile *ptile, const struct player *pplayer, enum vision_layer vlayer)
void give_shared_vision(struct player *pfrom, struct player *pto)
const char * nation_rule_name(const struct nation_type *pnation)
const char * nation_adjective_for_player(const struct player *pplayer)
struct nation_type * nation_of_player(const struct player *pplayer)
const char * nation_plural_for_player(const struct player *pplayer)
void notify_research(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
void notify_player(const struct player *pplayer, const struct tile *ptile, enum event_type event, const struct ft_color color, const char *format,...)
void notify_research_embassies(const struct research *presearch, const struct player *exclude, enum event_type event, const struct ft_color color, const char *format,...)
void dlsend_packet_diplomacy_init_meeting(struct conn_list *dest, int counterpart, int initiated_from)
void dlsend_packet_diplomacy_remove_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_create_clause(struct connection *pc, int counterpart, int giver, enum clause_type type, int value)
int dsend_packet_diplomacy_init_meeting(struct connection *pc, int counterpart, int initiated_from)
void dlsend_packet_diplomacy_create_clause(struct conn_list *dest, int counterpart, int giver, enum clause_type type, int value)
void dlsend_packet_diplomacy_accept_treaty(struct conn_list *dest, int counterpart, bool I_accepted, bool other_accepted)
void dlsend_packet_diplomacy_cancel_meeting(struct conn_list *dest, int counterpart, int initiated_from)
int dsend_packet_diplomacy_accept_treaty(struct connection *pc, int counterpart, bool I_accepted, bool other_accepted)
struct player * player_by_number(const int player_id)
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)
bool player_has_real_embassy(const struct player *pplayer, const struct player *pplayer2)
int player_index(const struct player *pplayer)
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
#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_list_iterate_end
void send_player_all_c(struct player *src, struct conn_list *dest)
void update_players_after_alliance_breakup(struct player *pplayer, struct player *pplayer2, const struct unit_list *pplayer_seen_units, const struct unit_list *pplayer2_seen_units)
bool are_reqs_active(const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct research * research_get(const struct player *pplayer)
enum tech_state research_invention_state(const struct research *presearch, Tech_type_id tech)
bool research_invention_gettable(const struct research *presearch, const Tech_type_id tech, bool allow_holes)
int research_pretty_name(const struct research *presearch, char *buf, size_t buf_len)
void script_server_signal_emit(const char *signal_name,...)
#define BAD_HEURISTIC_INIT(_ini_val_)
struct clause_list * clauses
struct civ_game::@30::@34 server
struct packet_game_info info
struct requirement_vector receiver_reqs
struct requirement_vector giver_reqs
bool tech_trade_allow_holes
enum diplstate_type max_state
struct conn_list * connections
struct player_economic economic
const struct player * player
const struct player_list * team_members(const struct team *pteam)
struct advance * advance_by_number(const Tech_type_id atype)
const char * advance_name_translation(const struct advance *padvance)
const char * advance_rule_name(const struct advance *padvance)