OpenTTD Landscape Internals - #2
Description: Structure of OpenTTD (OTTD) landscape arrays #2

### Landscape

Five arrays are used to encode the information of the contents of the tile. This can be seen in the Landscape document. This page tries to give an overview of used and free bits of the array so you can quickly see what is used and what is not.

- O - bit is free
- X - bit is used
- - bit of _map_* is abused for different purposes

- _map_owner[] - 8 bits in size, used to identify the owner of that tile (eg piece of rail, bridge, etc.).
- _map2[] - 16 bits in size, used to identify the index of the given tile (object) in the (object-)array.
- _map3[] - 16 bits in size, which is split up into _map3lo[] and _map3hi[] is used for general storage.
- _map_type_and_height[] - 8 bits in size, stores tile height (lower 4 bits) and tile class (upper 4 bits).
- _map5[] - 8 bits in size, is used for general storage.

class | _map_owner[L1] (8) | _map2[L2] (16) | _map3[lo& hi,L3] (16) | _map_type_and_height[L4] (8) | _map5[L5] (8)
--- | --- | --- | --- | --- | ---
(0) ground | XXXX XXXX | OOOO OOOO OOOO OOOO | XXXX OOOO OOXX XXXX | XXXX XXXX | XXXX XOXX
(1) rail | XXXX XXXX | XXXX XXXX OOOO OOOO | XXXX XXXX XXXO OOOO | XXXX XXXX | XXXX XXXX
depot/checkpoint | -inherit- | OOOO OOOO OOOO OOOO | XXXX XOOO XXXX XXXX | -inherit- | XXXO OOXX
(2) road | XXXX XXXX | XXXX XXXX XXXX XXXX | OOOO OOOO XXXX XXXX | XXXX XXXX | XXXX XXXX
level crossing | -inherit- | XXXX XXXX XXXX XXXX | XXXX XXXX XXXX XXXX | -inherit- | OOXX XXXX
road depot | -inherit- | OOOO OOOO OOOO OOOO | OOOO OOOO OOOO OOOX | -inherit- | XXXX XXXX
(3) town | XXXX XXXX | XXXX XXXX XXXX XXXX | XXXX XXXX XXXX XXXX | XXXX XXXX | XXXX XXOX
(4) trees | XXXX XXXX | XXXX XXOO OOOO OOOO | XXXX XXXX OOXX XXXX | XXXX XXXX | XXXO OOXX
(5) station | XXXX XXXX | XXXX XXXX XXXX XXXX | XXXX XOOO XXXX XXXX | XXXX XXXX | XXXX XXXX
(6) water | XXXX XXXX | OOOO OOOO OOOO OOOO | OOOO OOOO OOOO OOOO | XXXX XXXX | XXXX XXXX
(8) industry | XXXX XOOX | XXXX XXXX XXXX XXXX | OOOO OOOO OOOO OOOO | XXXX XXXX | XXXX XXXX
bubble/sugar/toffee | -inherit- | -inherit- | XXXX XXXX OOOO OOOO | -inherit- | -inherit-
toy factory | -inherit- | -inherit- | XXXX XXXX XXXX XXXX | -inherit- | -inherit-
gold/copper/coal | XXXX XXXX | -inherit- | -inherit- | -inherit- | -inherit-
oil wells | -inherit- | -inherit- | -inherit- | -inherit- | -inherit-
power station | XXXX XXOX | -inherit- | -inherit- | -inherit- | -inherit-
(9) tunnel | XXXX XXXX | OOOO OOOO OOOO OOOO | XXXX OOOO OOOO OOOX | XXXX XXXX | XXXX XXXX
bridge | XXXX XXXX | XXXX XXXX OOOO OOOO | XXXX XXXX OOOO OOOX | XXXX XXXX | XXXX XXXX
(10) various (HQ) | XXXX XXXX | OOOO OOOO OOOO OOOO | OOOO OOOO OOOO OOOO | XXXX XXXX | XXXX XXXX