Complete.Org: Mailing Lists: Archives: freeciv-dev: August 2003:
[Freeciv-Dev] (PR#4766) city happiness isn't calculated on game load
Home

[Freeciv-Dev] (PR#4766) city happiness isn't calculated on game load

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] (PR#4766) city happiness isn't calculated on game load
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Tue, 5 Aug 2003 20:16:56 -0700
Reply-to: rt@xxxxxxxxxxxxxx

In player_load() in savegame.c the city information is loaded for all 
cities.

Just below that in player_map_load the dumb city information is loaded 
for all players/cities.  This includes a call to update_dumb_city().

But update_dumb_city() calls city_happy and city_unhappy, which don't 
work at this point since happiness hasn't been calculated.

==5644== Conditional jump or move depends on uninitialised value(s)
==5644==    at 0x80A6DA9: city_happy (city.c:1116)
==5644==    by 0x8069CA8: update_dumb_city (citytools.c:1658)
==5644==    by 0x80973FF: player_map_load (savegame.c:1281)
==5644==    by 0x809AEF8: game_load (savegame.c:2190)
==5644==    by 0x80557E8: load_command (stdinhand.c:3524)
==5644==    by 0x8050271: srv_main (srv_main.c:1569)
==5644==    by 0x804A007: main (civserver.c:154)
==5644==    by 0x403A04EC: __libc_start_main (in /lib/libc-2.3.2.so)
==5644==    by 0x8049C60: (within /tmp/jshort/freeciv/server/civserver)
==5644==
==5644== Conditional jump or move depends on uninitialised value(s)
==5644==    at 0x8069E0B: update_dumb_city (citytools.c:1669)
==5644==    by 0x80973FF: player_map_load (savegame.c:1281)
==5644==    by 0x809AEF8: game_load (savegame.c:2190)
==5644==    by 0x80557E8: load_command (stdinhand.c:3524)
==5644==    by 0x8050271: srv_main (srv_main.c:1569)
==5644==    by 0x804A007: main (civserver.c:154)
==5644==    by 0x403A04EC: __libc_start_main (in /lib/libc-2.3.2.so)
==5644==    by 0x8049C60: (within /tmp/jshort/freeciv/server/civserver)

The easy solution is to call generic_city_refresh() for every city in 
player_load().  However generic_city_refresh does a lot of things and 
it's possible some of them have side effects.

The update_dumb_city() call isn't strictly required; the dumb city 
shouldn't *need* any updating.  However old savegames tend to be buggy 
and so it's safest to do the update.  But we should probably print an 
error or something if the update actually changes anything.

See also PR#4765.

jason




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