Fix #8316: Make sort industries by production and transported with a cargo filter...
[openttd-github.git] / src / map_type.h
blobf34f137c641348e59c9eca41bb977d8b9af17e8c
1 /*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
6 */
8 /** @file map_type.h Types related to maps. */
10 #ifndef MAP_TYPE_H
11 #define MAP_TYPE_H
13 /**
14 * Data that is stored per tile. Also used TileExtended for this.
15 * Look at docs/landscape.html for the exact meaning of the members.
17 struct Tile {
18 byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
19 byte height; ///< The height of the northern corner.
20 uint16 m2; ///< Primarily used for indices to towns, industries and stations
21 byte m1; ///< Primarily used for ownership information
22 byte m3; ///< General purpose
23 byte m4; ///< General purpose
24 byte m5; ///< General purpose
27 static_assert(sizeof(Tile) == 8);
29 /**
30 * Data that is stored per tile. Also used Tile for this.
31 * Look at docs/landscape.html for the exact meaning of the members.
33 struct TileExtended {
34 byte m6; ///< General purpose
35 byte m7; ///< Primarily used for newgrf support
36 uint16 m8; ///< General purpose
39 /**
40 * An offset value between to tiles.
42 * This value is used for the difference between
43 * to tiles. It can be added to a tileindex to get
44 * the resulting tileindex of the start tile applied
45 * with this saved difference.
47 * @see TileDiffXY(int, int)
49 typedef int32 TileIndexDiff;
51 /**
52 * A pair-construct of a TileIndexDiff.
54 * This can be used to save the difference between to
55 * tiles as a pair of x and y value.
57 struct TileIndexDiffC {
58 int16 x; ///< The x value of the coordinate
59 int16 y; ///< The y value of the coordinate
62 /** Minimal and maximal map width and height */
63 static const uint MIN_MAP_SIZE_BITS = 6; ///< Minimal size of map is equal to 2 ^ MIN_MAP_SIZE_BITS
64 static const uint MAX_MAP_SIZE_BITS = 12; ///< Maximal size of map is equal to 2 ^ MAX_MAP_SIZE_BITS
65 static const uint MIN_MAP_SIZE = 1 << MIN_MAP_SIZE_BITS; ///< Minimal map size = 64
66 static const uint MAX_MAP_SIZE = 1 << MAX_MAP_SIZE_BITS; ///< Maximal map size = 4096
68 /**
69 * Approximation of the length of a straight track, relative to a diagonal
70 * track (ie the size of a tile side).
72 * \#defined instead of const so it can
73 * stay integer. (no runtime float operations) Is this needed?
74 * Watch out! There are _no_ brackets around here, to prevent intermediate
75 * rounding! Be careful when using this!
76 * This value should be sqrt(2)/2 ~ 0.7071
78 #define STRAIGHT_TRACK_LENGTH 7071/10000
80 /** Argument for CmdLevelLand describing what to do. */
81 enum LevelMode {
82 LM_LEVEL, ///< Level the land.
83 LM_LOWER, ///< Lower the land.
84 LM_RAISE, ///< Raise the land.
87 #endif /* MAP_TYPE_H */