Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

RGSS archive Loader #35

Open HimeWorks opened 10 years ago

HimeWorks commented 10 years ago

I'm going to release a DLL that provides RGSS archive loading functionality. It will only support loading files, and requires you to pass in the filename that you want to load.

This will mimic the load_data function except you can load from custom rgssad, rgss2a, and rgss3a archives.

With this, I can finally complete my patch system.

HimeWorks commented 10 years ago

Ok so I had written a preliminary version of the archive loader but I didn't really like it very much.

The DLL should serve two functions

  1. Read the archive
  2. Return data when requested

Why DLL?

First, the archive is encrypted, so we need to be able to decrypt it on the fly very fast. If you try to XOR 5 MB of data, it'll take several seconds. Unacceptable.

Second, the archive is proprietary. I can't just release the decrypter in a script file because now you've got all these EULA people calling me out. So, it shall remain closed-source.

Now, the DLL will provide two methods related to archive loading

TH.load_archive(path, id=nil)

This will read the file table of a particular archive and cache the entries in memory. The ID of the file is what you will be using to reference it. If it is nil, then I assign an arbitrary ID myself. This is perfectly fine if you're only planning to use one additional archive (because then all accesses will assume that one). However, once you start using multiple archives, all data access will require you to specify an ID.

TH.load_data(path, id=nil)

This will return a byte-stream representing the data that you want. This works the same as the default load_data, except instead of loading from game.rgss3a you specify your own archive by the ID you assigned when you first loaded an archive.

All paths should be relative to the game's root folder. For example, Data/Weapons.rvdata2 can be stored in game.rgss3a, patch.rgss3a, random.rgss3a, etc. but it will always be the same path. You just need to specify a different archive if you decide to switch it.

I don't know if there are any other useful functions.