Complete.Org: Mailing Lists: Archives: freeciv-dev: February 1999:
[Freeciv-Dev] Patch: fixing problem with city workers when city changes
Home

[Freeciv-Dev] Patch: fixing problem with city workers when city changes

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Subject: [Freeciv-Dev] Patch: fixing problem with city workers when city changes owner...
From: rizos@xxxxxxxx
Date: Mon, 8 Feb 1999 21:55:05 -0600 (CST)

The problem with the workers of a city that changes owner
(no matter whether by conquest, revolt or trade), that seem
to be ignored by other cities,  is because whenever such an
ownership change occurs, a new city struct is created and the 
old one is removed. This removal means that the worker field
in the map is set to NULL for the workers of the old city
(in game_remove_city). As a result the map does not know about
the workers of the new city and is_worked_here() for such a tile
returns NULL (i presume that this has never been a problem with
the old time-consuming implementation, ie, old_is_worked_here).

At first i thought to fix this by doing auto_arrange_workers();
however, after a second thought, i felt that this should be
left to the new city owner to decide (well, i also thought
that doing this automatically would give a slight advantage
to the conqueror...). So my suggested approach to fix this is
simply to update the map with the workers of the new city,
ie, what has to be done anyway!

A new function implementing this, and the 3 places from where 
it has to be called follow below...

regards,
--rizos

================================================================
in server/diplhand.c, lines 195-196:
old: 
          city_check_workers(pdest ,pnewcity);
          city_refresh(pnewcity);

new:
          city_check_workers(pdest ,pnewcity);
          update_map_with_city_workers(pnewcity);
          city_refresh(pnewcity);

------------------------------------

in server/unitfunc.c, lines 498-499:
old:
  city_check_workers(pplayer,pnewcity);
  city_refresh(pnewcity);

new:
  city_check_workers(pplayer,pnewcity);
  update_map_with_city_workers(pnewcity);
  city_refresh(pnewcity);

-------------------------------------

in server/unithand.c, lines 1084-1086:
old:
/* maybe should auto_arr or otherwise reset ->worked? -- Syela */
 
    city_refresh(pnewcity);

new:
/* relocate workers of tiles occupied by enemy units */ 
    city_check_workers(pplayer,pnewcity);  
    update_map_with_city_workers(pnewcity);
    city_refresh(pnewcity);

===================================================================

void update_map_with_city_workers(struct city *pcity)
{
  int x, y;
  city_map_iterate(x,y) {
    if (pcity->city_map[x][y] == C_TILE_WORKER)
       set_worker_city(pcity, x, y, C_TILE_WORKER);
  }
}



[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] Patch: fixing problem with city workers when city changes owner..., rizos <=