(svn r4166) Sprinkle several map accessors with assert()s

This commit is contained in:
tron 2006-03-30 09:29:01 +00:00
parent 5476fd4b96
commit bbf4f982a0
9 changed files with 230 additions and 53 deletions

View File

@ -13,6 +13,7 @@
static inline bool IsBridge(TileIndex t) static inline bool IsBridge(TileIndex t)
{ {
assert(IsTileType(t, MP_TUNNELBRIDGE));
return HASBIT(_m[t].m5, 7); return HASBIT(_m[t].m5, 7);
} }
@ -24,11 +25,13 @@ static inline bool IsBridgeTile(TileIndex t)
static inline bool IsBridgeRamp(TileIndex t) static inline bool IsBridgeRamp(TileIndex t)
{ {
assert(IsBridgeTile(t));
return !HASBIT(_m[t].m5, 6); return !HASBIT(_m[t].m5, 6);
} }
static inline bool IsBridgeMiddle(TileIndex t) static inline bool IsBridgeMiddle(TileIndex t)
{ {
assert(IsBridgeTile(t));
return HASBIT(_m[t].m5, 6); return HASBIT(_m[t].m5, 6);
} }
@ -38,9 +41,10 @@ static inline bool IsBridgeMiddle(TileIndex t)
* @param tile The tile to analyze * @param tile The tile to analyze
* @return the piece * @return the piece
*/ */
static inline uint GetBridgePiece(TileIndex tile) static inline uint GetBridgePiece(TileIndex t)
{ {
return GB(_m[tile].m2, 0, 4); assert(IsBridgeMiddle(t));
return GB(_m[t].m2, 0, 4);
} }
@ -49,9 +53,10 @@ static inline uint GetBridgePiece(TileIndex tile)
* @param tile The tile to analyze * @param tile The tile to analyze
* @return The bridge type * @return The bridge type
*/ */
static inline uint GetBridgeType(TileIndex tile) static inline uint GetBridgeType(TileIndex t)
{ {
return GB(_m[tile].m2, 4, 4); assert(IsBridgeTile(t));
return GB(_m[t].m2, 4, 4);
} }
@ -60,6 +65,7 @@ static inline uint GetBridgeType(TileIndex tile)
*/ */
static inline DiagDirection GetBridgeRampDirection(TileIndex t) static inline DiagDirection GetBridgeRampDirection(TileIndex t)
{ {
assert(IsBridgeRamp(t));
/* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of /* Heavy wizardry to convert the X/Y (bit 0) + N/S (bit 5) encoding of
* bridges to a DiagDirection * bridges to a DiagDirection
*/ */
@ -69,44 +75,52 @@ static inline DiagDirection GetBridgeRampDirection(TileIndex t)
static inline Axis GetBridgeAxis(TileIndex t) static inline Axis GetBridgeAxis(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
return (Axis)GB(_m[t].m5, 0, 1); return (Axis)GB(_m[t].m5, 0, 1);
} }
static inline TransportType GetBridgeTransportType(TileIndex t) static inline TransportType GetBridgeTransportType(TileIndex t)
{ {
assert(IsBridgeTile(t));
return (TransportType)GB(_m[t].m5, 1, 2); return (TransportType)GB(_m[t].m5, 1, 2);
} }
static inline bool IsClearUnderBridge(TileIndex t) static inline bool IsClearUnderBridge(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
return GB(_m[t].m5, 3, 3) == 0; return GB(_m[t].m5, 3, 3) == 0;
} }
static inline bool IsWaterUnderBridge(TileIndex t) static inline bool IsWaterUnderBridge(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
return GB(_m[t].m5, 3, 3) == 1; return GB(_m[t].m5, 3, 3) == 1;
} }
static inline bool IsTransportUnderBridge(TileIndex t) static inline bool IsTransportUnderBridge(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
return HASBIT(_m[t].m5, 5); return HASBIT(_m[t].m5, 5);
} }
static inline TransportType GetTransportTypeUnderBridge(TileIndex t) static inline TransportType GetTransportTypeUnderBridge(TileIndex t)
{ {
assert(IsTransportUnderBridge(t));
return (TransportType)GB(_m[t].m5, 3, 2); return (TransportType)GB(_m[t].m5, 3, 2);
} }
static inline RoadBits GetRoadBitsUnderBridge(TileIndex t) static inline RoadBits GetRoadBitsUnderBridge(TileIndex t)
{ {
assert(GetTransportTypeUnderBridge(t) == TRANSPORT_ROAD);
return GetBridgeAxis(t) == AXIS_X ? ROAD_Y : ROAD_X; return GetBridgeAxis(t) == AXIS_X ? ROAD_Y : ROAD_X;
} }
static inline TrackBits GetRailBitsUnderBridge(TileIndex t) static inline TrackBits GetRailBitsUnderBridge(TileIndex t)
{ {
assert(GetTransportTypeUnderBridge(t) == TRANSPORT_RAIL);
return GetBridgeAxis(t) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X; return GetBridgeAxis(t) == AXIS_X ? TRACK_BIT_Y : TRACK_BIT_X;
} }
@ -131,18 +145,21 @@ uint GetBridgeHeight(TileIndex t);
static inline void SetClearUnderBridge(TileIndex t) static inline void SetClearUnderBridge(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
SetTileOwner(t, OWNER_NONE); SetTileOwner(t, OWNER_NONE);
SB(_m[t].m5, 3, 3, 0 << 2 | 0); SB(_m[t].m5, 3, 3, 0 << 2 | 0);
} }
static inline void SetWaterUnderBridge(TileIndex t) static inline void SetWaterUnderBridge(TileIndex t)
{ {
assert(IsBridgeMiddle(t));
SetTileOwner(t, OWNER_WATER); SetTileOwner(t, OWNER_WATER);
SB(_m[t].m5, 3, 3, 0 << 2 | 1); SB(_m[t].m5, 3, 3, 0 << 2 | 1);
} }
static inline void SetRailUnderBridge(TileIndex t, Owner o, RailType r) static inline void SetRailUnderBridge(TileIndex t, Owner o, RailType r)
{ {
assert(IsBridgeMiddle(t));
SetTileOwner(t, o); SetTileOwner(t, o);
SB(_m[t].m5, 3, 3, 1 << 2 | TRANSPORT_RAIL); SB(_m[t].m5, 3, 3, 1 << 2 | TRANSPORT_RAIL);
SB(_m[t].m3, 0, 4, r); SB(_m[t].m3, 0, 4, r);
@ -150,6 +167,7 @@ static inline void SetRailUnderBridge(TileIndex t, Owner o, RailType r)
static inline void SetRoadUnderBridge(TileIndex t, Owner o) static inline void SetRoadUnderBridge(TileIndex t, Owner o)
{ {
assert(IsBridgeMiddle(t));
SetTileOwner(t, o); SetTileOwner(t, o);
SB(_m[t].m5, 3, 3, 1 << 2 | TRANSPORT_ROAD); SB(_m[t].m5, 3, 3, 1 << 2 | TRANSPORT_ROAD);
} }

View File

@ -18,31 +18,96 @@ typedef enum ClearGround {
CL_DESERT = 5 // 1,3 CL_DESERT = 5 // 1,3
} ClearGround; } ClearGround;
static inline ClearGround GetClearGround(TileIndex t) { return GB(_m[t].m5, 2, 3); }
static inline bool IsClearGround(TileIndex t, ClearGround ct) { return GetClearGround(t) == ct; }
static inline void AddClearDensity(TileIndex t, int d) { _m[t].m5 += d; } static inline ClearGround GetClearGround(TileIndex t)
static inline uint GetClearDensity(TileIndex t) { return GB(_m[t].m5, 0, 2); } {
assert(IsTileType(t, MP_CLEAR));
return GB(_m[t].m5, 2, 3);
}
static inline bool IsClearGround(TileIndex t, ClearGround ct)
{
return GetClearGround(t) == ct;
}
static inline uint GetClearDensity(TileIndex t)
{
assert(IsTileType(t, MP_CLEAR));
return GB(_m[t].m5, 0, 2);
}
static inline void AddClearDensity(TileIndex t, int d)
{
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
_m[t].m5 += d;
}
static inline uint GetClearCounter(TileIndex t)
{
assert(IsTileType(t, MP_CLEAR));
return GB(_m[t].m5, 5, 3);
}
static inline void AddClearCounter(TileIndex t, int c)
{
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
_m[t].m5 += c << 5;
}
static inline void SetClearCounter(TileIndex t, uint c)
{
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
SB(_m[t].m5, 5, 3, c);
}
static inline void AddClearCounter(TileIndex t, int c) { _m[t].m5 += c << 5; }
static inline uint GetClearCounter(TileIndex t) { return GB(_m[t].m5, 5, 3); }
static inline void SetClearCounter(TileIndex t, uint c) { SB(_m[t].m5, 5, 3, c); }
/* Sets type and density in one go, also sets the counter to 0 */ /* Sets type and density in one go, also sets the counter to 0 */
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density) static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
{ {
assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
_m[t].m5 = 0 << 5 | type << 2 | density; _m[t].m5 = 0 << 5 | type << 2 | density;
} }
static inline uint GetFieldType(TileIndex t) { return GB(_m[t].m3, 0, 4); }
static inline void SetFieldType(TileIndex t, uint f) { SB(_m[t].m3, 0, 4, f); } static inline uint GetFieldType(TileIndex t)
{
assert(GetClearGround(t) == CL_FIELDS);
return GB(_m[t].m3, 0, 4);
}
static inline void SetFieldType(TileIndex t, uint f)
{
assert(GetClearGround(t) == CL_FIELDS); // XXX incomplete
SB(_m[t].m3, 0, 4, f);
}
/* Is used by tree tiles, too */ /* Is used by tree tiles, too */
static inline uint GetFenceSE(TileIndex t) { return GB(_m[t].m4, 2, 3); } static inline uint GetFenceSE(TileIndex t)
static inline void SetFenceSE(TileIndex t, uint h) { SB(_m[t].m4, 2, 3, h); } {
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
return GB(_m[t].m4, 2, 3);
}
static inline uint GetFenceSW(TileIndex t) { return GB(_m[t].m4, 5, 3); } static inline void SetFenceSE(TileIndex t, uint h)
static inline void SetFenceSW(TileIndex t, uint h) { SB(_m[t].m4, 5, 3, h); } {
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m4, 2, 3, h);
}
static inline uint GetFenceSW(TileIndex t)
{
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES));
return GB(_m[t].m4, 5, 3);
}
static inline void SetFenceSW(TileIndex t, uint h)
{
assert(IsTileType(t, MP_CLEAR) || IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m4, 5, 3, h);
}
static inline void MakeClear(TileIndex t, ClearGround g, uint density) static inline void MakeClear(TileIndex t, ClearGround g, uint density)

View File

@ -7,6 +7,7 @@
static inline uint GetIndustryIndex(TileIndex t) static inline uint GetIndustryIndex(TileIndex t)
{ {
assert(IsTileType(t, MP_INDUSTRY));
return _m[t].m2; return _m[t].m2;
} }
@ -16,19 +17,22 @@ static inline Industry* GetIndustryByTile(TileIndex t)
} }
static inline bool IsIndustryCompleted(TileIndex tile) static inline bool IsIndustryCompleted(TileIndex t)
{ {
return HASBIT(_m[tile].m1, 7); assert(IsTileType(t, MP_INDUSTRY));
return HASBIT(_m[t].m1, 7);
} }
static inline uint GetIndustryGfx(TileIndex t) static inline uint GetIndustryGfx(TileIndex t)
{ {
assert(IsTileType(t, MP_INDUSTRY));
return _m[t].m5; return _m[t].m5;
} }
static inline void SetIndustryGfx(TileIndex t, uint gfx) static inline void SetIndustryGfx(TileIndex t, uint gfx)
{ {
assert(IsTileType(t, MP_INDUSTRY));
_m[t].m5 = gfx; _m[t].m5 = gfx;
} }

View File

@ -28,20 +28,36 @@ static inline RoadBits DiagDirToRoadBits(DiagDirection d)
} }
static inline RoadBits GetRoadBits(TileIndex tile) typedef enum RoadType {
{ ROAD_NORMAL,
return GB(_m[tile].m5, 0, 4); ROAD_CROSSING,
} ROAD_DEPOT
} RoadType;
static inline void SetRoadBits(TileIndex tile, RoadBits r) static inline RoadType GetRoadType(TileIndex t)
{ {
SB(_m[tile].m5, 0, 4, r); assert(IsTileType(t, MP_STREET));
return GB(_m[t].m5, 4, 4);
} }
static inline Axis GetCrossingRoadAxis(TileIndex tile) static inline RoadBits GetRoadBits(TileIndex t)
{ {
return (Axis)GB(_m[tile].m5, 3, 1); assert(GetRoadType(t) == ROAD_NORMAL);
return GB(_m[t].m5, 0, 4);
}
static inline void SetRoadBits(TileIndex t, RoadBits r)
{
assert(GetRoadType(t) == ROAD_NORMAL); // XXX incomplete
SB(_m[t].m5, 0, 4, r);
}
static inline Axis GetCrossingRoadAxis(TileIndex t)
{
assert(GetRoadType(t) == ROAD_CROSSING);
return (Axis)GB(_m[t].m5, 3, 1);
} }
static inline RoadBits GetCrossingRoadBits(TileIndex tile) static inline RoadBits GetCrossingRoadBits(TileIndex tile)
@ -58,44 +74,39 @@ static inline TrackBits GetCrossingRailBits(TileIndex tile)
// TODO swap owner of road and rail // TODO swap owner of road and rail
static inline Owner GetCrossingRoadOwner(TileIndex t) static inline Owner GetCrossingRoadOwner(TileIndex t)
{ {
assert(GetRoadType(t) == ROAD_CROSSING);
return (Owner)_m[t].m3; return (Owner)_m[t].m3;
} }
static inline void SetCrossingRoadOwner(TileIndex t, Owner o) static inline void SetCrossingRoadOwner(TileIndex t, Owner o)
{ {
assert(GetRoadType(t) == ROAD_CROSSING);
_m[t].m3 = o; _m[t].m3 = o;
} }
static inline void UnbarCrossing(TileIndex t) static inline void UnbarCrossing(TileIndex t)
{ {
assert(GetRoadType(t) == ROAD_CROSSING);
CLRBIT(_m[t].m5, 2); CLRBIT(_m[t].m5, 2);
} }
static inline void BarCrossing(TileIndex t) static inline void BarCrossing(TileIndex t)
{ {
assert(GetRoadType(t) == ROAD_CROSSING);
SETBIT(_m[t].m5, 2); SETBIT(_m[t].m5, 2);
} }
static inline bool IsCrossingBarred(TileIndex t) static inline bool IsCrossingBarred(TileIndex t)
{ {
assert(GetRoadType(t) == ROAD_CROSSING);
return HASBIT(_m[t].m5, 2); return HASBIT(_m[t].m5, 2);
} }
typedef enum RoadType {
ROAD_NORMAL,
ROAD_CROSSING,
ROAD_DEPOT
} RoadType;
static inline RoadType GetRoadType(TileIndex tile) static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{ {
return GB(_m[tile].m5, 4, 4); assert(GetRoadType(t) == ROAD_DEPOT);
} return (DiagDirection)GB(_m[t].m5, 0, 2);
static inline DiagDirection GetRoadDepotDirection(TileIndex tile)
{
return (DiagDirection)GB(_m[tile].m5, 0, 2);
} }

View File

@ -9,6 +9,7 @@
static inline StationID GetStationIndex(TileIndex t) static inline StationID GetStationIndex(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return (StationID)_m[t].m2; return (StationID)_m[t].m2;
} }
@ -68,11 +69,13 @@ static inline RoadStopType GetRoadStopType(TileIndex t)
static inline bool IsRailwayStation(TileIndex t) static inline bool IsRailwayStation(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE; return _m[t].m5 < RAILWAY_BASE + RAILWAY_SIZE;
} }
static inline bool IsHangar(TileIndex t) static inline bool IsHangar(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return return
_m[t].m5 == HANGAR_TILE_0 || _m[t].m5 == HANGAR_TILE_0 ||
_m[t].m5 == HANGAR_TILE_1 || _m[t].m5 == HANGAR_TILE_1 ||
@ -81,6 +84,7 @@ static inline bool IsHangar(TileIndex t)
static inline bool IsAirport(TileIndex t) static inline bool IsAirport(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return return
IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) || IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE, AIRPORT_BASE + AIRPORT_SIZE) ||
IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED); IS_INT_INSIDE(_m[t].m5, AIRPORT_BASE_EXTENDED, AIRPORT_BASE_EXTENDED + AIRPORT_SIZE_EXTENDED);
@ -88,11 +92,13 @@ static inline bool IsAirport(TileIndex t)
static inline bool IsTruckStop(TileIndex t) static inline bool IsTruckStop(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return IS_INT_INSIDE(_m[t].m5, TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE); return IS_INT_INSIDE(_m[t].m5, TRUCK_BASE, TRUCK_BASE + TRUCK_SIZE);
} }
static inline bool IsBusStop(TileIndex t) static inline bool IsBusStop(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return IS_INT_INSIDE(_m[t].m5, BUS_BASE, BUS_BASE + BUS_SIZE); return IS_INT_INSIDE(_m[t].m5, BUS_BASE, BUS_BASE + BUS_SIZE);
} }
@ -103,16 +109,19 @@ static inline bool IsRoadStop(TileIndex t)
static inline bool IsOilRig(TileIndex t) static inline bool IsOilRig(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return _m[t].m5 == OILRIG_BASE; return _m[t].m5 == OILRIG_BASE;
} }
static inline bool IsDock(TileIndex t) static inline bool IsDock(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return IS_INT_INSIDE(_m[t].m5, DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL); return IS_INT_INSIDE(_m[t].m5, DOCK_BASE, DOCK_BASE + DOCK_SIZE_TOTAL);
} }
static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict static inline bool IsBuoy_(TileIndex t) // XXX _ due to naming conflict
{ {
assert(IsTileType(t, MP_STATION));
return _m[t].m5 == BUOY_BASE; return _m[t].m5 == BUOY_BASE;
} }
@ -147,17 +156,20 @@ static inline DiagDirection GetDockDirection(TileIndex t)
static inline bool IsCustomStationSprite(TileIndex t) static inline bool IsCustomStationSprite(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return HASBIT(_m[t].m3, 4); return HASBIT(_m[t].m3, 4);
} }
static inline void SetCustomStationSprite(TileIndex t, byte sprite) static inline void SetCustomStationSprite(TileIndex t, byte sprite)
{ {
assert(IsTileType(t, MP_STATION));
SETBIT(_m[t].m3, 4); SETBIT(_m[t].m3, 4);
_m[t].m4 = sprite; _m[t].m4 = sprite;
} }
static inline uint GetCustomStationSprite(TileIndex t) static inline uint GetCustomStationSprite(TileIndex t)
{ {
assert(IsTileType(t, MP_STATION));
return _m[t].m4; return _m[t].m4;
} }

View File

@ -5,6 +5,7 @@
static inline uint GetTownIndex(TileIndex t) static inline uint GetTownIndex(TileIndex t)
{ {
assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_STREET)); // XXX incomplete
return _m[t].m2; return _m[t].m2;
} }

View File

@ -31,30 +31,91 @@ typedef enum TreeGround {
TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert TR_SNOW_DESERT = 2 // 0-3 for snow, 3 for desert
} TreeGround; } TreeGround;
static inline TreeType GetTreeType(TileIndex t) { return _m[t].m3; }
static inline void SetTreeType(TileIndex t, TreeType r) { _m[t].m3 = r; }
static inline TreeGround GetTreeGround(TileIndex t) { return GB(_m[t].m2, 4, 2); } static inline TreeType GetTreeType(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return _m[t].m3;
}
static inline TreeGround GetTreeGround(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 4, 2);
}
static inline uint GetTreeDensity(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 6, 2);
}
static inline uint GetTreeDensity(TileIndex t) { return GB(_m[t].m2, 6, 2); }
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d) static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
{ {
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 4, 2, g); SB(_m[t].m2, 4, 2, g);
SB(_m[t].m2, 6, 2, d); SB(_m[t].m2, 6, 2, d);
} }
static inline void AddTreeCount(TileIndex t, int c) { _m[t].m5 += c << 6; }
static inline uint GetTreeCount(TileIndex t) { return GB(_m[t].m5, 6, 2); }
static inline void SetTreeCount(TileIndex t, uint c) { SB(_m[t].m5, 6, 2, c); }
static inline void AddTreeGrowth(TileIndex t, int a) { _m[t].m5 += a; } static inline uint GetTreeCount(TileIndex t)
static inline uint GetTreeGrowth(TileIndex t) { return GB(_m[t].m5, 0, 3); } {
static inline void SetTreeGrowth(TileIndex t, uint g) { SB(_m[t].m5, 0, 3, g); } assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 6, 2);
}
static inline void AddTreeCounter(TileIndex t, int a) { _m[t].m2 += a; } static inline void AddTreeCount(TileIndex t, int c)
static inline uint GetTreeCounter(TileIndex t) { return GB(_m[t].m2, 0, 4); } {
static inline void SetTreeCounter(TileIndex t, uint c) { SB(_m[t].m2, 0, 4, c); } assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += c << 6;
}
static inline void SetTreeCount(TileIndex t, uint c)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m5, 6, 2, c);
}
static inline uint GetTreeGrowth(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m5, 0, 3);
}
static inline void AddTreeGrowth(TileIndex t, int a)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m5 += a;
}
static inline void SetTreeGrowth(TileIndex t, uint g)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m5, 0, 3, g);
}
static inline uint GetTreeCounter(TileIndex t)
{
assert(IsTileType(t, MP_TREES));
return GB(_m[t].m2, 0, 4);
}
static inline void AddTreeCounter(TileIndex t, int a)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
_m[t].m2 += a;
}
static inline void SetTreeCounter(TileIndex t, uint c)
{
assert(IsTileType(t, MP_TREES)); // XXX incomplete
SB(_m[t].m2, 0, 4, c);
}
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density) static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)

View File

@ -11,6 +11,7 @@
static inline bool IsTunnel(TileIndex t) static inline bool IsTunnel(TileIndex t)
{ {
assert(IsTileType(t, MP_TUNNELBRIDGE));
return !HASBIT(_m[t].m5, 7); return !HASBIT(_m[t].m5, 7);
} }
@ -23,12 +24,14 @@ static inline bool IsTunnelTile(TileIndex t)
static inline DiagDirection GetTunnelDirection(TileIndex t) static inline DiagDirection GetTunnelDirection(TileIndex t)
{ {
assert(IsTunnelTile(t));
return (DiagDirection)GB(_m[t].m5, 0, 2); return (DiagDirection)GB(_m[t].m5, 0, 2);
} }
static inline TransportType GetTunnelTransportType(TileIndex t) static inline TransportType GetTunnelTransportType(TileIndex t)
{ {
assert(IsTunnelTile(t));
return (TransportType)GB(_m[t].m5, 2, 2); return (TransportType)GB(_m[t].m5, 2, 2);
} }

View File

@ -10,6 +10,7 @@ typedef enum UnmovableType {
static inline UnmovableType GetUnmovableType(TileIndex t) static inline UnmovableType GetUnmovableType(TileIndex t)
{ {
assert(IsTileType(t, MP_UNMOVABLE));
return _m[t].m5; return _m[t].m5;
} }
@ -24,6 +25,7 @@ static inline bool IsTransmitterTile(TileIndex t)
static inline bool IsOwnedLand(TileIndex t) static inline bool IsOwnedLand(TileIndex t)
{ {
assert(IsTileType(t, MP_UNMOVABLE));
return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND; return GetUnmovableType(t) == UNMOVABLE_OWNED_LAND;
} }