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: Fri, 10 Oct 2003 17:46:33 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> Here's the general situation:

> - auto_arrange_workers runs on the city.  But remember the city tile
> status hasn't been fully updated yet, since we didn't make it all the
> way through the loop.

Here's a different tack...

This patch makes sure the citymap is up-to-date before running through 
auto_arrange_workers.

The logic here isn't as simple as it looks.  Since the update may cause 
re-entry into auto_arrange_workers we could end up going through the 
loop more than once.  But this happens anyway currently when things 
break down.  So although this is an ugly solution, it should be safe 
enough as a workaround.

jason

Index: server/cityturn.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/cityturn.c,v
retrieving revision 1.227
diff -u -r1.227 cityturn.c
--- server/cityturn.c   2003/10/08 16:56:07     1.227
+++ server/cityturn.c   2003/10/11 00:34:41
@@ -171,6 +171,14 @@
   struct player *pplayer = city_owner(pcity);
   struct ai_data *ai = ai_data_get(pplayer);
 
+  /* HACK: make sure everything is up-to-date before continuing.  This may
+   * result in recursive calls to auto_arrange_workers, but it's better
+   * to have these calls here than while we're reassigning workers (when
+   * they will be fatal). */
+  map_city_radius_iterate(pcity->x, pcity->y, map_x, map_y) {
+    update_city_tile_status_map(pcity, map_x, map_y);
+  } map_city_radius_iterate_end;
+
   sanity_check_city(pcity);
   cm_clear_cache(pcity);
 

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