*.CMP
Files
Fil_CMP.html

Name

nyc.cmp, sanb.cmp, miami.cmp - contains city map layout

Location

gtadata\*.cmp

Description

This file contains the layout of the city map. Since GTA is a 3D-game, the map consists of 256x256x6 cubes (see Coordinates). The cubes have textures from the style*.* files pasted on the sides and contain some game logic, too. Up to 6 cubes make up a stack. Stacks are then placed on the 256x256 map grid.

Header

The first 28 bytes in the file contain 7 Integers (32-bit). I call them h0 through h6. They set the lengths of different parts of the file (see below) or something comletely different.

Example (nyc.cmp): 331, 1, 2423, 42210, 117694, 42544, 980.

Structure of *.CMP


Example: nyc.cmp

Section

Position

Length

Position

Length

Header

0

28

0

28

Map Grid

28

262144

28

262144

Cube Stack Table

262172

h4

262172

117694

??? 5318 8-byte(?) records

262172+h4

h5

379866

42544

??? 3015 14-byte records

262172+h4+h5

h3

422410

42210

???

262172+h3+h4+h5


464620


??? unidentified


h0


331

??? unidentified


h1


1

??? unidentified


h2


2423

District information

EOF-h6

h6

467151

980

File Size

EOF

0

468131

0

Map Grid

The Map Grid section contains 256x256 32-bit integers corresponding to map (x,y) locations.

The order is simple:
(0,0)(1,0)(2,0)...(255,0)(0,1)(1,1)(2,1)...
...(253,255)(254,255)(255,255) 

The integers point to the Cube Stack Table.

Usage:

You can edit the map by copying entries from one spot to another; e.g. if you know the (x,y) coordinates of a building, you can copy its Map Grid entries to another location and find a copy of that building there. You should not change the Map Grid values randomly because then you may not be pointing to a valid Cube Stack Table Entry.

Example

2154 is the most common entry in nyc.cmp; it appears in 7357 locations and stands for light water. 2148 and 2142 stand for medium and dark shaded water. Common sidewalk values are 2386, 2982 and 2370.

More than half of the 10062 different values in nyc.cmp are used only once.


Cube Stack Table

A cube stack is a stack of up to 6 cubes that can be placed on the map by pointing to its entry from the map grid.

A stack entry has 4 to 7 16-bit integers. The first one stands for a number of "nothing" cubes on the top of the stack, the others stand for the remaining cubes. Illustration:

0 z0 z1 z2 z3 z4 z5
1 z1 z2 z3 z4 z5
2 z2 z3 z4 z5
3 z3 z4 z5
4 z4 z5
5 z5

z0-z5 stand for cube integers; the cubes are placed in the stack at the corresponding z values (see Coordinates). A totally empty stack (single 6) has not been observed yet.

Where the cube data is located is currently unknown; tell me if you find out!

In nyc.cmp at byte 262172+2142=264314 (that is byte 2142 in this section) you find these 16-bit integers:
4 183 182 4 183 184 4 183 185

This means that the water stacks for dark(2142),medium (2148) and light(2152) water each consist of two cubes topped with 4 cubes of nothing. The top cube in each is 183; it can be surmised that this cube contains the logic for drowning while 182, 183 and 185 contain the water textures.
There is only one stack that starts with 5, and that is entry 26246: 5 182. This stack is used only 8 times in nyc.cmp (e.g. at (43,136)). It has a dark water texture, and you can safely step on it because the 183 drowning logic cube is absent.

You can view GIFs of the three cities' stack heights (3x10KB).

Unidentified section

I have no clue what is in this section, or if it even exists. Some must not exist, because when you add 28+262144+h0+...h6, (for nyc.cmp) you get 468355, yet the file is only 468131 bytes long.

District Information Table

This section contains the names and locations of the districts on the map. Each district has a 35-byte-record:

byte 0 and 1: x and y coordinate of top left corner
byte 2 and 3: width and height of district area
byte 4: index of district
bytes 5-34: name of district as 0-terminated string

Unused records are all 0 and reside at the front of this section. The last record in this section (the last 35 bytes in the file!) holds information on the city area.

Examples from nyc.cmp:

1 2 126 47 2 Hackenslash
165 154 89 101 13 Kings
1 1 253 255 1 Liberty City

Kings is District number 13 and extends from (165,154) to (154,255).


See also:

Coordinates, Style00x.gry

Notes

Information contributed by Ian Howson and Michael Mendelsohn.

Bugs

Large parts of this file are still uncharted territory. The connection to style00x.gry is still missing.

*.CMP

Last change: 5 Jan 1998

unofficial GTA Reference