author | peter1138 |
Fri, 31 Mar 2006 10:14:25 +0000 | |
changeset 3390 | ae4b0872dc78 |
parent 3382 | be14efb0dfd7 |
child 3426 | 451a6367552d |
permissions | -rw-r--r-- |
3319
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
2 |
|
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
3 |
#include "town.h" |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
4 |
|
3377
608cf1405409
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
celestar
parents:
3369
diff
changeset
|
5 |
static inline int GetHouseType(TileIndex t) |
608cf1405409
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
celestar
parents:
3369
diff
changeset
|
6 |
{ |
608cf1405409
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
celestar
parents:
3369
diff
changeset
|
7 |
assert(IsTileType(t, MP_HOUSE)); |
608cf1405409
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
celestar
parents:
3369
diff
changeset
|
8 |
return _m[t].m4; |
608cf1405409
(svn r4179) -Codechange: Add and make use of an accessor that obtains the building type
celestar
parents:
3369
diff
changeset
|
9 |
} |
3319
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
10 |
|
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
11 |
static inline uint GetTownIndex(TileIndex t) |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
12 |
{ |
3369
cab209754317
(svn r4166) Sprinkle several map accessors with assert()s
tron
parents:
3319
diff
changeset
|
13 |
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_STREET)); // XXX incomplete |
3319
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
14 |
return _m[t].m2; |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
15 |
} |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
16 |
|
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
17 |
static inline Town* GetTownByTile(TileIndex t) |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
18 |
{ |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
19 |
return GetTown(GetTownIndex(t)); |
16c0f06829a5
(svn r4085) Add GetTown{Index,ByTile}() to get the town index resp. the town from a tile
tron
parents:
diff
changeset
|
20 |
} |
3382
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
21 |
|
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
22 |
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, byte type) |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
23 |
{ |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
24 |
assert(IsTileType(t, MP_CLEAR)); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
25 |
|
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
26 |
SetTileType(t, MP_HOUSE); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
27 |
_m[t].m1 = 0; |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
28 |
_m[t].m2 = tid; |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
29 |
SB(_m[t].m3, 6, 2, stage); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
30 |
_m[t].m4 = type; |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
31 |
SB(_m[t].m5, 0, 2, counter); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
32 |
|
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
33 |
MarkTileDirtyByTile(t); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
34 |
} |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
35 |
|
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
36 |
enum { |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
37 |
TWO_BY_TWO_BIT = 2, ///< House is two tiles in X and Y directions |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
38 |
ONE_BY_TWO_BIT = 1, ///< House is two tiles in Y direction |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
39 |
TWO_BY_ONE_BIT = 0, ///< House is two tiles in X direction |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
40 |
}; |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
41 |
|
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
42 |
static inline void MakeTownHouse(TileIndex t, TownID tid, byte counter, byte stage, byte size, byte type) |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
43 |
{ |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
44 |
MakeHouseTile(t, tid, counter, stage, type); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
45 |
if (HASBIT(size, TWO_BY_TWO_BIT) || HASBIT(size, ONE_BY_TWO_BIT)) MakeHouseTile(t + TileDiffXY(0, 1), tid, counter, stage, ++type); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
46 |
if (HASBIT(size, TWO_BY_TWO_BIT) || HASBIT(size, TWO_BY_ONE_BIT)) MakeHouseTile(t + TileDiffXY(1, 0), tid, counter, stage, ++type); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
47 |
if (HASBIT(size, TWO_BY_TWO_BIT)) MakeHouseTile(t + TileDiffXY(1, 1), tid, counter, stage, ++type); |
be14efb0dfd7
(svn r4190) -Codechange: Add and make use of an accessor function to create houses
celestar
parents:
3377
diff
changeset
|
48 |
} |