Ok, so I have a Mappy map file (FMP format) stored in my datafile for a tanks game. I need to call this function to load the map:
int MapLoad(char * mapname)
I currently do not have any knowledge of how I can bypass this dumb char requirement. It would be unfortunate if I wouldn't be able to store my map file in the datafile...Can anybody help me out?
Would be great if I could somehow use: data[MAP3_FMP].dat (as in accessing the map file from my datafile).
Unfortunately I am not aware of a method to do that since MapLoad expects a path and as far as the datafile is concerned it's binary data. One solution would be to dump the binary data in data[MAP3_FMP].dat to a file then use MapLoad to load that file but then you aren't really getting anywhere
really? well...I think that would be just fine. Because the point of the datafile is to both reduce the number of files that have to be managed and get them away from users of the game. So uhm...how would I essentially extract the FMP file from the datafile (with regards to code) and then would it be possible to get rid of the file before the ending of the program? Essentially like a temporary file or something..
If Mappy uses Allegro's packfile routines, you should be able to use "somefile.dat#MAP3_FMP" as the filename (where somefile.dat is the datafile name, and MAP3_FMP is the entry in the datafile for the map).
I'm guessing the # character was key in that syntax. Anyone mind explaining how it works? Just for my future reference.
I believe that the # symbol just references a datafile object. For example:
actual_datafile.dat#objects_name_in_datafile
You'll need to find another MapLoad function that will take a memory address or stream. Failing that you should right click your MapLoad library and select Delete.
If you have the source to the library you could add in your own MapLoad function that takes a memory pointer. If not, you could set some flag in memory, crack open the libc for the dll file and inject your own fopen that checks for the flag and if set uses the passed char* as an actual data source instead of a filename.
Mm... that kind of sounds like a fun project now..
Mappy is Allegro-based, and the Mapload() function uses a series of pack_fopen(), pack_fread()
So it natively supports the datafile format.
The packfile functions also understand several "magic" filenames that are used for special purposes. These are:
`#' - read data that has been appended to your executable file with the exedat utility, as if it was a regular independent disk file.
`filename.dat#object_name' - open a specific object from a datafile, and read from it as if it was a regular file. You can treat nested datafiles exactly like a normal directory structure, for example you could open `filename.dat#graphics/level1/mapdata'.
</li>
(I checked the sources for the mapalr11.zip runtime)
all you need is a string varable and the string fountion str_c()
#include <string> using namespace std; string MAP3_FMP = "themapname"; MapLoad(MAP3_FMP.str_c());
piccolo, did you even read the question?
crap i miss understood it.