How would I go about finding out how many files are within a datafile. This is primarily for loading datafiles containing "tile gfx" within my map editor. I have a button within my map editor which allows me to load new datafiles at run time but the array of "buttons" that represent each file within the datafile needs to know how many their are, otherwise it reads to far into the datafile if I have to scroll through the objs.
Hope that makes sense :/
Thanks,
I believe it's called DAT_END
And what do I do with DAT_END? I want to convert it to an integer for use with loops. I was thinking about adding an obj at the end of a datafile called "END_OBJ" or something, and when the datafiles loaded using
DATAFILE *find_datafile_object(const DATAFILE *dat, const char *objectname);
If it returns null datafile is invalid, otherwise use
get_datafile_property(const DATAFILE *dat, int type);
I just don't know which "type" I'm looking for to find its ID. I need to get the number of the obj thats defined when you create a header for the datafile.
If you could elaborate on how to use DAT_END, I think that would be easier
Cheers
From the manual:
for (i=0; dat<i>.type != DAT_END; i++) { if (stricmp(get_datafile_property(dat+i, DAT_ID('N','A','M','E')), "my_object") == 0) { /* found the object at index i */ } } /* not found... */
Do you understand now how to use DAT_END?
(untested)
df = load_datafile("moretiles.dat"); if (! df) return -1; // error for (i=0; df<i>.type != DAT_END ; i++) { // do whatever you want with df<i> // You can choose to process only those where df<i>.type == DAT_BITMAP // df<i>.dat is a pointer to the item (ie: BITMAP *) }
Oh I don't know maybe it's called a manual?
for (i=0; dat<i>.type != DAT_END; i++)
Do you understand now how to use DAT_END?
Yes thankyou.