|
Data File Error(4.5) |
GibbSticks
Member #14,193
April 2012
|
hey all, allegro cc! So to the heart of my problem here; when the game is launched through the calling app argv[0] is shown to be bin\sws.bin and cause my datafile to not load. When I start the game through my IDE's execute command argv[0] is shown to be F:\Allegro_Stuff\RTS2\bin\sws.bin the datafile works fine. Any suggestions or is this just a limitation of allegro 4.5? C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
Matthew Leverton
Supreme Loser
January 1999
|
What code are you using to load the data file? Specifically what path are you using, and are you compensating for the fact that the program can start up with any working directory by issuing a chdir(), etc? |
raynebc
Member #11,908
May 2010
|
What we've done to counter this issue is to use get_executable_name() to change the current directory where appropriate (ie. before loading data within the application's folder). |
Matthew Leverton
Supreme Loser
January 1999
|
Does this technique not work? |
GibbSticks
Member #14,193
April 2012
|
The code im using to load the datafile is: inline void LoadGUI() { gui_data = load_datafile("data/GUI.dat"); if(gui_data == NULL) { allegro_message("Could Not Load GUI.dat"); exit(EXIT_FAILURE); } _button = (BITMAP*)gui_data[0].dat; _buttonhighlight = (BITMAP*)gui_data[1].dat; gui_menu.CreateItem(); return; } i do not understand the tehcnique that you linked to. Some explanation please? the code the calling app is using is:
C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
Matthew Leverton
Supreme Loser
January 1999
|
Assuming you have bin/data/GUI.dat: 1inline void LoadGUI()
2{
3 char name[1024];
4 get_executable_name(name, sizeof(name));
5 replace_filename(name, name, "data/GUI.dat", sizeof(name));
6
7 gui_data = load_datafile(name);
8 if(gui_data == NULL)
9 {
10 allegro_message("Could Not Load GUI.dat");
11 exit(EXIT_FAILURE);
12 }
13 _button = (BITMAP*)gui_data[0].dat;
14 _buttonhighlight = (BITMAP*)gui_data[1].dat;
15 gui_menu.CreateItem();
16 return;
17}
|
GibbSticks
Member #14,193
April 2012
|
thx for the speedy response Matthew, I copied and pasted the code you just posted however now the function is not even reporting that the data file is NULL, instead its just outright crashing 0.o C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
Matthew Leverton
Supreme Loser
January 1999
|
You'll have to do some debugging. I'm not 100% sure that replace_filename works with folder + file. |
GibbSticks
Member #14,193
April 2012
|
K Matthew, thanks anyway for your help. C++, C# developer Hitler was a fan of Chaplin. Chaplin was therefore responsible for the murder of millions of lives. |
raynebc
Member #11,908
May 2010
|
replace_filename() does allow you to pass a "folder\filename" path, but I've never tried having it replace more than just the filename part. |
|