Pack Files and Virtual Directories

From C4 Engine Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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 subfolders exist only for external organization and do not participate in the unique identification of any resources.

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

The resources that ship with the C4 Engine have been divided into the following subfolders:

  • A folder named Engine that contains the resources used by the core engine and required by all applications.
  • A folder named Tools that contains the resources used exclusively by the tool plugins.
  • A folder named Demo that contains the resources used exclusively by the demo worlds.
  • A folder named The31st that contains the resources used by our game The 31st.

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 subfolder 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 subfolder. For example, the command pack Demo will create the file Demo.pak containing all of the resources used exclusively by the Demo worlds.

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. (The pack file takes precedence over the folder from which it was created.)

Folders and pack files are the only items allowed at the top level of the Data directory. Other types of files in that location are ignored.

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 than MyPatch1.pak.

See Also