Difference between revisions of "WORLD.DAT"

From UFOpaedia
Jump to navigation Jump to search
m
 
(One intermediate revision by one other user not shown)
Line 39: Line 39:
  
 
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).
 
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 ==
 
== Texture / Terrain Type ==
Line 85: Line 87:
 
*[[TEXTURE.DAT]]
 
*[[TEXTURE.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