FreeCNC

FreeCNC - Linux Software and Games reviews

Template Format

admin @ 9:08 am

Templates are pieces of terrain, such as a cliff piece or a bridge. These templates are stored inside the WINTER, TEMPERATE or DESERT mixfiles. The template files contain the images for individual tiles.
The smallest template in the game is 1×1 tiles, the largest is 6×8 tiles.

Templates do not always have to be rectangular. Some templates such as diagonal roads or bridges have to fit into each other like a jigsaw puzzle. ‘Empty’ tiles (tiles without a related image) can either be replaced with the tiles of another template or they can actually be placed on the map – in this case the tile will be a simple land, or in some cases water, tile. Templates can be of complex shapes, but there is no way to tell the dimensions or shape of templates from the template files.

Template files have the following layout:

First there’s the header:

Data Type Field Name Description
uint16 width Width of the tiles – always 24
uint16 height Height of the tiles – always 24
uint16 tile_count Number of tiles in the template. This is not necessarily equal to the number of images in the file.
uint16 unknown1 Appears to always be 0×0000
uint32 filesize Filesize of the template file, in bytes
uint32 image_offset Offset of the image data
uint32 unknown2 Appears to always be 0×0000
uint16 unknown3 Appears to always be 0xFFFF
uint16 unknown4 Appears to always be 0×0D1A
uint32 image_index_offset Offset of image_index (see below)
uint32 tile_index_offset Offset of tile_index (see below)

The image data starts at image_offset, which is usually directly after the header. The images are uncompressed. Hence every individual image is 576 (24×24) bytes long. Each byte represents the index of the pixel’s color in the palette.
As said before, the number of tiles may differ from the number of images because of the aforementioned empty tiles (to allow for templates to fit into each other). The actual number of images in the file can be calculated like so:

image_count = (image_index_offset-image_offset)/(24*24)

tile_index_offset is an array of bytes of tile_count length, where every byte indicates which image is associated with the corresponding tile. Bytes for empty tiles have value 0xFF.
image_index_offset is an array of bytes of image_count length. The bytes are usually 0×00, but not always. The meaning of these values is unknown.

Below are listings of the various templates available in Tiberian Dawn and Red Alert.

Template List

Tiberian Dawn

… TODO …

Red Alert

… TODO…



Leave a comment

Name (required)

Mail (will not be published) (required)

Website