Complete.Org: Mailing Lists: Archives: freeciv-dev: July 2003:
[Freeciv-Dev] (PR#4657) updating borders done too early on city build
Home

[Freeciv-Dev] (PR#4657) updating borders done too early on city build

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4657) updating borders done too early on city build
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Wed, 23 Jul 2003 12:55:12 -0700
Reply-to: rt@xxxxxxxxxxxxxx

==21277== Conditional jump or move depends on uninitialised value(s)
==21277==    at 0x8069A68: update_city_tile_status (citytools.c:2013)
==21277==    by 0x80699D9: update_city_tile_status_map (citytools.c:1990)
==21277==    by 0x8083B49: tile_update_owner (maphand.c:1568)
==21277==    by 0x8083CDC: map_update_borders_recalculate_position 
(maphand.c:1586)
==21277==    by 0x8083DCA: map_update_borders_city_change (maphand.c:1618)
==21277==    by 0x8067442: create_city (citytools.c:1001)
==21277==    by 0x805822F: city_build (unithand.c:567)
==21277==    by 0x80582D2: handle_unit_build_city (unithand.c:587)
==21277==    by 0x804EF36: handle_packet_input (srv_main.c:856)
==21277==    by 0x809D855: sniff_packets (sernet.c:605)
==21277==    by 0x804FE94: main_loop (srv_main.c:1466)
==21277==    by 0x80502F4: srv_main (srv_main.c:1588)
==21277==    by 0x804A007: main (civserver.c:154)
==21277==    by 0x403A04EC: __libc_start_main (in /lib/libc-2.3.2.so)
==21277==    by 0x8049C60: (within /tmp/jshort/freeciv/server/civserver)

In other words, we're updating the borders before the city tile status 
values have been set at all.  This means some bogus info may be sent out 
to the clients in update_city_tile_status (or more likely not sent).

The fix is easy.  Ben, please comment.

jason

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.225
diff -u -r1.225 citytools.c
--- server/citytools.c  2003/07/23 13:46:04     1.225
+++ server/citytools.c  2003/07/23 19:54:35
@@ -997,9 +997,6 @@
   city_list_insert(&pplayer->cities, pcity);
   add_city_to_minimap(x, y);
 
-  /* Update the national borders. */
-  map_update_borders_city_change(pcity);
-
   /* it is possible to build a city on a tile that is already worked
    * this will displace the worker on the newly-built city's tile -- Syela */
   for (y_itr = 0; y_itr < CITY_MAP_SIZE; y_itr++) {
@@ -1011,6 +1008,10 @@
        pcity->city_map[x_itr][y_itr] = C_TILE_UNAVAILABLE;
     }
   }
+
+  /* Update the national borders.  This updates the citymap tile
+   * status and so must be done after the above. */
+  map_update_borders_city_change(pcity);
 
   server_set_tile_city(pcity, CITY_MAP_SIZE/2, CITY_MAP_SIZE/2, C_TILE_WORKER);
   auto_arrange_workers(pcity);

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