|
Need to go around char requirement. File from datafile. |
XcronZ3X
Member #8,222
January 2007
|
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). |
Steve Terry
Member #1,989
March 2002
|
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 ___________________________________ |
XcronZ3X
Member #8,222
January 2007
|
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.. |
Kitty Cat
Member #2,815
October 2002
|
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). -- |
XcronZ3X
Member #8,222
January 2007
|
I'm guessing the # character was key in that syntax. Anyone mind explaining how it works? Just for my future reference. |
ngiacomelli
Member #5,114
October 2004
|
I believe that the # symbol just references a datafile object. For example: actual_datafile.dat#objects_name_in_datafile
|
ImLeftFooted
Member #3,935
October 2003
|
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.. |
Audric
Member #907
January 2001
|
Mappy is Allegro-based, and the Mapload() function uses a series of pack_fopen(), pack_fread() manual said: The packfile functions also understand several "magic" filenames that are used for special purposes. These are:
</li> (I checked the sources for the mapalr11.zip runtime) |
piccolo
Member #3,163
January 2003
|
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());
wow |
Kauhiz
Member #4,798
July 2004
|
piccolo, did you even read the question? --- |
piccolo
Member #3,163
January 2003
|
crap i miss understood it. wow |
|