Archived

This topic is now archived and is closed to further replies.

Toolmaker

[Updated 4-1-2004]For those who want a PAK file to hide their game data

Recommended Posts

Toolmaker    967
Well, here we go! I finished and wrapped up doing Version 1.1.0 of the ToolPAK archive. I merged interface, created a more portable DLL(No longer requires a .LIB file) and wrote some solid documentation. For those who used V1.00, get v1.1.0 since v1.00 is no longer supported(For several reasons). This version contains a few tweaks, bug fixes and updates. I also implement adding/removing files from an existing archive. Get it here: http://toolmaker.homeip.net/upload/ToolPAKv110.zip Toolmaker ------------------- Original Post ------------------- I've seen recently a few threads asking how you can hide your game data in a PAK file. Well, I spent some time on developing my own PAK file format and Pak file compiler/reader. I squeezed into into a nice little DLL, wrote some simple WORD Doc for it and uploaded it. For those who want to use it: #include "PakFile.h" into the files you need it Add PakFile.h and PakFile.lib to your project. The files with that end with "_d" are the debug versions. I am currently revising the interface a bit, since 2 seperate interfaces suck.
- Make error codes into enum
- Merge the interfaces into 1
- Support adding/deleting of files
     
Here it can be downloaded from: (Removed old link) Lemme know what you think, and suggestions are welcome. Toolmaker
-Earth is 98% full. Please delete anybody you can. [edited by - toolmaker on March 31, 2004 9:18:38 AM] [edited by - toolmaker on April 1, 2004 10:38:40 AM] [edited by - toolmaker on April 1, 2004 10:39:57 AM]

Share this post


Link to post
Share on other sites
Toolmaker    967
This isn''t about LibTAR, but about my custom PAK file creator... I wonder if anyone already tried to use it...

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
im interested in it, but what exactly do i have to do to use it? ok, so i include the lib and header. now what? where do my images and sounds go? how do i tell SDL to read a .pak instead of a .png or .wav? because SDL is picky about what extensions you use. give some more info on how it works and i will use it

Share this post


Link to post
Share on other sites
Spudder    385
SDL does support loading from memory - look into SDL_RWops. If your using SDL_image or something similar here''s how you would load an image from the .pak


//open pak file
void *Buffer = //get pointer to image in memory from PAK library
long Size = //buffer size in bytes

//now you can load the image to an SDL Surface
SDL_RWops *RWop = SDL_RWFromMem(Buffer, Size);
SDL_Surface *Image = IMG_Load_RW(RWop, 0);


Thats all there is to it, some of the code you will have to add yourself like reading the image from the PAK and getting it''s size.

Share this post


Link to post
Share on other sites
Toolmaker    967
As I am currently revising the DLL to make it more abstract(Hide more icky details) and implementing new features.

Currently I merged the 2 interfaces into 1, which was pretty easy. Currently, I am doing to code to insert files into an existant pak file.

Well, to load a file from the pack file, you are responsible for memory allocation. Reason: You would need to delete memory allocated by the DLL if it would allocate the data. Below I show the code for loading RAW data from the file.


IPakFileReader Reader;
DWORD dwDatasize;
BYTE *Data;
if (Reader.Load("Game.DAT") != PAK_SUCCESS)
return (ERROR_CODE);

Datasize = Reader.GetFilesize("MyBitmap.bmp"); // Might do some error checking here, for instance, is datasize is 0(Error).
Data = new BYTE[dwDatasize];
if (!Data)
return (ERROR_CODE);
if (Reader.GetFile("MyBitmap.bmp", Data, dwDatasize) != PAK_SUCCESS)
{
delete [] Data;
return (ERROR_CODE);
}

// Do SDL loading here

delete [] Data;


The above code is the minimum required code for loading a file from the archive.

And you use the archive from your program by:
- Including PakFile.h into your header(s)
- Include PakFile.lib(or PakFile_d.lib for debug version) into your project
- Compile!

If you linked PakFile_d.lib, you need PakFile_d.dll otherwise just PakFile.dll. Also, I hope you are using MSVC, since I don''t have a Dev-C++ DLL yet. I am going to build an Dev-C++ version tomorrow.

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites
wolfman8k    140
um... have you looked at PhysicsFS?

http://icculus.org/physfs

It has everything you need for using pak-like files for games, including detection of cd-roms, and has support for quake pak files, zip files, and a bunch of other formats. it creates a virtual filesystem where you can add a bunch of sources. really powerful, and a very simple and easy API. as a bonus it's crossplatform and works on windows, linux, bsd, solaris, mac, and some others.

|edit|

forgot to mention that it also has the best license possible: it's zlib. basicly do whatever you want with the code

[edited by - wolfman8k on March 29, 2004 5:22:28 PM]

Share this post


Link to post
Share on other sites
DivineLight    100
Hi fellow!
I''m also a GameEngineProgrammer.
I saw you''r work it''s really nice. My engine was lacking a Virtual File System thanks to you it''s fine now. What i want to say that i''m a lone programmer of my engine, and it''s really a tough work.
Can you join me? Not as my assistant or sub-programmer but as my friend.
So we both get to some end?

You will handle the virtual file system module. And any other module if you can do that.

Reply soon!
Good Bye!

Share this post


Link to post
Share on other sites
Toolmaker    967
quote:
Original post by DivineLight
Hi fellow!
I''m also a GameEngineProgrammer.
I saw you''r work it''s really nice. My engine was lacking a Virtual File System thanks to you it''s fine now. What i want to say that i''m a lone programmer of my engine, and it''s really a tough work.
Can you join me? Not as my assistant or sub-programmer but as my friend.
So we both get to some end?

You will handle the virtual file system module. And any other module if you can do that.

Reply soon!
Good Bye!


I am sorry(For the late reply, I was busy with the module), I am picking game programming again, and I don''t really want to join a team at this moment. However, I will develop this module further, give support for it and fix bugs and maybe implement requests.

I hope to release a version later today for those who want it. I might also compile it as static library, but I consider those bad, since it requires you to re-link your whole engine after I updated it.

Toolmaker



-Earth is 98% full. Please delete anybody you can.

Share this post


Link to post
Share on other sites