Mod:World Files
This article documents the format of the Redguard WLD files, which contain world geometry/height map information. Note that the information here is very preliminary at this time.
Contents
Overall Format[edit]
Header (1184 bytes) Section1 (65558 bytes) SectionHeader (22 bytes) Map1 (16384 bytes) Map2 (16384 bytes) Map3 (16384 bytes) Map4 (16384 bytes) Section2 (65558 bytes) Section3 (65558 bytes) Section4 (65558 bytes) Footer (16 bytes)
There are only 4 WLD files and each has the same size of 263,432 bytes. It is possible that other WLD sizes are permitted. All data is in Big Endian byte order unless specified.
Header Format[edit]
The file header is 1184 bytes in size and has the rough format:
dword Header[296]
Most of the header's purpose is unknown and most data has a value of 00. Some interesting fields include:
-
- Header[0] = 16 (size of footer?)
- Header[1] = 2
- Header[2] = 2
- Header[3] = 0
- Header[4] = 160 (0xA0)
- Header[5] = 1
- Header[6] = 22 (size of SectionHeader?)
- Header[7] = Size of file not including footer?
- Header[36] = Offset to first section from start of file
- Header[37] = Offset to second section from start of file
- Header[38] = Offset to third section from start of file
- Header[39] = Offset to forth section from start of file
- Header[40] = Large value way beyond the end of the file?
Section Format[edit]
There are 4 sections in each of the WLD files, each containing a header and 4 maps.
SectionHeader (22 bytes) Map1 (16384 bytes) Map2 (16384 bytes) Map3 (16384 bytes) Map4 (16384 bytes)
The sections in all WLD files are the same size but other sizes might be permitted.
Section Header[edit]
The section header is 22 bytes of data at the start of each section:
word SectionHeader[11]
The purpose of the data is unknown. SectionHeader[0], SectionHeader[3], and SectionHeader[4] have non-zero values but no obvious purpose. The rest appears to be all 0s.
Map Data[edit]
There are 4 maps in each section. Each map is a 128x128 array of data 16,384 bytes in size.
byte Map[128][128]
Each map has a slightly different format:
-
- Map1 -- Low 7 bits are the height map. High 1 bit is an unknown flag.
- Map2 -- Always 0?
- Map3 -- Low 6 bits are the texture index (possibly for TEXBSI302?). The upper 2 bits are texture rotation?
- Map4 -- Always 0?
[edit]
The footer is the last 16 bytes at the end of the file:
dword Values[4]
We can note the following:
-
- Values[0] -- Looks like the string 'TULO.'
- Values[1] -- Unknown value
- Values[2] -- -1
- Values[3] -- Size of the file?
Combining Map Data[edit]
Each map from the 4 sections can be combined into a larger 256x256 map by the following grid:
Section1 Section2 Section3 Section4
Notes[edit]
- There appears to be noise or extra bits along the border of some of the maps. It's not clear if this is real map data, extraneous data, or something that should not be in the map (format different than stated).
Other Info[edit]
- Redguard-3dfiletest — Test project that contains some code for exporting WLD data to PNG file.