author | skidd13 |
Tue, 20 Nov 2007 14:11:19 +0000 | |
changeset 8428 | f8300c908bd9 |
parent 7866 | e19fda04e8d3 |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
6918
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6574
diff
changeset
|
3 |
/** @file tile.h */ |
5589c415e28f
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
belugas
parents:
6574
diff
changeset
|
4 |
|
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
5 |
#ifndef TILE_H |
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
6 |
#define TILE_H |
926
bd4312619522
(svn r1414) Move TileIndex, TILE_MASK and GET_TILE_[XY] to map.h and turn the latter into inline functions names Tile[XY]
tron
parents:
909
diff
changeset
|
7 |
|
1394
449e84bdc04e
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
8 |
#include "macros.h" |
5838
9c3129cb019b
(svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents:
5726
diff
changeset
|
9 |
#include "openttd.h" |
1209
a1ac96655b79
(svn r1713) Split off several functions which query/set information about a single tile from map.h and put them into a seperate file tile.h
tron
parents:
1202
diff
changeset
|
10 |
#include "map.h" |
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3379
diff
changeset
|
11 |
#include "slope.h" |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
12 |
|
7809
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
13 |
/** Maximum allowed tile height */ |
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
14 |
#define MAX_TILE_HEIGHT 15 |
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
15 |
|
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
16 |
/** Maximum allowed snowline height */ |
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
17 |
#define MAX_SNOWLINE_HEIGHT (MAX_TILE_HEIGHT - 2) |
40156c450f13
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6918
diff
changeset
|
18 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
19 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
20 |
* The different type of a tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
21 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
22 |
* Each tile belongs to one type, according whatever is build on it. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
23 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
24 |
* @note A railway with a crossing street is marked as MP_ROAD. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
25 |
*/ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5847
diff
changeset
|
26 |
enum TileType { |
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
27 |
MP_CLEAR, ///< A tile without any structures, i.e. grass, rocks, farm fields etc. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
28 |
MP_RAILWAY, ///< A railway |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7861
diff
changeset
|
29 |
MP_ROAD, ///< A tile with road (or tram tracks) |
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
30 |
MP_HOUSE, ///< A house by a town |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
31 |
MP_TREES, ///< Tile got trees |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
32 |
MP_STATION, ///< A tile of a station |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
33 |
MP_WATER, ///< Water tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
34 |
MP_VOID, ///< Invisible tiles at the SW and SE border |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
35 |
MP_INDUSTRY, ///< Part of an industry |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
36 |
MP_TUNNELBRIDGE, ///< Tunnel entry/exit and bridge heads |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
37 |
MP_UNMOVABLE, ///< Contains an object with cannot be removed like transmitters |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5847
diff
changeset
|
38 |
}; |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
39 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
40 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
41 |
* Additional infos of a tile on a tropic game. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
42 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
43 |
* Each non-water tile in a tropic game is either a rainforest tile or a |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
44 |
* desert one. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
45 |
*/ |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5847
diff
changeset
|
46 |
enum TropicZone { |
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
47 |
TROPICZONE_INVALID = 0, ///< Invalid tropiczone-type |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
48 |
TROPICZONE_DESERT = 1, ///< Tile is desert |
7866
e19fda04e8d3
(svn r10733) -Codechange: change MP_STREET into MP_ROAD as we use the word "road" everywhere except in the tile type.
rubidium
parents:
7861
diff
changeset
|
49 |
TROPICZONE_RAINFOREST = 2, ///< Rainforest tile |
6574
e1d1a12faaf7
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5847
diff
changeset
|
50 |
}; |
1211 | 51 |
|
3636
d87b21df2944
(svn r4541) Add a type for slopes and replace many magic numbers by the appropriate enums
tron
parents:
3379
diff
changeset
|
52 |
Slope GetTileSlope(TileIndex tile, uint *h); |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
53 |
uint GetTileZ(TileIndex tile); |
3773
996897ffc8ea
(svn r4765) Add GetTileMaxZ(), which returns the height of the highest corner of a tile, and use it to simplify the code in a few places
tron
parents:
3636
diff
changeset
|
54 |
uint GetTileMaxZ(TileIndex tile); |
1335
a635854c23b6
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
55 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
56 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
57 |
* Returns the height of a tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
58 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
59 |
* This function returns the height of the northern corner of a tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
60 |
* This is saved in the global map-array. It does not take affect by |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
61 |
* any slope-data of the tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
62 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
63 |
* @param tile The tile to get the height from |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
64 |
* @return the height of the tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
65 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
66 |
*/ |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
67 |
static inline uint TileHeight(TileIndex tile) |
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
68 |
{ |
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
69 |
assert(tile < MapSize()); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1967
diff
changeset
|
70 |
return GB(_m[tile].type_height, 0, 4); |
1044
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
71 |
} |
9b73df700a7c
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
72 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
73 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
74 |
* Sets the height of a tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
75 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
76 |
* This function sets the height of the northern corner of a tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
77 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
78 |
* @param tile The tile to change the height |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
79 |
* @param height The new height value of the tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
80 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
81 |
* @pre heigth <= MAX_TILE_HEIGHT |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
82 |
*/ |
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
83 |
static inline void SetTileHeight(TileIndex tile, uint height) |
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
84 |
{ |
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
85 |
assert(tile < MapSize()); |
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
86 |
assert(height <= MAX_TILE_HEIGHT); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1967
diff
changeset
|
87 |
SB(_m[tile].type_height, 0, 4, height); |
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
88 |
} |
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
89 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
90 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
91 |
* Returns the height of a tile in pixels. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
92 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
93 |
* This function returns the height of the northern corner of a tile in pixels. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
94 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
95 |
* @param tile The tile to get the height |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
96 |
* @return The height of the tile in pixel |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
97 |
*/ |
1041
be151b7bc909
(svn r1542) Rename TileHeight to TilePixelHeight, because this is what it actually returns
tron
parents:
1035
diff
changeset
|
98 |
static inline uint TilePixelHeight(TileIndex tile) |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
99 |
{ |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
100 |
return TileHeight(tile) * TILE_HEIGHT; |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
101 |
} |
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
102 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
103 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
104 |
* Get the tiletype of a given tile. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
105 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
106 |
* @param tile The tile to get the TileType |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
107 |
* @return The tiletype of the tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
108 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
109 |
*/ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
110 |
static inline TileType GetTileType(TileIndex tile) |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
111 |
{ |
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
112 |
assert(tile < MapSize()); |
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3794
diff
changeset
|
113 |
return (TileType)GB(_m[tile].type_height, 4, 4); |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
114 |
} |
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
115 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
116 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
117 |
* Set the type of a tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
118 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
119 |
* This functions sets the type of a tile. If the type |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
120 |
* MP_VOID is selected the tile must be at the south-west or |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
121 |
* south-east edges of the map and vice versa. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
122 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
123 |
* @param tile The tile to save the new type |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
124 |
* @param type The type to save |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
125 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
126 |
* @pre type MP_VOID <=> tile is on the south-east or south-west edge. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
127 |
*/ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
128 |
static inline void SetTileType(TileIndex tile, TileType type) |
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
129 |
{ |
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
130 |
assert(tile < MapSize()); |
4010
e1c717629783
(svn r5221) Make the assertion in SetTileType() more strict: "lower edge of map <=> VOID" instead of just "lower edge of map => VOID"
tron
parents:
3900
diff
changeset
|
131 |
/* VOID tiles (and no others) are exactly allowed at the lower left and right |
4077
d3022f976946
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
132 |
* edges of the map */ |
4010
e1c717629783
(svn r5221) Make the assertion in SetTileType() more strict: "lower edge of map <=> VOID" instead of just "lower edge of map => VOID"
tron
parents:
3900
diff
changeset
|
133 |
assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID)); |
2049
ad0d49c916d4
(svn r2558) Change the internal map format from 7 arrays to one array of structs, this doesn't change the saved format for now. It's a stepping stone for further changes.
tron
parents:
1967
diff
changeset
|
134 |
SB(_m[tile].type_height, 4, 4, type); |
1059
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
135 |
} |
c28c6be74291
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
136 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
137 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
138 |
* Checks if a tile is a give tiletype. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
139 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
140 |
* This function checks if a tile got the given tiletype. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
141 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
142 |
* @param tile The tile to check |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
143 |
* @param type The type to check agains |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
144 |
* @return true If the type matches agains the type of the tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
145 |
*/ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
146 |
static inline bool IsTileType(TileIndex tile, TileType type) |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
147 |
{ |
1214
33e07bbb7779
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
148 |
return GetTileType(tile) == type; |
1035
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
149 |
} |
0a170deb6e33
(svn r1536) Move GET_TILEHEIGHT, GET_TILETYPE and IS_TILETYPE to map.h, turn them into inline functions and add some asserts
tron
parents:
979
diff
changeset
|
150 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
151 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
152 |
* Returns the owner of a tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
153 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
154 |
* This function returns the owner of a tile. This cannot used |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
155 |
* for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
156 |
* as no player owned any of these buildings. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
157 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
158 |
* @param tile The tile to check |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
159 |
* @return The owner of the tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
160 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
161 |
* @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
162 |
*/ |
1333 | 163 |
static inline Owner GetTileOwner(TileIndex tile) |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
164 |
{ |
1333 | 165 |
assert(tile < MapSize()); |
1898
b9fe2a5b7e13
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
166 |
assert(!IsTileType(tile, MP_HOUSE)); |
b9fe2a5b7e13
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
167 |
assert(!IsTileType(tile, MP_VOID)); |
b9fe2a5b7e13
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
168 |
assert(!IsTileType(tile, MP_INDUSTRY)); |
b9fe2a5b7e13
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
169 |
|
3900
4984308f9125
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3794
diff
changeset
|
170 |
return (Owner)_m[tile].m1; |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
171 |
} |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
172 |
|
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
173 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
174 |
* Sets the owner of a tile |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
175 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
176 |
* This function sets the owner status of a tile. Note that you cannot |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
177 |
* set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
178 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
179 |
* @param tile The tile to change the owner status. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
180 |
* @param owner The new owner. |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
181 |
* @pre tile < MapSize() |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
182 |
* @pre The type of the tile must not be MP_HOUSE, MP_VOID and MP_INDUSTRY |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
183 |
*/ |
1902 | 184 |
static inline void SetTileOwner(TileIndex tile, Owner owner) |
185 |
{ |
|
186 |
assert(tile < MapSize()); |
|
187 |
assert(!IsTileType(tile, MP_HOUSE)); |
|
188 |
assert(!IsTileType(tile, MP_VOID)); |
|
189 |
assert(!IsTileType(tile, MP_INDUSTRY)); |
|
190 |
||
2360
09e42e4ee139
(svn r2886) Rename the "owner" attribute to "m1", because when it stores an owner it is accessed by [GS]etOwner anyway and when it doesn't store an owner, but arbitrary data, accessing a field called "owner" is confusing.
tron
parents:
2186
diff
changeset
|
191 |
_m[tile].m1 = owner; |
1902 | 192 |
} |
193 |
||
7861
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
194 |
/** |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
195 |
* Checks if a tile belongs to the given owner |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
196 |
* |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
197 |
* @param tile The tile to check |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
198 |
* @param owner The owner to check agains |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
199 |
* @return True if a tile belongs the the given owner |
e45fe49dbe58
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7809
diff
changeset
|
200 |
*/ |
1330
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
201 |
static inline bool IsTileOwner(TileIndex tile, Owner owner) |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
202 |
{ |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
203 |
return GetTileOwner(tile) == owner; |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
204 |
} |
8a67d04016ce
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1214
diff
changeset
|
205 |
|
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
206 |
/** |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
207 |
* Set the tropic zone |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
208 |
* @param tile the tile to set the zone of |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
209 |
* @param type the new type |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
210 |
* @pre assert(tile < MapSize()); |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
211 |
*/ |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
212 |
static inline void SetTropicZone(TileIndex tile, TropicZone type) |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
213 |
{ |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
214 |
assert(tile < MapSize()); |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
215 |
SB(_m[tile].m6, 0, 2, type); |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
216 |
} |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
217 |
|
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
218 |
/** |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
219 |
* Get the tropic zone |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
220 |
* @param tile the tile to get the zone of |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
221 |
* @pre assert(tile < MapSize()); |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
222 |
* @return the zone type |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
223 |
*/ |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
224 |
static inline TropicZone GetTropicZone(TileIndex tile) |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
225 |
{ |
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
226 |
assert(tile < MapSize()); |
5847
9ce114e1d90d
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5838
diff
changeset
|
227 |
return (TropicZone)GB(_m[tile].m6, 0, 2); |
3379
ea8aa9e71328
(svn r4181) CodeChange : Replaced [G/S]etMapExtraBits by [G/S]etTropicZone. Although it was an accessor, nor his usage nor the values were clear.
belugas
parents:
3279
diff
changeset
|
228 |
} |
2436
177cb6a8339f
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2360
diff
changeset
|
229 |
#endif /* TILE_H */ |