Complete.Org: Mailing Lists: Archives: freeciv-dev: March 2004:
[Freeciv-Dev] (PR#8338) city occupied flag & breaking alliances
Home

[Freeciv-Dev] (PR#8338) city occupied flag & breaking alliances

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#8338) city occupied flag & breaking alliances
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Mar 2004 18:41:08 -0800
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Wed Mar 24 02:54:50 2004]:
> 
> When I break an alliance all of the cities I was previously allied with 
> are now labeled as unoccupied.
> 
> Presumably what happens is this:
> 
> When the alliance was intact there was no pcity->occupied value.  Later 
> the alliance is broken and no new occupied value is sent.  However the 
> unit lists are no longer available so the client has no way to know the 
> city is occupied.

Indeed, that is exactly the problem.

At the same time when we remove non-seen units (the units in those
cities) we should send out new city packets to tell about the occupied flag.

This means the calls to remove_allied_visibility need to be moved down,
after the send_player_info calls.  Otherwise the client will get the
short city packet before it knows the alliance is broken.

I will attach as a comment a savegame to reproduce this problem.

jason

? data/civ3
? data/womoks
Index: server/plrhand.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/plrhand.c,v
retrieving revision 1.306
diff -u -r1.306 plrhand.c
--- server/plrhand.c    26 Mar 2004 17:50:33 -0000      1.306
+++ server/plrhand.c    30 Mar 2004 02:38:40 -0000
@@ -1024,13 +1024,6 @@
      illegally, and we need to call resolve_unit_stacks() */
   if (old_type == DS_ALLIANCE) {
     resolve_unit_stacks(pplayer, pplayer2, TRUE);
-
-    /* Inform clients about units that have been hidden.  Units in cities
-     * and transporters are visible to allies but not visible once the
-     * alliance is broken.  We have to call this after resolve_unit_stacks
-     * because that function may change units' locations. */
-    remove_allied_visibility(pplayer, pplayer2);
-    remove_allied_visibility(pplayer2, pplayer);
   }
 
   /* We want to go all the way to war, whatever the cost! 
@@ -1073,6 +1066,19 @@
 
   send_player_info(pplayer, NULL);
   send_player_info(pplayer2, NULL);
+
+
+  if (old_type == DS_ALLIANCE) {
+    /* Inform clients about units that have been hidden.  Units in cities
+     * and transporters are visible to allies but not visible once the
+     * alliance is broken.  We have to call this after resolve_unit_stacks
+     * because that function may change units' locations.  It also sends
+     * out new city info packets to tell the client about occupied cities,
+     * so it should also come after the send_player_info calls above. */
+    remove_allied_visibility(pplayer, pplayer2);
+    remove_allied_visibility(pplayer2, pplayer);
+  }
+
 
   /* 
    * Refresh all cities which have a unit of the other side within
Index: server/unittools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/unittools.c,v
retrieving revision 1.286
diff -u -r1.286 unittools.c
--- server/unittools.c  15 Mar 2004 21:57:34 -0000      1.286
+++ server/unittools.c  30 Mar 2004 02:38:41 -0000
@@ -1434,6 +1434,13 @@
       unit_goes_out_of_sight(pplayer, punit);
     }
   } unit_list_iterate_end;
+
+  city_list_iterate(aplayer->cities, pcity) {
+    /* The player used to know what units were in these cities.  Now that he
+     * doesn't, he needs to get a new short city packet updating the
+     * occupied status. */
+    send_city_info(pplayer, pcity);
+  } city_list_iterate_end;
 }
 
 /**************************************************************************

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