GAD

A GAD (GAme Data) file is used by the Thanatos Engine, which runs Age of Prisoners, to store game data, such as shaders, scripts, mazes, etc. It is an archive file, and therefore it stores a bunch of files inside it.

Up to Thanatos 0.0.7, a format now called "GADv1" was used; a new one is planned for Thanatos 0.0.8, named "GADv2". Due to the increasing size of those files as the game is being developed, GADv2 will be compressed.

Archive Contents
At the root of a GAD archive, there is a number of directories, and inside those directories, there are files that describe a game. This section of the article will describe those files.

Bitmaps
The  directory simply contains images used by the game, and by the engine. Some are required to be there, others are optional, and depend on whether they are needed due to settings in other files.

Cutscenes
The  directory contains scripts that describe what to do for each cutscene.

Fonts
The  directory contains ME-formatted fonts used in the game. As of 0.0.7 and 0.0.8, they are all required.

GUI
The  directory contains sub-directories, each specifying the workings of a different GUI. Some GUI are required, but may be customized. In each of those sub-directories, there are 4 files that describe a GUI:


 * : A script which tells the engine what to do for various events related to the GUI.
 * : Contains lines in the format, where the coordinates define a rectangle for a button, and   names a procedure in the   file that is to be called when the button is clicked.
 * : The image of the window of the GUI. All buttons are drawn on top.
 * : An image, the same size as, to be drawn on top of the buttons.

Mazes
The  directory contains the mazes for the game. Each one is named.

Misc
The  directory contains the following files:


 * : This file contains information about the game.
 * : This file contains the intro text.
 * : This file specifies game resources, such as materials and sounds.
 * / : Fragment & Vertex Shader templates.
 * : Tag information for the maze editor.

Phone
The  directory contains phone conversation files.

Scripts
The  directory contains scripts for controlling mazes, named , as well as a script for controlling the entire game,.

Shops
The  directory contains XML files that describe shops.

Sounds
The  directory contains WAVE-formatted sound files.

Weapons
The  directory contains images of weapons' bullets, normal and shooting overlays. For Thanatos 0.0.8+, we are planning to also add a weapon model there, for multiplayer games (so that players can see each other's weapons).

GADv1
GADv1 files contain a list of directories and files, and the file data. The file data is plain - no compression is involved. This section describes the structure of GADv1 files.

GADv1 Header
Right at the beginning of a file, you find a GADv1 Header, which is a structure that gives basic information about the file.

NOTE: A UNIX timestamp is the number of seconds since midnight, 1 January 1970 UTC.

Directory List
Right after the header, there is a list of directory names, separated by NULs. The list is sorted such that a directory's children always come after the parent.

File List
Right after the directory list, there is a file list. Each entry has a "file header", followed by a NUL-terminated file name, followed by the contents, whose size is specified by the header.

GADv2
GADv2 is a format planned for Thanatos 0.0.8, which adds support for compression. It is very similar to GADv1 in many ways, but different in others. This section describes this format.

GADv2 Header
Right at the beginning of a file, we have a GADv2 Header, which is almost the same as the GADv1 header, but please note the differences!

Empty Directory List
Right after the header, there is a list of empty directories; directories with content are not listed, because they can be extracted from file names, e.g. " " can be extracted from the fact that there is a " " file.

File List
Each entry in the file list is, yet again, made up of a "file header", a NUL-terminated file name, and the compressed file contents. The file header is also different:

Compression
GADv2 archives are compressed, and each file may have a different compression format. All the formats follow the same idea. You have a mapping of 'compressed bits', to "plain content". An example mapping could be:


 * 0 -> 11011011
 * 10 -> 11011100
 * 11 -> 11100011

Each format just has a different mapping. When you have a mapping, you can decompress a stream with the following algorythm (here I wrote it in pseudo-code):

while (input waiting) {   BitStream temp; while (no mapping for temp) {       temp += getBitFromInput; };

output += getMapping(temp); };

The rest of this section gives the mappings for various formats.

Format 0
There is no compression - the file is given in plain data.

Format 1
This is revision one of the format used by default to compress the file.

Bytes above 127 are not supported by this compression, as they should never legally appear in.