Author: jtn
Date: Mon May  4 13:43:29 2015
New Revision: 28983

URL: http://svn.gna.org/viewcvs/freeciv?rev=28983&view=rev
Log:
Emit the correct initiated_from in treaties from AI players.
This should stop the Gtk client bringing such treaties to the foreground
at awkward moments.

See gna bug #23565.

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=28983&r1=28982&r2=28983&view=diff
==============================================================================
--- trunk/ai/default/advdiplomacy.c     (original)
+++ trunk/ai/default/advdiplomacy.c     Mon May  4 13:43:29 2015
@@ -888,11 +888,14 @@
 }
 
 /********************************************************************** 
-  Suggest a treaty from pplayer to aplayer
+  Suggest a treaty.
+  pplayer is the (AI) player suggesting the treaty.
+  If to_pplayer, then aplayer is giver in the clause, else pplayer is.
 ***********************************************************************/
 static void dai_diplomacy_suggest(struct player *pplayer, 
                                  struct player *aplayer,
                                  enum clause_type what,
+                                  bool to_pplayer,
                                  int value)
 {
   if (!could_meet_with_player(pplayer, aplayer)) {
@@ -903,7 +906,9 @@
 
   handle_diplomacy_init_meeting_req(pplayer, player_number(aplayer));
   handle_diplomacy_create_clause_req(pplayer, player_number(aplayer),
-                                    player_number(pplayer), what, value);
+                                     player_number(to_pplayer ? aplayer
+                                                              : pplayer),
+                                     what, value);
 }
 
 /********************************************************************** 
@@ -920,7 +925,7 @@
            player_name(pplayer),
            player_name(aplayer));
     clear_old_treaty(pplayer, aplayer);
-    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, 0);
+    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, FALSE, 0);
   }
 }
 
@@ -1127,12 +1132,12 @@
       if ((diff > 0 && player1->economic.gold >= diff)
           || (diff < 0 && player2->economic.gold >= -diff)
          || diff == 0) {
-        dai_diplomacy_suggest(player1, player2, CLAUSE_ADVANCE, tech2);
-       dai_diplomacy_suggest(player2, player1, CLAUSE_ADVANCE, tech);
+        dai_diplomacy_suggest(player1, player2, CLAUSE_ADVANCE, FALSE, tech2);
+       dai_diplomacy_suggest(player1, player2, CLAUSE_ADVANCE, TRUE, tech);
        if (diff > 0) {
-          dai_diplomacy_suggest(player1, player2, CLAUSE_GOLD, diff);
+          dai_diplomacy_suggest(player1, player2, CLAUSE_GOLD, FALSE, diff);
        } else if (diff < 0) {
-          dai_diplomacy_suggest(player2, player1, CLAUSE_GOLD, -diff);
+          dai_diplomacy_suggest(player1, player2, CLAUSE_GOLD, TRUE, -diff);
        }
        return;
       }
@@ -1181,12 +1186,12 @@
           && research_invention_state(aresearch, index) == TECH_KNOWN
           && research_invention_gettable(presearch, index,
                                          game.info.tech_trade_allow_holes)) {
-       dai_diplomacy_suggest(aplayer, pplayer, CLAUSE_ADVANCE, index);
+       dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, TRUE, index);
       } else if (research_invention_state(presearch, index) == TECH_KNOWN
                  && research_invention_state(aresearch, index) != TECH_KNOWN
                  && research_invention_gettable(aresearch, index,
                         game.info.tech_trade_allow_holes)) {
-        dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, index);
+        dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, FALSE, index);
       }
     } advance_index_iterate_end;
   }
@@ -1195,21 +1200,21 @@
   gives_vision = gives_shared_vision(pplayer, aplayer);
   if (!gives_vision
       && shared_vision_is_safe(pplayer, aplayer)) {
-    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_VISION, 0);
+    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_VISION, FALSE, 0);
     gives_vision = TRUE;
   }
   if (gives_vision
       && !gives_shared_vision(aplayer, pplayer)
       && (!aplayer->ai_controlled
           || shared_vision_is_safe(aplayer, pplayer))) {
-    dai_diplomacy_suggest(aplayer, pplayer, CLAUSE_VISION, 0);
+    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_VISION, TRUE, 0);
   }
 
   if (!player_has_embassy(pplayer, aplayer)) {
-    dai_diplomacy_suggest(aplayer, pplayer, CLAUSE_EMBASSY, 0);
+    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_EMBASSY, TRUE, 0);
   }
   if (!player_has_embassy(aplayer, pplayer)) {
-    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_EMBASSY, 0);
+    dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_EMBASSY, FALSE, 0);
   }
 
   if (!has_handicap(pplayer, H_DIPLOMACY) || !aplayer->ai_controlled) {
@@ -1731,7 +1736,7 @@
         break;
       }
       clear_old_treaty(pplayer, aplayer);
-      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ALLIANCE, 0);
+      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ALLIANCE, FALSE, 0);
       adip->asked_about_alliance = !aplayer->ai_controlled ? 13 : 0;
       notify(aplayer, _("*%s (AI)* Greetings friend, may we suggest "
              "making a common cause and join in an alliance?"), 
@@ -1747,7 +1752,7 @@
         break;
       }
       clear_old_treaty(pplayer, aplayer);
-      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_PEACE, 0);
+      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_PEACE, FALSE, 0);
       adip->asked_about_peace = !aplayer->ai_controlled ? 12 : 0;
       notify(aplayer, _("*%s (AI)* Greetings neighbor, may we suggest "
              "more peaceful relations?"),
@@ -1763,7 +1768,7 @@
         break; /* Fight until the end! */
       }
       clear_old_treaty(pplayer, aplayer);
-      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, 0);
+      dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_CEASEFIRE, FALSE, 0);
       adip->asked_about_ceasefire = !aplayer->ai_controlled ? 9 : 0;
       notify(aplayer, _("*%s (AI)* We grow weary of this constant "
              "bloodshed. May we suggest a cessation of hostilities?"), 


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to