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

When new city is founded and some other might need to give up working
its central tile, things get tricky. It works, but not the way one may
expect. This patch adds comments, so we know what risks there is
making any changes to that system.


 - ML

diff -Nurd -X.diff_ignore freeciv/common/city.c freeciv/common/city.c
--- freeciv/common/city.c	2007-08-05 16:40:58.000000000 +0300
+++ freeciv/common/city.c	2007-08-10 22:28:11.000000000 +0300
@@ -301,6 +301,9 @@
     }
     pcity->city_map[city_x][city_y] = type;
     if (type == C_TILE_WORKER) {
+      /* No assert to check that nobody else is working this tile.
+       * City creation relies on claiming tile to new city first,
+       * and freeing it from another city only later. */
       ptile->worked = pcity;
     }
   } else {
diff -Nurd -X.diff_ignore freeciv/server/citytools.c freeciv/server/citytools.c
--- freeciv/server/citytools.c	2007-08-09 17:20:08.000000000 +0300
+++ freeciv/server/citytools.c	2007-08-10 22:25:08.000000000 +0300
@@ -1010,6 +1010,12 @@
   /* Place a worker at the city center; this is the free-worked tile.
    * This must be done before the city refresh (below) so that the city
    * is in a sane state. */
+  /* Ugly detail here is that if another city is currently working
+   * this tile, we first update only ptile->worked and our own
+   * city_map. At that point city_map of both cities claim that they
+   * are working that tile. But then we refresh adjacent cities - one of
+   * which that other city certainly is. And once it notices that
+   * ptile->worked does not point to it, it will give tile up. */
   server_set_tile_city(pcity, CITY_MAP_SIZE/2, CITY_MAP_SIZE/2, C_TILE_WORKER);
 
   /* Refresh the city.  First a city refresh is done (this shouldn't
_______________________________________________
Freeciv-dev mailing list
Freeciv-dev@gna.org
https://mail.gna.org/listinfo/freeciv-dev

Reply via email to