Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6260) server bug: city tile status
Home

[Freeciv-Dev] Re: (PR#6260) server bug: city tile status

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: paul@xxxxxxxxxxxxx, per@xxxxxxxxxxx
Subject: [Freeciv-Dev] Re: (PR#6260) server bug: city tile status
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 9 Oct 2003 16:15:51 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> Here's the general situation:
> 
> - I conquer a city.
> - In transfer_city, update_city_tile_status_map is called for every tile
> of the city.

Note this particular situation can only happen when there are two 
"WORKER" tiles that become "UNAVAILABLE" after the transfer.  So it's 
pretty rare.  But there must be other situations that lead to similar 
bugs (e.g., there was one crash that didn't involve recursion).

This patch is a bit of a hack, but an improvement on the current 
situation.  Instead of calling update_city_tile_status, which may do an 
auto-update, we manually update the tile status.

I'm not sure then if adjacent cities will get properly updated.  But, it 
does fix the segfault.

I think this is still not the correct solution, though.

jason

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.236
diff -u -r1.236 citytools.c
--- server/citytools.c  2003/10/08 16:56:07     1.236
+++ server/citytools.c  2003/10/09 23:15:15
@@ -908,9 +908,17 @@
    */
   maybe_make_contact(pcity->x, pcity->y, ptaker);
 
-  map_city_radius_iterate(pcity->x, pcity->y, x, y) {
-    update_city_tile_status_map(pcity, x, y);
-  } map_city_radius_iterate_end;
+  /* Manually update all tiles of the city, without any auto-updates. */
+  city_map_iterate(city_x, city_y) {
+    if (!is_city_center(city_x, city_y)) {
+      if (city_can_work_tile(pcity, city_x, city_y)) {
+       set_worker_city(pcity, city_x, city_y, C_TILE_EMPTY);
+      } else {
+       set_worker_city(pcity, city_x, city_y, C_TILE_UNAVAILABLE);
+      }
+    }
+  } city_map_iterate_end;
+  pcity->ppl_elvis = pcity->size; /* keep city sanity */
   auto_arrange_workers(pcity);
   initialize_infrastructure_cache(pcity);
   if (raze)

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