Complete.Org: Mailing Lists: Archives: freeciv-dev: January 2002:
[Freeciv-Dev] Re: switching tilesets at runtime
Home

[Freeciv-Dev] Re: switching tilesets at runtime

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: jdorje@xxxxxxxxxxxxxxxxxxxxx
Cc: freeciv-dev <freeciv-dev@xxxxxxxxxxx>
Subject: [Freeciv-Dev] Re: switching tilesets at runtime
From: Raimar Falke <hawk@xxxxxxxxxxxxxxxxxxxxxxx>
Date: Sun, 27 Jan 2002 15:10:13 +0100
Reply-to: rf13@xxxxxxxxxxxxxxxxxxxxxx

On Sun, Jan 13, 2002 at 04:23:28AM -0500, Jason Short wrote:
> Here's a preliminary (buggy and incomplete) patch to allow switching 
> tilesets at runtime.
> 
> It implements a new function, tilespec_reread, in tilespec.[ch].  When 
> invoked this function should destroy the old tileset data and load the 
> given new tileset.
> 
> This is explained in more detail in the patch, but the details are 
> pretty tricky.  Loading a tileset consists of three parts:
> 
> 1.  The top level tileset data is read from the specfile.
> 2.  All images are loaded and placed into a hash.
> 3.  When we receive ruleset data from the server, the sprite structure 
> is initialized to setup that sprite to point to the appropriate picture.
> 
> Step #3 is pretty difficult to mimic.  I basically iterate over all 
> valid ID's for each element and setup the sprite for that ID.  Hopefully 
> (and this seems to work) if the ID is invalid the sprite will just be 
> initialized to NULL (and won't be used anyway).
> 
> 
> That said, there are three bugs that I know of:
> 
> 1.  Rampant memory leaks.  Fixing these will probably require writing a 
> new function to free the images.  However, the memory leaks as they are 
> don't seem to make the system unusable - memory use doesn't grow 
> linearly; it gives the appearance that each tileset is cached by the 
> loader so switching repeatedly doesn't result in quickly unbounded 
> memory growth.
> 
> 2.  The city dialog view is not properly resized in GTK.  This is a 
> GUI-specific issue, so it's probably best to create a new gui-specific 
> function to be called at the end of the reload.
> 
> 3.  The mapview is offcenter after the conversion, because 
> map_view_x0/map_view_y0 remain the same while the tile size and 
> orientation may change.  This is easily fixed.
> 
> 
> I've also added some demo code to gui-gtk: an extra item in the "view" 
> menu to toggle between trident, engels, and hires tilesets.  Once the 
> tileset switching becomes more mature GUI programmers will no doubt want 
> to write frontends for tileset selection.

Can you make the problem easier by requiring that the switch can only
be done if the client isn't connected to the server? Will this make it
easier? IMHO this would still be sufficient.

        Raimar

-- 
 email: rf13@xxxxxxxxxxxxxxxxx
 "If at first you don't succeed... well so much for skydiving."


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