WORLD.DAT

From UFOpaedia
Revision as of 22:24, 10 April 2007 by Pi Masta (talk | contribs) (Updated, added XCOM and TFTD map with sensible color schemes)
Jump to navigation Jump to search

The original XCOM file is 13320 bytes long, while TFTD is 14660 bytes long. However, each uses the same 20-byte record length giving the original 666 entries and TFTD 733 entries. This file describes the terrain on the geoscape screen using quadrilateral polygons and triangles.

The first 16 bytes of file contain the points for the quad/triangle. 4 sets of 2 short (2-byte) integers, designating the 'X' and 'Y' coordinate (or latitude and longitude if you prefer). If the last set has an x value of -1 then it is to be rendered as a triangle, otherwise it is a quad.

The last 4 bytes in the record contain the terrain type. This could be a long integer or 2 short integers as the last 2 bytes in each record are 0.

Structure

Offsets Meaning Values
0-1 First X coordinate 0 - 2880
2-3 First Y coordinate -720 - 720
4-5 Second X coordinate 0 - 2880
6-7 Second Y coordinate -720 - 720
8-9 Third X coordinate 0 - 2880
10-11 Third Y coordinate -720 - 720
12-13 Fourth* X coordinate 0 - 2880
14-15 Fourth* Y coordinate -720 - 720
16-19 Terrain Type See Below 0-10 and 12

* As mentioned above, the fourth coordinate could be (-1, 0) denoting a triangle

Note: The values were obtained only on the original XCOM. Presumably the same restrictions apply for TFTD except for maybe the terrain types. Also the X ranges are assumed to max at 2880 as this is a multiple of 360, the max observed in the file is actually 2877

The last value

Xcom render2.gif

Rendering of the data in WORLD.DAT for the original XCOM. The colors are obtained by using offset 16-19 for each record. Click on the image to see the exact color key, generally speaking though it goes bright green to dark green for 0-5, and dark yellow to white for 6 - 12. Value 11 however is not used.

Tftd render.gif

Rendering of the data in WORLD.DAT for TFTD. Colors again are obtained by using the same offset as before. The colors simply go from blue to white for 0 to 13. It looks like it designates the depth of the water in the areas. Judging by the Great Barrier Reef as one of the shallowest places in the ocean, the lower the number the shallower the water. Thus blue is shallow and white is deep. (A bit counter-intuitive, I apologize Pi Masta)

Originally I thought the last value was the terrain type but I think that it cannot be since there are only 6 real terrain types on the map (10 in all, but xcom base, alien base, city, and mars aren't on the world map). For TFTD it seems obvious it is designating depths, but for XCOM I don't know what 12 different values would mean for terrain since there should only be 6.

Also TFTD seemed to have overlapping polygons at places whereas XCOM didn't (exception to the poles, which is probably because these polygon's are rendered to a sphere not a flat surface).

--Pi Masta 15:24, 10 April 2007 (PDT)

See Also

Saved Game Files

COS.DAT