Complete.Org: Mailing Lists: Archives: freeciv-dev: May 2005:
[Freeciv-Dev] Re: (PR#12950) Failed sanity check in latest cvs.
Home

[Freeciv-Dev] Re: (PR#12950) Failed sanity check in latest cvs.

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: matte@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#12950) Failed sanity check in latest cvs.
From: "Benedict Adamson" <badamson@xxxxxxxxxxx>
Date: Sun, 1 May 2005 14:48:20 -0700
Reply-to: bugs@xxxxxxxxxxx

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

Benedict Adamson wrote:
...
> [The] attached autogame reproduces this, or a similar, problem.
...

And the attacked patch partly fixes the problem. However a problem with 
the fogging of tiles due to city/unit transfer remains. The patch 
includes an assertion that catches the fogging problem.

diff -ru -Xvendor.freeciv.current/diff_ignore 
vendor.freeciv.current/server/maphand.c freeciv.PR12950/server/maphand.c
--- vendor.freeciv.current/server/maphand.c     2005-05-01 22:54:04.000000000 
+0100
+++ freeciv.PR12950/server/maphand.c    2005-05-01 22:51:37.000000000 +0100
@@ -978,6 +978,8 @@
 {
   struct player_tile *plrtile = map_get_player_tile(ptile, pplayer);
 
+  assert(0 <= change || -change <= plrtile->seen_count); /* else underflow */
+
   plrtile->seen_count += change;
   if (plrtile->seen_count != 0) {
     BV_SET(ptile->tile_seen, pplayer->player_no);
diff -ru -Xvendor.freeciv.current/diff_ignore 
vendor.freeciv.current/server/unithand.c freeciv.PR12950/server/unithand.c
--- vendor.freeciv.current/server/unithand.c    2005-05-01 22:54:04.000000000 
+0100
+++ freeciv.PR12950/server/unithand.c   2005-05-01 22:51:37.000000000 +0100
@@ -286,14 +286,20 @@
 void real_unit_change_homecity(struct unit *punit, struct city *new_pcity)
 {
   struct city *old_pcity = find_city_by_id(punit->homecity);
+  struct player *old_owner = unit_owner(punit);
+  struct player *new_owner = city_owner(new_pcity);
 
   unit_list_prepend(new_pcity->units_supported, punit);
   if (old_pcity) {
     unit_list_unlink(old_pcity->units_supported, punit);
   }
+  if (old_owner != new_owner) {
+    unit_list_unlink(old_owner->units, punit);
+    unit_list_prepend(new_owner->units, punit);
+    punit->owner = new_owner->player_no;
+  }
 
   punit->homecity = new_pcity->id;
-  punit->owner = unit_owner(punit)->player_no;
   send_unit_info(unit_owner(punit), punit);
 
   city_refresh(new_pcity);

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