Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Exchange embassies in diplomacy (PR#4800)
Home

[Freeciv-Dev] Exchange embassies in diplomacy (PR#4800)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Exchange embassies in diplomacy (PR#4800)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Fri, 27 Feb 2004 05:38:53 -0800
Reply-to: rt@xxxxxxxxxxx

<URL: http://rt.freeciv.org/Ticket/Display.html?id=4800 >

This patch implements PR#4800 (sorry it took so long), exchange of
embassies through the diplomacy dialog. Only the gtk2 client is updated,
I leave it to client maintainers to update the other clients later - the
patch will not break the other clients.

Next on my todo list: Fix cascading war declarations.

  - Per

Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.129
diff -u -r1.129 climisc.c
--- client/climisc.c    2004/02/25 20:09:50     1.129
+++ client/climisc.c    2004/02/27 13:15:59
@@ -288,6 +288,10 @@
     my_snprintf(buf, bufsiz, _("The %s gives shared vision"),
                get_nation_name_plural(pclause->from->nation));
     break;
+  case CLAUSE_EMBASSY:
+    my_snprintf(buf, bufsiz, _("The %s gives an embassy"),
+                get_nation_name_plural(pclause->from->nation));
+    break;
   default:
     assert(FALSE);
     if (bufsiz > 0) {
Index: client/options.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/options.c,v
retrieving revision 1.93
diff -u -r1.93 options.c
--- client/options.c    2004/02/07 11:49:44     1.93
+++ client/options.c    2004/02/27 13:16:00
@@ -273,6 +273,7 @@
   GEN_EV(N_("Wonder: Will Finish Next Turn"),         E_WONDER_WILL_BE_BUILT),
   GEN_EV(N_("Diplomatic Message"),                    E_DIPLOMACY),
   GEN_EV(N_("City: Production changed"),              
E_CITY_PRODUCTION_CHANGED),
+  GEN_EV(N_("Treaty: Embassy"),                       E_TREATY_EMBASSY),
   GEN_EV_TERMINATOR
 };
 
Index: client/gui-gtk-2.0/diplodlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/diplodlg.c,v
retrieving revision 1.18
diff -u -r1.18 diplodlg.c
--- client/gui-gtk-2.0/diplodlg.c       2004/02/03 20:21:14     1.18
+++ client/gui-gtk-2.0/diplodlg.c       2004/02/27 13:16:00
@@ -88,6 +88,7 @@
 static void diplomacy_dialog_alliance_callback(GtkWidget *w, gpointer data);
 static void diplomacy_dialog_team_callback(GtkWidget *w, gpointer data);
 static void diplomacy_dialog_vision_callback(GtkWidget *w, gpointer data);
+static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data);
 static void close_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
 static void update_diplomacy_dialog(struct Diplomacy_dialog *pdialog);
 static void diplo_dialog_returnkey(GtkWidget *w, gpointer data);
@@ -329,6 +330,19 @@
   gtk_widget_show(item);
 
 
+  /* Give embassy. */
+  item = gtk_menu_item_new_with_mnemonic(_("Give _embassy"));
+  g_object_set_data(G_OBJECT(item), "plr", plr);
+  g_signal_connect(item, "activate",
+                  G_CALLBACK(diplomacy_dialog_embassy_callback), pdialog);
+
+  if (player_has_embassy(plr1, plr0)) {
+    gtk_widget_set_sensitive(item, FALSE);
+  }
+  gtk_menu_shell_append(GTK_MENU_SHELL(parent), item);
+  gtk_widget_show(item);
+
+
   /* Pacts. */
   if (plr == pdialog->treaty.plr0) {
     menu = gtk_menu_new();
@@ -784,6 +798,21 @@
   dsend_packet_diplomacy_create_clause_req(&aconnection,
                                           pdialog->treaty.plr1->player_no,
                                           pgiver->player_no, CLAUSE_VISION,
+                                          0);
+}
+
+/****************************************************************
+...
+*****************************************************************/
+static void diplomacy_dialog_embassy_callback(GtkWidget *w, gpointer data)
+{
+  struct Diplomacy_dialog *pdialog = (struct Diplomacy_dialog *) data;
+  struct player *pgiver =
+      (struct player *) g_object_get_data(G_OBJECT(w), "plr");
+
+  dsend_packet_diplomacy_create_clause_req(&aconnection,
+                                          pdialog->treaty.plr1->player_no,
+                                          pgiver->player_no, CLAUSE_EMBASSY,
                                           0);
 }
 
Index: common/diptreaty.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.h,v
retrieving revision 1.14
diff -u -r1.14 diptreaty.h
--- common/diptreaty.h  2004/01/31 17:52:41     1.14
+++ common/diptreaty.h  2004/02/27 13:16:01
@@ -18,7 +18,7 @@
 enum clause_type { CLAUSE_ADVANCE, CLAUSE_GOLD, CLAUSE_MAP,
                   CLAUSE_SEAMAP, CLAUSE_CITY, 
                   CLAUSE_CEASEFIRE, CLAUSE_PEACE, CLAUSE_ALLIANCE,
-                  CLAUSE_VISION, CLAUSE_TEAM, CLAUSE_LAST };
+                  CLAUSE_VISION, CLAUSE_TEAM, CLAUSE_EMBASSY, CLAUSE_LAST };
 
 #define is_pact_clause(x)                                                   \
   ((x == CLAUSE_CEASEFIRE) || (x == CLAUSE_PEACE) || (x == CLAUSE_ALLIANCE) \
Index: common/events.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/events.h,v
retrieving revision 1.26
diff -u -r1.26 events.h
--- common/events.h     2004/02/07 11:49:44     1.26
+++ common/events.h     2004/02/27 13:16:01
@@ -106,6 +106,7 @@
   E_WONDER_WILL_BE_BUILT,
   E_DIPLOMACY,
   E_CITY_PRODUCTION_CHANGED,
+  E_TREATY_EMBASSY,
   /* 
    * Note: If you add a new event, make sure you make a similar change
    * to the events array in client/options.c using GEN_EV and to
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.79
diff -u -r1.79 diplhand.c
--- server/diplhand.c   2004/02/19 21:06:42     1.79
+++ server/diplhand.c   2004/02/27 13:16:01
@@ -126,6 +126,13 @@
 
       if (pclause->from == pplayer) {
        switch(pclause->type) {
+       case CLAUSE_EMBASSY:
+          if (player_has_embassy(pother, pplayer)) {
+            freelog(LOG_ERROR, "%s tried to give embassy to %s, who already "
+                    "has an embassy", pplayer->name, pother->name);
+            return;
+          }
+          break;
        case CLAUSE_ADVANCE:
           if (!tech_is_available(pother, pclause->value)) {
            /* It is impossible to give a technology to a civilization that
@@ -331,6 +338,15 @@
       struct player *pdest = (pplayer == pgiver) ? pother : pplayer;
 
       switch (pclause->type) {
+      case CLAUSE_EMBASSY:
+        establish_embassy(pdest, pgiver); /* sic */
+        notify_player_ex(pgiver, -1, -1, E_TREATY_SHARED_VISION,
+                         _("Game: You gave an embassy to %s."),
+                         pdest->name);
+        notify_player_ex(pdest, -1, -1, E_TREATY_SHARED_VISION,
+                         _("Game: %s allowed you to create an embassy!"),
+                         pgiver->name);
+        break;
       case CLAUSE_ADVANCE:
         /* It is possible that two players open the diplomacy dialog
          * and try to give us the same tech at the same time. This

[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Exchange embassies in diplomacy (PR#4800), Per I. Mathisen <=