Sign in to follow this  
chillypacman

putting files and textures in .paks or something?

Recommended Posts

Many games put their assetts in seperate folders with containers like .pak or .bak. I think it's called serialization or something similar? Can anyone point me in the right direction and recommend a good LGPL or similarly licensed libraries I could use to do something similar? Also how does it work? For example if I want to access a texture in a specific directory I just put in "../media/texture.bmp" or something like that, but if media has a .bak file which has the texture stored inside it would it mean I need to access it through a class? Or would I have to extract it during the loading time and place it in a temp directory then delete it once the game closed down? Sorry I don't know much about this topic so my questions might seem dumb.

Share this post


Link to post
Share on other sites
Usually you write some kind of virtual file system that you initialize with those *pak files in the beginning

e.g.:
addPack("main.pkg")
addPack("mod.pkg")


Now when you load a file

Buffer buf;
loadFile("somedir/filename.lol")
it will first lookup the central directories of the archive files in the determined order
either last->first or vise verse (regarding the addPack order), last->first has the advantage of file versioning usefull for overwriting files with modified ones.


if the given file doesn t exist in the *.pkg files you provided it will look it up on the harddrive.

e.g pwd /somedir/filename.lol where pwd is your current working directory


I would advice you to get the .zip file format specification and write a loader for it. Its pretty simple and can be done within 1-2 hours and is a good learning experience if you have never done this before.

Some restriction on the file format:
- use only uncompressed files
- do not use password protection

Just to make life easier :)

Hope that helps.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this