Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Need to go around char requirement. File from datafile.

This thread is locked; no one can reply to it. rss feed Print
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
avatar

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 :P but then you aren't really getting anywhere :)

___________________________________
[ Facebook ]
Microsoft is not the Borg collective. The Borg collective has got proper networking. - planetspace.de
Bill Gates is in fact Shawn Hargreaves' ßî+çh. - Gideon Weems

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
avatar

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).

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

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

Dustin Dettmer
Member #3,935
October 2003
avatar

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()
So it natively supports the datafile format.

manual said:

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)

piccolo
Member #3,163
January 2003
avatar

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
-------------------------------
i am who you are not am i

Kauhiz
Member #4,798
July 2004

piccolo, did you even read the question? :P

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

piccolo
Member #3,163
January 2003
avatar

:o crap i miss understood it.

wow
-------------------------------
i am who you are not am i

Go to: