Complete.Org: Mailing Lists: Archives: freeciv-dev: December 2004:
[Freeciv-Dev] (PR#11414) resolve_city_emergency shoudl call is_city_cent
Home

[Freeciv-Dev] (PR#11414) resolve_city_emergency shoudl call is_city_cent

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#11414) resolve_city_emergency shoudl call is_city_center
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Dec 2004 23:13:10 -0800
Reply-to: bugs@xxxxxxxxxxx

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

> [jdorje - Wed Dec 08 23:22:51 2004]:
> 
> There's this code:
> 
>        if (same_pos(acity->tile, ptile)) {
>          /* can't stop working city center */
>          continue;
>        }
> 
> which is bad.

Here's a patch.  I also removed a spurious city_map_to_map call (of
course another one is added in its place).

-jason

Index: ai/aicity.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/ai/aicity.c,v
retrieving revision 1.183
diff -u -r1.183 aicity.c
--- ai/aicity.c 11 Dec 2004 10:34:45 -0000      1.183
+++ ai/aicity.c 15 Dec 2004 07:10:05 -0000
@@ -1080,27 +1080,25 @@
           pcity->surplus[O_FOOD], pcity->surplus[O_SHIELD]);
 
   city_list_init(&minilist);
-  map_city_radius_iterate(pcity->tile, ptile) {
+  city_map_checked_iterate(pcity->tile, city_map_x, city_map_y, ptile) {
     struct city *acity = ptile->worked;
-    int city_map_x, city_map_y;
-    bool is_valid;
+    int acity_cx, acity_cy;
 
     if (acity && acity != pcity && acity->owner == pcity->owner)  {
-      if (same_pos(acity->tile, ptile)) {
+      if (map_to_city_map(&acity_cx, &acity_cy, acity, ptile)
+         && is_city_center(acity_cx, acity_cy)) {
         /* can't stop working city center */
         continue;
       }
       freelog(LOG_DEBUG, "%s taking over %s's square in (%d, %d)",
               pcity->name, acity->name, ptile->x, ptile->y);
-      is_valid = map_to_city_map(&city_map_x, &city_map_y, acity, ptile);
-      assert(is_valid);
       server_remove_worker_city(acity, city_map_x, city_map_y);
       acity->specialists[DEFAULT_SPECIALIST]++;
       if (!city_list_find_id(&minilist, acity->id)) {
        city_list_insert(&minilist, acity);
       }
     }
-  } map_city_radius_iterate_end;
+  } city_map_checked_iterate_end;
   auto_arrange_workers(pcity);
 
   if (!CITY_EMERGENCY(pcity)) {

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