OpenTTDDevBlackBook/Map/Tile

From OpenTTD

Jump to: navigation, search

[edit] Landscape

Five arrays are used to encode the information of the contents of each tile. These arrays are referred to as "type_height","m1","m2","m3", "m4","m5" and "extra". The known encodings are listed in the table below. The most important value is the class of a tile, stored in the upper 4 bits of the type_height array. The lower 4 bits are used to encode the height and slope data.

For a graphical representation of the tile-layout have a look at Landscape grid page.

Owner values 00 through 07 are companies (they're indices into the array of companies), 10 is no owner, 11 appears to be reserved for water, 80 and above are towns (in this case the low 7 bits contain an index into the town array).

The "extra" member's main purpose is to distinguish from rain forest area and desert ones. This is usefull for industries, for example. Only two bits (0 and 1) are used and saved. The others bits are not used nor saved.

TTD's class-specific periodic tile processing routine is called once every +256 ticks for each tile.

Classes B through F are reserved. The presence of a tile in one of the reserved classes will crash OTTD.

/**
* Data that is stored per tile. Also used TileExtended for this.
* Look at docs/landscape.html for the exact meaning of the members.
*/
struct Tile {
	byte type_height; ///< The type (bits 4..7) and height of the northern corner
	byte m1;   ///< Primarily used for ownership information
	uint16 m2; ///< Primarily used for indices to towns, industries and stations
	byte m3;   ///< General purpose
	byte m4;   ///< General purpose
	byte m5;   ///< General purpose
	byte m6;   ///< Primarily used for bridges and rainforest/desert
};
Personal tools