Custom format for resource packs problem

Started by
6 comments, last by nfries88 8 years, 1 month ago

Hello, i am currently working on custom format for resource packs for game. The packs contains assests, which are compressed. Currently i am facing the problem that if the assets outside the pack and inside it are the same, then the pack should not be rebuit.

The easiest solution that i could think of is to save the timestamps of the files (last write) inside the pack. When starting to build the pack, the last write time of each file will be compared with the timestamp in the pack and it will be determined if there is change in atleast one file. Then if there is, the pack is rebuilt.

Is there a better solution of the problem?

Advertisement

I store cache of pre-processed assets in "hidden" subdirectory.

Also there's sqlite db file in that dir, storing source file hashes and additional attributes.

When pack is rebuilt, for every added file I calculate hash and check if there's cached blob with that hash.

If there's such file in cache - it will be added to pack as is. If there's no file in cache, then asset will be pre-processed, compressed and cached.

In that way pack is rebuilt very quickly, as only changed resources will be actually processed.

And there's neat side effect - multiple identical assets will refer to same blob in pack.

Instead of storing the timestamp in the pack you can just refer to its last-modified date, assuming you're working on an OS that provides it.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
The other option is to just repack everything whenever you make a pack. If you are optimally arranging the files in the pack, you basically have to do this anyway. Trying to modify the file in place may even be _slower_ than just repacking, depending on what exactly you're doing.

Sean Middleditch – Game Systems Engineer – Join my team!


The other option is to just repack everything whenever you make a pack.

this is the approach i used to use when i used to use resource files.

i no longer use resource files, as hard disk space is not an issue, and they are not modder friendly.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

A GUI front-end for the packager and an architecture that scans for and prioritizes unpackaged assets removes the difficulty with active work on an asset.

Having a well thought out package format can make mod distribution easier, since it can be a single compressed file.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

I store cache of pre-processed assets in "hidden" subdirectory.

Also there's sqlite db file in that dir, storing source file hashes and additional attributes.

When pack is rebuilt, for every added file I calculate hash and check if there's cached blob with that hash.

If there's such file in cache - it will be added to pack as is. If there's no file in cache, then asset will be pre-processed, compressed and cached.

In that way pack is rebuilt very quickly, as only changed resources will be actually processed.

And there's neat side effect - multiple identical assets will refer to same blob in pack.

Thank you very much, your answer was very helpful.

CRC32 the file before compressing, keep the result in the package. If CRC32(new) == CRC32(old); ignore

This topic is closed to new replies.

Advertisement