- Online Community Forums » Programming Questions » Datafile confusion

This thread is locked; no one can reply to it. rss feed Print
Datafile confusion
Member #3,572
June 2003

I have many nested datafiles and loading is giving me an issue. The layout is as such:

       DATAFILE    (WALK)
           DATAFILE    (NORTH)
           ... //south, east, west
       DATAFILE    (IDLE)
           ... //just like the walk animation

So I'm running a few tests and I don't understand what is going on.

1 file = load_datafile("C:/warrior.dat");
2 if(!file)
3 allegro_message("FAILED: Datafile load");
5 strcpy(name, get_datafile_property(file, DAT_ID('N', 'A', 'M', 'E') ) );
6 allegro_message(name); //WARRIOR
9 colorDat = (DATAFILE*)file[0].dat;
10 strcpy(name, get_datafile_property(colorDat, DAT_ID('N', 'A', 'M', 'E') ) );
11 allegro_message(name);
13 //WALK
14 animDat = (DATAFILE*)colorDat[0].dat;
15 strcpy(name, get_datafile_property(animDat, DAT_ID('N', 'A', 'M', 'E') ) );
16 allegro_message(name);
18 //IDLE - ERRORS HERE because animDat is nothing
19 animDat = (DATAFILE*)colorDat[1].dat;
20 strcpy(name, get_datafile_property(animDat, DAT_ID('N', 'A', 'M', 'E') ) );
21 allegro_message(name);

Since colorDat has 2 datafiles nested away I would assume colorDat[0] gets the first datafile (WALK) and it does. I would also assume colorDat[1] would get the second datafile (IDLE) but it errors out. Any ideas?

I even exported the header file and from I can make of it what I have should be right.

#define WARRIOR_GREEN_WALK               0        /* FILE */
#define WARRIOR_GREEN_IDLE               1        /* FILE */

I access WALK with 0, I should be able to access IDLE with 1 right?

Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Paul whoknows
Member #5,081
September 2004

What a mess!:o
What is GREEN for?


"The unlimited potential has been replaced by the concrete reality of what I programmed today." - Jordan Mechner.

Member #3,572
June 2003

Really? I think it's neat. Everything is it's own datafile. Anyway green is a colored unit. You can have green/red/blue etc. For now that is the way I'm doing it, later adding transparent colors to the image that I can fill in at run-time. But really it shouldn't matter. Even if I remove GREEN or add another layer, I would think it should work. With this I access the layers based on their Name property in code, and my datafile can have any # of nested datafiles and it would load up without any other info.

Actually I think I'm a tad ugly, but some women disagree, mostly Asians for some reason.

Go to: