Resource loading order - yvt/openspades GitHub Wiki
Terminology
- loose files: files which are not packaged and put directly in a
Resources
directory or one of its subdirectories are called loose files. - packed files: files packaged into
.pak
are called packed files. - pak files: packages including one or more packed files. They have the extension
.pak
(or.zip
, as of 0.0.13).
Resource Search Order
Suppose the program wants to load a texture from the path Textures/SomeTexture.png
...
- OpenSpades searches loose files in the user-specific
Resources
directory.C:\Users\myusername\AppData\Roaming\OpenSpades\Resources\Textures\SomeTexture.png
/home/myusername/.local/openspades/Resources/Textures/SomeTexture.png
FIXME: needs verification
- OpenSpades searches loose files in the global
Resources
directory that is located near the executable file.E:\Downloads\OpenSpades-0.0.42\Resources\Textures\SomeTexture.png
/usr/local/share/games/openspades/Resources/Textures/SomeTexture.png
- And then OpenSpades searches every pak files in the following order: first, paks whose file name does not look like
pak0123456789.pak
, in alphabetic order. (note: Pak files are detected using the method of the step one and two.)Textures/SomeTexture.png
insideE:\Downloads\OpenSpades-0.0.42\Resources\CupcakesGunMod.pak
Textures/SomeTexture.png
insideE:\Downloads\OpenSpades-0.0.42\Resources\CupcakesGunMod2.pak
(only if the above one wasn't found)
- Second, paks whose file name looks like
pak0123456789-xxxx.pak
, in the reverse order of the number.Textures/SomeTexture.png
insideE:\Downloads\OpenSpades-0.0.42\Resources\pak020-NewerDefaultAssets.pak
Textures/SomeTexture.png
insideE:\Downloads\OpenSpades-0.0.42\Resources\pak010-OlderDefaultAssets.pak
(only if the above one wasn't found)
- If the file is not found yet at this point, the suffix
.weak
is appended to the file name, and the steps 1-4 are tried again.
In this way,
- Users can override the standard behavior just by copying
something.pak
into one ofResources
directories. - Patching the official package becomes easier by using the next index number (ex.
pak010-0.14.0-patch.pak
,pak011-0.14.1-patch.pak
).
Pak Format
Pak files are implemented as merely renamed ZIP files. Additional formats (for example, encrypted bundles for IP protection) might be supported in the future.