author | celestar |
Fri, 31 Mar 2006 08:18:14 +0000 | |
changeset 3382 | c9c8d85aa632 |
parent 3373 | f95cf3549591 |
child 3402 | 0b72e324d300 |
permissions | -rw-r--r-- |
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
1 |
/* $Id$ */ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
2 |
|
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
3 |
#ifndef WATER_MAP_H |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
4 |
#define WATER_MAP_H |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
5 |
|
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
6 |
typedef enum DepotPart { |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
7 |
DEPOT_NORTH = 0x80, |
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
8 |
DEPOT_SOUTH = 0x81, |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
9 |
DEPOT_END = 0x84, |
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
10 |
} DepotPart; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
11 |
|
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
12 |
typedef enum LockPart { |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
13 |
LOCK_MIDDLE = 0x10, |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
14 |
LOCK_LOWER = 0x14, |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
15 |
LOCK_UPPER = 0x18 |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
16 |
} LockPart; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
17 |
|
3373
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
18 |
static inline bool IsClearWaterTile(TileIndex tile) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
19 |
{ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
20 |
return |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
21 |
IsTileType(tile, MP_WATER) && |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
22 |
_m[tile].m5 == 0 && |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
23 |
GetTileSlope(tile, NULL) == 0; |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
24 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
25 |
|
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
26 |
static inline TileIndex GetOtherShipDepotTile(TileIndex t) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
27 |
{ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
28 |
return t + (HASBIT(_m[t].m5, 0) ? -1 : 1) * (HASBIT(_m[t].m5, 1) ? TileDiffXY(0, 1) : TileDiffXY(1, 0)); |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
29 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
30 |
|
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
31 |
static inline TileIndex IsShipDepot(TileIndex t) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
32 |
{ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
33 |
return IS_INT_INSIDE(_m[t].m5, DEPOT_NORTH, DEPOT_END); |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
34 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
35 |
|
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
36 |
static inline DiagDirection GetLockDirection(TileIndex t) |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
37 |
{ |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
38 |
return (DiagDirection)GB(_m[t].m5, 0, 2); |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
39 |
} |
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
40 |
|
f95cf3549591
(svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents:
3372
diff
changeset
|
41 |
|
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
42 |
static inline void MakeWater(TileIndex t) |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
43 |
{ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
44 |
SetTileType(t, MP_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
45 |
SetTileOwner(t, OWNER_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
46 |
_m[t].m2 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
47 |
_m[t].m3 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
48 |
_m[t].m4 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
49 |
_m[t].m5 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
50 |
} |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
51 |
|
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
52 |
static inline void MakeShore(TileIndex t) |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
53 |
{ |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
54 |
SetTileType(t, MP_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
55 |
SetTileOwner(t, OWNER_WATER); |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
56 |
_m[t].m2 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
57 |
_m[t].m3 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
58 |
_m[t].m4 = 0; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
59 |
_m[t].m5 = 1; |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
60 |
} |
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
61 |
|
3372
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
62 |
static inline void MakeShipDepot(TileIndex t, Owner o, DepotPart base, Axis a) |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
63 |
{ |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
64 |
SetTileType(t, MP_WATER); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
65 |
SetTileOwner(t, o); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
66 |
_m[t].m2 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
67 |
_m[t].m3 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
68 |
_m[t].m4 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
69 |
_m[t].m5 = base + a * 2; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
70 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
71 |
|
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
72 |
static inline void MakeLockTile(TileIndex t, byte section) |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
73 |
{ |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
74 |
SetTileType(t, MP_WATER); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
75 |
SetTileOwner(t, OWNER_WATER); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
76 |
_m[t].m2 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
77 |
_m[t].m3 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
78 |
_m[t].m4 = 0; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
79 |
_m[t].m5 = section; |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
80 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
81 |
|
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
82 |
static inline void MakeLock(TileIndex t, DiagDirection d) |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
83 |
{ |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
84 |
TileIndexDiff delta = TileOffsByDir(d); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
85 |
|
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
86 |
MakeLockTile(t, LOCK_MIDDLE + d); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
87 |
MakeLockTile(t - delta, LOCK_LOWER + d); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
88 |
MakeLockTile(t + delta, LOCK_UPPER + d); |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
89 |
} |
e9eaf986b264
(svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents:
3111
diff
changeset
|
90 |
|
3111
1edf71aa942e
(svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff
changeset
|
91 |
#endif |