Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2000:
[Freeciv-Dev] bug+patch: set_worker_city problem on reload (PR#228)
Home

[Freeciv-Dev] bug+patch: set_worker_city problem on reload (PR#228)

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: freeciv-dev@xxxxxxxxxxx
Cc: bugs@xxxxxxxxxxxxxxxxxxx
Subject: [Freeciv-Dev] bug+patch: set_worker_city problem on reload (PR#228)
From: David Pfitzner <dwp@xxxxxxxxxxxxxx>
Date: Sat, 8 Jan 2000 19:14:42 -0800 (PST)

I found a bug related to savegames, whereby the tile.worked
data can become messed up, and in some cases multiple cities 
can end up working the same square.

The problem is that set_worker_city() in common/city.c behaves
a bit strangely: it is used to set entries in pcity->city_map
while keeping ptile->worked (supposedly) consistent, but it
adjusts ptile->worked based on *existing* data in the city_map.
When a savegame is loaded this 'existing' data is bogus, and
ptile->worked gets wrongly set to NULL in some cases.

The first patch below is a fairly minimal fix, pre-initialising 
appropriate data before calling set_worker_city(), and also
similarly in packhand.c.  It also does a minimal fix for savegames
which have inconsistent worker assignments due to previous cases
of this bug.

I also tried using an assert() or freelog() in set_worker_city() to
detect other such cases, but it got a bit complicated because there
are some cases where the problem appears to be triggered but is
actually ok (specifically, when a city changes owner, via conquering/
bribing/trading/civil-war, things get a bit strange).  The second
patch adds the log message and code to remove the spurious messages,
but I'm not sure if this is really the right approach...

-- David

Attachment: set_worked_fix.diff.gz
Description: GNU Zip compressed data

Attachment: set_worked_fix_extra.diff.gz
Description: GNU Zip compressed data


[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] bug+patch: set_worker_city problem on reload (PR#228), David Pfitzner <=