Mercurial > hg > openttd
annotate src/tile_map.h @ 20729:ea20edff1862 draft default tip master
(svn r25643) -Fix (r25480): [OSX] Define version constants before they're used
author | planetmaker <planetmaker@openttd.org> |
---|---|
date | Wed, 31 Jul 2013 18:50:01 +0000 |
parents | 0dba7f49118c |
children |
rev | line source |
---|---|
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
1 /* $Id$ */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
2 |
12778
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
3 /* |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
4 * This file is part of OpenTTD. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
5 * 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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
6 * 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. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
7 * 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/>. |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
8 */ |
bc7926153e19
(svn r17248) -Fix: add GPL license notice where appropriate
rubidium <rubidium@openttd.org>
parents:
10855
diff
changeset
|
9 |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
10 /** @file tile_map.h Map writing/reading functions for tiles. */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
11 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
12 #ifndef TILE_MAP_H |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
13 #define TILE_MAP_H |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
14 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
15 #include "slope_type.h" |
8139
db99ba38abc0
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium <rubidium@openttd.org>
parents:
8113
diff
changeset
|
16 #include "map_func.h" |
8113
c35412099303
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium <rubidium@openttd.org>
parents:
8108
diff
changeset
|
17 #include "core/bitmath_func.hpp" |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10208
diff
changeset
|
18 #include "settings_type.h" |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
19 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
20 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
21 * Returns the height of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
22 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
23 * This function returns the height of the northern corner of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
24 * This is saved in the global map-array. It does not take affect by |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
25 * any slope-data of the tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
26 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
27 * @param tile The tile to get the height from |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
28 * @return the height of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
29 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
30 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
31 static inline uint TileHeight(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
32 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
33 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
34 return GB(_m[tile].type_height, 0, 4); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
35 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
36 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
37 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
38 * Sets the height of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
39 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
40 * This function sets the height of the northern corner of a tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
41 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
42 * @param tile The tile to change the height |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
43 * @param height The new height value of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
44 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
45 * @pre heigth <= MAX_TILE_HEIGHT |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
46 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
47 static inline void SetTileHeight(TileIndex tile, uint height) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
48 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
49 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
50 assert(height <= MAX_TILE_HEIGHT); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
51 SB(_m[tile].type_height, 0, 4, height); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
52 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
53 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
54 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
55 * Returns the height of a tile in pixels. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
56 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
57 * This function returns the height of the northern corner of a tile in pixels. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
58 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
59 * @param tile The tile to get the height |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
60 * @return The height of the tile in pixel |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
61 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
62 static inline uint TilePixelHeight(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
63 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
64 return TileHeight(tile) * TILE_HEIGHT; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
65 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
66 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
67 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
68 * Get the tiletype of a given tile. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
69 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
70 * @param tile The tile to get the TileType |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
71 * @return The tiletype of the tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
72 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
73 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
74 static inline TileType GetTileType(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
75 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
76 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
77 return (TileType)GB(_m[tile].type_height, 4, 4); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
78 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
79 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
80 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
81 * Set the type of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
82 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
83 * This functions sets the type of a tile. If the type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
84 * MP_VOID is selected the tile must be at the south-west or |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
85 * south-east edges of the map and vice versa. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
86 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
87 * @param tile The tile to save the new type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
88 * @param type The type to save |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
89 * @pre tile < MapSize() |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
90 * @pre type MP_VOID <=> tile is on the south-east or south-west edge. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
91 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
92 static inline void SetTileType(TileIndex tile, TileType type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
93 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
94 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
95 /* VOID tiles (and no others) are exactly allowed at the lower left and right |
10855
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10208
diff
changeset
|
96 * edges of the map. If _settings_game.construction.freeform_edges is true, |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10208
diff
changeset
|
97 * the upper edges of the map are also VOID tiles. */ |
7881d9cd55ab
(svn r15190) -Feature: Allow terraforming of the tiles at the edges of the map.
Yexo <Yexo@openttd.org>
parents:
10208
diff
changeset
|
98 assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY() || (_settings_game.construction.freeform_edges && (TileX(tile) == 0 || TileY(tile) == 0))) == (type == MP_VOID)); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
99 SB(_m[tile].type_height, 4, 4, type); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
100 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
101 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
102 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
103 * Checks if a tile is a give tiletype. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
104 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
105 * This function checks if a tile got the given tiletype. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
106 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
107 * @param tile The tile to check |
19968
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
18270
diff
changeset
|
108 * @param type The type to check against |
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
18270
diff
changeset
|
109 * @return true If the type matches against the type of the tile |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
110 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
111 static inline bool IsTileType(TileIndex tile, TileType type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
112 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
113 return GetTileType(tile) == type; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
114 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
115 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
116 /** |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
117 * Checks if a tile is valid |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
118 * |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
119 * @param tile The tile to check |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
120 * @return True if the tile is on the map and not one of MP_VOID. |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
121 */ |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
122 static inline bool IsValidTile(TileIndex tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
123 { |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
124 return tile < MapSize() && !IsTileType(tile, MP_VOID); |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
125 } |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
126 |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
127 /** |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
128 * Returns the owner of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
129 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
130 * This function returns the owner of a tile. This cannot used |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
131 * for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
10207
c54d140df948
(svn r14421) -Codechange: rename all player variables/types to company *or* client so it is immediatelly clear which one you are working with.
rubidium <rubidium@openttd.org>
parents:
8651
diff
changeset
|
132 * as no company owned any of these buildings. |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
133 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
134 * @param tile The tile to check |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
135 * @return The owner of the tile |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
136 * @pre IsValidTile(tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
137 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
138 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
139 static inline Owner GetTileOwner(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
140 { |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
141 assert(IsValidTile(tile)); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
142 assert(!IsTileType(tile, MP_HOUSE)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
143 assert(!IsTileType(tile, MP_INDUSTRY)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
144 |
15772
1a21d8e5c3fa
(svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents:
15769
diff
changeset
|
145 return (Owner)GB(_m[tile].m1, 0, 5); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
146 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
147 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
148 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
149 * Sets the owner of a tile |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
150 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
151 * This function sets the owner status of a tile. Note that you cannot |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
152 * set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
153 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
154 * @param tile The tile to change the owner status. |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
155 * @param owner The new owner. |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
156 * @pre IsValidTile(tile) |
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
157 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
158 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
159 static inline void SetTileOwner(TileIndex tile, Owner owner) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
160 { |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
161 assert(IsValidTile(tile)); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
162 assert(!IsTileType(tile, MP_HOUSE)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
163 assert(!IsTileType(tile, MP_INDUSTRY)); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
164 |
15772
1a21d8e5c3fa
(svn r20446) -Codechange: unify the location of the water class
rubidium <rubidium@openttd.org>
parents:
15769
diff
changeset
|
165 SB(_m[tile].m1, 0, 5, owner); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
166 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
167 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
168 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
169 * Checks if a tile belongs to the given owner |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
170 * |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
171 * @param tile The tile to check |
19968
0dba7f49118c
(svn r24900) -Fix [FS#5389]: Comments with typos (most fixes supplied by Eagle_rainbow)
planetmaker <planetmaker@openttd.org>
parents:
18270
diff
changeset
|
172 * @param owner The owner to check against |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
173 * @return True if a tile belongs the the given owner |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
174 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
175 static inline bool IsTileOwner(TileIndex tile, Owner owner) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
176 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
177 return GetTileOwner(tile) == owner; |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
178 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
179 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
180 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
181 * Set the tropic zone |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
182 * @param tile the tile to set the zone of |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
183 * @param type the new type |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
184 * @pre tile < MapSize() |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
185 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
186 static inline void SetTropicZone(TileIndex tile, TropicZone type) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
187 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
188 assert(tile < MapSize()); |
15140
8676e88fecb0
(svn r19769) -Fix [FS#3820]: MV_VOID tiles shall have no tropic zone.
frosch <frosch@openttd.org>
parents:
14258
diff
changeset
|
189 assert(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL); |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
190 SB(_m[tile].m6, 0, 2, type); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
191 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
192 |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
193 /** |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
194 * Get the tropic zone |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
195 * @param tile the tile to get the zone of |
8651
ab28a213b924
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx <glx@openttd.org>
parents:
8254
diff
changeset
|
196 * @pre tile < MapSize() |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
197 * @return the zone type |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
198 */ |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
199 static inline TropicZone GetTropicZone(TileIndex tile) |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
200 { |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
201 assert(tile < MapSize()); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
202 return (TropicZone)GB(_m[tile].m6, 0, 2); |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
203 } |
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
204 |
15934
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
205 /** |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
206 * Get the current animation frame |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
207 * @param t the tile |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
208 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION) |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
209 * @return frame number |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
210 */ |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
211 static inline byte GetAnimationFrame(TileIndex t) |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
212 { |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
213 assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)); |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
214 return _me[t].m7; |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
215 } |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
216 |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
217 /** |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
218 * Set a new animation frame |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
219 * @param t the tile |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
220 * @param frame the new frame number |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
221 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION) |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
222 */ |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
223 static inline void SetAnimationFrame(TileIndex t, byte frame) |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
224 { |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
225 assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)); |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
226 _me[t].m7 = frame; |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
227 } |
3172190fa127
(svn r20622) -Codechange: unify [GS]et[Statation|Object|Industry|House]AnimationFrame
rubidium <rubidium@openttd.org>
parents:
15772
diff
changeset
|
228 |
18270
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
229 Slope GetTileSlope(TileIndex tile, int *h = NULL); |
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
230 int GetTileZ(TileIndex tile); |
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
231 int GetTileMaxZ(TileIndex tile); |
18256
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
232 |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
233 /** |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
234 * Return the slope of a given tile |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
235 * @param tile Tile to compute slope of |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
236 * @param h If not \c NULL, pointer to storage of z height |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
237 * @return Slope of the tile, except for the HALFTILE part |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
238 */ |
18270
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
239 static inline Slope GetTilePixelSlope(TileIndex tile, int *h) |
18256
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
240 { |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
241 Slope s = GetTileSlope(tile, h); |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
242 if (h != NULL) *h *= TILE_HEIGHT; |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
243 return s; |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
244 } |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
245 |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
246 /** |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
247 * Get bottom height of the tile |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
248 * @param tile Tile to compute height of |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
249 * @return Minimum height of the tile |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
250 */ |
18270
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
251 static inline int GetTilePixelZ(TileIndex tile) |
18256
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
252 { |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
253 return GetTileZ(tile) * TILE_HEIGHT; |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
254 } |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
255 |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
256 /** |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
257 * Get top height of the tile |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
258 * @param t Tile to compute height of |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
259 * @return Maximum height of the tile |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
260 */ |
18270
432112453b2e
(svn r23106) -Codechange: pass int* to GetTileSlope and friends
rubidium <rubidium@openttd.org>
parents:
18256
diff
changeset
|
261 static inline int GetTileMaxPixelZ(TileIndex tile) |
18256
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
262 { |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
263 return GetTileMaxZ(tile) * TILE_HEIGHT; |
43d8a1ace139
(svn r23092) -Codechange: create a non-pixel version of some of the Get*PixelZ functions, and let Get*PixelZ wrap around the new function (multiplying the Z by TILE_HEIGHT) just like TileHeight and TilePixelHeight
rubidium <rubidium@openttd.org>
parents:
18255
diff
changeset
|
264 } |
8108
4faab45e2603
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium <rubidium@openttd.org>
parents:
diff
changeset
|
265 |
15769
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
266 |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
267 /** |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
268 * Calculate a hash value from a tile position |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
269 * |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
270 * @param x The X coordinate |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
271 * @param y The Y coordinate |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
272 * @return The hash of the tile |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
273 */ |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
274 static inline uint TileHash(uint x, uint y) |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
275 { |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
276 uint hash = x >> 4; |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
277 hash ^= x >> 6; |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
278 hash ^= y >> 4; |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
279 hash -= y >> 6; |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
280 return hash; |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
281 } |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
282 |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
283 /** |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
284 * Get the last two bits of the TileHash |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
285 * from a tile position. |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
286 * |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
287 * @see TileHash() |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
288 * @param x The X coordinate |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
289 * @param y The Y coordinate |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
290 * @return The last two bits from hash of the tile |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
291 */ |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
292 static inline uint TileHash2Bit(uint x, uint y) |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
293 { |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
294 return GB(TileHash(x, y), 0, 2); |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
295 } |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
296 |
e61270493ab3
(svn r20443) -Codechange: more TileHash to a more generic location
rubidium <rubidium@openttd.org>
parents:
15140
diff
changeset
|
297 #endif /* TILE_MAP_H */ |