Complete.Org: Mailing Lists: Archives: freeciv-dev: April 2003:
[Freeciv-Dev] Re: (PR#3745) Diplomacy patch (alpha version)
Home

[Freeciv-Dev] Re: (PR#3745) Diplomacy patch (alpha version)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients:;
Subject: [Freeciv-Dev] Re: (PR#3745) Diplomacy patch (alpha version)
From: "Per I. Mathisen" <per@xxxxxxxxxxx>
Date: Mon, 7 Apr 2003 13:12:11 -0700
Reply-to: rt@xxxxxxxxxxxxxx

On Sat, 5 Apr 2003, Jason Short wrote:
> I think this patch is overlarge.
>
> Many of the features can be split up, I think.Introducing them
> piecemeal will get better review and makes it easier for the GUI code to
> be written for them.

Ok. I've ripped out the first part.

This smaller patch does:
 - "No contact" is rephrased as "Never met", otherwise same.
 - "Contact" is now a new mode, which means units of these players have
been adjacent within the previous X turns, where X is a server set
variable. If this server variable is zero, this feature is turned off.
 - You can Meet with any player with embassy to you or that you have
embassy to or that you have Contact with.
 - Tech dialog is updated correctly in some rare cases where it wasn't.
 - All GUIs updated.

  - Per

Index: client/civclient.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/civclient.c,v
retrieving revision 1.166
diff -u -r1.166 civclient.c
--- client/civclient.c  2003/04/04 15:47:45     1.166
+++ client/civclient.c  2003/04/07 20:08:09
@@ -32,6 +32,7 @@
 #endif
 
 #include "capstr.h"
+#include "diptreaty.h"
 #include "fcintl.h"
 #include "game.h"
 #include "idex.h"
@@ -839,10 +840,7 @@
 **************************************************************************/
 bool can_meet_with_player(struct player *pplayer)
 {
-  return (pplayer->is_alive
-          && pplayer != game.player_ptr
-          && player_has_embassy(game.player_ptr, pplayer)
-          && pplayer->is_connected
+  return (could_meet_with_player(game.player_ptr, pplayer)
           && can_client_issue_orders());
 }
 
Index: client/climisc.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/climisc.c,v
retrieving revision 1.117
diff -u -r1.117 climisc.c
--- client/climisc.c    2003/04/06 18:24:36     1.117
+++ client/climisc.c    2003/04/07 20:08:09
@@ -195,7 +195,9 @@
 ***************************************************************************/
 const char *get_embassy_status(struct player *me, struct player *them)
 {
-  if (me == them) {
+  if (me == them
+      || !them->is_alive
+      || !me->is_alive) {
     return "-";
   }
   if (player_has_embassy(me, them)) {
@@ -206,6 +208,9 @@
     }
   } else if (player_has_embassy(them, me)) {
     return Q_("?embassy:With Us");
+  } else if (me->diplstates[them->player_no].contact_turns_left > 0
+             || them->diplstates[me->player_no].contact_turns_left > 0) {
+    return Q_("?embassy:Contact");
   } else {
     return "";
   }
Index: client/packhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/packhand.c,v
retrieving revision 1.299
diff -u -r1.299 packhand.c
--- client/packhand.c   2003/04/04 15:47:46     1.299
+++ client/packhand.c   2003/04/07 20:08:10
@@ -1196,7 +1196,7 @@
 /**************************************************************************
 ...
 **************************************************************************/
-static void read_player_info_techs(struct player *pplayer,
+static bool read_player_info_techs(struct player *pplayer,
                                   unsigned char *inventions)
 {
   int i;
@@ -1216,6 +1216,7 @@
     /* nothing yet */
   }
   update_research(pplayer);
+  return need_effect_update;
 }
 
 /**************************************************************************
@@ -1280,7 +1281,7 @@
 void handle_player_info(struct packet_player_info *pinfo)
 {
   int i;
-  bool poptechup;
+  bool poptechup = FALSE;
   char msg[MAX_LEN_MSG];
   struct player *pplayer = &game.players[pinfo->playerno];
 
@@ -1304,6 +1305,8 @@
       pinfo->diplstates[i].type;
     pplayer->diplstates[i].turns_left =
       pinfo->diplstates[i].turns_left;
+    pplayer->diplstates[i].contact_turns_left =
+      pinfo->diplstates[i].contact_turns_left;
     pplayer->diplstates[i].has_reason_to_cancel =
       pinfo->diplstates[i].has_reason_to_cancel;
   }
@@ -1314,10 +1317,12 @@
   if (pplayer->is_connected
       || get_client_state() == CLIENT_GAME_RUNNING_STATE
       || get_client_state() == CLIENT_GAME_OVER_STATE) {
-    read_player_info_techs(pplayer, pinfo->inventions);
+    poptechup = poptechup || read_player_info_techs(pplayer, 
pinfo->inventions);
   }
 
-  poptechup = (pplayer->research.researching!=pinfo->researching);
+  poptechup = (pplayer->research.researching != pinfo->researching
+               || pplayer->ai.tech_goal != pinfo->tech_goal
+               || poptechup);
   pplayer->research.bulbs_researched = pinfo->bulbs_researched;
   pplayer->research.techs_researched = pinfo->techs_researched;
   pplayer->research.researching=pinfo->researching;
Index: client/gui-gtk/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/plrdlg.c,v
retrieving revision 1.45
diff -u -r1.45 plrdlg.c
--- client/gui-gtk/plrdlg.c     2003/04/04 15:47:47     1.45
+++ client/gui-gtk/plrdlg.c     2003/04/07 20:08:10
@@ -535,7 +535,7 @@
   row = GPOINTER_TO_INT(selection->data);
   player_index = LI_2_PI(row);
 
-  if(player_has_embassy(game.player_ptr, &game.players[player_index])) {
+  if (can_meet_with_player(&game.players[player_index])) {
     struct packet_diplomacy_info pa;
   
     pa.plrno0=game.player_idx;
@@ -611,8 +611,9 @@
   row = GPOINTER_TO_INT(selection->data);
   player_index = LI_2_PI(row);
 
-  if(player_has_embassy(game.player_ptr, &game.players[player_index]))
+  if (can_intel_with_player(&game.players[player_index])) {
     popup_intel_dialog(&game.players[player_index]);
+  }
 }
 
 /**************************************************************************
Index: client/gui-gtk-2.0/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk-2.0/plrdlg.c,v
retrieving revision 1.19
diff -u -r1.19 plrdlg.c
--- client/gui-gtk-2.0/plrdlg.c 2003/04/04 15:47:47     1.19
+++ client/gui-gtk-2.0/plrdlg.c 2003/04/07 20:08:10
@@ -567,7 +567,7 @@
     return;
   gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
 
-  if(player_has_embassy(game.player_ptr, &game.players[plrno])) {
+  if (can_meet_with_player(&game.players[plrno])) {
     struct packet_diplomacy_info pa;
   
     pa.plrno0=game.player_idx;
@@ -635,8 +635,9 @@
     return;
   gtk_tree_model_get(model, &it, PLRNO_COLUMN, &plrno, -1);
 
-  if(player_has_embassy(game.player_ptr, &game.players[plrno]))
+  if (can_intel_with_player(&game.players[plrno])) {
     popup_intel_dialog(&game.players[plrno]);
+  }
 }
 
 /**************************************************************************
Index: client/gui-mui/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-mui/plrdlg.c,v
retrieving revision 1.27
diff -u -r1.27 plrdlg.c
--- client/gui-mui/plrdlg.c     2003/01/05 20:51:37     1.27
+++ client/gui-mui/plrdlg.c     2003/04/07 20:08:10
@@ -231,8 +231,9 @@
   {
     playerno -= 100;
 
-    if (player_has_embassy(game.player_ptr, &game.players[playerno]))
+    if (can_intel_with_player(&game.players[playerno])) {
       popup_intel_dialog(&game.players[playerno]);
+    }
   }
 }
 
@@ -248,10 +249,12 @@
   {
     playerno -= 100;
 
-    if (player_has_embassy(game.player_ptr, &game.players[playerno]))
-    {
+    if (can_meet_with_player(&game.players[playerno])) {
       request_diplomacy_init_meeting(game.player_idx, playerno);
-    } else append_output_window(_("Game: You need an embassy to establish a 
diplomatic meeting."));
+    } else {
+      append_output_window(_("Game: You need an embassy to establish a "
+                             "diplomatic meeting."));
+    }
   }
 }
 
Index: client/gui-win32/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-win32/plrdlg.c,v
retrieving revision 1.13
diff -u -r1.13 plrdlg.c
--- client/gui-win32/plrdlg.c   2003/04/04 15:47:48     1.13
+++ client/gui-win32/plrdlg.c   2003/04/07 20:08:10
@@ -64,8 +64,9 @@
 *******************************************************************/
 static void players_meet(int player_index)
 {
-  if (player_has_embassy(game.player_ptr,&game.players[player_index])) {
+  if (can_meet_with_player(&game.players[player_index])) {
     struct packet_diplomacy_info pa;
+
     pa.plrno0=game.player_idx;
     pa.plrno1=player_index;
     pa.plrno_from=pa.plrno0;
@@ -105,9 +106,9 @@
 *******************************************************************/
 static void players_intel(int player_index)
 {
-  if(player_has_embassy(game.player_ptr, &game.players[player_index]))
+  if (can_intel_with_player(&game.players[player_index])) {
     popup_intel_dialog(&game.players[player_index]);
-  
+  } 
 }
 
 /******************************************************************
Index: client/gui-xaw/plrdlg.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-xaw/plrdlg.c,v
retrieving revision 1.35
diff -u -r1.35 plrdlg.c
--- client/gui-xaw/plrdlg.c     2003/01/05 20:51:37     1.35
+++ client/gui-xaw/plrdlg.c     2003/04/07 20:08:10
@@ -348,7 +348,7 @@
 
   if(ret->list_index!=XAW_LIST_NONE) {
     int player_index = list_index_to_player_index[ret->list_index];
-    if(player_has_embassy(game.player_ptr, &game.players[player_index])) {
+    if (can_meet_with_player(&game.players[player_index])) {
       struct packet_diplomacy_info pa;
 
       pa.plrno0=game.player_idx;
@@ -376,8 +376,10 @@
 
   if(ret->list_index!=XAW_LIST_NONE) {
     int player_index = list_index_to_player_index[ret->list_index];
-    if(player_has_embassy(game.player_ptr, &game.players[player_index]))
+
+    if (can_intel_with_player(&game.players[player_index])) {
       popup_intel_dialog(&game.players[player_index]);
+    }
   }
 }
 
Index: common/capstr.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/capstr.c,v
retrieving revision 1.130
diff -u -r1.130 capstr.c
--- common/capstr.c     2003/04/04 15:47:48     1.130
+++ common/capstr.c     2003/04/07 20:08:10
@@ -77,7 +77,7 @@
 #define CAPABILITY "+1.14.0 conn_info +occupied team tech_impr_gfx " \
                    "city_struct_minor_cleanup obsolete_last class_legend " \
                    "+impr_req +waste +fastfocus +continent +small_dipl " \
-                   "+no_nation_selected"
+                   "+no_nation_selected +diplomacy"
 /* "+1.14.0" is protocol for 1.14.0 release.
  *
  * "conn_info" is sending the conn_id field. To preserve compatability
@@ -115,6 +115,8 @@
  *
  * "no_nation_selected" means that -1 (NO_NATION_SELECTED) is used for
  * players who have no assigned nation (rather than MAX_NUM_NATIONS).
+ *
+ * "diplomacy": changed requirements for diplomatic meetings
  */
 
 void init_our_capability(void)
Index: common/diptreaty.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.c,v
retrieving revision 1.14
diff -u -r1.14 diptreaty.c
--- common/diptreaty.c  2002/11/15 21:24:30     1.14
+++ common/diptreaty.c  2003/04/07 20:08:10
@@ -28,6 +28,22 @@
 #define SPECLIST_TYPE struct Clause
 #include "speclist_c.h"
 
+/**************************************************************************
+  Returns TRUE iff pplayer could do diplomatic meetings with aplayer.
+**************************************************************************/
+bool could_meet_with_player(struct player *pplayer, struct player *aplayer)
+{
+  return (pplayer->is_alive
+          && aplayer->is_alive
+          && pplayer != aplayer
+          && (player_has_embassy(aplayer, pplayer) 
+              || player_has_embassy(pplayer, aplayer)
+              || pplayer->diplstates[aplayer->player_no].contact_turns_left > 0
+              || aplayer->diplstates[pplayer->player_no].contact_turns_left > 
0)
+          && aplayer->is_connected
+          && pplayer->is_connected);
+}
+
 /****************************************************************
 ...
 *****************************************************************/
Index: common/diptreaty.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/diptreaty.h,v
retrieving revision 1.9
diff -u -r1.9 diptreaty.h
--- common/diptreaty.h  2002/11/15 21:24:30     1.9
+++ common/diptreaty.h  2003/04/07 20:08:10
@@ -45,6 +45,8 @@
   struct clause_list clauses;
 };
 
+bool could_meet_with_player(struct player *pplayer, struct player *aplayer);
+
 void init_treaty(struct Treaty *ptreaty, 
                 struct player *plr0, struct player *plr1);
 bool add_clause(struct Treaty *ptreaty, struct player *pfrom, 
Index: common/game.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.c,v
retrieving revision 1.159
diff -u -r1.159 game.c
--- common/game.c       2003/04/04 15:47:49     1.159
+++ common/game.c       2003/04/07 20:08:10
@@ -674,6 +674,7 @@
   game.cityfactor  = GAME_DEFAULT_CITYFACTOR;
   game.citymindist = GAME_DEFAULT_CITYMINDIST;
   game.civilwarsize= GAME_DEFAULT_CIVILWARSIZE;
+  game.contactturns= GAME_DEFAULT_CONTACTTURNS;
   game.rapturedelay= GAME_DEFAULT_RAPTUREDELAY;
   game.savepalace  = GAME_DEFAULT_SAVEPALACE;
   game.natural_city_names = GAME_DEFAULT_NATURALCITYNAMES;
Index: common/game.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/game.h,v
retrieving revision 1.120
diff -u -r1.120 game.h
--- common/game.h       2003/04/04 15:47:49     1.120
+++ common/game.h       2003/04/07 20:08:10
@@ -85,6 +85,7 @@
   int cityfactor;
   int citymindist;
   int civilwarsize;
+  int contactturns;
   int rapturedelay;
   int min_players, max_players, nplayers;
   int aifill;
@@ -335,6 +336,10 @@
 #define GAME_DEFAULT_CIVILWARSIZE    10
 #define GAME_MIN_CIVILWARSIZE        6
 #define GAME_MAX_CIVILWARSIZE        1000
+
+#define GAME_DEFAULT_CONTACTTURNS    20
+#define GAME_MIN_CONTACTTURNS        0
+#define GAME_MAX_CONTACTTURNS        100
 
 #define GAME_DEFAULT_RAPTUREDELAY    1
 #define GAME_MIN_RAPTUREDELAY        1
Index: common/packets.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/packets.c,v
retrieving revision 1.243
diff -u -r1.243 packets.c
--- common/packets.c    2003/04/04 15:47:49     1.243
+++ common/packets.c    2003/04/07 20:08:10
@@ -877,6 +877,7 @@
   for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
     dio_put_uint8(&dout, pinfo->diplstates[i].type);
     dio_put_uint8(&dout, pinfo->diplstates[i].turns_left);
+    dio_put_uint8(&dout, pinfo->diplstates[i].contact_turns_left);
     dio_put_uint8(&dout, pinfo->diplstates[i].has_reason_to_cancel);
   }
 
@@ -934,6 +935,7 @@
   for (i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
     dio_get_uint8(&din, (int *) &pinfo->diplstates[i].type);
     dio_get_uint8(&din, &pinfo->diplstates[i].turns_left);
+    dio_get_uint8(&din, &pinfo->diplstates[i].contact_turns_left);
     dio_get_uint8(&din, &pinfo->diplstates[i].has_reason_to_cancel);
   }
 
Index: common/player.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.c,v
retrieving revision 1.114
diff -u -r1.114 player.c
--- common/player.c     2003/04/01 17:19:49     1.114
+++ common/player.c     2003/04/07 20:08:10
@@ -84,6 +84,7 @@
   for(i = 0; i < MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS; i++) {
     plr->diplstates[i].type = DS_NO_CONTACT;
     plr->diplstates[i].has_reason_to_cancel = 0;
+    plr->diplstates[i].contact_turns_left = 0;
   }
   plr->city_style=0;            /* should be first basic style */
   plr->ai.control=FALSE;
@@ -489,7 +490,7 @@
 }
 
 /**************************************************************************
-Return a diplomatic state as a human-readable string
+  Return a diplomatic state as a human-readable string
 **************************************************************************/
 const char *diplstate_text(const enum diplstate_type type)
 {
@@ -500,11 +501,12 @@
     N_("?diplomatic_state:Cease-fire"),
     N_("?diplomatic_state:Peace"),
     N_("?diplomatic_state:Alliance"),
-    N_("?diplomatic_state:No Contact")
+    N_("?diplomatic_state:Never met")
   };
 
-  if (type < DS_LAST)
+  if (type < DS_LAST) {
     return Q_(ds_names[type]);
+  }
   die("Bad diplstate_type in diplstate_text: %d", type);
   return NULL;
 }
Index: common/player.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/common/player.h,v
retrieving revision 1.96
diff -u -r1.96 player.h
--- common/player.h     2003/03/05 12:53:27     1.96
+++ common/player.h     2003/04/07 20:08:10
@@ -156,6 +156,7 @@
   /* the following are for "pacts" */
   int turns_left;              /* until pact (e.g., cease-fire) ends */
   int has_reason_to_cancel;    /* 0: no, 1: this turn, 2: this or next turn */
+  int contact_turns_left;      /* until contact ends */
 };
 
 /***************************************************************************
Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.214
diff -u -r1.214 citytools.c
--- server/citytools.c  2003/03/07 05:14:40     1.214
+++ server/citytools.c  2003/04/07 20:08:10
@@ -912,11 +912,11 @@
   city_refresh(pcity);
 
   /* 
-   * maybe_make_first_contact have to be called before
+   * maybe_make_contact have to be called before
    * update_city_tile_status_map below since the diplomacy status can
    * influence if a tile is available.
    */
-  maybe_make_first_contact(pcity->x, pcity->y, ptaker);
+  maybe_make_contact(pcity->x, pcity->y, ptaker);
 
   map_city_radius_iterate(pcity->x, pcity->y, x, y) {
     update_city_tile_status_map(pcity, x, y);
@@ -1117,7 +1117,7 @@
 
   notify_player_ex(pplayer, x, y, E_CITY_BUILD,
                   _("Game: You have founded %s"), pcity->name);
-  maybe_make_first_contact(x, y, city_owner(pcity));
+  maybe_make_contact(x, y, city_owner(pcity));
 
   /* Catch fortress building, transforming into ocean, etc. */
   unit_list_iterate(map_get_tile(x, y)->units, punit) {
Index: server/diplhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/diplhand.c,v
retrieving revision 1.67
diff -u -r1.67 diplhand.c
--- server/diplhand.c   2003/04/04 15:47:49     1.67
+++ server/diplhand.c   2003/04/07 20:08:10
@@ -549,8 +549,7 @@
       return;
     }
 
-    if (player_has_embassy(plr0, plr1) && plr0->is_connected && 
-       plr0->is_alive && plr1->is_connected && plr1->is_alive) {
+    if (could_meet_with_player(plr0, plr1)) {
       struct Treaty *ptreaty;
 
       ptreaty=fc_malloc(sizeof(struct Treaty));
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.264
diff -u -r1.264 plrhand.c
--- server/plrhand.c    2003/04/04 15:47:50     1.264
+++ server/plrhand.c    2003/04/07 20:08:11
@@ -1183,6 +1183,8 @@
     for(i=0; i<MAX_NUM_PLAYERS+MAX_NUM_BARBARIANS; i++) {
       packet->diplstates[i].type       = plr->diplstates[i].type;
       packet->diplstates[i].turns_left = plr->diplstates[i].turns_left;
+      packet->diplstates[i].contact_turns_left = 
+         plr->diplstates[i].contact_turns_left;
       packet->diplstates[i].has_reason_to_cancel = 
plr->diplstates[i].has_reason_to_cancel;
     }
   } else {
@@ -1208,12 +1210,15 @@
       packet->diplstates[i].type       = DS_NEUTRAL;
       packet->diplstates[i].turns_left = 0;
       packet->diplstates[i].has_reason_to_cancel = 0;
+      packet->diplstates[i].contact_turns_left = 0;
     }
     /* We always know the players relation to us */
     if (receiver) {
       int p_no = receiver->player_no;
       packet->diplstates[p_no].type       = plr->diplstates[p_no].type;
       packet->diplstates[p_no].turns_left = plr->diplstates[p_no].turns_left;
+      packet->diplstates[i].contact_turns_left = 
+         plr->diplstates[i].contact_turns_left;
       packet->diplstates[p_no].has_reason_to_cancel =
        plr->diplstates[p_no].has_reason_to_cancel;
     }
@@ -1310,7 +1315,7 @@
 }
 
 /**************************************************************************
-...
+  Update contact info.
 **************************************************************************/
 void make_contact(struct player *pplayer1, struct player *pplayer2,
                  int x, int y)
@@ -1319,39 +1324,48 @@
 
   if (pplayer1 == pplayer2
       || !pplayer1->is_alive || !pplayer2->is_alive
-      || is_barbarian(pplayer1) || is_barbarian(pplayer2)
-      || pplayer_get_diplstate(pplayer1, pplayer2)->type != DS_NO_CONTACT)
+      || is_barbarian(pplayer1) || is_barbarian(pplayer2)) {
     return;
+  }
 
-  /* FIXME: Always declairing war for the AI is a kludge until AI
+  /* FIXME: Always declaring war for the AI is a kludge until AI
      diplomacy is implemented. */
-  pplayer1->diplstates[player2].type
-    = pplayer2->diplstates[player1].type
-    = pplayer1->ai.control || pplayer2->ai.control ? DS_WAR : DS_NEUTRAL;
-  notify_player_ex(pplayer1, x, y,
-                  E_FIRST_CONTACT,
-                  _("Game: You have made contact with the %s, ruled by %s."),
-                  get_nation_name_plural(pplayer2->nation), pplayer2->name);
-  notify_player_ex(pplayer2, x, y,
-                  E_FIRST_CONTACT,
-                  _("Game: You have made contact with the %s, ruled by %s."),
-                  get_nation_name_plural(pplayer1->nation), pplayer1->name);
+  if (pplayer_get_diplstate(pplayer1, pplayer2)->type == DS_NO_CONTACT) {
+    pplayer1->diplstates[player2].type
+      = pplayer2->diplstates[player1].type
+      = pplayer1->ai.control || pplayer2->ai.control ? DS_WAR : DS_NEUTRAL;
+    notify_player_ex(pplayer1, x, y,
+                    E_FIRST_CONTACT,
+                    _("Game: You have made contact with the %s, ruled by %s."),
+                    get_nation_name_plural(pplayer2->nation), pplayer2->name);
+    notify_player_ex(pplayer2, x, y,
+                    E_FIRST_CONTACT,
+                    _("Game: You have made contact with the %s, ruled by %s."),
+                    get_nation_name_plural(pplayer1->nation), pplayer1->name);
+    send_player_info(pplayer1, pplayer2);
+    send_player_info(pplayer2, pplayer1);
+  }
+  if (player_has_embassy(pplayer1, pplayer2)
+      || player_has_embassy(pplayer2, pplayer1)) {
+    return;
+  }
+  pplayer1->diplstates[player2].contact_turns_left = game.contactturns;
+  pplayer2->diplstates[player1].contact_turns_left = game.contactturns;
   send_player_info(pplayer1, pplayer1);
-  send_player_info(pplayer1, pplayer2);
-  send_player_info(pplayer2, pplayer1);
   send_player_info(pplayer2, pplayer2);
 }
 
 /**************************************************************************
-...
+  Check if we make contact with anyone.
 **************************************************************************/
-void maybe_make_first_contact(int x, int y, struct player *pplayer)
+void maybe_make_contact(int x, int y, struct player *pplayer)
 {
   square_iterate(x, y, 1, x_itr, y_itr) {
     struct tile *ptile = map_get_tile(x_itr, y_itr);
     struct city *pcity = ptile->city;
-    if (pcity)
+    if (pcity) {
       make_contact(pplayer, city_owner(pcity), x, y);
+    }
     unit_list_iterate(ptile->units, punit) {
       make_contact(pplayer, unit_owner(punit), x, y);
     } unit_list_iterate_end;
Index: server/plrhand.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.h,v
retrieving revision 1.52
diff -u -r1.52 plrhand.h
--- server/plrhand.h    2003/03/24 22:20:58     1.52
+++ server/plrhand.h    2003/04/07 20:08:11
@@ -37,7 +37,7 @@
 void handle_player_cancel_pact(struct player *pplayer, int other_player);
 void make_contact(struct player *pplayer1, struct player *pplayer2, int x,
                  int y);
-void maybe_make_first_contact(int x, int y, struct player *pplayer);
+void maybe_make_contact(int x, int y, struct player *pplayer);
 
 void send_player_info(struct player *src, struct player *dest);
 void send_player_info_c(struct player *src, struct conn_list *dest);
Index: server/savegame.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/savegame.c,v
retrieving revision 1.114
diff -u -r1.114 savegame.c
--- server/savegame.c   2003/02/17 22:49:28     1.114
+++ server/savegame.c   2003/04/07 20:08:11
@@ -37,6 +37,7 @@
 
 #include "citytools.h"
 #include "cityturn.h"
+#include "diplhand.h"
 #include "mapgen.h"
 #include "maphand.h"
 #include "meta.h"
@@ -700,6 +701,9 @@
       secfile_lookup_int_default(file, 0,
                                 "player%d.diplstate%d.has_reason_to_cancel",
                                 plrno, i);
+    plr->diplstates[i].contact_turns_left = 
+      secfile_lookup_int_default(file, 0,
+                          "player%d.diplstate%d.contact_turns_left", plrno, i);
   }
   /* We don't need this info, but savegames carry it anyway.
      To avoid getting "unused" warnings we touch the values like this. */
@@ -711,6 +715,8 @@
     secfile_lookup_int_default(file, 0,
                               "player%d.diplstate%d.has_reason_to_cancel",
                               plrno, i);
+    secfile_lookup_int_default(file, 0,
+                          "player%d.diplstate%d.contact_turns_left", plrno, i);
   }
   
   { /* spacerace */
@@ -1335,6 +1341,8 @@
                       "player%d.diplstate%d.turns_left", plrno, i);
     secfile_insert_int(file, plr->diplstates[i].has_reason_to_cancel,
                       "player%d.diplstate%d.has_reason_to_cancel", plrno, i);
+    secfile_insert_int(file, plr->diplstates[i].contact_turns_left,
+                      "player%d.diplstate%d.contact_turns_left", plrno, i);
   }
 
   {
@@ -1874,6 +1882,9 @@
     game.civilwarsize =
       secfile_lookup_int_default(file, GAME_DEFAULT_CIVILWARSIZE,
                                 "game.civilwarsize");
+    game.contactturns =
+      secfile_lookup_int_default(file, GAME_DEFAULT_CONTACTTURNS,
+                                "game.contactturns");
   
     if(has_capability("diplchance_percent", savefile_options)) {
       game.diplchance = secfile_lookup_int_default(file, game.diplchance,
@@ -2209,6 +2220,7 @@
   secfile_insert_int(file, game.cityfactor, "game.cityfactor");
   secfile_insert_int(file, game.citymindist, "game.citymindist");
   secfile_insert_int(file, game.civilwarsize, "game.civilwarsize");
+  secfile_insert_int(file, game.contactturns, "game.contactturns");
   secfile_insert_int(file, game.rapturedelay, "game.rapturedelay");
   secfile_insert_int(file, game.diplcost, "game.diplcost");
   secfile_insert_int(file, game.freecost, "game.freecost");
Index: server/srv_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/srv_main.c,v
retrieving revision 1.120
diff -u -r1.120 srv_main.c
--- server/srv_main.c   2003/04/06 21:44:07     1.120
+++ server/srv_main.c   2003/04/07 20:08:11
@@ -380,6 +380,9 @@
       pdiplstate->has_reason_to_cancel =
          MAX(pdiplstate->has_reason_to_cancel - 1, 0);
 
+      pdiplstate->contact_turns_left =
+         MAX(pdiplstate->contact_turns_left - 1, 0);
+
       if(pdiplstate->type == DS_CEASEFIRE) {
        switch(--pdiplstate->turns_left) {
        case 1:
Index: server/stdinhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/stdinhand.c,v
retrieving revision 1.274
diff -u -r1.274 stdinhand.c
--- server/stdinhand.c  2003/04/04 15:47:50     1.274
+++ server/stdinhand.c  2003/04/07 20:08:11
@@ -632,6 +632,15 @@
          GAME_MIN_CIVILWARSIZE, GAME_MAX_CIVILWARSIZE, 
          GAME_DEFAULT_CIVILWARSIZE)
 
+  GEN_INT("contactturns", game.contactturns, SSET_RULES_FLEXIBLE,
+         SSET_TO_CLIENT,
+         N_("Number of turns players may meet after contact"),
+         N_("Players may meet for diplomacy this number of turns "
+            "after their units have last met. Set this to zero "
+            "to turn this feature off entirely."), NULL,
+         GAME_MIN_CONTACTTURNS, GAME_MAX_CONTACTTURNS, 
+         GAME_DEFAULT_CONTACTTURNS)
+
   GEN_BOOL("savepalace", game.savepalace, SSET_RULES_FLEXIBLE, SSET_TO_CLIENT,
           N_("Rebuild palace if capital is conquered"),
           N_("If this is set to 1 when the capital is conquered, palace "
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.217
diff -u -r1.217 unittools.c
--- server/unittools.c  2003/04/04 15:47:50     1.217
+++ server/unittools.c  2003/04/07 20:08:11
@@ -1641,7 +1641,7 @@
     unfog_area(pplayer, x, y, unit_type(punit)->vision_range);
 
   send_unit_info(NULL, punit);
-  maybe_make_first_contact(x, y, unit_owner(punit));
+  maybe_make_contact(x, y, unit_owner(punit));
   wakeup_neighbor_sentries(punit);
 
   /* The unit may have changed the available tiles in nearby cities. */
@@ -2254,7 +2254,7 @@
       || is_non_allied_unit_tile(ptile, pplayer)) {
     int srange = unit_type(punit)->vision_range;
     show_area(pplayer, dest_x, dest_y, srange);
-    maybe_make_first_contact(dest_x, dest_y, pplayer);
+    maybe_make_contact(dest_x, dest_y, pplayer);
     notify_player_ex(pplayer, dest_x, dest_y, E_UNIT_LOST_ATT,
                      _("Game: Your %s was killed by enemy units at the "
                        "paradrop destination."),
@@ -3020,7 +3020,7 @@
 
   handle_unit_move_consequences(punit, src_x, src_y, dest_x, dest_y);
   wakeup_neighbor_sentries(punit);
-  maybe_make_first_contact(dest_x, dest_y, unit_owner(punit));
+  maybe_make_contact(dest_x, dest_y, unit_owner(punit));
 
   conn_list_do_unbuffer(&pplayer->connections);
 

[Prev in Thread] Current Thread [Next in Thread]