Ok,
it would appear that linux has a problem with finding files based on a path.
ok heres the part of code that matters
spell = load_datafile("spell.dat"); if(!spell) { file_select("load spell.dat", filename, "dat"); spell = load_datafile(filename); if(!spell){no_dat=0;}else{no_dat=1;} } }
And when the program runs, the spell.dat is in the same folder as the exe and it dosen't find it and I enter the if(!spell) statement, loading spell from the file_select at runtime it is able load spell.dat
So whats the prob??
Thankss
are you in the directory that the program is in when you run it? Are you running it from a console? Or just clicking on the program?
Check the path parameter. That's not a path you pass here. Try "./" instead.
Also use file_select_ex().
Make sure that you pass bothe upper and lower case extension "dat;DAT" just to make sure.
yea i'm in the directory and I'm clicking on it
yea i'm in the directory and I'm clicking on it
Right, so your filemanager is in that directory. Try running the program from the command-line (many things work naturally from a terminal in Linux, so it's probably good to get used to those too).
Amd make absolutely sure the case of the filename is the same in either case - Linux is case sensitive.
Ok I found the direct problem,
maybe its how the path is set
I did some debugging and I found out that
its putting
/home/superstar4410
at the beginning of ever " "
so with spell = load_datafile("spell.dat")
its trying to load /home/superstar4410/spell.dat and thats not the correct path
so how can I fix this
Thanks
[EDIT]:o:o:o:o:o:o
Yea you were right, it works from the konsole fine, but from the folder it tries to add /home/superstar4410 before the path
use allgros functions to get the path of the executable.
Then use that path to prefix your file paths.
not to be lazy but,
could you give me a code example
The file manager (apparently) starts the program with the working directory set to your home directory. You should probably make the program so that it doesn't care from what directory it is started, as spellcaster suggested.
You could probably do (untested!) chdir(get_filename_path(argv[0])); from main, though that isn't exactly nice.
The other option would be to store the path information in the game config file and read it when the game starts (put configfiles in the directory pointed to by $HOME; use the C function getenv to get it's value).
whats the acutally function name
it dosen't recognize get_filename_path
I think the function you really need is getcwd(); which returns the current working directory.. argv[0] is the application name and does not always contain the path.
Oooh it's not ANSI/POSIX compliant... but I know it works in Windows/DOS/Linux... what do they exactly mean by that anyway.
Have a look at the Allegro docs, there's a function like that somewhere that does effectively that. Come to think of it, you shouldn't pass it argv[0], but the result of get_executable_name().
As Steve Terry said though, the result is unreliable. You should really make your game so that it will work from any directory. The config file solution I mentioned above is probably your best bet for now, otherwise just stick with running from a terminal (shouldn't be too hard - you're using make anyway, right )