Re: [AD] Custom packfiles

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Chris wrote:

Evert Glebbeek wrote:

I agree with Peter that I don't really like the idea of a new `state' in Allegro. Maybe I'm just not yet used to the idea though.


Perhaps. Or maybe I just don't fully understand Peter's method. Looking back at it, I think I see where he's going, now.. Basically he'd split up, say, load_wav into load_wav and load_wav_pf. load_wav would open up the file as a PACKFILE, pass it to load_wav_pf, amd then close the PACKFILE, right?


Exactly.

If so, I think I'm alright with that.. except I'm not sure I like the naming convention of the vtable methods or functions. Since the vtable is in a stuct, I don't see any reason to prepend them with pf_,


I only put in the prefix because getc and putc from stdio.h can be macros and cause problems (which they did). It's also recommended practice in some standard to put prefixes on structure member names, for exactly this reason (e.g. that's why they have struct timeval { tv_sec, tv_usec }, and struct dirent { d_name, d_type }, etc.) -- not that anybody can be bothered most of the time.

and I'd think normal Allegro convention for the functions would be to put the pf_ first, so it'd be pf_load_wav, pf_load_bmp, etc.


I based it on the _ex naming convention, substituting pf instead.

Now, as I understand it, the packfile handles would each contain a pointer to their vtable, right? So functions such as pack_fread, pack_fseek, etc, would actually run functions from the vtable?


Yes.

This does bring up one question for me, though.. what would we do about seeking? pack_fseek doesn't have a 'whence' parameter, and we can't add one. I think the best thing to do would be to allow negative seeking (at least pass on negativee values to the vtable function, and let that worry about failing ot succeeding). Either that, or create a new function, but I'm not too sure that'd be worth it for this.


I don't see any real need to add backwards seeking just because we're letting the user override pack_fseek. None of the current Allegro code needs it, and the main reason for adding packfile vtables is for the user to take advantage of existing file format loaders.

Peter




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/