Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Allegro DATFILES and char arrays

This topic is 5326 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hello all, question about Allegro''s datafiles: is there a way to store char data in a datfile? Ex. map.txt listing 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 end map.txt listing levels.dat listing 0 BINARY DATA map.txt MYMAP end levels.dat listing c++ source #include <allegro.h> DATAFILE * mydat; unsigned char * lvl1[25][19]; int main(void){ allegro_init(); install_keyboard(); mydat = load_datafile(".\\levels.dat"); lvl1 = mydat[0].dat; //error, cannot convert from void * to unsigned char* return 0; } how could i cast this correctly? thank you much!

Share this post

Link to post
Share on other sites
Haven''t tested that out, but as far as I can remember, Allegro dat-entries always have to be cast...meaning that it might look like something like this:

#include <allegro.h>

DATAFILE * mydat;
unsigned char * my_entry;
int main(void){

mydat = load_datafile(".\\levels.dat");

my_entry = (char *)mydat[0].dat;
//this should work
return 0;

But the problem is the following: you declared your map.txt in ASCII format, single entries seperated by ",". This doesn''t mean that the dat-entry will be split up in those so-called tokens!

You either have to make the map-format binary or write a parser for your ASCII-based files...

For further questions, feel free to contact me via ICQ!


--si tacuisses, philosophus mansisses--

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!