author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 8651 | 037a1ae32547 |
child 10207 | c291a21b304e |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
3 |
/** @file tile_map.h Map writing/reading functions for tiles. */ |
7313
a36dc43afcb5
(svn r10665) -Codechange: replace magic 15 with MAX_TILE_HEIGHT (bilbo)
truelight
parents:
6422
diff
changeset
|
4 |
|
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
5 |
#ifndef TILE_MAP_H |
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
6 |
#define TILE_MAP_H |
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 |
|
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
8 |
#include "tile_type.h" |
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
9 |
#include "slope_type.h" |
8254
1496654ca5e7
(svn r11818) -Codechange: split player.h into smaller pieces.
rubidium
parents:
8139
diff
changeset
|
10 |
#include "player_type.h" |
8139
4e91c448c409
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8113
diff
changeset
|
11 |
#include "map_func.h" |
8113
31b7784db761
(svn r11674) -Codechange: refactor some functions out of macros.h into more logical locations.
rubidium
parents:
8108
diff
changeset
|
12 |
#include "core/bitmath_func.hpp" |
1335
a5f223b9f549
(svn r1839) Move GetTileSlope() and GetTileZ() into tile.[ch] and use more explicit types as parameters
tron
parents:
1333
diff
changeset
|
13 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
14 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
15 |
* Returns the height of a tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
16 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
17 |
* This function returns the height of the northern corner of a tile. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
18 |
* This is saved in the global map-array. It does not take affect by |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
19 |
* any slope-data of the tile. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
20 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
21 |
* @param tile The tile to get the height from |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
22 |
* @return the height of the tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
23 |
* @pre tile < MapSize() |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
24 |
*/ |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
25 |
static inline uint TileHeight(TileIndex tile) |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
26 |
{ |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
27 |
assert(tile < MapSize()); |
2049
538e73c53f54
(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
|
28 |
return GB(_m[tile].type_height, 0, 4); |
1044
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
29 |
} |
63e0601a43cc
(svn r1545) Add TileHeight() which returns the height (not multiplied by 8)
tron
parents:
1041
diff
changeset
|
30 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
31 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
32 |
* Sets the height of a tile. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
33 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
34 |
* This function sets the height of the northern corner of a tile. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
35 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
36 |
* @param tile The tile to change the height |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
37 |
* @param height The new height value of the tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
38 |
* @pre tile < MapSize() |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
39 |
* @pre heigth <= MAX_TILE_HEIGHT |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
40 |
*/ |
1059
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
41 |
static inline void SetTileHeight(TileIndex tile, uint height) |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
42 |
{ |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
43 |
assert(tile < MapSize()); |
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
44 |
assert(height <= MAX_TILE_HEIGHT); |
2049
538e73c53f54
(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
|
45 |
SB(_m[tile].type_height, 0, 4, height); |
1059
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 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
48 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
49 |
* Returns the height of a tile in pixels. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
50 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
51 |
* This function returns the height of the northern corner of a tile in pixels. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
52 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
53 |
* @param tile The tile to get the height |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
54 |
* @return The height of the tile in pixel |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
55 |
*/ |
1041
94db182c3614
(svn r1542) Rename TileHeight to TilePixelHeight, because this is what it actually returns
tron
parents:
1035
diff
changeset
|
56 |
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
|
57 |
{ |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
58 |
return TileHeight(tile) * TILE_HEIGHT; |
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
|
59 |
} |
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
|
60 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
61 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
62 |
* Get the tiletype of a given tile. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
63 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
64 |
* @param tile The tile to get the TileType |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
65 |
* @return The tiletype of the tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
66 |
* @pre tile < MapSize() |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
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 |
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
|
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 |
assert(tile < MapSize()); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3794
diff
changeset
|
71 |
return (TileType)GB(_m[tile].type_height, 4, 4); |
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
|
72 |
} |
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
|
73 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
74 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
75 |
* Set the type of a tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
76 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
77 |
* This functions sets the type of a tile. If the type |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
78 |
* MP_VOID is selected the tile must be at the south-west or |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
79 |
* south-east edges of the map and vice versa. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
80 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
81 |
* @param tile The tile to save the new type |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
82 |
* @param type The type to save |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
83 |
* @pre tile < MapSize() |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
84 |
* @pre type MP_VOID <=> tile is on the south-east or south-west edge. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
85 |
*/ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
86 |
static inline void SetTileType(TileIndex tile, TileType type) |
1059
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
87 |
{ |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
88 |
assert(tile < MapSize()); |
4010
4d674c7df23a
(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
|
89 |
/* VOID tiles (and no others) are exactly allowed at the lower left and right |
4077
d4d440dd8925
(svn r5391) Miscellaneous, mostly bracing and whitespace, nothing spectacular
tron
parents:
4067
diff
changeset
|
90 |
* edges of the map */ |
4010
4d674c7df23a
(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
|
91 |
assert((TileX(tile) == MapMaxX() || TileY(tile) == MapMaxY()) == (type == MP_VOID)); |
2049
538e73c53f54
(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
|
92 |
SB(_m[tile].type_height, 4, 4, type); |
1059
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
93 |
} |
fe97d81a1b4f
(svn r1560) Introduce SetTileType() and SetTileHeight()
tron
parents:
1044
diff
changeset
|
94 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
95 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
96 |
* Checks if a tile is a give tiletype. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
97 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
98 |
* This function checks if a tile got the given tiletype. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
99 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
100 |
* @param tile The tile to check |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
101 |
* @param type The type to check agains |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
102 |
* @return true If the type matches agains the type of the tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
103 |
*/ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
104 |
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
|
105 |
{ |
1214
8262981ac274
(svn r1718) Use the enum TileType as parameter/return type for [GS]etTileType() instead of plain int.
tron
parents:
1211
diff
changeset
|
106 |
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
|
107 |
} |
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
|
108 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
109 |
/** |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
110 |
* Checks if a tile is valid |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
111 |
* |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
112 |
* @param tile The tile to check |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
113 |
* @return True if the tile is on the map and not one of MP_VOID. |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
114 |
*/ |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
115 |
static inline bool IsValidTile(TileIndex tile) |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
116 |
{ |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
117 |
return tile < MapSize() && !IsTileType(tile, MP_VOID); |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
118 |
} |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
119 |
|
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
120 |
/** |
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
121 |
* Returns the owner of a tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
122 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
123 |
* This function returns the owner of a tile. This cannot used |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
124 |
* for tiles which type is one of MP_HOUSE, MP_VOID and MP_INDUSTRY |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
125 |
* as no player owned any of these buildings. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
126 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
127 |
* @param tile The tile to check |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
128 |
* @return The owner of the tile |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
129 |
* @pre IsValidTile(tile) |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
130 |
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
131 |
*/ |
1333 | 132 |
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
|
133 |
{ |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
134 |
assert(IsValidTile(tile)); |
1898
0b84ad3a8c92
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
135 |
assert(!IsTileType(tile, MP_HOUSE)); |
0b84ad3a8c92
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
136 |
assert(!IsTileType(tile, MP_INDUSTRY)); |
0b84ad3a8c92
(svn r2404) assert that GetTileOwner() isn't called for tiles, which don't store owner information
tron
parents:
1852
diff
changeset
|
137 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
3794
diff
changeset
|
138 |
return (Owner)_m[tile].m1; |
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
|
139 |
} |
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
|
140 |
|
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
141 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
142 |
* Sets the owner of a tile |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
143 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
144 |
* This function sets the owner status of a tile. Note that you cannot |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
145 |
* set a owner for tiles of type MP_HOUSE, MP_VOID and MP_INDUSTRY. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
146 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
147 |
* @param tile The tile to change the owner status. |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
148 |
* @param owner The new owner. |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
149 |
* @pre IsValidTile(tile) |
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
150 |
* @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY |
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
151 |
*/ |
1902 | 152 |
static inline void SetTileOwner(TileIndex tile, Owner owner) |
153 |
{ |
|
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
154 |
assert(IsValidTile(tile)); |
1902 | 155 |
assert(!IsTileType(tile, MP_HOUSE)); |
156 |
assert(!IsTileType(tile, MP_INDUSTRY)); |
|
157 |
||
2360
4e4ebe18e448
(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
|
158 |
_m[tile].m1 = owner; |
1902 | 159 |
} |
160 |
||
7365
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
161 |
/** |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
162 |
* Checks if a tile belongs to the given owner |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
163 |
* |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
164 |
* @param tile The tile to check |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
165 |
* @param owner The owner to check agains |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
166 |
* @return True if a tile belongs the the given owner |
32d244531e1a
(svn r10728) -Documentation [FS#1088]: of tile.h. Based on a patch by Progman.
rubidium
parents:
7313
diff
changeset
|
167 |
*/ |
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
|
168 |
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
|
169 |
{ |
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
|
170 |
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
|
171 |
} |
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
|
172 |
|
3379
50b253bb9819
(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
|
173 |
/** |
50b253bb9819
(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
|
174 |
* Set the tropic zone |
50b253bb9819
(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
|
175 |
* @param tile the tile to set the zone of |
50b253bb9819
(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
|
176 |
* @param type the new type |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
177 |
* @pre tile < MapSize() |
3379
50b253bb9819
(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
|
178 |
*/ |
50b253bb9819
(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
|
179 |
static inline void SetTropicZone(TileIndex tile, TropicZone type) |
50b253bb9819
(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
|
180 |
{ |
50b253bb9819
(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
|
181 |
assert(tile < MapSize()); |
5596
5bf7128140a0
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5587
diff
changeset
|
182 |
SB(_m[tile].m6, 0, 2, type); |
3379
50b253bb9819
(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
|
183 |
} |
50b253bb9819
(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
|
184 |
|
50b253bb9819
(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
|
185 |
/** |
50b253bb9819
(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
|
186 |
* Get the tropic zone |
50b253bb9819
(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
|
187 |
* @param tile the tile to get the zone of |
8651
037a1ae32547
(svn r12303) -Codechange: move IsValidTile() in a more suitable place and make it static inline
glx
parents:
8254
diff
changeset
|
188 |
* @pre tile < MapSize() |
3379
50b253bb9819
(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
|
189 |
* @return the zone type |
50b253bb9819
(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
|
190 |
*/ |
50b253bb9819
(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
|
191 |
static inline TropicZone GetTropicZone(TileIndex tile) |
50b253bb9819
(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
|
192 |
{ |
50b253bb9819
(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
|
193 |
assert(tile < MapSize()); |
5596
5bf7128140a0
(svn r8050) -Codechange: Rename map member extra to m6, since its usage has been widden.
belugas
parents:
5587
diff
changeset
|
194 |
return (TropicZone)GB(_m[tile].m6, 0, 2); |
3379
50b253bb9819
(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
|
195 |
} |
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
196 |
|
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
197 |
Slope GetTileSlope(TileIndex tile, uint *h); |
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
198 |
uint GetTileZ(TileIndex tile); |
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
199 |
uint GetTileMaxZ(TileIndex tile); |
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
200 |
|
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7370
diff
changeset
|
201 |
#endif /* TILE_TYPE_H */ |