Difference between revisions of "WORLD.DAT"

From UFOpaedia
Jump to navigation Jump to search
(Last value is the Terrain Texture)
(Polygon type vs Battle terrain)
Line 1: Line 1:
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 original XCOM file is 13320 bytes long, while TFTD is 14660 bytes long. However, each uses the same 20-byte record format 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 first 16 bytes of file contain the points for the polygon. 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.
 
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.
Line 26: Line 26:
 
| 14-15 || Fourth* Y coordinate || -720 - 720
 
| 14-15 || Fourth* Y coordinate || -720 - 720
 
|-
 
|-
| 16-19 || Terrain Texture [[#The last value|See Below]] || 0-10 and 12
+
| 16-19 || Terrain Type/Texture || 0-12
 
|}
 
|}
 
<small><nowiki>*</nowiki> As mentioned above, the fourth coordinate could be (-1, 0) denoting a triangle</small>
 
<small><nowiki>*</nowiki> As mentioned above, the fourth coordinate could be (-1, 0) denoting a triangle</small>
  
'''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
+
As the possible latitude values range from 0 to 2880 and the longitude values range from -720 to 720, the resulting map could be said to have a resolution of 00°07'30".
  
=== The last value ===
+
=== Texture / Terrain Type ===
 +
 
 +
The final value in each record points to the [[TEXTURE.DAT|texture type]] to be displayed for that polygon. It also serves to determine the terrain type used when you start a battle in that area.
 +
 
 +
<b>UFO</b>                                    <b>TFTD</b>
 +
  0: Forest / Jungle                    0: (Nothing?)
 +
  1: Farm                                1: Pipes
 +
  2: Farm                                2: Crashed Plane
 +
  3: Farm                                3: Atlantis
 +
  4: Farm                                4: Mu
 +
  5: Mountain                            5: Sunken Galleon
 +
  6: Forest / Jungle                    6: Sunken Liner
 +
  7: Desert                              7: Volcanic
 +
  8: Desert                              8: (Nothing?)
 +
  9: Polar                              9: Volcanic
 +
10: Forest / Jungle                    10: Sunken Liner
 +
11: Forest / Jungle                    11: Pipes
 +
12: Polar                              12: Mu
 +
 
 +
In UFO, terrain types 0, 6, 10 and 11 will produce forest missions in the northern hemisphere and jungle mission in the south.
 +
 
 +
For TFTD, the terrain type is always selected randomly from a choice of three - Coral, Seabed Rubbish, and whatever the terrain type for that actual polygon is. In the case of a type 0 or 8, the mission will always be in either the Coral or Seabed Rubbish terrains.
 +
 
 +
Although TFTD has three choices of underwater depth that can be associated with any given mission (plus a forth "depth" for surface missions), that value is not derived from this file. Most likely it's taken from the [[LOC.DAT]] record that points to the mission in concern.
  
 
{|
 
{|
 
| [[Image:xcom_render2.gif|360px]]
 
| [[Image:xcom_render2.gif|360px]]
 
|  
 
|  
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.
+
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 anywhere in the map.
 
|-
 
|-
 
| [[Image:tftd_render.gif|360px]]
 
| [[Image:tftd_render.gif|360px]]
 
|
 
|
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 [[User:Pi Masta|Pi Masta]])
+
Rendering of the data in WORLD.DAT for TFTD. Colors again are obtained by using the same offset as before. They go from  blue to white for 0 to 12.  
 
|}
 
|}
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).
+
<i>TFTD seems 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).
  
 
--[[User:Pi Masta|Pi Masta]] 15:24, 10 April 2007 (PDT)
 
--[[User:Pi Masta|Pi Masta]] 15:24, 10 April 2007 (PDT)
  
'''UPDATE:'''
+
Each polygon has it's light calculated individually, This gives rise to the effect of a large area of the same texture having different colors.
Ok, I believe these last values map to [[TEXTURE.DAT]]. There seems to be 3 sets of 13 textures, with the 13th one always looking like ice chunks (white on my rendering). As to which set of 13 textures it will use where I think it depends on the zoom level. It seems though that multiple textures map to the same terrain type for generating a map. If you zoom in enough you will notice different textures for grassy and forested areas. As to what number maps to what generated terrain and where that's stored is most likely in the executable.
 
  
Also, each polygon has it's light calculated individually, This gives rise to the effect of a large area of the same texture having different colors.
+
The country and regional borders must be stored in the executable somewhere. I've tried hard looking for the position of cities in there hoping the position would be near it's [[ENGLISH.DAT]] index, but I haven't had much luck.
  
The country and regional borders must be stored in the executable somewhere. I've tried hard looking for the position of cities in there hoping the position would be near it's [[ENGLISH.DAT]] index, but I haven't had much luck. --[[User:Pi Masta|Pi Masta]] 16:06, 10 April 2007 (PDT)
+
--[[User:Pi Masta|Pi Masta]] 16:06, 10 April 2007 (PDT)</i>
  
 
== See Also ==
 
== See Also ==
  
[[Saved Game Files]]
+
*[[COS.DAT]]
 
+
*[[TEXTURE.DAT]]
[[COS.DAT]]
 
 
[[Category:Game Files]]
 
[[Category:Game Files]]

Revision as of 09:23, 30 January 2008

The original XCOM file is 13320 bytes long, while TFTD is 14660 bytes long. However, each uses the same 20-byte record format 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 polygon. 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/Texture 0-12

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

As the possible latitude values range from 0 to 2880 and the longitude values range from -720 to 720, the resulting map could be said to have a resolution of 00°07'30".

Texture / Terrain Type

The final value in each record points to the texture type to be displayed for that polygon. It also serves to determine the terrain type used when you start a battle in that area.

UFO                                    TFTD
 0: Forest / Jungle                     0: (Nothing?)
 1: Farm                                1: Pipes 
 2: Farm                                2: Crashed Plane 
 3: Farm                                3: Atlantis
 4: Farm                                4: Mu
 5: Mountain                            5: Sunken Galleon
 6: Forest / Jungle                     6: Sunken Liner
 7: Desert                              7: Volcanic
 8: Desert                              8: (Nothing?)
 9: Polar                               9: Volcanic
10: Forest / Jungle                    10: Sunken Liner
11: Forest / Jungle                    11: Pipes 
12: Polar                              12: Mu

In UFO, terrain types 0, 6, 10 and 11 will produce forest missions in the northern hemisphere and jungle mission in the south.

For TFTD, the terrain type is always selected randomly from a choice of three - Coral, Seabed Rubbish, and whatever the terrain type for that actual polygon is. In the case of a type 0 or 8, the mission will always be in either the Coral or Seabed Rubbish terrains.

Although TFTD has three choices of underwater depth that can be associated with any given mission (plus a forth "depth" for surface missions), that value is not derived from this file. Most likely it's taken from the LOC.DAT record that points to the mission in concern.

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 anywhere in the map.

Tftd render.gif

Rendering of the data in WORLD.DAT for TFTD. Colors again are obtained by using the same offset as before. They go from blue to white for 0 to 12.

TFTD seems 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)

Each polygon has it's light calculated individually, This gives rise to the effect of a large area of the same texture having different colors.

The country and regional borders must be stored in the executable somewhere. I've tried hard looking for the position of cities in there hoping the position would be near it's ENGLISH.DAT index, but I haven't had much luck.

--Pi Masta 16:06, 10 April 2007 (PDT)

See Also