Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6544) Tile marked as worked but occupied by an ene
Home

[Freeciv-Dev] Re: (PR#6544) Tile marked as worked but occupied by an ene

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#6544) Tile marked as worked but occupied by an enemy unit.
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Mon, 27 Oct 2003 10:40:48 -0800
Reply-to: rt@xxxxxxxxxxxxxx

Gregory Berkolaiko wrote:
> I get this error message:
> 
> 1: Tile at Lecce->2,2 marked as worked but occupied by an enemy unit!
> 
> with the savegame that I will load directly to RT.

1. Unit X enters/conquers city Y.
2. City Y's size is reduced by 1 (city_reduce_size()).
3. Size reduction triggers an auto_arrange_workers() call.
4. City Y is transferred to new owner.
5. auto_arrange_workers() is called again.

In step 3 the city is in an inconsistent state: the original owner still 
has posession, but the conquering unit now occupies the city.  I suspect 
that aaw should simply not be called in this case.  (This may not be a 
true bug but it's at least a bad situation.  We're rearranging workers 
while the city tile status map isn't fully updated, so the result may 
also be inconsistent.)

As a side note, city_reduce_size should probably call aaw even when we 
don't have to rearrange workers.  Currently aaw is not called if 
removing specialists is enough to satisfy the population loss.

A more complicated solution would move step 2 down below step 4.  But 
this is probably not good since it means the city is in the hands of the 
new owner when it is destroyed.  This could have side effects someday.

All in all, fixing this is a bit tricky.  Maybe we should just accept 
the buglet and change real_sanity_check_city.

jason

Index: server/citytools.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/server/citytools.c,v
retrieving revision 1.237
diff -u -r1.237 citytools.c
--- server/citytools.c  2003/10/13 01:33:31     1.237
+++ server/citytools.c  2003/10/27 18:22:54
@@ -1265,7 +1265,6 @@
     return;
   }
 
-  city_reduce_size(pcity, 1);
   coins = cplayer->economic.gold;
   coins = myrand((coins / 20) + 1) + (coins * (pcity->size)) / 200;
   pplayer->economic.gold += coins;
@@ -1301,7 +1300,10 @@
   get_a_tech(pplayer, cplayer);
   make_partisans(pcity);
 
+  /* We transfer the city first so that it is in a consistent state when
+   * the size is reduced. */
   transfer_city(pplayer, pcity , 0, TRUE, TRUE, TRUE);
+  city_reduce_size(pcity, 1);
   send_player_info(pplayer, pplayer); /* Update techs */
 
   if (do_civil_war) {

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