Datafile confusion
Rick

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

Warrior.dat
DATAFILE   (WARRIOR)
   DATAFILE    (GREEN)
       DATAFILE    (WALK)
           DATAFILE    (NORTH)
               BITMAP1
               .....
           ... //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");
4 
5 strcpy(name, get_datafile_property(file, DAT_ID('N', 'A', 'M', 'E') ) );
6 allegro_message(name); //WARRIOR
7 
8 //GREEN
9 colorDat = (DATAFILE*)file[0].dat;
10 strcpy(name, get_datafile_property(colorDat, DAT_ID('N', 'A', 'M', 'E') ) );
11 allegro_message(name);
12 
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);
17 
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?

Paul whoknows

What a mess!:o
What is GREEN for?

Rick

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.

Thread #588298. Printed from Allegro.cc