[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: packaging games



On Sat, 23 Nov 2002, Jason Stechschulte wrote:

> This question really isn't a Linux game programming question, but rather
> a Linux game packaging question.  In the game I'm working on, I have a
> data directory in which I place the graphics.  In my code I have a line
> like:
> 
> const string DATADIR = "/usr/local/share/games/fred";
> 

As Steve writes, you can use autoconf, automake to set up initial strings. 
For datafiles, I have been implementing a system where I used named 
strings internal in the game and had a class that looked up the files to 
begin with. So, there is a hardcoded string in the game; 
"graphics/splash.png", which, whenever I need the file, is run through a 
"resolver". This resolver returns a full path. If the base to my data is 
/usr/local/games/somegame/data, it will return 
"/usr/local/games/somegame/data/graphics/splash.png".

Now, the interessting part is to add additional paths to the resolver.  
Typically I add ./data (if it exists) and another possibility is
$HOME/.somegame/data. Files from the latest paths override the earlier
ones (they are looked up when added). This means that users can replace
individual data files ala quake.  It is quite OK.

You can check the class out in the game "yanoid", which is available from 
sourceforge. The files you would want to look at is 
ressourcemanager.{hh,cc}. It also includes support for autoconf and even 
for platforms where the realpath call is missing. (Windows... :-).

Mads

-- 
Mads Bondo Dydensborg.                               madsdyd@challenge.dk
All national institutions of churches, whether Jewish, Christian or
Turkish, appear to me no other than human inventions, set up to terrify and
enslave mankind, and monopolize power and profit.
                                        - Thomas Paine (The Age of Reason)