Difference between revisions of "WORLD.DAT"

From UFOpaedia
Jump to navigation Jump to search
m
 
(21 intermediate revisions by 9 users not shown)
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 longitude and latitude respectively, 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 10: Line 10:
 
! Offsets !! Meaning !! Values
 
! Offsets !! Meaning !! Values
 
|-
 
|-
| 0-1  || First X coordinate || 0 - 2880
+
| 0-1  || First X coordinate/longitude || 0 - 2879
 
|-
 
|-
| 2-3  || First Y coordinate || -720 - 720
+
| 2-3  || First Y coordinate/latitude || -720 - 720
 
|-
 
|-
| 4-5  || Second X coordinate || 0 - 2880
+
| 4-5  || Second X coordinate/longitude || 0 - 2879
 
|-
 
|-
| 6-7  || Second Y coordinate || -720 - 720
+
| 6-7  || Second Y coordinate/latitude || -720 - 720
 
|-
 
|-
| 8-9  || Third X coordinate || 0 - 2880
+
| 8-9  || Third X coordinate/longitude || 0 - 2879
 
|-
 
|-
| 10-11 || Third Y coordinate || -720 - 720
+
| 10-11 || Third Y coordinate/latitude || -720 - 720
 
|-
 
|-
| 12-13 || Fourth* X coordinate || 0 - 2880
+
| 12-13 || Fourth* X coordinate/longitude || 0 - 2879
 
|-
 
|-
| 14-15 || Fourth* Y coordinate || -720 - 720
+
| 14-15 || Fourth* Y coordinate/latitude || -720 - 720
 
|-
 
|-
| 16-19 || <s>Terrain Type</s> [[#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
+
== Relationship to Real World Geography ==
  
=== The last value ===
+
As the 2880 possible longitude values range from 0 to 2879 (hex: 3F 0B) and the latitude values range from -720 to 720, the resulting map could be said to have a spatial resolution of one-eighth of a degree, both in latitude and in longitude (0.125° or 00°07'30"). (2880 = 360 x 8, and 720 = 90 x 8.)
  
{|
+
This implies that, at the equator, each possible map location on the Geoscape occupies a square that is 60 nautical miles (111 kilometres, 69 statute miles) on its side, or an area of 4,761 square miles / 12,321 square kilometres. This area would of course reduce with North or South latitude as you move away from the equator (and also the shape of the area will become progressively less square).
| [[Image:world_render.gif|640px]]
 
|
 
Originally I thought the last value was the terrain type but it is obvious 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) There are 12 discrete values, 0 to 10 and then 12. Some reason 11 is skipped. There are 12 regions in the world but a rough rendering of the data shows it must be representing the terrain as well.
 
  
Rough rendering of the data in WORLD.DAT. Each color is a different number in offset 16-19, for example white is 2. You can see that it does follow some terrain as found, but for example the Rocky Mountains and the Alps are different colors but should both be mountainous.
+
The X coordinate starts with X = 0 at 0° longitude (the Prime Meridian or Greenwich Meridian) and increases going eastward. Unlike real-world longitude, there is only "East" longitude, from 0°E to 359.875°E. This is the result of forcing the coordinate system to be positive-only, for algorithmic purposes. So, for example, the equivalent of 90°W longitude would be "270°E longitude", with a game X coordinate of 270 x 8 = 2160.  
  
--[[User:Pi Masta|Pi Masta]] 23:24, 5 April 2007 (PDT)
+
A Y coordinate value of 720 (hex: D0 02) corresponds to 90°S latitude (the South Pole); a Y coordinate value of -720 (hex: 30 FD) corresponds to 90°N latitude (the North Pole).
|}
+
 
 +
The coordinate system used in EU and TFTD is a form of geodetic coordinate system [http://en.wikipedia.org/wiki/Geodetic_coordinates].
 +
 
 +
== 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 Ice                          9: Volcanic
 +
10: Forest / Jungle                    10: Sunken Liner
 +
11: Forest / Jungle                    11: Pipes
 +
12: Polar Seas w/Icebergs              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. (11 is not actually used in the game, but hacking reveals this.)
 +
 
 +
For TFTD, the terrain type is always selected randomly from a choice of three - Coral, Seabed, 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 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.
 +
 
 +
<gallery widths="400" heights="225">
 +
Image: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.
 +
Image: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.
 +
</gallery>
 +
 
 +
<i>TFTD seems to have overlapping polygons at places whereas XCOM didn't (exception to the poles, which is probably because these polygons are rendered to a sphere, not a flat surface).</i>
 +
 
 +
--[[User:Pi Masta|Pi Masta]] 15:24, 10 April 2007 (PDT)
 +
 
 +
Each polygon has its light calculated individually. This gives rise to the effect of a large area of the same texture having different colors, depending on how much sunlight the particular area defined by the WORLD.DAT record is receiving.
 +
 
 +
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 its [[ENGLISH.DAT]] index, but I haven't had much luck.
 +
 
 +
--[[User:Pi Masta|Pi Masta]] 16:06, 10 April 2007 (PDT)
  
 
== See Also ==
 
== See Also ==
  
[[Saved Game Files]]
+
*[[COS.DAT]]
 
+
*[[TEXTURE.DAT]]
[[COS.DAT]]
 
 
[[Category:Game Files]]
 
[[Category:Game Files]]
 +
[[Category:Enemy Unknown/UFO Defense]]

Latest revision as of 15:58, 16 August 2014

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 longitude and latitude respectively, 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/longitude 0 - 2879
2-3 First Y coordinate/latitude -720 - 720
4-5 Second X coordinate/longitude 0 - 2879
6-7 Second Y coordinate/latitude -720 - 720
8-9 Third X coordinate/longitude 0 - 2879
10-11 Third Y coordinate/latitude -720 - 720
12-13 Fourth* X coordinate/longitude 0 - 2879
14-15 Fourth* Y coordinate/latitude -720 - 720
16-19 Terrain Type/Texture 0-12

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

Relationship to Real World Geography

As the 2880 possible longitude values range from 0 to 2879 (hex: 3F 0B) and the latitude values range from -720 to 720, the resulting map could be said to have a spatial resolution of one-eighth of a degree, both in latitude and in longitude (0.125° or 00°07'30"). (2880 = 360 x 8, and 720 = 90 x 8.)

This implies that, at the equator, each possible map location on the Geoscape occupies a square that is 60 nautical miles (111 kilometres, 69 statute miles) on its side, or an area of 4,761 square miles / 12,321 square kilometres. This area would of course reduce with North or South latitude as you move away from the equator (and also the shape of the area will become progressively less square).

The X coordinate starts with X = 0 at 0° longitude (the Prime Meridian or Greenwich Meridian) and increases going eastward. Unlike real-world longitude, there is only "East" longitude, from 0°E to 359.875°E. This is the result of forcing the coordinate system to be positive-only, for algorithmic purposes. So, for example, the equivalent of 90°W longitude would be "270°E longitude", with a game X coordinate of 270 x 8 = 2160.

A Y coordinate value of 720 (hex: D0 02) corresponds to 90°S latitude (the South Pole); a Y coordinate value of -720 (hex: 30 FD) corresponds to 90°N latitude (the North Pole).

The coordinate system used in EU and TFTD is a form of geodetic coordinate system [1].

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 Ice                           9: Volcanic
10: Forest / Jungle                    10: Sunken Liner
11: Forest / Jungle                    11: Pipes 
12: Polar Seas w/Icebergs              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. (11 is not actually used in the game, but hacking reveals this.)

For TFTD, the terrain type is always selected randomly from a choice of three - Coral, Seabed, 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 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.

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

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

Each polygon has its light calculated individually. This gives rise to the effect of a large area of the same texture having different colors, depending on how much sunlight the particular area defined by the WORLD.DAT record is receiving.

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 its ENGLISH.DAT index, but I haven't had much luck.

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

See Also