Advertisement

PAKs, WADs, and MPQs

Started by December 16, 2000 10:48 AM
5 comments, last by DarkMage139 24 years ago
Does anybody know of any good tutorials on how to make resource files like, say, a Quake PAK? Thanks. - DarkMage139 (Neokatana Software) "I can smell the sea." - Majiir Paktu, Homeworld
- DarkMage139
why don''t you just use zlib, (zip file format), and rename it to .pak file format. screw the tutorials unless you are making a quake 2 renderer or something.

JoeMont001@aol.com www.polarisoft.n3.net
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
Advertisement
Well, no, not yet, but I was just curious...

- DarkMage139 (Neokatana Software)
"I can smell the sea." - Majiir Paktu, Homeworld
- DarkMage139
PAK is EXTREMELY simple, look it up on www.wotsit.org, it''s basically just a file starting with the string "PAK" then the file data and at the end is a simple FAT, might I say an EXTREMELY simple FAT. I just happen to be writing my own format, with a few extra features, like every resource in the file has sort of a GUID, more SUID (Somewhat Unique Identifier) actually and the filemanager accepts either strings with the resource-name or those SUIDS. Those SUIDS can than be used as persistant pinters to data. The filemanager will also keep track of which data is in memory and will return a pointer to that data if a request comes twice, I''ll probably have to use some sort of reference counting for that.....




Gyzmo
=======================
Meddle not in the affairs of dragons for you are crunchy and go well with toast.
Gyzmo=============================="Well is the world standard" - The Alchemist"Not in Canada!" - jonnyfish
mainly what u do is setup 2 strcutures:

typedef struct
{
char id[4];
int dirofs;
int dirlen;
} pakheader_t;

typedef struct
{
char name[40];
int filepos;
int filesize;
} paklump_t;

example to display all the lumps:
NOTE: i dunno if using the C input/output
funtions is good in C++, nut i havent learned the C++
ones yet

void main()
{
FILE *file;
pakheader_t header;
paklump_t *lumps;
int iNumLumps;

file = fopen("pak0.pak", "rb");
if (!fopen)
return 1;

// Read the header and check ident
fread(&header, sizeof(header), 1, file);
if (stricmp(header.id, "PACK"))
{
fclose(file);
return 1;
}

fread(&header.dirofs, sizeof(int), 1, file);
fread(&header.dirlen, sizeof(int), 1, file);
iNumLumps = header.dirlen / sizeof(header);
lumps = new paklump_t(iNumLumps);

fseek(file, header.dirofs, SEEK_SET);

for (int i = 0; i < iNumLumps; i++)
cout << lumps.name << endl;

return 0;
}
Sorry left out a line.
After fseek(...); put :
fread(lumps, sizeof(paklump_t), iNumLumps, file);
Advertisement
Doh sorry it was late, another thing to fix.
change...

if (stricmp(....))
...

to

if (strncmp(header.id, "PACK", 4)

This topic is closed to new replies.

Advertisement