Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2004:
[Freeciv-Dev] (PR#9614) initialize city cache after building a city
Home

[Freeciv-Dev] (PR#9614) initialize city cache after building a city

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#9614) initialize city cache after building a city
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 10 Aug 2004 09:25:25 -0700
Reply-to: rt@xxxxxxxxxxx

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

> [jdorje - Thu Aug 05 20:00:31 2004]:
> 
> When the AI builds a city in the middle of autosettler actions, the 
> cache for that city isn't built.  Perhaps in future other cached items 
> may need to be rebuilt too.
> 
> This is a major bug!  Settlers will be given nearly random orders.
> 
> This patch solves it by calling initialize_infrastructure_cache.  Note 
> this means re-initializing all caches for the player, which may be slow. 
>   On the other hand cities aren't founded all that often.

I made a new patch, then found that this patch was already here.  So
here's the new patch (with a couple of added assertions).

This should be committed soon.

jason

? new
? orig
Index: server/settlers.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/settlers.c,v
retrieving revision 1.193
diff -u -r1.193 settlers.c
--- server/settlers.c   8 Aug 2004 16:44:20 -0000       1.193
+++ server/settlers.c   10 Aug 2004 16:23:20 -0000
@@ -64,6 +64,7 @@
   int x = punit->x, y = punit->y;
   struct city *pcity;
 
+  assert(pplayer == unit_owner(punit));
   handle_unit_activity_request(punit, ACTIVITY_IDLE);
 
   /* Free city reservations */
@@ -78,6 +79,12 @@
     return FALSE;
   }
 
+  /* We have to rebuild at least the cache for this city.  This event is
+   * rare enough we might as well build the whole thing.  Who knows what
+   * else might be cached in the future? */
+  assert(pplayer == city_owner(pcity));
+  initialize_infrastructure_cache(pplayer);
+
   return TRUE;
 }
 

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