Author: jtn
Date: Mon May  4 13:51:10 2015
New Revision: 28989

URL: http://svn.gna.org/viewcvs/freeciv?rev=28989&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:
    branches/S2_5/ai/default/advdiplomacy.c

Modified: branches/S2_5/ai/default/advdiplomacy.c
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_5/ai/default/advdiplomacy.c?rev=28989&r1=28988&r2=28989&view=diff
==============================================================================
--- branches/S2_5/ai/default/advdiplomacy.c     (original)
+++ branches/S2_5/ai/default/advdiplomacy.c     Mon May  4 13:51:10 2015
@@ -880,11 +880,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)) {
@@ -895,7 +898,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);
 }
 
 /********************************************************************** 
@@ -912,7 +917,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);
   }
 }
 
@@ -1114,12 +1119,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;
       }
@@ -1163,11 +1168,11 @@
       if ((player_invention_state(pplayer, index) != TECH_KNOWN)
           && (player_invention_state(aplayer, index) == TECH_KNOWN)
           && player_invention_reachable(pplayer, index, FALSE)) {
-       dai_diplomacy_suggest(aplayer, pplayer, CLAUSE_ADVANCE, index);
+       dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, TRUE, index);
       } else if ((player_invention_state(pplayer, index) == TECH_KNOWN)
                  && (player_invention_state(aplayer, index) != TECH_KNOWN)
                  && player_invention_reachable(aplayer, index, FALSE)) {
-        dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, index);
+        dai_diplomacy_suggest(pplayer, aplayer, CLAUSE_ADVANCE, FALSE, index);
       }
     } advance_index_iterate_end;
   }
@@ -1176,21 +1181,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 (!ai_handicap(pplayer, H_DIPLOMACY) || !aplayer->ai_controlled) {
@@ -1712,7 +1717,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?"), 
@@ -1728,7 +1733,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?"),
@@ -1744,7 +1749,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