Files
@ r6422:5983361e241a
Branch filter:
Location: cpp/openttd-patchpack/source/src/unmovable_map.h
r6422:5983361e241a
3.0 KiB
text/x-c
(svn r9558) -Documentation: doxygen and comment changes: 'T' now. Almost done
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | /* $Id$ */
#ifndef UNMOVABLE_MAP_H
#define UNMOVABLE_MAP_H
enum {
HQ_NUM_TILE = 4,
HQ_NUM_SIZE = 5
};
enum UnmovableType {
UNMOVABLE_TRANSMITTER = 0,
UNMOVABLE_LIGHTHOUSE = 1,
UNMOVABLE_STATUE = 2,
UNMOVABLE_OWNED_LAND = 3,
UNMOVABLE_HQ_NORTH = 0x80,
UNMOVABLE_HQ_WEST = 0x81,
UNMOVABLE_HQ_EAST = 0x82,
UNMOVABLE_HQ_SOUTH = 0x83,
UNMOVABLE_HQ_END = UNMOVABLE_HQ_NORTH + HQ_NUM_SIZE * HQ_NUM_TILE
};
static inline UnmovableType GetUnmovableType(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return (UnmovableType)_m[t].m5;
}
static inline bool IsTransmitterTile(TileIndex t)
{
return
IsTileType(t, MP_UNMOVABLE) &&
GetUnmovableType(t) == UNMOVABLE_TRANSMITTER;
}
static inline bool IsOwnedLand(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
}
static inline bool IsOwnedLandTile(TileIndex t)
{
return IsTileType(t, MP_UNMOVABLE) && IsOwnedLand(t);
}
static inline bool IsCompanyHQ(TileIndex t)
{
return IS_INT_INSIDE(GetUnmovableType(t), UNMOVABLE_HQ_NORTH, UNMOVABLE_HQ_END);
}
static inline bool IsStatue(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE));
return GetUnmovableType(t) == UNMOVABLE_STATUE;
}
static inline bool IsStatueTile(TileIndex t)
{
return IsTileType(t, MP_UNMOVABLE) && IsStatue(t);
}
static inline TownID GetStatueTownID(TileIndex t)
{
assert(IsStatue(t));
return _m[t].m2;
}
static inline byte GetCompanyHQSize(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 2, 3);
}
static inline byte GetCompanyHQSection(TileIndex t)
{
assert(IsTileType(t, MP_UNMOVABLE) && IsCompanyHQ(t));
return GB(_m[t].m5, 0, 5);
}
static inline void EnlargeCompanyHQ(TileIndex t, byte size)
{
size *= 4;
if (size <= _m[t].m5 - UNMOVABLE_HQ_NORTH) return;
_m[t + TileDiffXY(0, 0)].m5 = UNMOVABLE_HQ_NORTH + size;
_m[t + TileDiffXY(0, 1)].m5 = UNMOVABLE_HQ_WEST + size;
_m[t + TileDiffXY(1, 0)].m5 = UNMOVABLE_HQ_EAST + size;
_m[t + TileDiffXY(1, 1)].m5 = UNMOVABLE_HQ_SOUTH + size;
}
static inline void MakeUnmovable(TileIndex t, UnmovableType u, Owner o)
{
SetTileType(t, MP_UNMOVABLE);
SetTileOwner(t, o);
_m[t].m2 = 0;
_m[t].m3 = 0;
_m[t].m4 = 0;
_m[t].m5 = u;
}
static inline void MakeTransmitter(TileIndex t)
{
MakeUnmovable(t, UNMOVABLE_TRANSMITTER, OWNER_NONE);
}
static inline void MakeLighthouse(TileIndex t)
{
MakeUnmovable(t, UNMOVABLE_LIGHTHOUSE, OWNER_NONE);
}
static inline void MakeStatue(TileIndex t, Owner o, TownID town_id)
{
MakeUnmovable(t, UNMOVABLE_STATUE, o);
_m[t].m2 = town_id;
}
static inline void MakeOwnedLand(TileIndex t, Owner o)
{
MakeUnmovable(t, UNMOVABLE_OWNED_LAND, o);
}
static inline void MakeCompanyHQ(TileIndex t, Owner o)
{
MakeUnmovable(t + TileDiffXY(0, 0), UNMOVABLE_HQ_NORTH, o);
MakeUnmovable(t + TileDiffXY(0, 1), UNMOVABLE_HQ_WEST, o);
MakeUnmovable(t + TileDiffXY(1, 0), UNMOVABLE_HQ_EAST, o);
MakeUnmovable(t + TileDiffXY(1, 1), UNMOVABLE_HQ_SOUTH, o);
}
#endif /* UNMOVABLE_MAP_H */
|