water_map.h
author orudge
Fri, 31 Mar 2006 16:19:58 +0000
changeset 3398 f4c7427ffe9e
parent 3373 2838aadd3a28
child 3402 812f9dc4baff
permissions -rw-r--r--
(svn r4208) - Update OS/2 readme on trunk, sorry for all the commits!
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
     1
/* $Id$ */
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
     2
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
     3
#ifndef WATER_MAP_H
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
     4
#define WATER_MAP_H
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
     5
3372
f6afa98d5219 (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 {
f6afa98d5219 (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
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
     8
	DEPOT_SOUTH = 0x81,
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
     9
	DEPOT_END   = 0x84,
3372
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    10
} DepotPart;
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    11
f6afa98d5219 (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 {
f6afa98d5219 (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,
f6afa98d5219 (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,
f6afa98d5219 (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
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    16
} LockPart;
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    17
3373
2838aadd3a28 (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)
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    19
{
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    20
	return
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    21
		IsTileType(tile, MP_WATER) &&
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    22
		_m[tile].m5 == 0 &&
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    23
		GetTileSlope(tile, NULL) == 0;
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    24
}
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    25
2838aadd3a28 (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)
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    27
{
2838aadd3a28 (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));
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    29
}
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    30
2838aadd3a28 (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)
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    32
{
2838aadd3a28 (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);
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    34
}
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    35
2838aadd3a28 (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)
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    37
{
2838aadd3a28 (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);
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    39
}
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    40
2838aadd3a28 (svn r4172) -Codechange: Added a few accessors to work with ShipDepots and Locks
celestar
parents: 3372
diff changeset
    41
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    42
static inline void MakeWater(TileIndex t)
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    43
{
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    44
	SetTileType(t, MP_WATER);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    45
	SetTileOwner(t, OWNER_WATER);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    46
	_m[t].m2 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    47
	_m[t].m3 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    48
	_m[t].m4 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    49
	_m[t].m5 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    50
}
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    51
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    52
static inline void MakeShore(TileIndex t)
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    53
{
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    54
	SetTileType(t, MP_WATER);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    55
	SetTileOwner(t, OWNER_WATER);
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    56
	_m[t].m2 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    57
	_m[t].m3 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    58
	_m[t].m4 = 0;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    59
	_m[t].m5 = 1;
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    60
}
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    61
3372
f6afa98d5219 (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)
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    63
{
f6afa98d5219 (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);
f6afa98d5219 (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);
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    70
}
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    71
f6afa98d5219 (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)
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    73
{
f6afa98d5219 (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);
f6afa98d5219 (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);
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (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;
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    80
}
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    81
f6afa98d5219 (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)
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    83
{
f6afa98d5219 (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);
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    85
f6afa98d5219 (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);
f6afa98d5219 (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);
f6afa98d5219 (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);
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    89
}
f6afa98d5219 (svn r4171) -Codechange: Create map accessor functions for creating ship depots and locks. Make use of them
celestar
parents: 3111
diff changeset
    90
3111
750f37699a13 (svn r3714) Add functions to turn tiles into water and shore tiles
tron
parents:
diff changeset
    91
#endif