Complete.Org: Mailing Lists: Archives: freeciv-dev: February 2005:
[Freeciv-Dev] (PR#12368) RFC: encapsulating, modularizing, and objectify
Home

[Freeciv-Dev] (PR#12368) RFC: encapsulating, modularizing, and objectify

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
Subject: [Freeciv-Dev] (PR#12368) RFC: encapsulating, modularizing, and objectifying the tileset data
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 26 Feb 2005 12:03:16 -0800
Reply-to: bugs@xxxxxxxxxxx

<URL: http://bugs.freeciv.org/Ticket/Display.html?id=12368 >

Currently it's hard to do much with the tileset.  For instance loading a 
new tileset means overwriting the current tileset.  There's no way to 
pre-load the tileset to check for matching capabilities since this 
overwrites the current tileset.  The client exits if a tileset load 
fails at any point, rather than having any error handling.

Fixing this isn't easy because the tileset is in global data in a large 
number of separate variables.  The solution is simple but will take a 
bit of work.

1.  All tileset data should be encapsulated, and read through accessor 
functions.

2.  The tileset data variables should be put together into one struct.

3.  We can then treat this struct as an object.  tilespec_load_toplevel 
should for instance just return NULL if the tileset load fails.

I tried making a patch that went straight to 2, but it would be very 
large and intrusive.  Instead I think we should first encapsulate the 
data (e.g., move is_isometric into tilespec.c, with a 
tileset_is_isometric() accessor); then the next set of changes will be 
confined within tilespec.c.

As an unrelated side note, tilespec.c should be split into two or three 
files.  It performs several unrelated tasks:

* Loading the tileset meta-data (the top level).
* Loading the tileset sprites (via lots and lots of load_sprite calls).
* Filling in sprite arrays (this is the largest part of the drawing code).

These three tasks share the tileset data structure but nothing else (I 
think).

-jason





[Prev in Thread] Current Thread [Next in Thread]
  • [Freeciv-Dev] (PR#12368) RFC: encapsulating, modularizing, and objectifying the tileset data, Jason Short <=