Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2004:
[Freeciv-Dev] Re: (PR#7408) unit_list_size(&ptile->units) == 0 Again (Se
Home

[Freeciv-Dev] Re: (PR#7408) unit_list_size(&ptile->units) == 0 Again (Se

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#7408) unit_list_size(&ptile->units) == 0 Again (Sea barbarians)
From: "mateusz stefek" <matusik_s@xxxxx>
Date: Wed, 18 Feb 2004 01:36:30 -0800
Reply-to: rt@xxxxxxxxxxx

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


Dnia 2004.02.17 09:34, mateusz stefek napisał(a):
> 
> <URL: http://rt.freeciv.org/Ticket/Display.html?id=7408 >
> 
> On 2004.02.16 08:49, Jason Short wrote:
> > <URL: http://rt.freeciv.org/Ticket/Display.html?id=7408 >
> > 
> > mateusz stefek wrote:
> > 
> > > There's another problem: Suppose that Player B has a loaded transport 
> > > within sight of player A. They have shared vision.
> > > Then player B removes shared vision and moves his transport. Server 
> > > doesn't remove units inside transport from A's client.
> 
> Strange, This bug "works wrong". When B shares vision with A, A shouldn't be 
> able to see units inside B's transport anyway. This bug is supposed to occur 
> only when B cancels alliance. (Bug "works" also when players are at war, but 
> with shared vision)
> Probably problem is in move_unit(). It somehow sends transported units to 
> onlookers when transport moves.
>  
> > Argh!  And I guess for units in cities, too?
> > 
> > Solutions:
> > 
> > - Server detects when alliances change and goes over every unit to see 
> > if it must be removed.
> 
> It would be very hard because shared vision is transitive and alliance is not 
> equivalent to shared vision in this case. (Transported units are shown when 
> players are allied, not when they share vision)
> 
Not so hard. Patch attached.
--
mateusz
diff -Xdiff_ignore -ur freeorig/server/plrhand.c freeciv/server/plrhand.c
--- freeorig/server/plrhand.c   2004-02-09 09:41:58.000000000 +0100
+++ freeciv/server/plrhand.c    2004-02-18 10:11:51.000000000 +0100
@@ -1055,6 +1055,8 @@
      illegally, and we need to call resolve_unit_stacks() */
   if (old_type == DS_ALLIANCE) {
     resolve_unit_stacks(pplayer, pplayer2, TRUE);
+    remove_allied_visibility(pplayer, pplayer2);
+    remove_allied_visibility(pplayer2, pplayer);
   }
 
   /* We want to go all the way to war, whatever the cost! 
Tylko w freeciv/server: test.gz
diff -Xdiff_ignore -ur freeorig/server/unittools.c freeciv/server/unittools.c
--- freeorig/server/unittools.c 2004-02-09 09:41:58.000000000 +0100
+++ freeciv/server/unittools.c  2004-02-18 10:30:16.000000000 +0100
@@ -1406,6 +1406,21 @@
 }
 
 /**************************************************************************
+pplayer and aplayer canceled alliance. We have to inform clients that they
+cannot see unit in transports and in cities. Note that this function should
+be called _after_ resolve_unit_stacks()
+**************************************************************************/
+void remove_allied_visibility(struct player* pplayer, struct player* aplayer)
+{
+  unit_list_iterate(aplayer->units, punit) {
+    if (map_is_known_and_seen(punit->x, punit->y, pplayer) &&
+        !can_player_see_unit_at2(pplayer, punit, punit->x, punit->y)) {
+      unit_goes_out_of_sight(pplayer, punit);
+    }
+  } unit_list_iterate_end;
+}
+
+/**************************************************************************
 ...
 **************************************************************************/
 bool is_airunit_refuel_point(int x, int y, struct player *pplayer,
diff -Xdiff_ignore -ur freeorig/server/unittools.h freeciv/server/unittools.h
--- freeorig/server/unittools.h 2004-01-28 08:28:53.000000000 +0100
+++ freeciv/server/unittools.h  2004-02-18 10:11:48.000000000 +0100
@@ -45,6 +45,7 @@
                          bool verbose);
 void resolve_unit_stacks(struct player *pplayer, struct player *aplayer,
                          bool verbose);
+void remove_allied_visibility(struct player* pplayer, struct player* aplayer);
 int get_watchtower_vision(struct unit *punit);
 bool unit_profits_of_watchtower(struct unit *punit);
 void pay_for_units(struct player *pplayer, struct city *pcity);

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