Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2006:
[Freeciv-Dev] Re: (PR#10052) Apollo & Marco Polo work even when they sho
Home

[Freeciv-Dev] Re: (PR#10052) Apollo & Marco Polo work even when they sho

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: marko.lindqvist@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#10052) Apollo & Marco Polo work even when they should be obsolete
From: "Marko Lindqvist" <cazfi74@xxxxxxxxx>
Date: Sat, 8 Jul 2006 16:49:25 -0700
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=10052 >

Marko Lindqvist wrote:
> 
> Jason Short wrote:
>> But Marko Polo should make contact only one-way, I thought?  That's the 
>> way it was in the old code, and the way it should be (it can be a big 
>> disadvantage for other players to have contact with you).
> 
>   True, but fixing this may be risky. I have impression that some places 
> in current code assume that diplstate between players A->B is same as 
> between B->A. Just how old code are you referring to?

  Patch


  - ML

diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2006-07-08 23:35:33.796875000 +0300
+++ freeciv/server/plrhand.c    2006-07-09 02:33:11.078125000 +0300
@@ -1135,12 +1135,22 @@
 }
 
 /**************************************************************************
-  Update contact info.
+  Update contact info for both parties.
 **************************************************************************/
 void make_contact(struct player *pplayer1, struct player *pplayer2,
-                 struct tile *ptile)
+                   struct tile *ptile)
 {
-  int player1 = pplayer1->player_no, player2 = pplayer2->player_no;
+  make_one_way_contact(pplayer1, pplayer2, ptile);
+  make_one_way_contact(pplayer2, pplayer1, ptile);
+}
+
+/**************************************************************************
+  Update contact info.
+**************************************************************************/
+void make_one_way_contact(struct player *pplayer1, struct player *pplayer2,
+                          struct tile *ptile)
+{
+  int player2 = pplayer2->player_no;
 
   if (pplayer1 == pplayer2
       || !pplayer1->is_alive
@@ -1150,41 +1160,25 @@
   if (get_player_bonus(pplayer1, EFT_NO_DIPLOMACY) == 0
       && get_player_bonus(pplayer2, EFT_NO_DIPLOMACY) == 0) {
     pplayer1->diplstates[player2].contact_turns_left = game.info.contactturns;
-    pplayer2->diplstates[player1].contact_turns_left = game.info.contactturns;
   }
   if (pplayer_get_diplstate(pplayer1, pplayer2)->type == DS_NO_CONTACT) {
     pplayer1->diplstates[player2].type = DS_WAR;
-    pplayer2->diplstates[player1].type = DS_WAR;
     pplayer1->diplstates[player2].first_contact_turn = game.info.turn;
-    pplayer2->diplstates[player1].first_contact_turn = game.info.turn;
     notify_player(pplayer1, ptile,
                     E_FIRST_CONTACT,
                     _("You have made contact with the %s, ruled by %s."),
                     get_nation_name_plural(pplayer2->nation), pplayer2->name);
-    notify_player(pplayer2, ptile,
-                    E_FIRST_CONTACT,
-                    _("You have made contact with the %s, ruled by %s."),
-                    get_nation_name_plural(pplayer1->nation), pplayer1->name);
     if (pplayer1->ai.control) {
       ai_diplomacy_first_contact(pplayer1, pplayer2);
     }
-    if (pplayer2->ai.control && !pplayer1->ai.control) {
-      ai_diplomacy_first_contact(pplayer2, pplayer1);
-    }
-    send_player_info(pplayer1, pplayer2);
     send_player_info(pplayer2, pplayer1);
     send_player_info(pplayer1, pplayer1);
-    send_player_info(pplayer2, pplayer2);
     return;
-  } else {
-    assert(pplayer_get_diplstate(pplayer2, pplayer1)->type != DS_NO_CONTACT);
   }
-  if (player_has_embassy(pplayer1, pplayer2)
-      || player_has_embassy(pplayer2, pplayer1)) {
+  if (player_has_embassy(pplayer1, pplayer2)) {
     return; /* Avoid sending too much info over the network */
   }
   send_player_info(pplayer1, pplayer1);
-  send_player_info(pplayer2, pplayer2);
 }
 
 /**************************************************************************
diff -Nurd -X.diff_ignore freeciv/server/plrhand.h freeciv/server/plrhand.h
--- freeciv/server/plrhand.h    2006-07-08 23:35:33.828125000 +0300
+++ freeciv/server/plrhand.h    2006-07-09 02:24:41.890625000 +0300
@@ -43,6 +43,8 @@
 void check_player_government_rates(struct player *pplayer);
 void make_contact(struct player *pplayer1, struct player *pplayer2,
                  struct tile *ptile);
+void make_one_way_contact(struct player *pplayer1, struct player *pplayer2,
+                          struct tile *ptile);
 void maybe_make_contact(struct tile *ptile, struct player *pplayer);
 
 void send_player_info(struct player *src, struct player *dest);
diff -Nurd -X.diff_ignore freeciv/server/sanitycheck.c 
freeciv/server/sanitycheck.c
--- freeciv/server/sanitycheck.c        2006-07-08 23:35:33.953125000 +0300
+++ freeciv/server/sanitycheck.c        2006-07-09 02:44:16.468750000 +0300
@@ -457,9 +457,11 @@
     } city_list_iterate_end;
 
     players_iterate(pplayer2) {
-      SANITY_CHECK(pplayer->diplstates[pplayer2->player_no].type
-            == pplayer2->diplstates[pplayer->player_no].type);
-      if (pplayer->diplstates[pplayer2->player_no].type == DS_CEASEFIRE) {
+      enum diplstate_type p1top2 = 
pplayer->diplstates[pplayer2->player_no].type;
+      enum diplstate_type p2top1 = 
pplayer2->diplstates[pplayer->player_no].type;
+      SANITY_CHECK(p1top2 == p2top1 || (p1top2 == DS_NO_CONTACT && p2top1 == 
DS_WAR)
+                   || (p1top2 == DS_WAR && p2top1 == DS_NO_CONTACT));
+      if (p1top2 == DS_CEASEFIRE) {
        SANITY_CHECK(pplayer->diplstates[pplayer2->player_no].turns_left
               == pplayer2->diplstates[pplayer->player_no].turns_left);
       }
diff -Nurd -X.diff_ignore freeciv/server/srv_main.c freeciv/server/srv_main.c
--- freeciv/server/srv_main.c   2006-07-08 23:35:35.625000000 +0300
+++ freeciv/server/srv_main.c   2006-07-09 02:24:26.750000000 +0300
@@ -383,7 +383,7 @@
        /* Note this gives pplayer contact with pother, but doesn't give
         * pother contact with pplayer.  This may cause problems in other
         * parts of the code if we're not careful. */
-       make_contact(pplayer, pother, NULL);
+       make_one_way_contact(pplayer, pother, NULL);
       } players_iterate_end;
     }
   } phase_players_iterate_end;

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