Using Pack Files and Virtual Directories

From C4 Engine Wiki

Jump to: navigation, search

The Resource Manager supports pack files and a virtual directory hierarchy. All resources are stored inside the Data folder, where resources can be organized in an arbitrary manner. However, the top-level contents of the Data folder have special meanings.

All of the top-level sub-folders of the Data folder behave as if their contents belonged to a single virtual folder at the root of the resource name space. These top-level sub-folders exist only for external organization and do not participate in the unique identification of any resources.

As an example, suppose that there existed two sub-folders Data/Interiors/ and Data/Exteriors/. A resource named Wood.tex could be stored in either sub-folder, but it would still be identified only as Wood by the Resource Manager. The name of the top-level sub-folder is not part of the resource's path. However, if the Wood.tex resource was placed in an additional sub-folder such as Data/Exteriors/Forest/, then the name of the resource would be Forest/Wood. All folder names beneath the top-level sub-folders of the Data directory are part of the resource name.

The resources that ship with the C4 Engine have been divided into the following sub-folders:

  • A C4 folder containing the resources used by the core engine and required by all applications built with C4.
  • A Demo folder containing the resources used exclusively by the demo game.
  • A Tools folder containing the resources used exclusively by the tool plugins.
  • A Tutorial folder containing the resources associated with the tutorials and sample worlds.

Pack files, having the extension .pak, can also be stored at the top level of the Data directory. A pack file is created by using the Resource Packer tool, to pack the contents of a top-level sub-folder into a single file. The console command pack name is used to create a pack file, where name is the name of a top-level sub-folder. For example, the command pack Demo will create the file Demo.pak, containing all of the resources used exclusively by the Demo game.

Once a pack file has been created, the folder from which it was made can be deleted, and the Resource Manager will then fetch resources from the pack file instead. (Pack files actually override ordinary folders.)

Some additional miscellaneous notes about the Resource Manager:

  • Folders and pack files are the only items allowed at the top level of the Data directory. Other types of files in that location will be ignored.
  • QuickTime movies cannot be accessed inside pack files.
  • Because concealment is a benefit provided by pack files, there will not be an unpacking tool that would allow users to easily extract resources from a .pak file.
  • Pack files take precedence in reverse lexicographical order according to their names. So if a resource with the same name exists in MyPatch1.pak and MyPatch2.pak, then the one in MyPatch2.pak will always be loaded because the name of the pack file comes later then MyPatch1.pak.
Personal tools