Author: cazfi Date: Mon Dec 1 05:02:50 2014 New Revision: 27162 URL: http://svn.gna.org/viewcvs/freeciv?rev=27162&view=rev Log: AI cancels old clauses before building up a new treaty proposal.
See bug #20761 Modified: trunk/ai/default/advdiplomacy.c Modified: trunk/ai/default/advdiplomacy.c URL: http://svn.gna.org/viewcvs/freeciv/trunk/ai/default/advdiplomacy.c?rev=27162&r1=27161&r2=27162&view=diff ============================================================================== --- trunk/ai/default/advdiplomacy.c (original) +++ trunk/ai/default/advdiplomacy.c Mon Dec 1 05:02:50 2014 @@ -87,6 +87,7 @@ static void dai_incident_nuclear_self(struct player *violator, struct player *victim); static void dai_incident_pillage(struct player *violator, struct player *victim); +static void clear_old_treaty(struct player *pplayer, struct player *aplayer); /********************************************************************** Send a diplomatic message. Use this instead of notify directly @@ -920,6 +921,7 @@ "while we get to know each other better?"), player_name(pplayer), player_name(aplayer)); + clear_old_treaty(pplayer, aplayer); dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, 0); } } @@ -1141,13 +1143,37 @@ } /********************************************************************** + Clear old clauses from the treaty between players +***********************************************************************/ +static void clear_old_treaty(struct player *pplayer, struct player *aplayer) +{ + struct Treaty *old_treaty = find_treaty(pplayer, aplayer); + + if (old_treaty != NULL) { + /* Remove existing clauses */ + clause_list_iterate(old_treaty->clauses, pclause) { + dlsend_packet_diplomacy_remove_clause(aplayer->connections, + player_number(pplayer), + player_number(pclause->from), + pclause->type, pclause->value); + free(pclause); + } clause_list_iterate_end; + clause_list_destroy(old_treaty->clauses); + old_treaty->clauses = clause_list_new(); + } +} + +/********************************************************************** Offer techs and stuff to other player and ask for techs we need. ***********************************************************************/ -static void dai_share(struct ai_type *ait, struct player *pplayer, struct player *aplayer) +static void dai_share(struct ai_type *ait, struct player *pplayer, + struct player *aplayer) { struct research *presearch = research_get(pplayer); struct research *aresearch = research_get(aplayer); bool gives_vision; + + clear_old_treaty(pplayer, aplayer); /* Only share techs with team mates */ if (presearch != aresearch @@ -1706,6 +1732,7 @@ FALSE, DS_ALLIANCE) < 0) { break; } + clear_old_treaty(pplayer, aplayer); dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ALLIANCE, 0); adip->asked_about_alliance = !aplayer->ai_controlled ? 13 : 0; notify(aplayer, _("*%s (AI)* Greetings friend, may we suggest " @@ -1721,6 +1748,7 @@ FALSE, DS_PEACE) < 0) { break; } + clear_old_treaty(pplayer, aplayer); dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_PEACE, 0); adip->asked_about_peace = !aplayer->ai_controlled ? 12 : 0; notify(aplayer, _("*%s (AI)* Greetings neighbor, may we suggest " @@ -1736,6 +1764,7 @@ FALSE, DS_CEASEFIRE) < 0) { break; /* Fight until the end! */ } + clear_old_treaty(pplayer, aplayer); dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, 0); adip->asked_about_ceasefire = !aplayer->ai_controlled ? 9 : 0; notify(aplayer, _("*%s (AI)* We grow weary of this constant " _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits