Jump to content
  • Advertisement
Sign in to follow this  
svetpet

Custom format for resource packs problem

This topic is 856 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites


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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!