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: Sun, 9 Jul 2006 06:39:43 -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).
> 
>   Patch

  - Fixed is_valid_alliance() to handle one-way war.


  - ML

diff -Nurd -X.diff_ignore freeciv/common/player.c freeciv/common/player.c
--- freeciv/common/player.c     2006-07-09 16:24:38.265625000 +0300
+++ freeciv/common/player.c     2006-07-09 16:24:14.343750000 +0300
@@ -77,11 +77,12 @@
 {
   players_iterate(pplayer) {
     enum diplstate_type ds = pplayer_get_diplstate(p1, pplayer)->type;
+    enum diplstate_type ds2 = pplayer_get_diplstate(pplayer, p1)->type;
 
     if (pplayer != p1
         && pplayer != p2
         && pplayers_allied(p2, pplayer)
-        && ds == DS_WAR /* do not count 'never met' as war here */
+        && (ds == DS_WAR || ds2 == DS_WAR) /* do not count 'never met' as war 
here */
         && pplayer->is_alive) {
       return FALSE;
     }
diff -Nurd -X.diff_ignore freeciv/server/plrhand.c freeciv/server/plrhand.c
--- freeciv/server/plrhand.c    2006-07-09 16:26:36.625000000 +0300
+++ freeciv/server/plrhand.c    2006-07-09 16:24:06.953125000 +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-09 16:26:37.109375000 +0300
+++ freeciv/server/plrhand.h    2006-07-09 16:24:06.953125000 +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-09 16:26:37.250000000 +0300
+++ freeciv/server/sanitycheck.c        2006-07-09 16:24:06.984375000 +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-09 16:26:39.562500000 +0300
+++ freeciv/server/srv_main.c   2006-07-09 16:24:07.000000000 +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]