www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/12/09:51:39

From: Shawn Hargreaves <Shawn AT talula DOT demon DOT co DOT uk>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro: Loading sub-datafiles
Date: Sat, 12 Apr 1997 12:54:57 +0100
Organization: None
Distribution: world
Message-ID: <+56cJJARg3TzEwZh@talula.demon.co.uk>
References: <01bc43e8$e6ddcae0$18f22499 AT chris>
NNTP-Posting-Host: talula.demon.co.uk
MIME-Version: 1.0
Lines: 26
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Chris La Mantia writes:
>Allegro 2.2 now has the ability to store datafiles within datafiles.  I
>want to use this ability to load only those datafiles that must be in
>memory at any given time.  Unfortunately, I'm having trouble accessing data
>in the sub-datafile.
[snip]
>DATAFILE *gamedata;
>gamedata = load_datafile_object("data.dat","GAME");
>set_mouse_sprite(gamedata[GAME_POINTER].dat);

You've missed out a level of indirection via the 'dat' field. The
load_datafile_object() function returns a single entry from a datafile,
not an entire datafile array. This object might contain a nested
datafile, but it could just as well be a single bitmap, sample, etc, so
a wrapper structure is needed. Try replacing your code with:

    DATAFILE *dataobject;
    DATAFILE *gamedata;
    dataobject = load_datafile_object("data.dat","GAME");
    gamedata = (DATAFILE *)dataobject->dat;
    set_mouse_sprite(gamedata[GAME_POINTER].dat);


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk/
Beauty is a French phonetic corruption of a short cloth neck ornament.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019