author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1394 | 79cb56d80a3a |
child 1749 | 711c154a1fb7 |
permissions | -rw-r--r-- |
1209
2e00193652b2
(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
|
1 |
#ifndef TILE_H |
2e00193652b2
(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
|
2 |
#define TILE_H |
926
a6d140a6a4de
(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
|
3 |
|
1394
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
4 |
#include "macros.h" |
1209
2e00193652b2
(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 |
#include "map.h" |
1035
812f837ee03f
(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
|
6 |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
7 |
typedef enum TileType { |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
8 |
MP_CLEAR, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
9 |
MP_RAILWAY, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
10 |
MP_STREET, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
11 |
MP_HOUSE, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
12 |
MP_TREES, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
13 |
MP_STATION, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
14 |
MP_WATER, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
15 |
MP_VOID, // invisible tiles at the SW and SE border |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
16 |
MP_INDUSTRY, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
17 |
MP_TUNNELBRIDGE, |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
18 |
MP_UNMOVABLE |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
19 |
} TileType; |
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
20 |
|
1211 | 21 |
void SetMapExtraBits(TileIndex tile, byte flags); |
22 |
uint GetMapExtraBits(TileIndex tile); |
|
23 |
||
1335
a5f223b9f549
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
24 |
uint GetTileSlope(TileIndex tile, uint *h); |
a5f223b9f549
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
25 |
uint GetTileZ(TileIndex tile); |
a5f223b9f549
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
26 |
|
1394
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
27 |
static inline bool CorrectZ(uint tileh) |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
28 |
{ |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
29 |
/* tile height must be corrected if the north corner is not raised, but |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
30 |
* any other corner is. These are the cases 1 till 7 */ |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
31 |
return IS_INT_INSIDE(tileh, 1, 8); |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
32 |
} |
79cb56d80a3a
(svn r1898) Remove some unused macros from macros.h and move some others to more appropriate headers
tron
parents:
1335
diff
changeset
|
33 |
|
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
34 |
static inline uint TileHeight(TileIndex tile) |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
35 |
{ |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
36 |
assert(tile < MapSize()); |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
37 |
return _map_type_and_height[tile] & 0xf; |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
38 |
} |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
39 |
|
1059
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
40 |
static inline void SetTileHeight(TileIndex tile, uint height) |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
41 |
{ |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
42 |
assert(tile < MapSize()); |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
43 |
assert(height < 16); |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
44 |
_map_type_and_height[tile] &= ~0x0F; |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
45 |
_map_type_and_height[tile] |= height; |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
46 |
} |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
47 |
|
1041
94db182c3614
(svn r1542) Rename TileHeight to TilePixelHeight, because this is what it actually returns
tron
parents:
1035
diff
changeset
|
48 |
static inline uint TilePixelHeight(TileIndex tile) |
1035
812f837ee03f
(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
|
49 |
{ |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
50 |
return TileHeight(tile) * 8; |
1035
812f837ee03f
(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
|
51 |
} |
812f837ee03f
(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
|
52 |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
53 |
static inline TileType GetTileType(TileIndex tile) |
1035
812f837ee03f
(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
|
54 |
{ |
812f837ee03f
(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
|
55 |
assert(tile < MapSize()); |
812f837ee03f
(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
|
56 |
return _map_type_and_height[tile] >> 4; |
812f837ee03f
(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
|
57 |
} |
812f837ee03f
(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
|
58 |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
59 |
static inline void SetTileType(TileIndex tile, TileType type) |
1059
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
60 |
{ |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
61 |
assert(tile < MapSize()); |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
62 |
_map_type_and_height[tile] &= ~0xF0; |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
63 |
_map_type_and_height[tile] |= type << 4; |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
64 |
} |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
65 |
|
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
66 |
static inline bool IsTileType(TileIndex tile, TileType type) |
1035
812f837ee03f
(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
|
67 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
68 |
return GetTileType(tile) == type; |
1035
812f837ee03f
(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
|
69 |
} |
812f837ee03f
(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
|
70 |
|
1333 | 71 |
static inline Owner GetTileOwner(TileIndex tile) |
1330
5d76a0522a11
(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
|
72 |
{ |
1333 | 73 |
assert(tile < MapSize()); |
1330
5d76a0522a11
(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
|
74 |
return _map_owner[tile]; |
5d76a0522a11
(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
|
75 |
} |
5d76a0522a11
(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
|
76 |
|
5d76a0522a11
(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
|
77 |
static inline bool IsTileOwner(TileIndex tile, Owner owner) |
5d76a0522a11
(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
|
78 |
{ |
5d76a0522a11
(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
|
79 |
return GetTileOwner(tile) == owner; |
5d76a0522a11
(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
|
80 |
} |
5d76a0522a11
(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
|
81 |
|
679
04ca2cd69420
(svn r1117) Move map arrays and some related macros into their own files map.c and map.h
tron
parents:
diff
changeset
|
82 |
#endif |