Changeset - r26931:7d5bce03e821
[Not reviewed]
master
0 30 0
Rubidium - 15 months ago 2023-01-21 15:40:28
rubidium@openttd.org
Codechange: make use of Tile in for all direct map accesses
30 files changed with 967 insertions and 950 deletions:
0 comments (0 inline, 0 general)
src/bridge_map.h
Show inline comments
 
@@ -21,10 +21,10 @@
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if the structure is a bridge one
 
 */
 
static inline bool IsBridge(TileIndex t)
 
static inline bool IsBridge(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return HasBit(_m[t].m5, 7);
 
	return HasBit(t.m5(), 7);
 
}
 

	
 
/**
 
@@ -32,7 +32,7 @@ static inline bool IsBridge(TileIndex t)
 
 * @param t The tile to analyze
 
 * @return true if a bridge is present
 
 */
 
static inline bool IsBridgeTile(TileIndex t)
 
static inline bool IsBridgeTile(Tile t)
 
{
 
	return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
 
}
 
@@ -42,9 +42,9 @@ static inline bool IsBridgeTile(TileInde
 
 * @param t The tile to analyze
 
 * @return true if a bridge is detected above
 
 */
 
static inline bool IsBridgeAbove(TileIndex t)
 
static inline bool IsBridgeAbove(Tile t)
 
{
 
	return GB(_m[t].type, 2, 2) != 0;
 
	return GB(t.type(), 2, 2) != 0;
 
}
 

	
 
/**
 
@@ -53,10 +53,10 @@ static inline bool IsBridgeAbove(TileInd
 
 * @pre IsBridgeTile(t)
 
 * @return The bridge type
 
 */
 
static inline BridgeType GetBridgeType(TileIndex t)
 
static inline BridgeType GetBridgeType(Tile t)
 
{
 
	assert(IsBridgeTile(t));
 
	return GB(_me[t].m6, 2, 4);
 
	return GB(t.m6(), 2, 4);
 
}
 

	
 
/**
 
@@ -65,10 +65,10 @@ static inline BridgeType GetBridgeType(T
 
 * @pre IsBridgeAbove(t)
 
 * @return the above mentioned axis
 
 */
 
static inline Axis GetBridgeAxis(TileIndex t)
 
static inline Axis GetBridgeAxis(Tile t)
 
{
 
	assert(IsBridgeAbove(t));
 
	return (Axis)(GB(_m[t].type, 2, 2) - 1);
 
	return (Axis)(GB(t.type(), 2, 2) - 1);
 
}
 

	
 
TileIndex GetNorthernBridgeEnd(TileIndex t);
 
@@ -91,16 +91,16 @@ static inline int GetBridgePixelHeight(T
 
 * @param t the tile to remove the bridge from
 
 * @param a the axis of the bridge to remove
 
 */
 
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
 
static inline void ClearSingleBridgeMiddle(Tile t, Axis a)
 
{
 
	ClrBit(_m[t].type, 2 + a);
 
	ClrBit(t.type(), 2 + a);
 
}
 

	
 
/**
 
 * Removes bridges from the given, that is bridges along the X and Y axis.
 
 * @param t the tile to remove the bridge from
 
 */
 
static inline void ClearBridgeMiddle(TileIndex t)
 
static inline void ClearBridgeMiddle(Tile t)
 
{
 
	ClearSingleBridgeMiddle(t, AXIS_X);
 
	ClearSingleBridgeMiddle(t, AXIS_Y);
 
@@ -111,9 +111,9 @@ static inline void ClearBridgeMiddle(Til
 
 * @param t the tile to add the bridge to
 
 * @param a the axis of the bridge to add
 
 */
 
static inline void SetBridgeMiddle(TileIndex t, Axis a)
 
static inline void SetBridgeMiddle(Tile t, Axis a)
 
{
 
	SetBit(_m[t].type, 2 + a);
 
	SetBit(t.type(), 2 + a);
 
}
 

	
 
/**
 
@@ -125,18 +125,18 @@ static inline void SetBridgeMiddle(TileI
 
 * @param tt         the transport type of the bridge
 
 * @note this function should not be called directly.
 
 */
 
static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
 
static inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
 
{
 
	SetTileType(t, MP_TUNNELBRIDGE);
 
	SetTileOwner(t, o);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = INVALID_ROADTYPE;
 
	_m[t].m5 = 1 << 7 | tt << 2 | d;
 
	SB(_me[t].m6, 2, 4, bridgetype);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = INVALID_ROADTYPE << 6;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = INVALID_ROADTYPE;
 
	t.m5() = 1 << 7 | tt << 2 | d;
 
	SB(t.m6(), 2, 4, bridgetype);
 
	t.m7() = 0;
 
	t.m8() = INVALID_ROADTYPE << 6;
 
}
 

	
 
/**
 
@@ -150,7 +150,7 @@ static inline void MakeBridgeRamp(TileIn
 
 * @param road_rt    the road type of the bridge
 
 * @param tram_rt    the tram type of the bridge
 
 */
 
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 
static inline void MakeRoadBridgeRamp(Tile t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 
{
 
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD);
 
	SetRoadOwner(t, RTT_ROAD, owner_road);
 
@@ -166,7 +166,7 @@ static inline void MakeRoadBridgeRamp(Ti
 
 * @param d          the direction this ramp must be facing
 
 * @param rt         the rail type of the bridge
 
 */
 
static inline void MakeRailBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
 
static inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
 
{
 
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL);
 
	SetRailType(t, rt);
 
@@ -178,7 +178,7 @@ static inline void MakeRailBridgeRamp(Ti
 
 * @param o          the new owner of the bridge ramp
 
 * @param d          the direction this ramp must be facing
 
 */
 
static inline void MakeAqueductBridgeRamp(TileIndex t, Owner o, DiagDirection d)
 
static inline void MakeAqueductBridgeRamp(Tile t, Owner o, DiagDirection d)
 
{
 
	MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER);
 
}
src/clear_map.h
Show inline comments
 
@@ -32,10 +32,10 @@ enum ClearGround {
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return whether the tile is covered with snow.
 
 */
 
static inline bool IsSnowTile(TileIndex t)
 
static inline bool IsSnowTile(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return HasBit(_m[t].m3, 4);
 
	return HasBit(t.m3(), 4);
 
}
 

	
 
/**
 
@@ -44,10 +44,10 @@ static inline bool IsSnowTile(TileIndex 
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetRawClearGround(TileIndex t)
 
static inline ClearGround GetRawClearGround(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return (ClearGround)GB(_m[t].m5, 2, 3);
 
	return (ClearGround)GB(t.m5(), 2, 3);
 
}
 

	
 
/**
 
@@ -56,7 +56,7 @@ static inline ClearGround GetRawClearGro
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetClearGround(TileIndex t)
 
static inline ClearGround GetClearGround(Tile t)
 
{
 
	if (IsSnowTile(t)) return CLEAR_SNOW;
 
	return GetRawClearGround(t);
 
@@ -68,7 +68,7 @@ static inline ClearGround GetClearGround
 
 * @param ct the ground type
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline bool IsClearGround(TileIndex t, ClearGround ct)
 
static inline bool IsClearGround(Tile t, ClearGround ct)
 
{
 
	return GetClearGround(t) == ct;
 
}
 
@@ -80,10 +80,10 @@ static inline bool IsClearGround(TileInd
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the density
 
 */
 
static inline uint GetClearDensity(TileIndex t)
 
static inline uint GetClearDensity(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return GB(_m[t].m5, 0, 2);
 
	return GB(t.m5(), 0, 2);
 
}
 

	
 
/**
 
@@ -92,10 +92,10 @@ static inline uint GetClearDensity(TileI
 
 * @param d the amount to increment the density with
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void AddClearDensity(TileIndex t, int d)
 
static inline void AddClearDensity(Tile t, int d)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	_m[t].m5 += d;
 
	t.m5() += d;
 
}
 

	
 
/**
 
@@ -104,10 +104,10 @@ static inline void AddClearDensity(TileI
 
 * @param d the new density
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearDensity(TileIndex t, uint d)
 
static inline void SetClearDensity(Tile t, uint d)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	SB(_m[t].m5, 0, 2, d);
 
	SB(t.m5(), 0, 2, d);
 
}
 

	
 

	
 
@@ -117,10 +117,10 @@ static inline void SetClearDensity(TileI
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the value of the counter
 
 */
 
static inline uint GetClearCounter(TileIndex t)
 
static inline uint GetClearCounter(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return GB(_m[t].m5, 5, 3);
 
	return GB(t.m5(), 5, 3);
 
}
 

	
 
/**
 
@@ -129,10 +129,10 @@ static inline uint GetClearCounter(TileI
 
 * @param c the amount to increment the counter with
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void AddClearCounter(TileIndex t, int c)
 
static inline void AddClearCounter(Tile t, int c)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	_m[t].m5 += c << 5;
 
	t.m5() += c << 5;
 
}
 

	
 
/**
 
@@ -141,10 +141,10 @@ static inline void AddClearCounter(TileI
 
 * @param c the amount to set the counter to
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearCounter(TileIndex t, uint c)
 
static inline void SetClearCounter(Tile t, uint c)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	SB(_m[t].m5, 5, 3, c);
 
	SB(t.m5(), 5, 3, c);
 
}
 

	
 

	
 
@@ -155,10 +155,10 @@ static inline void SetClearCounter(TileI
 
 * @param density the density of the ground tile
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearGroundDensity(TileIndex t, ClearGround type, uint density)
 
static inline void SetClearGroundDensity(Tile t, ClearGround type, uint density)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	_m[t].m5 = 0 << 5 | type << 2 | density;
 
	t.m5() = 0 << 5 | type << 2 | density;
 
}
 

	
 

	
 
@@ -168,10 +168,10 @@ static inline void SetClearGroundDensity
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 * @return the field type
 
 */
 
static inline uint GetFieldType(TileIndex t)
 
static inline uint GetFieldType(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	return GB(_m[t].m3, 0, 4);
 
	return GB(t.m3(), 0, 4);
 
}
 

	
 
/**
 
@@ -180,10 +180,10 @@ static inline uint GetFieldType(TileInde
 
 * @param f the field type
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 */
 
static inline void SetFieldType(TileIndex t, uint f)
 
static inline void SetFieldType(Tile t, uint f)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete
 
	SB(_m[t].m3, 0, 4, f);
 
	SB(t.m3(), 0, 4, f);
 
}
 

	
 
/**
 
@@ -192,10 +192,10 @@ static inline void SetFieldType(TileInde
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 * @return the industry that made the field
 
 */
 
static inline IndustryID GetIndustryIndexOfField(TileIndex t)
 
static inline IndustryID GetIndustryIndexOfField(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	return(IndustryID) _m[t].m2;
 
	return(IndustryID) t.m2();
 
}
 

	
 
/**
 
@@ -204,10 +204,10 @@ static inline IndustryID GetIndustryInde
 
 * @param i the industry that made the field
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 */
 
static inline void SetIndustryIndexOfField(TileIndex t, IndustryID i)
 
static inline void SetIndustryIndexOfField(Tile t, IndustryID i)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	_m[t].m2 = i;
 
	t.m2() = i;
 
}
 

	
 

	
 
@@ -218,15 +218,15 @@ static inline void SetIndustryIndexOfFie
 
 * @pre IsClearGround(t, CLEAR_FIELDS)
 
 * @return 0 if there is no fence, otherwise the fence type
 
 */
 
static inline uint GetFence(TileIndex t, DiagDirection side)
 
static inline uint GetFence(Tile t, DiagDirection side)
 
{
 
	assert(IsClearGround(t, CLEAR_FIELDS));
 
	switch (side) {
 
		default: NOT_REACHED();
 
		case DIAGDIR_SE: return GB(_m[t].m4, 2, 3);
 
		case DIAGDIR_SW: return GB(_m[t].m4, 5, 3);
 
		case DIAGDIR_NE: return GB(_m[t].m3, 5, 3);
 
		case DIAGDIR_NW: return GB(_me[t].m6, 2, 3);
 
		case DIAGDIR_SE: return GB(t.m4(), 2, 3);
 
		case DIAGDIR_SW: return GB(t.m4(), 5, 3);
 
		case DIAGDIR_NE: return GB(t.m3(), 5, 3);
 
		case DIAGDIR_NW: return GB(t.m6(), 2, 3);
 
	}
 
}
 

	
 
@@ -237,15 +237,15 @@ static inline uint GetFence(TileIndex t,
 
 * @param h 0 if there is no fence, otherwise the fence type
 
 * @pre IsClearGround(t, CLEAR_FIELDS)
 
 */
 
static inline void SetFence(TileIndex t, DiagDirection side, uint h)
 
static inline void SetFence(Tile t, DiagDirection side, uint h)
 
{
 
	assert(IsClearGround(t, CLEAR_FIELDS));
 
	switch (side) {
 
		default: NOT_REACHED();
 
		case DIAGDIR_SE: SB(_m[t].m4, 2, 3, h); break;
 
		case DIAGDIR_SW: SB(_m[t].m4, 5, 3, h); break;
 
		case DIAGDIR_NE: SB(_m[t].m3, 5, 3, h); break;
 
		case DIAGDIR_NW: SB(_me[t].m6, 2, 3, h); break;
 
		case DIAGDIR_SE: SB(t.m4(), 2, 3, h); break;
 
		case DIAGDIR_SW: SB(t.m4(), 5, 3, h); break;
 
		case DIAGDIR_NE: SB(t.m3(), 5, 3, h); break;
 
		case DIAGDIR_NW: SB(t.m6(), 2, 3, h); break;
 
	}
 
}
 

	
 
@@ -256,18 +256,18 @@ static inline void SetFence(TileIndex t,
 
 * @param g       the type of ground
 
 * @param density the density of the grass/snow/desert etc
 
 */
 
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
 
static inline void MakeClear(Tile t, ClearGround g, uint density)
 
{
 
	SetTileType(t, MP_CLEAR);
 
	_m[t].m1 = 0;
 
	t.m1() = 0;
 
	SetTileOwner(t, OWNER_NONE);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0 << 5 | 0 << 2;
 
	SetClearGroundDensity(t, g, density); // Sets m5
 
	_me[t].m6 = 0;
 
	_me[t].m7 = 0;
 
	_me[t].m8 = 0;
 
	t.m6() = 0;
 
	t.m7() = 0;
 
	t.m8() = 0;
 
}
 

	
 

	
 
@@ -277,18 +277,18 @@ static inline void MakeClear(TileIndex t
 
 * @param field_type the 'growth' level of the field
 
 * @param industry   the industry this tile belongs to
 
 */
 
static inline void MakeField(TileIndex t, uint field_type, IndustryID industry)
 
static inline void MakeField(Tile t, uint field_type, IndustryID industry)
 
{
 
	SetTileType(t, MP_CLEAR);
 
	_m[t].m1 = 0;
 
	t.m1() = 0;
 
	SetTileOwner(t, OWNER_NONE);
 
	_m[t].m2 = industry;
 
	_m[t].m3 = field_type;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	t.m2() = industry;
 
	t.m3() = field_type;
 
	t.m4() = 0 << 5 | 0 << 2;
 
	SetClearGroundDensity(t, CLEAR_FIELDS, 3);
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = 0;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	t.m8() = 0;
 
}
 

	
 
/**
 
@@ -297,10 +297,10 @@ static inline void MakeField(TileIndex t
 
 * @param density The density of snowiness.
 
 * @pre GetClearGround(t) != CLEAR_SNOW
 
 */
 
static inline void MakeSnow(TileIndex t, uint density = 0)
 
static inline void MakeSnow(Tile t, uint density = 0)
 
{
 
	assert(GetClearGround(t) != CLEAR_SNOW);
 
	SetBit(_m[t].m3, 4);
 
	SetBit(t.m3(), 4);
 
	if (GetRawClearGround(t) == CLEAR_FIELDS) {
 
		SetClearGroundDensity(t, CLEAR_GRASS, density);
 
	} else {
 
@@ -313,10 +313,10 @@ static inline void MakeSnow(TileIndex t,
 
 * @param t the tile to clear of snow
 
 * @pre GetClearGround(t) == CLEAR_SNOW
 
 */
 
static inline void ClearSnow(TileIndex t)
 
static inline void ClearSnow(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_SNOW);
 
	ClrBit(_m[t].m3, 4);
 
	ClrBit(t.m3(), 4);
 
	SetClearDensity(t, 3);
 
}
 

	
src/depot_map.h
Show inline comments
 
@@ -15,7 +15,7 @@
 
/**
 
 * Check if a tile is a depot and it is a depot of the given type.
 
 */
 
static inline bool IsDepotTypeTile(TileIndex tile, TransportType type)
 
static inline bool IsDepotTypeTile(Tile tile, TransportType type)
 
{
 
	switch (type) {
 
		default: NOT_REACHED();
 
@@ -38,7 +38,7 @@ static inline bool IsDepotTypeTile(TileI
 
 * @param tile the tile to check
 
 * @return true if and only if there is a depot on the tile.
 
 */
 
static inline bool IsDepotTile(TileIndex tile)
 
static inline bool IsDepotTile(Tile tile)
 
{
 
	return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
 
}
 
@@ -49,11 +49,11 @@ static inline bool IsDepotTile(TileIndex
 
 * @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t)
 
 * @return DepotID
 
 */
 
static inline DepotID GetDepotIndex(TileIndex t)
 
static inline DepotID GetDepotIndex(Tile t)
 
{
 
	/* Hangars don't have a Depot class, thus store no DepotID. */
 
	assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
 
	return _m[t].m2;
 
	return t.m2();
 
}
 

	
 
/**
 
@@ -62,7 +62,7 @@ static inline DepotID GetDepotIndex(Tile
 
 * @pre IsDepotTile(t)
 
 * @return the type of vehicles that can use the depot
 
 */
 
static inline VehicleType GetDepotVehicleType(TileIndex t)
 
static inline VehicleType GetDepotVehicleType(Tile t)
 
{
 
	switch (GetTileType(t)) {
 
		default: NOT_REACHED();
src/industry_cmd.cpp
Show inline comments
 
@@ -103,7 +103,7 @@ void ResetIndustries()
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return general type for this industry, as defined in industry.h
 
 */
 
IndustryType GetIndustryType(TileIndex tile)
 
IndustryType GetIndustryType(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 

	
src/industry_map.h
Show inline comments
 
@@ -60,10 +60,10 @@ enum IndustryGraphics {
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the industry ID
 
 */
 
static inline IndustryID GetIndustryIndex(TileIndex t)
 
static inline IndustryID GetIndustryIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return _m[t].m2;
 
	return t.m2();
 
}
 

	
 
/**
 
@@ -72,23 +72,23 @@ static inline IndustryID GetIndustryInde
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return true if and only if the industry tile is fully built
 
 */
 
static inline bool IsIndustryCompleted(TileIndex t)
 
static inline bool IsIndustryCompleted(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return HasBit(_m[t].m1, 7);
 
	return HasBit(t.m1(), 7);
 
}
 

	
 
IndustryType GetIndustryType(TileIndex tile);
 
IndustryType GetIndustryType(Tile tile);
 

	
 
/**
 
 * Set if the industry that owns the tile as under construction or not
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryCompleted(TileIndex tile)
 
static inline void SetIndustryCompleted(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(_m[tile].m1, 7, 1, 1);
 
	SB(tile.m1(), 7, 1, 1);
 
}
 

	
 
/**
 
@@ -97,10 +97,10 @@ static inline void SetIndustryCompleted(
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return the construction stage
 
 */
 
static inline byte GetIndustryConstructionStage(TileIndex tile)
 
static inline byte GetIndustryConstructionStage(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(_m[tile].m1, 0, 2);
 
	return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2);
 
}
 

	
 
/**
 
@@ -109,10 +109,10 @@ static inline byte GetIndustryConstructi
 
 * @param value the new construction stage
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryConstructionStage(TileIndex tile, byte value)
 
static inline void SetIndustryConstructionStage(Tile tile, byte value)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(_m[tile].m1, 0, 2, value);
 
	SB(tile.m1(), 0, 2, value);
 
}
 

	
 
/**
 
@@ -122,10 +122,10 @@ static inline void SetIndustryConstructi
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the gfx ID
 
 */
 
static inline IndustryGfx GetCleanIndustryGfx(TileIndex t)
 
static inline IndustryGfx GetCleanIndustryGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return _m[t].m5 | (GB(_me[t].m6, 2, 1) << 8);
 
	return t.m5() | (GB(t.m6(), 2, 1) << 8);
 
}
 

	
 
/**
 
@@ -134,7 +134,7 @@ static inline IndustryGfx GetCleanIndust
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the gfx ID
 
 */
 
static inline IndustryGfx GetIndustryGfx(TileIndex t)
 
static inline IndustryGfx GetIndustryGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
 
@@ -146,11 +146,11 @@ static inline IndustryGfx GetIndustryGfx
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @param gfx the graphics ID
 
 */
 
static inline void SetIndustryGfx(TileIndex t, IndustryGfx gfx)
 
static inline void SetIndustryGfx(Tile t, IndustryGfx gfx)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	_m[t].m5 = GB(gfx, 0, 8);
 
	SB(_me[t].m6, 2, 1, GB(gfx, 8, 1));
 
	t.m5() = GB(gfx, 0, 8);
 
	SB(t.m6(), 2, 1, GB(gfx, 8, 1));
 
}
 

	
 
/**
 
@@ -159,10 +159,10 @@ static inline void SetIndustryGfx(TileIn
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return the construction counter
 
 */
 
static inline byte GetIndustryConstructionCounter(TileIndex tile)
 
static inline byte GetIndustryConstructionCounter(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return GB(_m[tile].m1, 2, 2);
 
	return GB(tile.m1(), 2, 2);
 
}
 

	
 
/**
 
@@ -171,10 +171,10 @@ static inline byte GetIndustryConstructi
 
 * @param value the new value for the construction counter
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryConstructionCounter(TileIndex tile, byte value)
 
static inline void SetIndustryConstructionCounter(Tile tile, byte value)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(_m[tile].m1, 2, 2, value);
 
	SB(tile.m1(), 2, 2, value);
 
}
 

	
 
/**
 
@@ -184,11 +184,11 @@ static inline void SetIndustryConstructi
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void ResetIndustryConstructionStage(TileIndex tile)
 
static inline void ResetIndustryConstructionStage(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(_m[tile].m1, 0, 4, 0);
 
	SB(_m[tile].m1, 7, 1, 0);
 
	SB(tile.m1(), 0, 4, 0);
 
	SB(tile.m1(), 7, 1, 0);
 
}
 

	
 
/**
 
@@ -196,10 +196,10 @@ static inline void ResetIndustryConstruc
 
 * @param tile the tile to get the animation loop number of
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline byte GetIndustryAnimationLoop(TileIndex tile)
 
static inline byte GetIndustryAnimationLoop(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return _m[tile].m4;
 
	return tile.m4();
 
}
 

	
 
/**
 
@@ -208,63 +208,63 @@ static inline byte GetIndustryAnimationL
 
 * @param count the new animation frame number
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryAnimationLoop(TileIndex tile, byte count)
 
static inline void SetIndustryAnimationLoop(Tile tile, byte count)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	_m[tile].m4 = count;
 
	tile.m4() = count;
 
}
 

	
 
/**
 
 * Get the random bits for this tile.
 
 * Used for grf callbacks
 
 * @param tile TileIndex of the tile to query
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return requested bits
 
 */
 
static inline byte GetIndustryRandomBits(TileIndex tile)
 
static inline byte GetIndustryRandomBits(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return _m[tile].m3;
 
	return tile.m3();
 
}
 

	
 
/**
 
 * Set the random bits for this tile.
 
 * Used for grf callbacks
 
 * @param tile TileIndex of the tile to query
 
 * @param tile the tile to query
 
 * @param bits the random bits
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryRandomBits(TileIndex tile, byte bits)
 
static inline void SetIndustryRandomBits(Tile tile, byte bits)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	_m[tile].m3 = bits;
 
	tile.m3() = bits;
 
}
 

	
 
/**
 
 * Get the activated triggers bits for this industry tile
 
 * Used for grf callbacks
 
 * @param tile TileIndex of the tile to query
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return requested triggers
 
 */
 
static inline byte GetIndustryTriggers(TileIndex tile)
 
static inline byte GetIndustryTriggers(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return GB(_me[tile].m6, 3, 3);
 
	return GB(tile.m6(), 3, 3);
 
}
 

	
 

	
 
/**
 
 * Set the activated triggers bits for this industry tile
 
 * Used for grf callbacks
 
 * @param tile TileIndex of the tile to query
 
 * @param tile the tile to query
 
 * @param triggers the triggers to set
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryTriggers(TileIndex tile, byte triggers)
 
static inline void SetIndustryTriggers(Tile tile, byte triggers)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(_me[tile].m6, 3, 3, triggers);
 
	SB(tile.m6(), 3, 3, triggers);
 
}
 

	
 
/**
 
@@ -275,17 +275,17 @@ static inline void SetIndustryTriggers(T
 
 * @param random the random value
 
 * @param wc     the water class for this industry; only useful when build on water
 
 */
 
static inline void MakeIndustry(TileIndex t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
 
static inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8 random, WaterClass wc)
 
{
 
	SetTileType(t, MP_INDUSTRY);
 
	_m[t].m1 = 0;
 
	_m[t].m2 = index;
 
	t.m1() = 0;
 
	t.m2() = index;
 
	SetIndustryRandomBits(t, random); // m3
 
	_m[t].m4 = 0;
 
	t.m4() = 0;
 
	SetIndustryGfx(t, gfx); // m5, part of m6
 
	SetIndustryTriggers(t, 0); // rest of m6
 
	SetWaterClass(t, wc);
 
	_me[t].m7 = 0;
 
	t.m7() = 0;
 
}
 

	
 
#endif /* INDUSTRY_MAP_H */
src/map_func.h
Show inline comments
 
@@ -50,6 +50,12 @@ public:
 
	debug_inline Tile(TileIndex tile) : tile(tile) {}
 

	
 
	/**
 
	 * Create the tile wrapper for the given tile.
 
	 * @param tile The tile to access the map for.
 
	 */
 
	Tile(uint tile) : tile(tile) {}
 

	
 
	/**
 
	 * Implicit conversion to the TileIndex.
 
	 */
 
	debug_inline constexpr operator TileIndex() const { return tile; }
 
@@ -189,16 +195,16 @@ private:
 
	 * Iterator to iterate all Tiles
 
	 */
 
	struct Iterator {
 
		typedef TileIndex value_type;
 
		typedef TileIndex *pointer;
 
		typedef TileIndex &reference;
 
		typedef Tile value_type;
 
		typedef Tile *pointer;
 
		typedef Tile &reference;
 
		typedef size_t difference_type;
 
		typedef std::forward_iterator_tag iterator_category;
 

	
 
		explicit Iterator(TileIndex index) : index(index) {}
 
		bool operator==(const Iterator &other) const { return this->index == other.index; }
 
		bool operator!=(const Iterator &other) const { return !(*this == other); }
 
		TileIndex operator*() const { return this->index; }
 
		Tile operator*() const { return this->index; }
 
		Iterator & operator++() { this->index++; return *this; }
 
	private:
 
		TileIndex index;
src/misc_gui.cpp
Show inline comments
 
@@ -107,7 +107,7 @@ public:
 
		}
 
	}
 

	
 
	LandInfoWindow(TileIndex tile) : Window(&_land_info_desc), tile(tile)
 
	LandInfoWindow(Tile tile) : Window(&_land_info_desc), tile(tile)
 
	{
 
		this->InitNested();
 

	
 
@@ -117,16 +117,16 @@ public:
 
#	define LANDINFOD_LEVEL 1
 
#endif
 
		Debug(misc, LANDINFOD_LEVEL, "TILE: {:#x} ({},{})", tile, TileX(tile), TileY(tile));
 
		Debug(misc, LANDINFOD_LEVEL, "type   = {:#x}", _m[tile].type);
 
		Debug(misc, LANDINFOD_LEVEL, "height = {:#x}", _m[tile].height);
 
		Debug(misc, LANDINFOD_LEVEL, "m1     = {:#x}", _m[tile].m1);
 
		Debug(misc, LANDINFOD_LEVEL, "m2     = {:#x}", _m[tile].m2);
 
		Debug(misc, LANDINFOD_LEVEL, "m3     = {:#x}", _m[tile].m3);
 
		Debug(misc, LANDINFOD_LEVEL, "m4     = {:#x}", _m[tile].m4);
 
		Debug(misc, LANDINFOD_LEVEL, "m5     = {:#x}", _m[tile].m5);
 
		Debug(misc, LANDINFOD_LEVEL, "m6     = {:#x}", _me[tile].m6);
 
		Debug(misc, LANDINFOD_LEVEL, "m7     = {:#x}", _me[tile].m7);
 
		Debug(misc, LANDINFOD_LEVEL, "m8     = {:#x}", _me[tile].m8);
 
		Debug(misc, LANDINFOD_LEVEL, "type   = {:#x}", tile.type());
 
		Debug(misc, LANDINFOD_LEVEL, "height = {:#x}", tile.height());
 
		Debug(misc, LANDINFOD_LEVEL, "m1     = {:#x}", tile.m1());
 
		Debug(misc, LANDINFOD_LEVEL, "m2     = {:#x}", tile.m2());
 
		Debug(misc, LANDINFOD_LEVEL, "m3     = {:#x}", tile.m3());
 
		Debug(misc, LANDINFOD_LEVEL, "m4     = {:#x}", tile.m4());
 
		Debug(misc, LANDINFOD_LEVEL, "m5     = {:#x}", tile.m5());
 
		Debug(misc, LANDINFOD_LEVEL, "m6     = {:#x}", tile.m6());
 
		Debug(misc, LANDINFOD_LEVEL, "m7     = {:#x}", tile.m7());
 
		Debug(misc, LANDINFOD_LEVEL, "m8     = {:#x}", tile.m8());
 
#undef LANDINFOD_LEVEL
 
	}
 

	
src/object_cmd.cpp
Show inline comments
 
@@ -61,7 +61,7 @@ uint16 Object::counts[NUM_OBJECTS];
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return the type.
 
 */
 
ObjectType GetObjectType(TileIndex t)
 
ObjectType GetObjectType(Tile t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return Object::GetByTile(t)->type;
src/object_map.h
Show inline comments
 
@@ -13,7 +13,7 @@
 
#include "water_map.h"
 
#include "object_type.h"
 

	
 
ObjectType GetObjectType(TileIndex t);
 
ObjectType GetObjectType(Tile t);
 

	
 
/**
 
 * Check whether the object on a tile is of a specific type.
 
@@ -22,7 +22,7 @@ ObjectType GetObjectType(TileIndex t);
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return True if type matches.
 
 */
 
static inline bool IsObjectType(TileIndex t, ObjectType type)
 
static inline bool IsObjectType(Tile t, ObjectType type)
 
{
 
	return GetObjectType(t) == type;
 
}
 
@@ -33,7 +33,7 @@ static inline bool IsObjectType(TileInde
 
 * @param type Type to test.
 
 * @return True if type matches.
 
 */
 
static inline bool IsObjectTypeTile(TileIndex t, ObjectType type)
 
static inline bool IsObjectTypeTile(Tile t, ObjectType type)
 
{
 
	return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type;
 
}
 
@@ -44,10 +44,10 @@ static inline bool IsObjectTypeTile(Tile
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return The ObjectID of the object.
 
 */
 
static inline ObjectID GetObjectIndex(TileIndex t)
 
static inline ObjectID GetObjectIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return _m[t].m2 | _m[t].m5 << 16;
 
	return t.m2() | t.m5() << 16;
 
}
 

	
 
/**
 
@@ -56,10 +56,10 @@ static inline ObjectID GetObjectIndex(Ti
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return The random bits.
 
 */
 
static inline byte GetObjectRandomBits(TileIndex t)
 
static inline byte GetObjectRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return _m[t].m3;
 
	return t.m3();
 
}
 

	
 

	
 
@@ -71,17 +71,17 @@ static inline byte GetObjectRandomBits(T
 
 * @param wc     Water class for this object.
 
 * @param random Random data to store on the tile
 
 */
 
static inline void MakeObject(TileIndex t, Owner o, ObjectID index, WaterClass wc, byte random)
 
static inline void MakeObject(Tile t, Owner o, ObjectID index, WaterClass wc, byte random)
 
{
 
	SetTileType(t, MP_OBJECT);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, wc);
 
	_m[t].m2 = index;
 
	_m[t].m3 = random;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = index >> 16;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = index;
 
	t.m3() = random;
 
	t.m4() = 0;
 
	t.m5() = index >> 16;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
#endif /* OBJECT_MAP_H */
src/pathfinder/npf/npf.cpp
Show inline comments
 
@@ -144,7 +144,7 @@ static uint NPFHash(uint key1, uint key2
 
	uint part2 = TileY(key1) & NPF_HASH_HALFMASK;
 

	
 
	assert(IsValidTrackdir((Trackdir)key2));
 
	assert(IsValidTile(key1));
 
	assert(IsValidTile((TileIndex)key1));
 
	return ((part1 << NPF_HASH_HALFBITS | part2) + (NPF_HASH_SIZE * key2 / TRACKDIR_END)) % NPF_HASH_SIZE;
 
}
 

	
src/rail.cpp
Show inline comments
 
@@ -152,7 +152,7 @@ extern const TrackdirBits _uphill_trackd
 
/**
 
 * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
 
 */
 
RailType GetTileRailType(TileIndex tile)
 
RailType GetTileRailType(Tile tile)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_RAILWAY:
src/rail_map.h
Show inline comments
 
@@ -33,10 +33,10 @@ enum RailTileType {
 
 * @pre IsTileType(t, MP_RAILWAY)
 
 * @return the RailTileType
 
 */
 
debug_inline static RailTileType GetRailTileType(TileIndex t)
 
debug_inline static RailTileType GetRailTileType(Tile t)
 
{
 
	assert(IsTileType(t, MP_RAILWAY));
 
	return (RailTileType)GB(_m[t].m5, 6, 2);
 
	return (RailTileType)GB(t.m5(), 6, 2);
 
}
 

	
 
/**
 
@@ -46,7 +46,7 @@ debug_inline static RailTileType GetRail
 
 * @pre IsTileType(t, MP_RAILWAY)
 
 * @return true if and only if the tile is normal rail (with or without signals)
 
 */
 
debug_inline static bool IsPlainRail(TileIndex t)
 
debug_inline static bool IsPlainRail(Tile t)
 
{
 
	RailTileType rtt = GetRailTileType(t);
 
	return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
 
@@ -57,7 +57,7 @@ debug_inline static bool IsPlainRail(Til
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is normal rail (with or without signals)
 
 */
 
debug_inline static bool IsPlainRailTile(TileIndex t)
 
debug_inline static bool IsPlainRailTile(Tile t)
 
{
 
	return IsTileType(t, MP_RAILWAY) && IsPlainRail(t);
 
}
 
@@ -69,7 +69,7 @@ debug_inline static bool IsPlainRailTile
 
 * @pre IsTileType(t, MP_RAILWAY)
 
 * @return true if and only if the tile has signals
 
 */
 
static inline bool HasSignals(TileIndex t)
 
static inline bool HasSignals(Tile t)
 
{
 
	return GetRailTileType(t) == RAIL_TILE_SIGNALS;
 
}
 
@@ -80,10 +80,10 @@ static inline bool HasSignals(TileIndex 
 
 * @param signals whether the rail tile should have signals or not
 
 * @pre IsPlainRailTile(tile)
 
 */
 
static inline void SetHasSignals(TileIndex tile, bool signals)
 
static inline void SetHasSignals(Tile tile, bool signals)
 
{
 
	assert(IsPlainRailTile(tile));
 
	SB(_m[tile].m5, 6, 1, signals);
 
	SB(tile.m5(), 6, 1, signals);
 
}
 

	
 
/**
 
@@ -92,7 +92,7 @@ static inline void SetHasSignals(TileInd
 
 * @pre IsTileType(t, MP_RAILWAY)
 
 * @return true if and only if the tile is a rail depot
 
 */
 
debug_inline static bool IsRailDepot(TileIndex t)
 
debug_inline static bool IsRailDepot(Tile t)
 
{
 
	return GetRailTileType(t) == RAIL_TILE_DEPOT;
 
}
 
@@ -102,7 +102,7 @@ debug_inline static bool IsRailDepot(Til
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is a rail depot
 
 */
 
debug_inline static bool IsRailDepotTile(TileIndex t)
 
debug_inline static bool IsRailDepotTile(Tile t)
 
{
 
	return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
 
}
 
@@ -112,9 +112,9 @@ debug_inline static bool IsRailDepotTile
 
 * @param t the tile to get the rail type from
 
 * @return the rail type of the tile
 
 */
 
static inline RailType GetRailType(TileIndex t)
 
static inline RailType GetRailType(Tile t)
 
{
 
	return (RailType)GB(_me[t].m8, 0, 6);
 
	return (RailType)GB(t.m8(), 0, 6);
 
}
 

	
 
/**
 
@@ -122,9 +122,9 @@ static inline RailType GetRailType(TileI
 
 * @param t the tile to set the rail type of
 
 * @param r the new rail type for the tile
 
 */
 
static inline void SetRailType(TileIndex t, RailType r)
 
static inline void SetRailType(Tile t, RailType r)
 
{
 
	SB(_me[t].m8, 0, 6, r);
 
	SB(t.m8(), 0, 6, r);
 
}
 

	
 

	
 
@@ -133,10 +133,10 @@ static inline void SetRailType(TileIndex
 
 * @param tile the tile to get the track bits from
 
 * @return the track bits of the tile
 
 */
 
static inline TrackBits GetTrackBits(TileIndex tile)
 
static inline TrackBits GetTrackBits(Tile tile)
 
{
 
	assert(IsPlainRailTile(tile));
 
	return (TrackBits)GB(_m[tile].m5, 0, 6);
 
	return (TrackBits)GB(tile.m5(), 0, 6);
 
}
 

	
 
/**
 
@@ -144,10 +144,10 @@ static inline TrackBits GetTrackBits(Til
 
 * @param t the tile to set the track bits of
 
 * @param b the new track bits for the tile
 
 */
 
static inline void SetTrackBits(TileIndex t, TrackBits b)
 
static inline void SetTrackBits(Tile t, TrackBits b)
 
{
 
	assert(IsPlainRailTile(t));
 
	SB(_m[t].m5, 0, 6, b);
 
	SB(t.m5(), 0, 6, b);
 
}
 

	
 
/**
 
@@ -157,7 +157,7 @@ static inline void SetTrackBits(TileInde
 
 * @pre IsPlainRailTile(tile)
 
 * @return true if and only if the given track exists on the tile
 
 */
 
static inline bool HasTrack(TileIndex tile, Track track)
 
static inline bool HasTrack(Tile tile, Track track)
 
{
 
	return HasBit(GetTrackBits(tile), track);
 
}
 
@@ -168,9 +168,9 @@ static inline bool HasTrack(TileIndex ti
 
 * @pre IsRailDepotTile(t)
 
 * @return the direction the depot is facing
 
 */
 
static inline DiagDirection GetRailDepotDirection(TileIndex t)
 
static inline DiagDirection GetRailDepotDirection(Tile t)
 
{
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
	return (DiagDirection)GB(t.m5(), 0, 2);
 
}
 

	
 
/**
 
@@ -179,7 +179,7 @@ static inline DiagDirection GetRailDepot
 
 * @param t the tile to get the depot track from
 
 * @return the track of the depot
 
 */
 
static inline Track GetRailDepotTrack(TileIndex t)
 
static inline Track GetRailDepotTrack(Tile t)
 
{
 
	return DiagDirToDiagTrack(GetRailDepotDirection(t));
 
}
 
@@ -191,13 +191,13 @@ static inline Track GetRailDepotTrack(Ti
 
 * @param t the tile to query
 
 * @return the track bits
 
 */
 
static inline TrackBits GetRailReservationTrackBits(TileIndex t)
 
static inline TrackBits GetRailReservationTrackBits(Tile t)
 
{
 
	assert(IsPlainRailTile(t));
 
	byte track_b = GB(_m[t].m2, 8, 3);
 
	byte track_b = GB(t.m2(), 8, 3);
 
	Track track = (Track)(track_b - 1);    // map array saves Track+1
 
	if (track_b == 0) return TRACK_BIT_NONE;
 
	return (TrackBits)(TrackToTrackBits(track) | (HasBit(_m[t].m2, 11) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
 
	return (TrackBits)(TrackToTrackBits(track) | (HasBit(t.m2(), 11) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
 
}
 

	
 
/**
 
@@ -206,14 +206,14 @@ static inline TrackBits GetRailReservati
 
 * @param t the tile to change
 
 * @param b the track bits
 
 */
 
static inline void SetTrackReservation(TileIndex t, TrackBits b)
 
static inline void SetTrackReservation(Tile t, TrackBits b)
 
{
 
	assert(IsPlainRailTile(t));
 
	assert(b != INVALID_TRACK_BIT);
 
	assert(!TracksOverlap(b));
 
	Track track = RemoveFirstTrack(&b);
 
	SB(_m[t].m2, 8, 3, track == INVALID_TRACK ? 0 : track + 1);
 
	SB(_m[t].m2, 11, 1, (byte)(b != TRACK_BIT_NONE));
 
	SB(t.m2(), 8, 3, track == INVALID_TRACK ? 0 : track + 1);
 
	SB(t.m2(), 11, 1, (byte)(b != TRACK_BIT_NONE));
 
}
 

	
 
/**
 
@@ -223,7 +223,7 @@ static inline void SetTrackReservation(T
 
 * @param t the rack to reserve
 
 * @return true if successful
 
 */
 
static inline bool TryReserveTrack(TileIndex tile, Track t)
 
static inline bool TryReserveTrack(Tile tile, Track t)
 
{
 
	assert(HasTrack(tile, t));
 
	TrackBits bits = TrackToTrackBits(t);
 
@@ -241,7 +241,7 @@ static inline bool TryReserveTrack(TileI
 
 * @param tile the tile
 
 * @param t the track to free
 
 */
 
static inline void UnreserveTrack(TileIndex tile, Track t)
 
static inline void UnreserveTrack(Tile tile, Track t)
 
{
 
	assert(HasTrack(tile, t));
 
	TrackBits res = GetRailReservationTrackBits(tile);
 
@@ -255,10 +255,10 @@ static inline void UnreserveTrack(TileIn
 
 * @param t the depot tile
 
 * @return reservation state
 
 */
 
static inline bool HasDepotReservation(TileIndex t)
 
static inline bool HasDepotReservation(Tile t)
 
{
 
	assert(IsRailDepot(t));
 
	return HasBit(_m[t].m5, 4);
 
	return HasBit(t.m5(), 4);
 
}
 

	
 
/**
 
@@ -267,10 +267,10 @@ static inline bool HasDepotReservation(T
 
 * @param t the depot tile
 
 * @param b the reservation state
 
 */
 
static inline void SetDepotReservation(TileIndex t, bool b)
 
static inline void SetDepotReservation(Tile t, bool b)
 
{
 
	assert(IsRailDepot(t));
 
	SB(_m[t].m5, 4, 1, (byte)b);
 
	SB(t.m5(), 4, 1, (byte)b);
 
}
 

	
 
/**
 
@@ -279,7 +279,7 @@ static inline void SetDepotReservation(T
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetDepotReservationTrackBits(TileIndex t)
 
static inline TrackBits GetDepotReservationTrackBits(Tile t)
 
{
 
	return HasDepotReservation(t) ? TrackToTrackBits(GetRailDepotTrack(t)) : TRACK_BIT_NONE;
 
}
 
@@ -290,58 +290,58 @@ static inline bool IsPbsSignal(SignalTyp
 
	return s == SIGTYPE_PBS || s == SIGTYPE_PBS_ONEWAY;
 
}
 

	
 
static inline SignalType GetSignalType(TileIndex t, Track track)
 
static inline SignalType GetSignalType(Tile t, Track track)
 
{
 
	assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
 
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
 
	return (SignalType)GB(_m[t].m2, pos, 3);
 
	return (SignalType)GB(t.m2(), pos, 3);
 
}
 

	
 
static inline void SetSignalType(TileIndex t, Track track, SignalType s)
 
static inline void SetSignalType(Tile t, Track track, SignalType s)
 
{
 
	assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
 
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
 
	SB(_m[t].m2, pos, 3, s);
 
	if (track == INVALID_TRACK) SB(_m[t].m2, 4, 3, s);
 
	SB(t.m2(), pos, 3, s);
 
	if (track == INVALID_TRACK) SB(t.m2(), 4, 3, s);
 
}
 

	
 
static inline bool IsPresignalEntry(TileIndex t, Track track)
 
static inline bool IsPresignalEntry(Tile t, Track track)
 
{
 
	return GetSignalType(t, track) == SIGTYPE_ENTRY || GetSignalType(t, track) == SIGTYPE_COMBO;
 
}
 

	
 
static inline bool IsPresignalExit(TileIndex t, Track track)
 
static inline bool IsPresignalExit(Tile t, Track track)
 
{
 
	return GetSignalType(t, track) == SIGTYPE_EXIT || GetSignalType(t, track) == SIGTYPE_COMBO;
 
}
 

	
 
/** One-way signals can't be passed the 'wrong' way. */
 
static inline bool IsOnewaySignal(TileIndex t, Track track)
 
static inline bool IsOnewaySignal(Tile t, Track track)
 
{
 
	return GetSignalType(t, track) != SIGTYPE_PBS;
 
}
 

	
 
static inline void CycleSignalSide(TileIndex t, Track track)
 
static inline void CycleSignalSide(Tile t, Track track)
 
{
 
	byte sig;
 
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 6;
 

	
 
	sig = GB(_m[t].m3, pos, 2);
 
	sig = GB(t.m3(), pos, 2);
 
	if (--sig == 0) sig = IsPbsSignal(GetSignalType(t, track)) ? 2 : 3;
 
	SB(_m[t].m3, pos, 2, sig);
 
	SB(t.m3(), pos, 2, sig);
 
}
 

	
 
static inline SignalVariant GetSignalVariant(TileIndex t, Track track)
 
static inline SignalVariant GetSignalVariant(Tile t, Track track)
 
{
 
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
 
	return (SignalVariant)GB(_m[t].m2, pos, 1);
 
	return (SignalVariant)GB(t.m2(), pos, 1);
 
}
 

	
 
static inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v)
 
static inline void SetSignalVariant(Tile t, Track track, SignalVariant v)
 
{
 
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
 
	SB(_m[t].m2, pos, 1, v);
 
	if (track == INVALID_TRACK) SB(_m[t].m2, 7, 1, v);
 
	SB(t.m2(), pos, 1, v);
 
	if (track == INVALID_TRACK) SB(t.m2(), 7, 1, v);
 
}
 

	
 
/**
 
@@ -349,9 +349,9 @@ static inline void SetSignalVariant(Tile
 
 * @param tile  the tile to set the states for
 
 * @param state the new state
 
 */
 
static inline void SetSignalStates(TileIndex tile, uint state)
 
static inline void SetSignalStates(Tile tile, uint state)
 
{
 
	SB(_m[tile].m4, 4, 4, state);
 
	SB(tile.m4(), 4, 4, state);
 
}
 

	
 
/**
 
@@ -359,9 +359,9 @@ static inline void SetSignalStates(TileI
 
 * @param tile  the tile to set the states for
 
 * @return the state of the signals
 
 */
 
static inline uint GetSignalStates(TileIndex tile)
 
static inline uint GetSignalStates(Tile tile)
 
{
 
	return GB(_m[tile].m4, 4, 4);
 
	return GB(tile.m4(), 4, 4);
 
}
 

	
 
/**
 
@@ -370,7 +370,7 @@ static inline uint GetSignalStates(TileI
 
 * @param signalbit the signal
 
 * @return the state of the signal
 
 */
 
static inline SignalState GetSingleSignalState(TileIndex t, byte signalbit)
 
static inline SignalState GetSingleSignalState(Tile t, byte signalbit)
 
{
 
	return (SignalState)HasBit(GetSignalStates(t), signalbit);
 
}
 
@@ -380,9 +380,9 @@ static inline SignalState GetSingleSigna
 
 * @param tile    the tile to set the present signals for
 
 * @param signals the signals that have to be present
 
 */
 
static inline void SetPresentSignals(TileIndex tile, uint signals)
 
static inline void SetPresentSignals(Tile tile, uint signals)
 
{
 
	SB(_m[tile].m3, 4, 4, signals);
 
	SB(tile.m3(), 4, 4, signals);
 
}
 

	
 
/**
 
@@ -390,9 +390,9 @@ static inline void SetPresentSignals(Til
 
 * @param tile the tile to get the present signals for
 
 * @return the signals that are present
 
 */
 
static inline uint GetPresentSignals(TileIndex tile)
 
static inline uint GetPresentSignals(Tile tile)
 
{
 
	return GB(_m[tile].m3, 4, 4);
 
	return GB(tile.m3(), 4, 4);
 
}
 

	
 
/**
 
@@ -401,7 +401,7 @@ static inline uint GetPresentSignals(Til
 
 * @param signalbit the signal
 
 * @return true if and only if the signal is present
 
 */
 
static inline bool IsSignalPresent(TileIndex t, byte signalbit)
 
static inline bool IsSignalPresent(Tile t, byte signalbit)
 
{
 
	return HasBit(GetPresentSignals(t), signalbit);
 
}
 
@@ -410,7 +410,7 @@ static inline bool IsSignalPresent(TileI
 
 * Checks for the presence of signals (either way) on the given track on the
 
 * given rail tile.
 
 */
 
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
 
static inline bool HasSignalOnTrack(Tile tile, Track track)
 
{
 
	assert(IsValidTrack(track));
 
	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
 
@@ -423,7 +423,7 @@ static inline bool HasSignalOnTrack(Tile
 
 * Along meaning if you are currently driving on the given trackdir, this is
 
 * the signal that is facing us (for which we stop when it's red).
 
 */
 
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
 
static inline bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
 
{
 
	assert (IsValidTrackdir(trackdir));
 
	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
 
@@ -435,7 +435,7 @@ static inline bool HasSignalOnTrackdir(T
 
 * Along meaning if you are currently driving on the given trackdir, this is
 
 * the signal that is facing us (for which we stop when it's red).
 
 */
 
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
 
static inline SignalState GetSignalStateByTrackdir(Tile tile, Trackdir trackdir)
 
{
 
	assert(IsValidTrackdir(trackdir));
 
	assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
 
@@ -446,7 +446,7 @@ static inline SignalState GetSignalState
 
/**
 
 * Sets the state of the signal along the given trackdir.
 
 */
 
static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
 
static inline void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
 
{
 
	if (state == SIGNAL_STATE_GREEN) { // set 1
 
		SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
 
@@ -460,7 +460,7 @@ static inline void SetSignalStateByTrack
 
 * @param tile the tile to check
 
 * @param td the trackdir to check
 
 */
 
static inline bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td)
 
static inline bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
 
{
 
	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, td) &&
 
			IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
 
@@ -472,14 +472,14 @@ static inline bool HasPbsSignalOnTrackdi
 
 * @param tile the tile to check
 
 * @param td the trackdir to check
 
 */
 
static inline bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
 
static inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
 
{
 
	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
 
			!HasSignalOnTrackdir(tile, td) && IsOnewaySignal(tile, TrackdirToTrack(td));
 
}
 

	
 

	
 
RailType GetTileRailType(TileIndex tile);
 
RailType GetTileRailType(Tile tile);
 

	
 
/** The ground 'under' the rail */
 
enum RailGroundType {
 
@@ -500,49 +500,49 @@ enum RailGroundType {
 
	RAIL_GROUND_HALF_SNOW    = 14, ///< Snow only on higher part of slope (steep or one corner raised)
 
};
 

	
 
static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
 
static inline void SetRailGroundType(Tile t, RailGroundType rgt)
 
{
 
	SB(_m[t].m4, 0, 4, rgt);
 
	SB(t.m4(), 0, 4, rgt);
 
}
 

	
 
static inline RailGroundType GetRailGroundType(TileIndex t)
 
static inline RailGroundType GetRailGroundType(Tile t)
 
{
 
	return (RailGroundType)GB(_m[t].m4, 0, 4);
 
	return (RailGroundType)GB(t.m4(), 0, 4);
 
}
 

	
 
static inline bool IsSnowRailGround(TileIndex t)
 
static inline bool IsSnowRailGround(Tile t)
 
{
 
	return GetRailGroundType(t) == RAIL_GROUND_ICE_DESERT;
 
}
 

	
 

	
 
static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
 
static inline void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
 
{
 
	SetTileType(t, MP_RAILWAY);
 
	SetTileOwner(t, o);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = RAIL_TILE_NORMAL << 6 | b;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = r;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = RAIL_TILE_NORMAL << 6 | b;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	t.m8() = r;
 
}
 

	
 

	
 
static inline void MakeRailDepot(TileIndex t, Owner o, DepotID did, DiagDirection d, RailType r)
 
static inline void MakeRailDepot(Tile t, Owner o, DepotID did, DiagDirection d, RailType r)
 
{
 
	SetTileType(t, MP_RAILWAY);
 
	SetTileOwner(t, o);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = did;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = RAIL_TILE_DEPOT << 6 | d;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = r;
 
	t.m2() = did;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = RAIL_TILE_DEPOT << 6 | d;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	t.m8() = r;
 
}
 

	
 
#endif /* RAIL_MAP_H */
src/road_map.cpp
Show inline comments
 
@@ -30,7 +30,7 @@
 
 * @param straight_tunnel_bridge_entrance whether to return straight road bits for tunnels/bridges.
 
 * @return the road bits of the given tile
 
 */
 
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
 
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance)
 
{
 
	if (!MayHaveRoad(tile) || !HasTileRoadType(tile, rtt)) return ROAD_NONE;
 

	
src/road_map.h
Show inline comments
 
@@ -30,7 +30,7 @@ enum RoadTileType {
 
 * @param t Tile to query.
 
 * @return true if tile can be queried about road/tram types.
 
 */
 
static inline bool MayHaveRoad(TileIndex t)
 
static inline bool MayHaveRoad(Tile t)
 
{
 
	switch (GetTileType(t)) {
 
		case MP_ROAD:
 
@@ -49,10 +49,10 @@ static inline bool MayHaveRoad(TileIndex
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return The road tile type.
 
 */
 
debug_inline static RoadTileType GetRoadTileType(TileIndex t)
 
debug_inline static RoadTileType GetRoadTileType(Tile t)
 
{
 
	assert(IsTileType(t, MP_ROAD));
 
	return (RoadTileType)GB(_m[t].m5, 6, 2);
 
	return (RoadTileType)GB(t.m5(), 6, 2);
 
}
 

	
 
/**
 
@@ -61,7 +61,7 @@ debug_inline static RoadTileType GetRoad
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return True if normal road.
 
 */
 
debug_inline static bool IsNormalRoad(TileIndex t)
 
debug_inline static bool IsNormalRoad(Tile t)
 
{
 
	return GetRoadTileType(t) == ROAD_TILE_NORMAL;
 
}
 
@@ -71,7 +71,7 @@ debug_inline static bool IsNormalRoad(Ti
 
 * @param t Tile to query.
 
 * @return True if normal road tile.
 
 */
 
debug_inline static bool IsNormalRoadTile(TileIndex t)
 
debug_inline static bool IsNormalRoadTile(Tile t)
 
{
 
	return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
 
}
 
@@ -82,7 +82,7 @@ debug_inline static bool IsNormalRoadTil
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return True if level crossing.
 
 */
 
static inline bool IsLevelCrossing(TileIndex t)
 
static inline bool IsLevelCrossing(Tile t)
 
{
 
	return GetRoadTileType(t) == ROAD_TILE_CROSSING;
 
}
 
@@ -92,7 +92,7 @@ static inline bool IsLevelCrossing(TileI
 
 * @param t Tile to query.
 
 * @return True if level crossing tile.
 
 */
 
static inline bool IsLevelCrossingTile(TileIndex t)
 
static inline bool IsLevelCrossingTile(Tile t)
 
{
 
	return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
 
}
 
@@ -103,7 +103,7 @@ static inline bool IsLevelCrossingTile(T
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return True if road depot.
 
 */
 
debug_inline static bool IsRoadDepot(TileIndex t)
 
debug_inline static bool IsRoadDepot(Tile t)
 
{
 
	return GetRoadTileType(t) == ROAD_TILE_DEPOT;
 
}
 
@@ -113,7 +113,7 @@ debug_inline static bool IsRoadDepot(Til
 
 * @param t Tile to query.
 
 * @return True if road depot tile.
 
 */
 
debug_inline static bool IsRoadDepotTile(TileIndex t)
 
debug_inline static bool IsRoadDepotTile(Tile t)
 
{
 
	return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
 
}
 
@@ -125,11 +125,11 @@ debug_inline static bool IsRoadDepotTile
 
 * @pre IsNormalRoad(t)
 
 * @return The present road bits for the road type.
 
 */
 
static inline RoadBits GetRoadBits(TileIndex t, RoadTramType rtt)
 
static inline RoadBits GetRoadBits(Tile t, RoadTramType rtt)
 
{
 
	assert(IsNormalRoad(t));
 
	if (rtt == RTT_TRAM) return (RoadBits)GB(_m[t].m3, 0, 4);
 
	return (RoadBits)GB(_m[t].m5, 0, 4);
 
	if (rtt == RTT_TRAM) return (RoadBits)GB(t.m3(), 0, 4);
 
	return (RoadBits)GB(t.m5(), 0, 4);
 
}
 

	
 
/**
 
@@ -138,7 +138,7 @@ static inline RoadBits GetRoadBits(TileI
 
 * @param tile The tile from which we want to get the RoadBits
 
 * @return all set RoadBits of the tile
 
 */
 
static inline RoadBits GetAllRoadBits(TileIndex tile)
 
static inline RoadBits GetAllRoadBits(Tile tile)
 
{
 
	return GetRoadBits(tile, RTT_ROAD) | GetRoadBits(tile, RTT_TRAM);
 
}
 
@@ -150,29 +150,29 @@ static inline RoadBits GetAllRoadBits(Ti
 
 * @param rt Road type.
 
 * @pre IsNormalRoad(t)
 
 */
 
static inline void SetRoadBits(TileIndex t, RoadBits r, RoadTramType rtt)
 
static inline void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
 
{
 
	assert(IsNormalRoad(t)); // XXX incomplete
 
	if (rtt == RTT_TRAM) {
 
		SB(_m[t].m3, 0, 4, r);
 
		SB(t.m3(), 0, 4, r);
 
	} else {
 
		SB(_m[t].m5, 0, 4, r);
 
		SB(t.m5(), 0, 4, r);
 
	}
 
}
 

	
 
static inline RoadType GetRoadTypeRoad(TileIndex t)
 
static inline RoadType GetRoadTypeRoad(Tile t)
 
{
 
	assert(MayHaveRoad(t));
 
	return (RoadType)GB(_m[t].m4, 0, 6);
 
	return (RoadType)GB(t.m4(), 0, 6);
 
}
 

	
 
static inline RoadType GetRoadTypeTram(TileIndex t)
 
static inline RoadType GetRoadTypeTram(Tile t)
 
{
 
	assert(MayHaveRoad(t));
 
	return (RoadType)GB(_me[t].m8, 6, 6);
 
	return (RoadType)GB(t.m8(), 6, 6);
 
}
 

	
 
static inline RoadType GetRoadType(TileIndex t, RoadTramType rtt)
 
static inline RoadType GetRoadType(Tile t, RoadTramType rtt)
 
{
 
	return (rtt == RTT_TRAM) ? GetRoadTypeTram(t) : GetRoadTypeRoad(t);
 
}
 
@@ -182,7 +182,7 @@ static inline RoadType GetRoadType(TileI
 
 * @param t The tile to query.
 
 * @return Present road types.
 
 */
 
static inline RoadTypes GetPresentRoadTypes(TileIndex t)
 
static inline RoadTypes GetPresentRoadTypes(Tile t)
 
{
 
	RoadTypes result = ROADTYPES_NONE;
 
	if (MayHaveRoad(t)) {
 
@@ -192,12 +192,12 @@ static inline RoadTypes GetPresentRoadTy
 
	return result;
 
}
 

	
 
static inline bool HasRoadTypeRoad(TileIndex t)
 
static inline bool HasRoadTypeRoad(Tile t)
 
{
 
	return GetRoadTypeRoad(t) != INVALID_ROADTYPE;
 
}
 

	
 
static inline bool HasRoadTypeTram(TileIndex t)
 
static inline bool HasRoadTypeTram(Tile t)
 
{
 
	return GetRoadTypeTram(t) != INVALID_ROADTYPE;
 
}
 
@@ -208,7 +208,7 @@ static inline bool HasRoadTypeTram(TileI
 
 * @param tram True to check tram, false to check road.
 
 * @return True if the tile has the specified road type.
 
 */
 
static inline bool HasTileRoadType(TileIndex t, RoadTramType rtt)
 
static inline bool HasTileRoadType(Tile t, RoadTramType rtt)
 
{
 
	return GetRoadType(t, rtt) != INVALID_ROADTYPE;
 
}
 
@@ -219,7 +219,7 @@ static inline bool HasTileRoadType(TileI
 
 * @param rts Allowed road types.
 
 * @return True if the tile has one of the specified road types.
 
 */
 
static inline bool HasTileAnyRoadType(TileIndex t, RoadTypes rts)
 
static inline bool HasTileAnyRoadType(Tile t, RoadTypes rts)
 
{
 
	if (!MayHaveRoad(t)) return false;
 
	return (GetPresentRoadTypes(t) & rts);
 
@@ -231,14 +231,14 @@ static inline bool HasTileAnyRoadType(Ti
 
 * @param rtt RoadTramType.
 
 * @return Owner of the given road type.
 
 */
 
static inline Owner GetRoadOwner(TileIndex t, RoadTramType rtt)
 
static inline Owner GetRoadOwner(Tile t, RoadTramType rtt)
 
{
 
	assert(MayHaveRoad(t));
 
	if (rtt == RTT_ROAD) return (Owner)GB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5);
 
	if (rtt == RTT_ROAD) return (Owner)GB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5);
 

	
 
	/* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
 
	 * to OWNER_TOWN makes it use one bit less */
 
	Owner o = (Owner)GB(_m[t].m3, 4, 4);
 
	Owner o = (Owner)GB(t.m3(), 4, 4);
 
	return o == OWNER_TOWN ? OWNER_NONE : o;
 
}
 

	
 
@@ -248,12 +248,12 @@ static inline Owner GetRoadOwner(TileInd
 
 * @param rtt RoadTramType.
 
 * @param o  New owner of the given road type.
 
 */
 
static inline void SetRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
 
static inline void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
{
 
	if (rtt == RTT_ROAD) {
 
		SB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5, o);
 
		SB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5, o);
 
	} else {
 
		SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o);
 
		SB(t.m3(), 4, 4, o == OWNER_NONE ? OWNER_TOWN : o);
 
	}
 
}
 

	
 
@@ -265,7 +265,7 @@ static inline void SetRoadOwner(TileInde
 
 * @pre HasTileRoadType(t, rt)
 
 * @return True if the road type is owned by the given owner.
 
 */
 
static inline bool IsRoadOwner(TileIndex t, RoadTramType rtt, Owner o)
 
static inline bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
{
 
	assert(HasTileRoadType(t, rtt));
 
	return (GetRoadOwner(t, rtt) == o);
 
@@ -277,7 +277,7 @@ static inline bool IsRoadOwner(TileIndex
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return true iff tile has road and the road is owned by a town
 
 */
 
static inline bool HasTownOwnedRoad(TileIndex t)
 
static inline bool HasTownOwnedRoad(Tile t)
 
{
 
	return HasTileRoadType(t, RTT_ROAD) && IsRoadOwner(t, RTT_ROAD, OWNER_TOWN);
 
}
 
@@ -298,10 +298,10 @@ static inline bool IsValidDisallowedRoad
 
 * @param t the tile to get the directions from
 
 * @return the disallowed directions
 
 */
 
static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
 
static inline DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
 
{
 
	assert(IsNormalRoad(t));
 
	return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
 
	return (DisallowedRoadDirections)GB(t.m5(), 4, 2);
 
}
 

	
 
/**
 
@@ -309,11 +309,11 @@ static inline DisallowedRoadDirections G
 
 * @param t   the tile to set the directions for
 
 * @param drd the disallowed directions
 
 */
 
static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
 
static inline void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
 
{
 
	assert(IsNormalRoad(t));
 
	assert(drd < DRD_END);
 
	SB(_m[t].m5, 4, 2, drd);
 
	SB(t.m5(), 4, 2, drd);
 
}
 

	
 
/**
 
@@ -322,10 +322,10 @@ static inline void SetDisallowedRoadDire
 
 * @pre IsLevelCrossing(t)
 
 * @return The axis of the road.
 
 */
 
static inline Axis GetCrossingRoadAxis(TileIndex t)
 
static inline Axis GetCrossingRoadAxis(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return (Axis)GB(_m[t].m5, 0, 1);
 
	return (Axis)GB(t.m5(), 0, 1);
 
}
 

	
 
/**
 
@@ -334,7 +334,7 @@ static inline Axis GetCrossingRoadAxis(T
 
 * @pre IsLevelCrossing(t)
 
 * @return The axis of the rail.
 
 */
 
static inline Axis GetCrossingRailAxis(TileIndex t)
 
static inline Axis GetCrossingRailAxis(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return OtherAxis((Axis)GetCrossingRoadAxis(t));
 
@@ -345,7 +345,7 @@ static inline Axis GetCrossingRailAxis(T
 
 * @param tile The tile to query.
 
 * @return The present road bits.
 
 */
 
static inline RoadBits GetCrossingRoadBits(TileIndex tile)
 
static inline RoadBits GetCrossingRoadBits(Tile tile)
 
{
 
	return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
 
}
 
@@ -355,7 +355,7 @@ static inline RoadBits GetCrossingRoadBi
 
 * @param tile The tile to query.
 
 * @return The rail track.
 
 */
 
static inline Track GetCrossingRailTrack(TileIndex tile)
 
static inline Track GetCrossingRailTrack(Tile tile)
 
{
 
	return AxisToTrack(GetCrossingRailAxis(tile));
 
}
 
@@ -365,7 +365,7 @@ static inline Track GetCrossingRailTrack
 
 * @param tile The tile to query.
 
 * @return The rail track bits.
 
 */
 
static inline TrackBits GetCrossingRailBits(TileIndex tile)
 
static inline TrackBits GetCrossingRailBits(Tile tile)
 
{
 
	return AxisToTrackBits(GetCrossingRailAxis(tile));
 
}
 
@@ -377,10 +377,10 @@ static inline TrackBits GetCrossingRailB
 
 * @return reservation state
 
 * @pre IsLevelCrossingTile(t)
 
 */
 
static inline bool HasCrossingReservation(TileIndex t)
 
static inline bool HasCrossingReservation(Tile t)
 
{
 
	assert(IsLevelCrossingTile(t));
 
	return HasBit(_m[t].m5, 4);
 
	return HasBit(t.m5(), 4);
 
}
 

	
 
/**
 
@@ -390,10 +390,10 @@ static inline bool HasCrossingReservatio
 
 * @param b the reservation state
 
 * @pre IsLevelCrossingTile(t)
 
 */
 
static inline void SetCrossingReservation(TileIndex t, bool b)
 
static inline void SetCrossingReservation(Tile t, bool b)
 
{
 
	assert(IsLevelCrossingTile(t));
 
	SB(_m[t].m5, 4, 1, b ? 1 : 0);
 
	SB(t.m5(), 4, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
@@ -402,7 +402,7 @@ static inline void SetCrossingReservatio
 
 * @pre IsLevelCrossingTile(t)
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetCrossingReservationTrackBits(TileIndex t)
 
static inline TrackBits GetCrossingReservationTrackBits(Tile t)
 
{
 
	return HasCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
 
}
 
@@ -413,10 +413,10 @@ static inline TrackBits GetCrossingReser
 
 * @pre IsLevelCrossing(t)
 
 * @return True if the level crossing is barred.
 
 */
 
static inline bool IsCrossingBarred(TileIndex t)
 
static inline bool IsCrossingBarred(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return HasBit(_m[t].m5, 5);
 
	return HasBit(t.m5(), 5);
 
}
 

	
 
/**
 
@@ -425,17 +425,17 @@ static inline bool IsCrossingBarred(Tile
 
 * @param barred True if the crossing should be barred, false otherwise.
 
 * @pre IsLevelCrossing(t)
 
 */
 
static inline void SetCrossingBarred(TileIndex t, bool barred)
 
static inline void SetCrossingBarred(Tile t, bool barred)
 
{
 
	assert(IsLevelCrossing(t));
 
	SB(_m[t].m5, 5, 1, barred ? 1 : 0);
 
	SB(t.m5(), 5, 1, barred ? 1 : 0);
 
}
 

	
 
/**
 
 * Unbar a level crossing.
 
 * @param t The tile to change.
 
 */
 
static inline void UnbarCrossing(TileIndex t)
 
static inline void UnbarCrossing(Tile t)
 
{
 
	SetCrossingBarred(t, false);
 
}
 
@@ -444,7 +444,7 @@ static inline void UnbarCrossing(TileInd
 
 * Bar a level crossing.
 
 * @param t The tile to change.
 
 */
 
static inline void BarCrossing(TileIndex t)
 
static inline void BarCrossing(Tile t)
 
{
 
	SetCrossingBarred(t, true);
 
}
 
@@ -456,9 +456,9 @@ static inline void BarCrossing(TileIndex
 
 * @param t The tile to query.
 
 * @return True if the tile has snow/desert.
 
 */
 
static inline bool IsOnSnow(TileIndex t)
 
static inline bool IsOnSnow(Tile t)
 
{
 
	return HasBit(_me[t].m7, 5);
 
	return HasBit(t.m7(), 5);
 
}
 

	
 
/** Toggle the snow/desert state of a road tile. */
 
@@ -467,9 +467,9 @@ static inline bool IsOnSnow(TileIndex t)
 
 * Toggle the snow/desert state of a road tile.
 
 * @param t The tile to change.
 
 */
 
static inline void ToggleSnow(TileIndex t)
 
static inline void ToggleSnow(Tile t)
 
{
 
	ToggleBit(_me[t].m7, 5);
 
	ToggleBit(t.m7(), 5);
 
}
 

	
 

	
 
@@ -490,9 +490,9 @@ enum Roadside {
 
 * @param tile The tile to query.
 
 * @return The road decoration of the tile.
 
 */
 
static inline Roadside GetRoadside(TileIndex tile)
 
static inline Roadside GetRoadside(Tile tile)
 
{
 
	return (Roadside)GB(_me[tile].m6, 3, 3);
 
	return (Roadside)GB(tile.m6(), 3, 3);
 
}
 

	
 
/**
 
@@ -500,9 +500,9 @@ static inline Roadside GetRoadside(TileI
 
 * @param tile The tile to change.
 
 * @param s    The new road decoration of the tile.
 
 */
 
static inline void SetRoadside(TileIndex tile, Roadside s)
 
static inline void SetRoadside(Tile tile, Roadside s)
 
{
 
	SB(_me[tile].m6, 3, 3, s);
 
	SB(tile.m6(), 3, 3, s);
 
}
 

	
 
/**
 
@@ -510,7 +510,7 @@ static inline void SetRoadside(TileIndex
 
 * @param t The tile to check.
 
 * @return True if the tile has road works in progress.
 
 */
 
static inline bool HasRoadWorks(TileIndex t)
 
static inline bool HasRoadWorks(Tile t)
 
{
 
	return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
 
}
 
@@ -520,11 +520,11 @@ static inline bool HasRoadWorks(TileInde
 
 * @param t The tile to modify.
 
 * @return True if the road works are in the last stage.
 
 */
 
static inline bool IncreaseRoadWorksCounter(TileIndex t)
 
static inline bool IncreaseRoadWorksCounter(Tile t)
 
{
 
	AB(_me[t].m7, 0, 4, 1);
 
	AB(t.m7(), 0, 4, 1);
 

	
 
	return GB(_me[t].m7, 0, 4) == 15;
 
	return GB(t.m7(), 0, 4) == 15;
 
}
 

	
 
/**
 
@@ -532,7 +532,7 @@ static inline bool IncreaseRoadWorksCoun
 
 * @param t The tile to start the work on.
 
 * @pre !HasRoadWorks(t)
 
 */
 
static inline void StartRoadWorks(TileIndex t)
 
static inline void StartRoadWorks(Tile t)
 
{
 
	assert(!HasRoadWorks(t));
 
	/* Remove any trees or lamps in case or roadwork */
 
@@ -548,12 +548,12 @@ static inline void StartRoadWorks(TileIn
 
 * @param t Tile to stop the road works on.
 
 * @pre HasRoadWorks(t)
 
 */
 
static inline void TerminateRoadWorks(TileIndex t)
 
static inline void TerminateRoadWorks(Tile t)
 
{
 
	assert(HasRoadWorks(t));
 
	SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
 
	/* Stop the counter */
 
	SB(_me[t].m7, 0, 4, 0);
 
	SB(t.m7(), 0, 4, 0);
 
}
 

	
 

	
 
@@ -562,25 +562,25 @@ static inline void TerminateRoadWorks(Ti
 
 * @param t The tile to query.
 
 * @return Diagonal direction of the depot exit.
 
 */
 
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
 
static inline DiagDirection GetRoadDepotDirection(Tile t)
 
{
 
	assert(IsRoadDepot(t));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
	return (DiagDirection)GB(t.m5(), 0, 2);
 
}
 

	
 

	
 
RoadBits GetAnyRoadBits(TileIndex tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance = false);
 
RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge_entrance = false);
 

	
 
/**
 
 * Set the road road type of a tile.
 
 * @param t The tile to change.
 
 * @param rt The road type to set.
 
 */
 
static inline void SetRoadTypeRoad(TileIndex t, RoadType rt)
 
static inline void SetRoadTypeRoad(Tile t, RoadType rt)
 
{
 
	assert(MayHaveRoad(t));
 
	assert(rt == INVALID_ROADTYPE || RoadTypeIsRoad(rt));
 
	SB(_m[t].m4, 0, 6, rt);
 
	SB(t.m4(), 0, 6, rt);
 
}
 

	
 
/**
 
@@ -588,11 +588,11 @@ static inline void SetRoadTypeRoad(TileI
 
 * @param t The tile to change.
 
 * @param rt The road type to set.
 
 */
 
static inline void SetRoadTypeTram(TileIndex t, RoadType rt)
 
static inline void SetRoadTypeTram(Tile t, RoadType rt)
 
{
 
	assert(MayHaveRoad(t));
 
	assert(rt == INVALID_ROADTYPE || RoadTypeIsTram(rt));
 
	SB(_me[t].m8, 6, 6, rt);
 
	SB(t.m8(), 6, 6, rt);
 
}
 

	
 
/**
 
@@ -601,7 +601,7 @@ static inline void SetRoadTypeTram(TileI
 
 * @param rtt Set road or tram type.
 
 * @param rt The road type to set.
 
 */
 
static inline void SetRoadType(TileIndex t, RoadTramType rtt, RoadType rt)
 
static inline void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
 
{
 
	if (rtt == RTT_TRAM) {
 
		SetRoadTypeTram(t, rt);
 
@@ -616,7 +616,7 @@ static inline void SetRoadType(TileIndex
 
 * @param road_rt The road roadtype to set for the tile.
 
 * @param tram_rt The tram roadtype to set for the tile.
 
 */
 
static inline void SetRoadTypes(TileIndex t, RoadType road_rt, RoadType tram_rt)
 
static inline void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
 
{
 
	SetRoadTypeRoad(t, road_rt);
 
	SetRoadTypeTram(t, tram_rt);
 
@@ -632,15 +632,15 @@ static inline void SetRoadTypes(TileInde
 
 * @param road    New owner of road.
 
 * @param tram    New owner of tram tracks.
 
 */
 
static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
 
static inline void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
 
{
 
	SetTileType(t, MP_ROAD);
 
	SetTileOwner(t, road);
 
	_m[t].m2 = town;
 
	_m[t].m3 = (tram_rt != INVALID_ROADTYPE ? bits : 0);
 
	_m[t].m5 = (road_rt != INVALID_ROADTYPE ? bits : 0) | ROAD_TILE_NORMAL << 6;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = town;
 
	t.m3() = (tram_rt != INVALID_ROADTYPE ? bits : 0);
 
	t.m5() = (road_rt != INVALID_ROADTYPE ? bits : 0) | ROAD_TILE_NORMAL << 6;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	SetRoadTypes(t, road_rt, tram_rt);
 
	SetRoadOwner(t, RTT_TRAM, tram);
 
}
 
@@ -657,17 +657,17 @@ static inline void MakeRoadNormal(TileIn
 
 * @param tram_rt The tram roadtype to set for the tile.
 
 * @param town    Town ID if the road is a town-owned road.
 
 */
 
static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
 
static inline void MakeRoadCrossing(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
 
{
 
	SetTileType(t, MP_ROAD);
 
	SetTileOwner(t, rail);
 
	_m[t].m2 = town;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = INVALID_ROADTYPE;
 
	_m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = road;
 
	_me[t].m8 = INVALID_ROADTYPE << 6 | rat;
 
	t.m2() = town;
 
	t.m3() = 0;
 
	t.m4() = INVALID_ROADTYPE;
 
	t.m5() = ROAD_TILE_CROSSING << 6 | roaddir;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = road;
 
	t.m8() = INVALID_ROADTYPE << 6 | rat;
 
	SetRoadTypes(t, road_rt, tram_rt);
 
	SetRoadOwner(t, RTT_TRAM, tram);
 
}
 
@@ -680,17 +680,17 @@ static inline void MakeRoadCrossing(Tile
 
 * @param dir   Direction of the depot exit.*
 
 * @param rt    Road type of the depot.
 
 */
 
static inline void MakeRoadDepot(TileIndex t, Owner owner, DepotID did, DiagDirection dir, RoadType rt)
 
static inline void MakeRoadDepot(Tile t, Owner owner, DepotID did, DiagDirection dir, RoadType rt)
 
{
 
	SetTileType(t, MP_ROAD);
 
	SetTileOwner(t, owner);
 
	_m[t].m2 = did;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = INVALID_ROADTYPE;
 
	_m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = owner;
 
	_me[t].m8 = INVALID_ROADTYPE << 6;
 
	t.m2() = did;
 
	t.m3() = 0;
 
	t.m4() = INVALID_ROADTYPE;
 
	t.m5() = ROAD_TILE_DEPOT << 6 | dir;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = owner;
 
	t.m8() = INVALID_ROADTYPE << 6;
 
	SetRoadType(t, GetRoadTramType(rt), rt);
 
	SetRoadOwner(t, RTT_TRAM, owner);
 
}
src/saveload/afterload.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ extern Company *DoStartupNewCompany(bool
 
 * @param t the tile to change.
 
 * @param include_invalid_water_class Also consider WATER_CLASS_INVALID, i.e. industry tiles on land
 
 */
 
void SetWaterClassDependingOnSurroundings(TileIndex t, bool include_invalid_water_class)
 
void SetWaterClassDependingOnSurroundings(Tile t, bool include_invalid_water_class)
 
{
 
	/* If the slope is not flat, we always assume 'land' (if allowed). Also for one-corner-raised-shores.
 
	 * Note: Wrt. autosloping under industry tiles this is the most fool-proof behaviour. */
 
@@ -104,7 +104,7 @@ void SetWaterClassDependingOnSurrounding
 
	bool has_river = false;
 

	
 
	for (DiagDirection dir = DIAGDIR_BEGIN; dir < DIAGDIR_END; dir++) {
 
		TileIndex neighbour = TileAddByDiagDir(t, dir);
 
		Tile neighbour = TileAddByDiagDir(t, dir);
 
		switch (GetTileType(neighbour)) {
 
			case MP_WATER:
 
				/* clear water and shipdepots have already a WaterClass associated */
 
@@ -127,7 +127,7 @@ void SetWaterClassDependingOnSurrounding
 

	
 
			case MP_TREES:
 
				/* trees on shore */
 
				has_water |= (GB(_m[neighbour].m2, 4, 2) == TREE_GROUND_SHORE);
 
				has_water |= (GB(neighbour.m2(), 4, 2) == TREE_GROUND_SHORE);
 
				break;
 

	
 
			default: break;
 
@@ -153,13 +153,13 @@ static void ConvertTownOwner()
 
	for (auto tile : Map::Iterate()) {
 
		switch (GetTileType(tile)) {
 
			case MP_ROAD:
 
				if (GB(_m[tile].m5, 4, 2) == ROAD_TILE_CROSSING && HasBit(_m[tile].m3, 7)) {
 
					_m[tile].m3 = OWNER_TOWN;
 
				if (GB(tile.m5(), 4, 2) == ROAD_TILE_CROSSING && HasBit(tile.m3(), 7)) {
 
					tile.m3() = OWNER_TOWN;
 
				}
 
				FALLTHROUGH;
 

	
 
			case MP_TUNNELBRIDGE:
 
				if (_m[tile].m1 & 0x80) SetTileOwner(tile, OWNER_TOWN);
 
				if (tile.m1() & 0x80) SetTileOwner(tile, OWNER_TOWN);
 
				break;
 

	
 
			default: break;
 
@@ -439,14 +439,14 @@ static void CDECL HandleSavegameLoadCras
 
 * a rail track had an invalid owner. When conversion isn't possible, track is removed.
 
 * @param t tile to update
 
 */
 
static void FixOwnerOfRailTrack(TileIndex t)
 
static void FixOwnerOfRailTrack(Tile t)
 
{
 
	assert(!Company::IsValidID(GetTileOwner(t)) && (IsLevelCrossingTile(t) || IsPlainRailTile(t)));
 

	
 
	/* remove leftover rail piece from crossing (from very old savegames) */
 
	Train *v = nullptr;
 
	for (Train *w : Train::Iterate()) {
 
		if (w->tile == t) {
 
		if (w->tile == TileIndex(t)) {
 
			v = w;
 
			break;
 
		}
 
@@ -474,15 +474,15 @@ static void FixOwnerOfRailTrack(TileInde
 
		Owner road = GetRoadOwner(t, RTT_ROAD);
 
		Owner tram = GetRoadOwner(t, RTT_TRAM);
 
		RoadBits bits = GetCrossingRoadBits(t);
 
		bool hasroad = HasBit(_me[t].m7, 6);
 
		bool hastram = HasBit(_me[t].m7, 7);
 
		bool hasroad = HasBit(t.m7(), 6);
 
		bool hastram = HasBit(t.m7(), 7);
 

	
 
		/* MakeRoadNormal */
 
		SetTileType(t, MP_ROAD);
 
		SetTileOwner(t, road);
 
		_m[t].m3 = (hasroad ? bits : 0);
 
		_m[t].m5 = (hastram ? bits : 0) | ROAD_TILE_NORMAL << 6;
 
		SB(_me[t].m6, 2, 4, 0);
 
		t.m3() = (hasroad ? bits : 0);
 
		t.m5() = (hastram ? bits : 0) | ROAD_TILE_NORMAL << 6;
 
		SB(t.m6(), 2, 4, 0);
 
		SetRoadOwner(t, RTT_TRAM, tram);
 
		return;
 
	}
 
@@ -533,7 +533,7 @@ static uint FixVehicleInclination(Vehicl
 
 * @param t The tile to analyze
 
 * @return True if a bridge might have been present prior to savegame 194.
 
 */
 
static inline bool MayHaveBridgeAbove(TileIndex t)
 
static inline bool MayHaveBridgeAbove(Tile t)
 
{
 
	return IsTileType(t, MP_CLEAR) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_ROAD) ||
 
			IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
 
@@ -614,8 +614,8 @@ bool AfterLoadGame()
 
		}
 
		for (auto t : Map::Iterate()) {
 
			if (!IsTileType(t, MP_STATION)) continue;
 
			if (_m[t].m5 > 7) continue; // is it a rail station tile?
 
			Station *st = Station::Get(_m[t].m2);
 
			if (t.m5() > 7) continue; // is it a rail station tile?
 
			Station *st = Station::Get(t.m2());
 
			assert(st->train_station.tile != 0);
 
			int dx = TileX(t) - TileX(st->train_station.tile);
 
			int dy = TileY(t) - TileY(st->train_station.tile);
 
@@ -630,14 +630,14 @@ bool AfterLoadGame()
 

	
 
		/* In old savegame versions, the heightlevel was coded in bits 0..3 of the type field */
 
		for (auto t : Map::Iterate()) {
 
			_m[t].height = GB(_m[t].type, 0, 4);
 
			SB(_m[t].type, 0, 2, GB(_me[t].m6, 0, 2));
 
			SB(_me[t].m6, 0, 2, 0);
 
			t.height() = GB(t.type(), 0, 4);
 
			SB(t.type(), 0, 2, GB(t.m6(), 0, 2));
 
			SB(t.m6(), 0, 2, 0);
 
			if (MayHaveBridgeAbove(t)) {
 
				SB(_m[t].type, 2, 2, GB(_me[t].m6, 6, 2));
 
				SB(_me[t].m6, 6, 2, 0);
 
				SB(t.type(), 2, 2, GB(t.m6(), 6, 2));
 
				SB(t.m6(), 6, 2, 0);
 
			} else {
 
				SB(_m[t].type, 2, 2, 0);
 
				SB(t.type(), 2, 2, 0);
 
			}
 
		}
 
	}
 
@@ -847,7 +847,7 @@ bool AfterLoadGame()
 
					break;
 

	
 
				case MP_STATION: {
 
					if (HasBit(_me[t].m6, 3)) SetBit(_me[t].m6, 2);
 
					if (HasBit(t.m6(), 3)) SetBit(t.m6(), 2);
 
					StationGfx gfx = GetStationGfx(t);
 
					StationType st;
 
					if (       IsInsideMM(gfx,   0,   8)) { // Rail station
 
@@ -885,7 +885,7 @@ bool AfterLoadGame()
 
						ResetSignalHandlers();
 
						return false;
 
					}
 
					SB(_me[t].m6, 3, 3, st);
 
					SB(t.m6(), 3, 3, st);
 
					break;
 
				}
 
			}
 
@@ -965,13 +965,13 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			switch (GetTileType(t)) {
 
				case MP_HOUSE:
 
					_m[t].m4 = _m[t].m2;
 
					t.m4() = t.m2();
 
					SetTownIndex(t, CalcClosestTownFromTile(t)->index);
 
					break;
 

	
 
				case MP_ROAD:
 
					_m[t].m4 |= (_m[t].m2 << 4);
 
					if ((GB(_m[t].m5, 4, 2) == ROAD_TILE_CROSSING ? (Owner)_m[t].m3 : GetTileOwner(t)) == OWNER_TOWN) {
 
					t.m4() |= (t.m2() << 4);
 
					if ((GB(t.m5(), 4, 2) == ROAD_TILE_CROSSING ? (Owner)t.m3() : GetTileOwner(t)) == OWNER_TOWN) {
 
						SetTownIndex(t, CalcClosestTownFromTile(t)->index);
 
					} else {
 
						SetTownIndex(t, 0);
 
@@ -1023,20 +1023,20 @@ bool AfterLoadGame()
 
					if (IsPlainRail(t)) {
 
						/* Swap ground type and signal type for plain rail tiles, so the
 
						 * ground type uses the same bits as for depots and waypoints. */
 
						uint tmp = GB(_m[t].m4, 0, 4);
 
						SB(_m[t].m4, 0, 4, GB(_m[t].m2, 0, 4));
 
						SB(_m[t].m2, 0, 4, tmp);
 
					} else if (HasBit(_m[t].m5, 2)) {
 
						uint tmp = GB(t.m4(), 0, 4);
 
						SB(t.m4(), 0, 4, GB(t.m2(), 0, 4));
 
						SB(t.m2(), 0, 4, tmp);
 
					} else if (HasBit(t.m5(), 2)) {
 
						/* Split waypoint and depot rail type and remove the subtype. */
 
						ClrBit(_m[t].m5, 2);
 
						ClrBit(_m[t].m5, 6);
 
						ClrBit(t.m5(), 2);
 
						ClrBit(t.m5(), 6);
 
					}
 
					break;
 

	
 
				case MP_ROAD:
 
					/* Swap m3 and m4, so the track type for rail crossings is the
 
					 * same as for normal rail. */
 
					Swap(_m[t].m3, _m[t].m4);
 
					Swap(t.m3(), t.m4());
 
					break;
 

	
 
				default: break;
 
@@ -1050,31 +1050,31 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			switch (GetTileType(t)) {
 
				case MP_ROAD:
 
					SB(_m[t].m5, 6, 2, GB(_m[t].m5, 4, 2));
 
					SB(t.m5(), 6, 2, GB(t.m5(), 4, 2));
 
					switch (GetRoadTileType(t)) {
 
						default: SlErrorCorrupt("Invalid road tile type");
 
						case ROAD_TILE_NORMAL:
 
							SB(_m[t].m4, 0, 4, GB(_m[t].m5, 0, 4));
 
							SB(_m[t].m4, 4, 4, 0);
 
							SB(_me[t].m6, 2, 4, 0);
 
							SB(t.m4(), 0, 4, GB(t.m5(), 0, 4));
 
							SB(t.m4(), 4, 4, 0);
 
							SB(t.m6(), 2, 4, 0);
 
							break;
 
						case ROAD_TILE_CROSSING:
 
							SB(_m[t].m4, 5, 2, GB(_m[t].m5, 2, 2));
 
							SB(t.m4(), 5, 2, GB(t.m5(), 2, 2));
 
							break;
 
						case ROAD_TILE_DEPOT:    break;
 
					}
 
					SB(_me[t].m7, 6, 2, 1); // Set pre-NRT road type bits for conversion later.
 
					SB(t.m7(), 6, 2, 1); // Set pre-NRT road type bits for conversion later.
 
					break;
 

	
 
				case MP_STATION:
 
					if (IsRoadStop(t)) SB(_me[t].m7, 6, 2, 1);
 
					if (IsRoadStop(t)) SB(t.m7(), 6, 2, 1);
 
					break;
 

	
 
				case MP_TUNNELBRIDGE:
 
					/* Middle part of "old" bridges */
 
					if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
 
					if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
 
						SB(_me[t].m7, 6, 2, 1); // Set pre-NRT road type bits for conversion later.
 
					if (old_bridge && IsBridge(t) && HasBit(t.m5(), 6)) break;
 
					if (((old_bridge && IsBridge(t)) ? (TransportType)GB(t.m5(), 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
 
						SB(t.m7(), 6, 2, 1); // Set pre-NRT road type bits for conversion later.
 
					}
 
					break;
 

	
 
@@ -1090,24 +1090,24 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			switch (GetTileType(t)) {
 
				case MP_ROAD:
 
					if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_me[t].m7, 5, 3));
 
					SB(_me[t].m7, 5, 1, GB(_m[t].m3, 7, 1)); // snow/desert
 
					if (fix_roadtypes) SB(t.m7(), 6, 2, (RoadTypes)GB(t.m7(), 5, 3));
 
					SB(t.m7(), 5, 1, GB(t.m3(), 7, 1)); // snow/desert
 
					switch (GetRoadTileType(t)) {
 
						default: SlErrorCorrupt("Invalid road tile type");
 
						case ROAD_TILE_NORMAL:
 
							SB(_me[t].m7, 0, 4, GB(_m[t].m3, 0, 4));  // road works
 
							SB(_me[t].m6, 3, 3, GB(_m[t].m3, 4, 3));  // ground
 
							SB(_m[t].m3, 0, 4, GB(_m[t].m4, 4, 4));   // tram bits
 
							SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4));   // tram owner
 
							SB(_m[t].m5, 0, 4, GB(_m[t].m4, 0, 4));   // road bits
 
							SB(t.m7(), 0, 4, GB(t.m3(), 0, 4));  // road works
 
							SB(t.m6(), 3, 3, GB(t.m3(), 4, 3));  // ground
 
							SB(t.m3(), 0, 4, GB(t.m4(), 4, 4));   // tram bits
 
							SB(t.m3(), 4, 4, GB(t.m5(), 0, 4));   // tram owner
 
							SB(t.m5(), 0, 4, GB(t.m4(), 0, 4));   // road bits
 
							break;
 

	
 
						case ROAD_TILE_CROSSING:
 
							SB(_me[t].m7, 0, 5, GB(_m[t].m4, 0, 5));  // road owner
 
							SB(_me[t].m6, 3, 3, GB(_m[t].m3, 4, 3));  // ground
 
							SB(_m[t].m3, 4, 4, GB(_m[t].m5, 0, 4));   // tram owner
 
							SB(_m[t].m5, 0, 1, GB(_m[t].m4, 6, 1));   // road axis
 
							SB(_m[t].m5, 5, 1, GB(_m[t].m4, 5, 1));   // crossing state
 
							SB(t.m7(), 0, 5, GB(t.m4(), 0, 5));  // road owner
 
							SB(t.m6(), 3, 3, GB(t.m3(), 4, 3));  // ground
 
							SB(t.m3(), 4, 4, GB(t.m5(), 0, 4));   // tram owner
 
							SB(t.m5(), 0, 1, GB(t.m4(), 6, 1));   // road axis
 
							SB(t.m5(), 5, 1, GB(t.m4(), 5, 1));   // crossing state
 
							break;
 

	
 
						case ROAD_TILE_DEPOT:
 
@@ -1117,32 +1117,32 @@ bool AfterLoadGame()
 
						const Town *town = CalcClosestTownFromTile(t);
 
						if (town != nullptr) SetTownIndex(t, town->index);
 
					}
 
					_m[t].m4 = 0;
 
					t.m4() = 0;
 
					break;
 

	
 
				case MP_STATION:
 
					if (!IsRoadStop(t)) break;
 

	
 
					if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_m[t].m3, 0, 3));
 
					SB(_me[t].m7, 0, 5, HasBit(_me[t].m6, 2) ? OWNER_TOWN : GetTileOwner(t));
 
					SB(_m[t].m3, 4, 4, _m[t].m1);
 
					_m[t].m4 = 0;
 
					if (fix_roadtypes) SB(t.m7(), 6, 2, (RoadTypes)GB(t.m3(), 0, 3));
 
					SB(t.m7(), 0, 5, HasBit(t.m6(), 2) ? OWNER_TOWN : GetTileOwner(t));
 
					SB(t.m3(), 4, 4, t.m1());
 
					t.m4() = 0;
 
					break;
 

	
 
				case MP_TUNNELBRIDGE:
 
					if (old_bridge && IsBridge(t) && HasBit(_m[t].m5, 6)) break;
 
					if (((old_bridge && IsBridge(t)) ? (TransportType)GB(_m[t].m5, 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
 
						if (fix_roadtypes) SB(_me[t].m7, 6, 2, (RoadTypes)GB(_m[t].m3, 0, 3));
 
					if (old_bridge && IsBridge(t) && HasBit(t.m5(), 6)) break;
 
					if (((old_bridge && IsBridge(t)) ? (TransportType)GB(t.m5(), 1, 2) : GetTunnelBridgeTransportType(t)) == TRANSPORT_ROAD) {
 
						if (fix_roadtypes) SB(t.m7(), 6, 2, (RoadTypes)GB(t.m3(), 0, 3));
 

	
 
						Owner o = GetTileOwner(t);
 
						SB(_me[t].m7, 0, 5, o); // road owner
 
						SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); // tram owner
 
						SB(t.m7(), 0, 5, o); // road owner
 
						SB(t.m3(), 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); // tram owner
 
					}
 
					SB(_me[t].m6, 2, 4, GB(_m[t].m2, 4, 4)); // bridge type
 
					SB(_me[t].m7, 5, 1, GB(_m[t].m4, 7, 1)); // snow/desert
 

	
 
					_m[t].m2 = 0;
 
					_m[t].m4 = 0;
 
					SB(t.m6(), 2, 4, GB(t.m2(), 4, 4)); // bridge type
 
					SB(t.m7(), 5, 1, GB(t.m4(), 7, 1)); // snow/desert
 

	
 
					t.m2() = 0;
 
					t.m4() = 0;
 
					break;
 

	
 
				default: break;
 
@@ -1155,24 +1155,24 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			switch (GetTileType(t)) {
 
				case MP_RAILWAY:
 
					SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
 
					SetRailType(t, (RailType)GB(t.m3(), 0, 4));
 
					break;
 

	
 
				case MP_ROAD:
 
					if (IsLevelCrossing(t)) {
 
						SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
 
						SetRailType(t, (RailType)GB(t.m3(), 0, 4));
 
					}
 
					break;
 

	
 
				case MP_STATION:
 
					if (HasStationRail(t)) {
 
						SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
 
						SetRailType(t, (RailType)GB(t.m3(), 0, 4));
 
					}
 
					break;
 

	
 
				case MP_TUNNELBRIDGE:
 
					if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) {
 
						SetRailType(t, (RailType)GB(_m[t].m3, 0, 4));
 
						SetRailType(t, (RailType)GB(t.m3(), 0, 4));
 
					}
 
					break;
 

	
 
@@ -1186,11 +1186,11 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			if (MayHaveBridgeAbove(t)) ClearBridgeMiddle(t);
 
			if (IsBridgeTile(t)) {
 
				if (HasBit(_m[t].m5, 6)) { // middle part
 
					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
 

	
 
					if (HasBit(_m[t].m5, 5)) { // transport route under bridge?
 
						if (GB(_m[t].m5, 3, 2) == TRANSPORT_RAIL) {
 
				if (HasBit(t.m5(), 6)) { // middle part
 
					Axis axis = (Axis)GB(t.m5(), 0, 1);
 

	
 
					if (HasBit(t.m5(), 5)) { // transport route under bridge?
 
						if (GB(t.m5(), 3, 2) == TRANSPORT_RAIL) {
 
							MakeRailNormal(
 
								t,
 
								GetTileOwner(t),
 
@@ -1202,15 +1202,15 @@ bool AfterLoadGame()
 

	
 
							/* MakeRoadNormal */
 
							SetTileType(t, MP_ROAD);
 
							_m[t].m2 = town;
 
							_m[t].m3 = 0;
 
							_m[t].m5 = (axis == AXIS_X ? ROAD_Y : ROAD_X) | ROAD_TILE_NORMAL << 6;
 
							SB(_me[t].m6, 2, 4, 0);
 
							_me[t].m7 = 1 << 6;
 
							t.m2() = town;
 
							t.m3() = 0;
 
							t.m5() = (axis == AXIS_X ? ROAD_Y : ROAD_X) | ROAD_TILE_NORMAL << 6;
 
							SB(t.m6(), 2, 4, 0);
 
							t.m7() = 1 << 6;
 
							SetRoadOwner(t, RTT_TRAM, OWNER_NONE);
 
						}
 
					} else {
 
						if (GB(_m[t].m5, 3, 2) == 0) {
 
						if (GB(t.m5(), 3, 2) == 0) {
 
							MakeClear(t, CLEAR_GRASS, 3);
 
						} else {
 
							if (!IsTileFlat(t)) {
 
@@ -1226,12 +1226,12 @@ bool AfterLoadGame()
 
					}
 
					SetBridgeMiddle(t, axis);
 
				} else { // ramp
 
					Axis axis = (Axis)GB(_m[t].m5, 0, 1);
 
					uint north_south = GB(_m[t].m5, 5, 1);
 
					Axis axis = (Axis)GB(t.m5(), 0, 1);
 
					uint north_south = GB(t.m5(), 5, 1);
 
					DiagDirection dir = ReverseDiagDir(XYNSToDiagDir(axis, north_south));
 
					TransportType type = (TransportType)GB(_m[t].m5, 1, 2);
 

	
 
					_m[t].m5 = 1 << 7 | type << 2 | dir;
 
					TransportType type = (TransportType)GB(t.m5(), 1, 2);
 

	
 
					t.m5() = 1 << 7 | type << 2 | dir;
 
				}
 
			}
 
		}
 
@@ -1282,12 +1282,12 @@ bool AfterLoadGame()
 
			}
 

	
 
			if (has_road) {
 
				RoadType road_rt = HasBit(_me[t].m7, 6) ? ROADTYPE_ROAD : INVALID_ROADTYPE;
 
				RoadType tram_rt = HasBit(_me[t].m7, 7) ? ROADTYPE_TRAM : INVALID_ROADTYPE;
 
				RoadType road_rt = HasBit(t.m7(), 6) ? ROADTYPE_ROAD : INVALID_ROADTYPE;
 
				RoadType tram_rt = HasBit(t.m7(), 7) ? ROADTYPE_TRAM : INVALID_ROADTYPE;
 

	
 
				assert(road_rt != INVALID_ROADTYPE || tram_rt != INVALID_ROADTYPE);
 
				SetRoadTypes(t, road_rt, tram_rt);
 
				SB(_me[t].m7, 6, 2, 0); // Clear pre-NRT road type bits.
 
				SB(t.m7(), 6, 2, 0); // Clear pre-NRT road type bits.
 
			}
 
		}
 
	}
 
@@ -1365,23 +1365,23 @@ bool AfterLoadGame()
 
						 * (see the code somewhere above) so don't use m4, use m2 instead. */
 

	
 
						/* convert PBS signals to combo-signals */
 
						if (HasBit(_m[t].m2, 2)) SB(_m[t].m2, 0, 2, SIGTYPE_COMBO);
 
						if (HasBit(t.m2(), 2)) SB(t.m2(), 0, 2, SIGTYPE_COMBO);
 

	
 
						/* move the signal variant back */
 
						SB(_m[t].m2, 2, 1, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						ClrBit(_m[t].m2, 3);
 
						SB(t.m2(), 2, 1, HasBit(t.m2(), 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						ClrBit(t.m2(), 3);
 
					}
 

	
 
					/* Clear PBS reservation on track */
 
					if (!IsRailDepotTile(t)) {
 
						SB(_m[t].m4, 4, 4, 0);
 
						SB(t.m4(), 4, 4, 0);
 
					} else {
 
						ClrBit(_m[t].m3, 6);
 
						ClrBit(t.m3(), 6);
 
					}
 
					break;
 

	
 
				case MP_STATION: // Clear PBS reservation on station
 
					ClrBit(_m[t].m3, 6);
 
					ClrBit(t.m3(), 6);
 
					break;
 

	
 
				default: break;
 
@@ -1475,31 +1475,31 @@ bool AfterLoadGame()
 
	if (IsSavegameVersionBefore(SLV_53)) {
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_HOUSE)) {
 
				if (GB(_m[t].m3, 6, 2) != TOWN_HOUSE_COMPLETED) {
 
				if (GB(t.m3(), 6, 2) != TOWN_HOUSE_COMPLETED) {
 
					/* Move the construction stage from m3[7..6] to m5[5..4].
 
					 * The construction counter does not have to move. */
 
					SB(_m[t].m5, 3, 2, GB(_m[t].m3, 6, 2));
 
					SB(_m[t].m3, 6, 2, 0);
 
					SB(t.m5(), 3, 2, GB(t.m3(), 6, 2));
 
					SB(t.m3(), 6, 2, 0);
 

	
 
					/* The "house is completed" bit is now in m6[2]. */
 
					SetHouseCompleted(t, false);
 
				} else {
 
					/* The "lift has destination" bit has been moved from
 
					 * m5[7] to m7[0]. */
 
					SB(_me[t].m7, 0, 1, HasBit(_m[t].m5, 7));
 
					ClrBit(_m[t].m5, 7);
 
					SB(t.m7(), 0, 1, HasBit(t.m5(), 7));
 
					ClrBit(t.m5(), 7);
 

	
 
					/* The "lift is moving" bit has been removed, as it does
 
					 * the same job as the "lift has destination" bit. */
 
					ClrBit(_m[t].m1, 7);
 
					ClrBit(t.m1(), 7);
 

	
 
					/* The position of the lift goes from m1[7..0] to m6[7..2],
 
					 * making m1 totally free, now. The lift position does not
 
					 * have to be a full byte since the maximum value is 36. */
 
					SetLiftPosition(t, GB(_m[t].m1, 0, 6 ));
 

	
 
					_m[t].m1 = 0;
 
					_m[t].m3 = 0;
 
					SetLiftPosition(t, GB(t.m1(), 0, 6 ));
 

	
 
					t.m1() = 0;
 
					t.m3() = 0;
 
					SetHouseCompleted(t, true);
 
				}
 
			}
 
@@ -1514,19 +1514,19 @@ bool AfterLoadGame()
 
			if (IsTileType(t, MP_INDUSTRY)) {
 
				switch (GetIndustryGfx(t)) {
 
					case GFX_POWERPLANT_SPARKS:
 
						_m[t].m3 = GB(_m[t].m1, 2, 5);
 
						t.m3() = GB(t.m1(), 2, 5);
 
						break;
 

	
 
					case GFX_OILWELL_ANIMATED_1:
 
					case GFX_OILWELL_ANIMATED_2:
 
					case GFX_OILWELL_ANIMATED_3:
 
						_m[t].m3 = GB(_m[t].m1, 0, 2);
 
						t.m3() = GB(t.m1(), 0, 2);
 
						break;
 

	
 
					case GFX_COAL_MINE_TOWER_ANIMATED:
 
					case GFX_COPPER_MINE_TOWER_ANIMATED:
 
					case GFX_GOLD_MINE_TOWER_ANIMATED:
 
						 _m[t].m3 = _m[t].m1;
 
						 t.m3() = t.m1();
 
						 break;
 

	
 
					default: // No animation states to change
 
@@ -1571,8 +1571,8 @@ bool AfterLoadGame()
 

	
 
	if (IsSavegameVersionBefore(SLV_52)) {
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_OBJECT) && _m[t].m5 == OBJECT_STATUE) {
 
				_m[t].m2 = CalcClosestTownFromTile(t)->index;
 
			if (IsTileType(t, MP_OBJECT) && t.m5() == OBJECT_STATUE) {
 
				t.m2() = CalcClosestTownFromTile(t)->index;
 
			}
 
		}
 
	}
 
@@ -1631,10 +1631,10 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_RAILWAY) && HasSignals(t)) {
 
				/* move signal states */
 
				SetSignalStates(t, GB(_m[t].m2, 4, 4));
 
				SB(_m[t].m2, 4, 4, 0);
 
				SetSignalStates(t, GB(t.m2(), 4, 4));
 
				SB(t.m2(), 4, 4, 0);
 
				/* clone signal type and variant */
 
				SB(_m[t].m2, 4, 3, GB(_m[t].m2, 0, 3));
 
				SB(t.m2(), 4, 3, GB(t.m2(), 0, 3));
 
			}
 
		}
 
	}
 
@@ -1675,7 +1675,7 @@ bool AfterLoadGame()
 
	if (IsSavegameVersionBefore(SLV_83)) {
 
		for (auto t : Map::Iterate()) {
 
			if (IsShipDepotTile(t)) {
 
				_m[t].m4 = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
 
				t.m4() = (TileHeight(t) == 0) ? OWNER_WATER : OWNER_NONE;
 
			}
 
		}
 
	}
 
@@ -1709,8 +1709,8 @@ bool AfterLoadGame()
 
	if (IsSavegameVersionBefore(SLV_81)) {
 
		for (auto t : Map::Iterate()) {
 
			if (GetTileType(t) == MP_TREES) {
 
				TreeGround groundType = (TreeGround)GB(_m[t].m2, 4, 2);
 
				if (groundType != TREE_GROUND_SNOW_DESERT) SB(_m[t].m2, 6, 2, 3);
 
				TreeGround groundType = (TreeGround)GB(t.m2(), 4, 2);
 
				if (groundType != TREE_GROUND_SNOW_DESERT) SB(t.m2(), 6, 2, 3);
 
			}
 
		}
 
	}
 
@@ -1772,8 +1772,8 @@ bool AfterLoadGame()
 
						case STATION_OILRIG:
 
						case STATION_DOCK:
 
						case STATION_BUOY:
 
							SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
 
							SB(_m[t].m3, 0, 2, 0);
 
							SetWaterClass(t, (WaterClass)GB(t.m3(), 0, 2));
 
							SB(t.m3(), 0, 2, 0);
 
							break;
 

	
 
						default:
 
@@ -1783,8 +1783,8 @@ bool AfterLoadGame()
 
					break;
 

	
 
				case MP_WATER:
 
					SetWaterClass(t, (WaterClass)GB(_m[t].m3, 0, 2));
 
					SB(_m[t].m3, 0, 2, 0);
 
					SetWaterClass(t, (WaterClass)GB(t.m3(), 0, 2));
 
					SB(t.m3(), 0, 2, 0);
 
					break;
 

	
 
				case MP_OBJECT:
 
@@ -1811,7 +1811,7 @@ bool AfterLoadGame()
 
							MakeCanal(t, o, Random());
 
						}
 
					} else if (IsShipDepot(t)) {
 
						Owner o = (Owner)_m[t].m4; // Original water owner
 
						Owner o = (Owner)t.m4(); // Original water owner
 
						SetWaterClass(t, o == OWNER_WATER ? WATER_CLASS_SEA : WATER_CLASS_CANAL);
 
					}
 
				}
 
@@ -1899,8 +1899,8 @@ bool AfterLoadGame()
 
		/* Increase HouseAnimationFrame from 5 to 7 bits */
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_HOUSE) && GetHouseType(t) >= NEW_HOUSE_OFFSET) {
 
				SB(_me[t].m6, 2, 6, GB(_me[t].m6, 3, 5));
 
				SB(_m[t].m3, 5, 1, 0);
 
				SB(t.m6(), 2, 6, GB(t.m6(), 3, 5));
 
				SB(t.m3(), 5, 1, 0);
 
			}
 
		}
 
	}
 
@@ -1933,7 +1933,7 @@ bool AfterLoadGame()
 

	
 
			/* Replace "house construction year" with "house age" */
 
			if (IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)) {
 
				_m[t].m5 = Clamp(_cur_year - (_m[t].m5 + ORIGINAL_BASE_YEAR), 0, 0xFF);
 
				t.m5() = Clamp(_cur_year - (t.m5() + ORIGINAL_BASE_YEAR), 0, 0xFF);
 
			}
 
		}
 
	}
 
@@ -1947,10 +1947,10 @@ bool AfterLoadGame()
 
				case MP_RAILWAY:
 
					if (HasSignals(t)) {
 
						/* move the signal variant */
 
						SetSignalVariant(t, TRACK_UPPER, HasBit(_m[t].m2, 2) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						SetSignalVariant(t, TRACK_LOWER, HasBit(_m[t].m2, 6) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						ClrBit(_m[t].m2, 2);
 
						ClrBit(_m[t].m2, 6);
 
						SetSignalVariant(t, TRACK_UPPER, HasBit(t.m2(), 2) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						SetSignalVariant(t, TRACK_LOWER, HasBit(t.m2(), 6) ? SIG_SEMAPHORE : SIG_ELECTRIC);
 
						ClrBit(t.m2(), 2);
 
						ClrBit(t.m2(), 6);
 
					}
 

	
 
					/* Clear PBS reservation on track */
 
@@ -2028,11 +2028,11 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			/* Check for HQ bit being set, instead of using map accessor,
 
			 * since we've already changed it code-wise */
 
			if (IsTileType(t, MP_OBJECT) && HasBit(_m[t].m5, 7)) {
 
			if (IsTileType(t, MP_OBJECT) && HasBit(t.m5(), 7)) {
 
				/* Move size and part identification of HQ out of the m5 attribute,
 
				 * on new locations */
 
				_m[t].m3 = GB(_m[t].m5, 0, 5);
 
				_m[t].m5 = OBJECT_HQ;
 
				t.m3() = GB(t.m5(), 0, 5);
 
				t.m5() = OBJECT_HQ;
 
			}
 
		}
 
	}
 
@@ -2041,13 +2041,13 @@ bool AfterLoadGame()
 
			if (!IsTileType(t, MP_OBJECT)) continue;
 

	
 
			/* Reordering/generalisation of the object bits. */
 
			ObjectType type = _m[t].m5;
 
			SB(_me[t].m6, 2, 4, type == OBJECT_HQ ? GB(_m[t].m3, 2, 3) : 0);
 
			_m[t].m3 = type == OBJECT_HQ ? GB(_m[t].m3, 1, 1) | GB(_m[t].m3, 0, 1) << 4 : 0;
 
			ObjectType type = t.m5();
 
			SB(t.m6(), 2, 4, type == OBJECT_HQ ? GB(t.m3(), 2, 3) : 0);
 
			t.m3() = type == OBJECT_HQ ? GB(t.m3(), 1, 1) | GB(t.m3(), 0, 1) << 4 : 0;
 

	
 
			/* Make sure those bits are clear as well! */
 
			_m[t].m4 = 0;
 
			_me[t].m7 = 0;
 
			t.m4() = 0;
 
			t.m7() = 0;
 
		}
 
	}
 

	
 
@@ -2060,15 +2060,15 @@ bool AfterLoadGame()
 
				/* No towns, so remove all objects! */
 
				DoClearSquare(t);
 
			} else {
 
				uint offset = _m[t].m3;
 
				uint offset = t.m3();
 

	
 
				/* Also move the animation state. */
 
				_m[t].m3 = GB(_me[t].m6, 2, 4);
 
				SB(_me[t].m6, 2, 4, 0);
 
				t.m3() = GB(t.m6(), 2, 4);
 
				SB(t.m6(), 2, 4, 0);
 

	
 
				if (offset == 0) {
 
					/* No offset, so make the object. */
 
					ObjectType type = _m[t].m5;
 
					ObjectType type = t.m5();
 
					int size = type == OBJECT_HQ ? 2 : 1;
 

	
 
					if (!Object::CanAllocateItem()) {
 
@@ -2078,18 +2078,18 @@ bool AfterLoadGame()
 
					}
 

	
 
					Object *o = new Object();
 
					o->location.tile = t;
 
					o->location.tile = (TileIndex)t;
 
					o->location.w    = size;
 
					o->location.h    = size;
 
					o->build_date    = _date;
 
					o->town          = type == OBJECT_STATUE ? Town::Get(_m[t].m2) : CalcClosestTownFromTile(t, UINT_MAX);
 
					_m[t].m2 = o->index;
 
					o->town          = type == OBJECT_STATUE ? Town::Get(t.m2()) : CalcClosestTownFromTile(t, UINT_MAX);
 
					t.m2() = o->index;
 
					Object::IncTypeCount(type);
 
				} else {
 
					/* We're at an offset, so get the ID from our "root". */
 
					TileIndex northern_tile = t - TileXY(GB(offset, 0, 4), GB(offset, 4, 4));
 
					Tile northern_tile = t - TileXY(GB(offset, 0, 4), GB(offset, 4, 4));
 
					assert(IsTileType(northern_tile, MP_OBJECT));
 
					_m[t].m2 = _m[northern_tile].m2;
 
					t.m2() = northern_tile.m2();
 
				}
 
			}
 
		}
 
@@ -2294,16 +2294,17 @@ bool AfterLoadGame()
 

	
 
	if (IsSavegameVersionBefore(SLV_128)) {
 
		for (const Depot *d : Depot::Iterate()) {
 
			Tile tile = d->xy;
 
			/* At some point, invalid depots were saved into the game (possibly those removed in the past?)
 
			 * Remove them here, so they don't cause issues further down the line */
 
			if (!IsDepotTile(d->xy)) {
 
			if (!IsDepotTile(tile)) {
 
				Debug(sl, 0, "Removing invalid depot {} at {}, {}", d->index, TileX(d->xy), TileY(d->xy));
 
				delete d;
 
				d = nullptr;
 
				continue;
 
			}
 
			_m[d->xy].m2 = d->index;
 
			if (IsTileType(d->xy, MP_WATER)) _m[GetOtherShipDepotTile(d->xy)].m2 = d->index;
 
			tile.m2() = d->index;
 
			if (IsTileType(tile, MP_WATER)) Tile(GetOtherShipDepotTile(tile)).m2() = d->index;
 
		}
 
	}
 

	
 
@@ -2324,15 +2325,15 @@ bool AfterLoadGame()
 
			if (IsTileType(t, MP_CLEAR)) {
 
				if (GetRawClearGround(t) == CLEAR_SNOW) {
 
					SetClearGroundDensity(t, CLEAR_GRASS, GetClearDensity(t));
 
					SetBit(_m[t].m3, 4);
 
					SetBit(t.m3(), 4);
 
				} else {
 
					ClrBit(_m[t].m3, 4);
 
					ClrBit(t.m3(), 4);
 
				}
 
			}
 
			if (IsTileType(t, MP_TREES)) {
 
				uint density = GB(_m[t].m2, 6, 2);
 
				uint ground = GB(_m[t].m2, 4, 2);
 
				_m[t].m2 = ground << 6 | density << 4;
 
				uint density = GB(t.m2(), 6, 2);
 
				uint ground = GB(t.m2(), 4, 2);
 
				t.m2() = ground << 6 | density << 4;
 
			}
 
		}
 
	}
 
@@ -2440,23 +2441,23 @@ bool AfterLoadGame()
 
			switch (GetTileType(t)) {
 
				case MP_HOUSE:
 
					if (GetHouseType(t) >= NEW_HOUSE_OFFSET) {
 
						uint per_proc = _me[t].m7;
 
						_me[t].m7 = GB(_me[t].m6, 2, 6) | (GB(_m[t].m3, 5, 1) << 6);
 
						SB(_m[t].m3, 5, 1, 0);
 
						SB(_me[t].m6, 2, 6, std::min(per_proc, 63U));
 
						uint per_proc = t.m7();
 
						t.m7() = GB(t.m6(), 2, 6) | (GB(t.m3(), 5, 1) << 6);
 
						SB(t.m3(), 5, 1, 0);
 
						SB(t.m6(), 2, 6, std::min(per_proc, 63U));
 
					}
 
					break;
 

	
 
				case MP_INDUSTRY: {
 
					uint rand = _me[t].m7;
 
					_me[t].m7 = _m[t].m3;
 
					_m[t].m3 = rand;
 
					uint rand = t.m7();
 
					t.m7() = t.m3();
 
					t.m3() = rand;
 
					break;
 
				}
 

	
 
				case MP_OBJECT:
 
					_me[t].m7 = _m[t].m3;
 
					_m[t].m3 = 0;
 
					t.m7() = t.m3();
 
					t.m3() = 0;
 
					break;
 

	
 
				default:
 
@@ -2771,16 +2772,16 @@ bool AfterLoadGame()
 
		for (auto t : Map::Iterate()) {
 
			if (!IsTileType(t, MP_CLEAR) && !IsTileType(t, MP_TREES)) continue;
 
			if (IsTileType(t, MP_CLEAR) && IsClearGround(t, CLEAR_FIELDS)) continue;
 
			uint fence = GB(_m[t].m4, 5, 3);
 
			uint fence = GB(t.m4(), 5, 3);
 
			if (fence != 0 && IsTileType(TILE_ADDXY(t, 1, 0), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 1, 0), CLEAR_FIELDS)) {
 
				SetFence(TILE_ADDXY(t, 1, 0), DIAGDIR_NE, fence);
 
			}
 
			fence = GB(_m[t].m4, 2, 3);
 
			fence = GB(t.m4(), 2, 3);
 
			if (fence != 0 && IsTileType(TILE_ADDXY(t, 0, 1), MP_CLEAR) && IsClearGround(TILE_ADDXY(t, 0, 1), CLEAR_FIELDS)) {
 
				SetFence(TILE_ADDXY(t, 0, 1), DIAGDIR_NW, fence);
 
			}
 
			SB(_m[t].m4, 2, 3, 0);
 
			SB(_m[t].m4, 5, 3, 0);
 
			SB(t.m4(), 2, 3, 0);
 
			SB(t.m4(), 5, 3, 0);
 
		}
 
	}
 

	
 
@@ -2880,9 +2881,9 @@ bool AfterLoadGame()
 
		/* Move ObjectType from map to pool */
 
		for (auto t : Map::Iterate()) {
 
			if (IsTileType(t, MP_OBJECT)) {
 
				Object *o = Object::Get(_m[t].m2);
 
				o->type = _m[t].m5;
 
				_m[t].m5 = 0; // zero upper bits of (now bigger) ObjectID
 
				Object *o = Object::Get(t.m2());
 
				o->type = t.m5();
 
				t.m5() = 0; // zero upper bits of (now bigger) ObjectID
 
			}
 
		}
 
	}
 
@@ -3191,7 +3192,7 @@ bool AfterLoadGame()
 
			/* Reset unused tree counters to reduce the savegame size. */
 
			for (auto t : Map::Iterate()) {
 
				if (IsTileType(t, MP_TREES)) {
 
					SB(_m[t].m2, 0, 4, 0);
 
					SB(t.m2(), 0, 4, 0);
 
				}
 
			}
 
		}
src/saveload/map_sl.cpp
Show inline comments
 
@@ -77,7 +77,7 @@ struct MAPTChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].type = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).type() = buf[j];
 
		}
 
	}
 

	
 
@@ -88,7 +88,7 @@ struct MAPTChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].type;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).type();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -104,7 +104,7 @@ struct MAPHChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].height = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).height() = buf[j];
 
		}
 
	}
 

	
 
@@ -115,7 +115,7 @@ struct MAPHChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].height;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).height();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -131,7 +131,7 @@ struct MAPOChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m1 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m1() = buf[j];
 
		}
 
	}
 

	
 
@@ -142,7 +142,7 @@ struct MAPOChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m1;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m1();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -161,7 +161,7 @@ struct MAP2ChunkHandler : ChunkHandler {
 
				/* In those versions the m2 was 8 bits */
 
				IsSavegameVersionBefore(SLV_5) ? SLE_FILE_U8 | SLE_VAR_U16 : SLE_UINT16
 
			);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m2 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m2() = buf[j];
 
		}
 
	}
 

	
 
@@ -172,7 +172,7 @@ struct MAP2ChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size * sizeof(uint16));
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m2;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m2();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);
 
		}
 
	}
 
@@ -188,7 +188,7 @@ struct M3LOChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m3 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m3() = buf[j];
 
		}
 
	}
 

	
 
@@ -199,7 +199,7 @@ struct M3LOChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m3;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m3();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -215,7 +215,7 @@ struct M3HIChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m4 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m4() = buf[j];
 
		}
 
	}
 

	
 
@@ -226,7 +226,7 @@ struct M3HIChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m4;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m4();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -242,7 +242,7 @@ struct MAP5ChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _m[i++].m5 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m5() = buf[j];
 
		}
 
	}
 

	
 
@@ -253,7 +253,7 @@ struct MAP5ChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _m[i++].m5;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m5();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -272,16 +272,16 @@ struct MAPEChunkHandler : ChunkHandler {
 
				/* 1024, otherwise we overflow on 64x64 maps! */
 
				SlCopy(buf.data(), 1024, SLE_UINT8);
 
				for (uint j = 0; j != 1024; j++) {
 
					_me[i++].m6 = GB(buf[j], 0, 2);
 
					_me[i++].m6 = GB(buf[j], 2, 2);
 
					_me[i++].m6 = GB(buf[j], 4, 2);
 
					_me[i++].m6 = GB(buf[j], 6, 2);
 
					Tile(i++).m6() = GB(buf[j], 0, 2);
 
					Tile(i++).m6() = GB(buf[j], 2, 2);
 
					Tile(i++).m6() = GB(buf[j], 4, 2);
 
					Tile(i++).m6() = GB(buf[j], 6, 2);
 
				}
 
			}
 
		} else {
 
			for (TileIndex i = 0; i != size;) {
 
				SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
				for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m6 = buf[j];
 
				for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m6() = buf[j];
 
			}
 
		}
 
	}
 
@@ -293,7 +293,7 @@ struct MAPEChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m6;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m6();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -309,7 +309,7 @@ struct MAP7ChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m7 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m7() = buf[j];
 
		}
 
	}
 

	
 
@@ -320,7 +320,7 @@ struct MAP7ChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size);
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m7;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m7();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT8);
 
		}
 
	}
 
@@ -336,7 +336,7 @@ struct MAP8ChunkHandler : ChunkHandler {
 

	
 
		for (TileIndex i = 0; i != size;) {
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) _me[i++].m8 = buf[j];
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) Tile(i++).m8() = buf[j];
 
		}
 
	}
 

	
 
@@ -347,7 +347,7 @@ struct MAP8ChunkHandler : ChunkHandler {
 

	
 
		SlSetLength(size * sizeof(uint16));
 
		for (TileIndex i = 0; i != size;) {
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = _me[i++].m8;
 
			for (uint j = 0; j != MAP_SL_BUF_SIZE; j++) buf[j] = Tile(i++).m8();
 
			SlCopy(buf.data(), MAP_SL_BUF_SIZE, SLE_UINT16);
 
		}
 
	}
src/saveload/oldloader_sl.cpp
Show inline comments
 
@@ -54,46 +54,48 @@ static void FixTTDMapArray()
 
{
 
	/* _old_map3 is moved to _m::m3 and _m::m4 */
 
	for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
 
		_m[t].m3 = _old_map3[t * 2];
 
		_m[t].m4 = _old_map3[t * 2 + 1];
 
		Tile tile(t);
 
		tile.m3() = _old_map3[t * 2];
 
		tile.m4() = _old_map3[t * 2 + 1];
 
	}
 

	
 
	for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
 
		switch (GetTileType(t)) {
 
		Tile tile(t);
 
		switch (GetTileType(tile)) {
 
			case MP_STATION:
 
				_m[t].m4 = 0; // We do not understand this TTDP station mapping (yet)
 
				switch (_m[t].m5) {
 
				tile.m4() = 0; // We do not understand this TTDP station mapping (yet)
 
				switch (tile.m5()) {
 
					/* We have drive through stops at a totally different place */
 
					case 0x53: case 0x54: _m[t].m5 += 170 - 0x53; break; // Bus drive through
 
					case 0x57: case 0x58: _m[t].m5 += 168 - 0x57; break; // Truck drive through
 
					case 0x55: case 0x56: _m[t].m5 += 170 - 0x55; break; // Bus tram stop
 
					case 0x59: case 0x5A: _m[t].m5 += 168 - 0x59; break; // Truck tram stop
 
					case 0x53: case 0x54: tile.m5() += 170 - 0x53; break; // Bus drive through
 
					case 0x57: case 0x58: tile.m5() += 168 - 0x57; break; // Truck drive through
 
					case 0x55: case 0x56: tile.m5() += 170 - 0x55; break; // Bus tram stop
 
					case 0x59: case 0x5A: tile.m5() += 168 - 0x59; break; // Truck tram stop
 
					default: break;
 
				}
 
				break;
 

	
 
			case MP_RAILWAY:
 
				/* We save presignals different from TTDPatch, convert them */
 
				if (GB(_m[t].m5, 6, 2) == 1) { // RAIL_TILE_SIGNALS
 
				if (GB(tile.m5(), 6, 2) == 1) { // RAIL_TILE_SIGNALS
 
					/* This byte is always zero in TTD for this type of tile */
 
					if (_m[t].m4) { // Convert the presignals to our own format
 
						_m[t].m4 = (_m[t].m4 >> 1) & 7;
 
					if (tile.m4()) { // Convert the presignals to our own format
 
						tile.m4() = (tile.m4() >> 1) & 7;
 
					}
 
				}
 
				/* TTDPatch stores PBS things in L6 and all elsewhere; so we'll just
 
				 * clear it for ourselves and let OTTD's rebuild PBS itself */
 
				_m[t].m4 &= 0xF; // Only keep the lower four bits; upper four is PBS
 
				tile.m4() &= 0xF; // Only keep the lower four bits; upper four is PBS
 
				break;
 

	
 
			case MP_WATER:
 
				/* if water class == 3, make river there */
 
				if (GB(_m[t].m3, 0, 2) == 3) {
 
					SetTileType(t, MP_WATER);
 
					SetTileOwner(t, OWNER_WATER);
 
					_m[t].m2 = 0;
 
					_m[t].m3 = 2; // WATER_CLASS_RIVER
 
					_m[t].m4 = Random();
 
					_m[t].m5 = 0;
 
				if (GB(tile.m3(), 0, 2) == 3) {
 
					SetTileType(tile, MP_WATER);
 
					SetTileOwner(tile, OWNER_WATER);
 
					tile.m2() = 0;
 
					tile.m3() = 2; // WATER_CLASS_RIVER
 
					tile.m4() = Random();
 
					tile.m5() = 0;
 
				}
 
				break;
 

	
 
@@ -192,7 +194,8 @@ void FixOldVehicles()
 
			RoadVehicle *rv = RoadVehicle::From(v);
 
			if (rv->state != RVSB_IN_DEPOT && rv->state != RVSB_WORMHOLE) {
 
				ClrBit(rv->state, 2);
 
				if (IsTileType(rv->tile, MP_STATION) && _m[rv->tile].m5 >= 168) {
 
				Tile tile(rv->tile);
 
				if (IsTileType(tile, MP_STATION) && tile.m5() >= 168) {
 
					/* Update the vehicle's road state to show we're in a drive through road stop. */
 
					SetBit(rv->state, RVS_IN_DT_ROAD_STOP);
 
				}
 
@@ -218,13 +221,14 @@ void FixOldVehicles()
 
static bool FixTTOMapArray()
 
{
 
	for (TileIndex t = 0; t < OLD_MAP_SIZE; t++) {
 
		TileType tt = GetTileType(t);
 
		Tile tile(t);
 
		TileType tt = GetTileType(tile);
 
		if (tt == 11) {
 
			/* TTO has a different way of storing monorail.
 
			 * Instead of using bits in m3 it uses a different tile type. */
 
			_m[t].m3 = 1; // rail type = monorail (in TTD)
 
			SetTileType(t, MP_RAILWAY);
 
			_m[t].m2 = 1; // set monorail ground to RAIL_GROUND_GRASS
 
			tile.m3() = 1; // rail type = monorail (in TTD)
 
			SetTileType(tile, MP_RAILWAY);
 
			tile.m2() = 1; // set monorail ground to RAIL_GROUND_GRASS
 
			tt = MP_RAILWAY;
 
		}
 

	
 
@@ -233,18 +237,18 @@ static bool FixTTOMapArray()
 
				break;
 

	
 
			case MP_RAILWAY:
 
				switch (GB(_m[t].m5, 6, 2)) {
 
				switch (GB(tile.m5(), 6, 2)) {
 
					case 0: // RAIL_TILE_NORMAL
 
						break;
 
					case 1: // RAIL_TILE_SIGNALS
 
						_m[t].m4 = (~_m[t].m5 & 1) << 2;        // signal variant (present only in OTTD)
 
						SB(_m[t].m2, 6, 2, GB(_m[t].m5, 3, 2)); // signal status
 
						_m[t].m3 |= 0xC0;                       // both signals are present
 
						_m[t].m5 = HasBit(_m[t].m5, 5) ? 2 : 1; // track direction (only X or Y)
 
						_m[t].m5 |= 0x40;                       // RAIL_TILE_SIGNALS
 
						tile.m4() = (~tile.m5() & 1) << 2;        // signal variant (present only in OTTD)
 
						SB(tile.m2(), 6, 2, GB(tile.m5(), 3, 2)); // signal status
 
						tile.m3() |= 0xC0;                       // both signals are present
 
						tile.m5() = HasBit(tile.m5(), 5) ? 2 : 1; // track direction (only X or Y)
 
						tile.m5() |= 0x40;                       // RAIL_TILE_SIGNALS
 
						break;
 
					case 3: // RAIL_TILE_DEPOT
 
						_m[t].m2 = 0;
 
						tile.m2() = 0;
 
						break;
 
					default:
 
						return false;
 
@@ -252,12 +256,12 @@ static bool FixTTOMapArray()
 
				break;
 

	
 
			case MP_ROAD: // road (depot) or level crossing
 
				switch (GB(_m[t].m5, 4, 4)) {
 
				switch (GB(tile.m5(), 4, 4)) {
 
					case 0: // ROAD_TILE_NORMAL
 
						if (_m[t].m2 == 4) _m[t].m2 = 5; // 'small trees' -> ROADSIDE_TREES
 
						if (tile.m2() == 4) tile.m2() = 5; // 'small trees' -> ROADSIDE_TREES
 
						break;
 
					case 1: // ROAD_TILE_CROSSING (there aren't monorail crossings in TTO)
 
						_m[t].m3 = _m[t].m1; // set owner of road = owner of rail
 
						tile.m3() = tile.m1(); // set owner of road = owner of rail
 
						break;
 
					case 2: // ROAD_TILE_DEPOT
 
						break;
 
@@ -267,69 +271,69 @@ static bool FixTTOMapArray()
 
				break;
 

	
 
			case MP_HOUSE:
 
				_m[t].m3 = _m[t].m2 & 0xC0;    // construction stage
 
				_m[t].m2 &= 0x3F;              // building type
 
				if (_m[t].m2 >= 5) _m[t].m2++; // skip "large office block on snow"
 
				tile.m3() = tile.m2() & 0xC0;    // construction stage
 
				tile.m2() &= 0x3F;               // building type
 
				if (tile.m2() >= 5) tile.m2()++; // skip "large office block on snow"
 
				break;
 

	
 
			case MP_TREES:
 
				_m[t].m3 = GB(_m[t].m5, 3, 3); // type of trees
 
				_m[t].m5 &= 0xC7;              // number of trees and growth status
 
				tile.m3() = GB(tile.m5(), 3, 3); // type of trees
 
				tile.m5() &= 0xC7;               // number of trees and growth status
 
				break;
 

	
 
			case MP_STATION:
 
				_m[t].m3 = (_m[t].m5 >= 0x08 && _m[t].m5 <= 0x0F) ? 1 : 0; // monorail -> 1, others 0 (rail, road, airport, dock)
 
				if (_m[t].m5 >= 8) _m[t].m5 -= 8; // shift for monorail
 
				if (_m[t].m5 >= 0x42) _m[t].m5++; // skip heliport
 
				tile.m3() = (tile.m5() >= 0x08 && tile.m5() <= 0x0F) ? 1 : 0; // monorail -> 1, others 0 (rail, road, airport, dock)
 
				if (tile.m5() >= 8) tile.m5() -= 8; // shift for monorail
 
				if (tile.m5() >= 0x42) tile.m5()++; // skip heliport
 
				break;
 

	
 
			case MP_WATER:
 
				_m[t].m3 = _m[t].m2 = 0;
 
				tile.m3() = tile.m2() = 0;
 
				break;
 

	
 
			case MP_VOID:
 
				_m[t].m2 = _m[t].m3 = _m[t].m5 = 0;
 
				tile.m2() = tile.m3() = tile.m5() = 0;
 
				break;
 

	
 
			case MP_INDUSTRY:
 
				_m[t].m3 = 0;
 
				switch (_m[t].m5) {
 
				tile.m3() = 0;
 
				switch (tile.m5()) {
 
					case 0x24: // farm silo
 
						_m[t].m5 = 0x25;
 
						tile.m5() = 0x25;
 
						break;
 
					case 0x25: case 0x27: // farm
 
					case 0x28: case 0x29: case 0x2A: case 0x2B: // factory
 
						_m[t].m5--;
 
						tile.m5()--;
 
						break;
 
					default:
 
						if (_m[t].m5 >= 0x2C) _m[t].m5 += 3; // iron ore mine, steel mill or bank
 
						if (tile.m5() >= 0x2C) tile.m5() += 3; // iron ore mine, steel mill or bank
 
						break;
 
				}
 
				break;
 

	
 
			case MP_TUNNELBRIDGE:
 
				if (HasBit(_m[t].m5, 7)) { // bridge
 
					byte m5 = _m[t].m5;
 
					_m[t].m5 = m5 & 0xE1; // copy bits 7..5, 1
 
					if (GB(m5, 1, 2) == 1) _m[t].m5 |= 0x02; // road bridge
 
					if (GB(m5, 1, 2) == 3) _m[t].m2 |= 0xA0; // monorail bridge -> tubular, steel bridge
 
				if (HasBit(tile.m5(), 7)) { // bridge
 
					byte m5 = tile.m5();
 
					tile.m5() = m5 & 0xE1; // copy bits 7..5, 1
 
					if (GB(m5, 1, 2) == 1) tile.m5() |= 0x02; // road bridge
 
					if (GB(m5, 1, 2) == 3) tile.m2() |= 0xA0; // monorail bridge -> tubular, steel bridge
 
					if (!HasBit(m5, 6)) { // bridge head
 
						_m[t].m3 = (GB(m5, 1, 2) == 3) ? 1 : 0; // track subtype (1 for monorail, 0 for others)
 
						tile.m3() = (GB(m5, 1, 2) == 3) ? 1 : 0; // track subtype (1 for monorail, 0 for others)
 
					} else { // middle bridge part
 
						_m[t].m3 = HasBit(m5, 2) ? 0x10 : 0;  // track subtype on bridge
 
						if (GB(m5, 3, 2) == 3) _m[t].m3 |= 1; // track subtype under bridge
 
						if (GB(m5, 3, 2) == 1) _m[t].m5 |= 0x08; // set for road/water under (0 for rail/clear)
 
						tile.m3() = HasBit(m5, 2) ? 0x10 : 0;  // track subtype on bridge
 
						if (GB(m5, 3, 2) == 3) tile.m3() |= 1; // track subtype under bridge
 
						if (GB(m5, 3, 2) == 1) tile.m5() |= 0x08; // set for road/water under (0 for rail/clear)
 
					}
 
				} else { // tunnel entrance/exit
 
					_m[t].m2 = 0;
 
					_m[t].m3 = HasBit(_m[t].m5, 3); // monorail
 
					_m[t].m5 &= HasBit(_m[t].m5, 3) ? 0x03 : 0x07 ; // direction, transport type (== 0 for rail)
 
					tile.m2() = 0;
 
					tile.m3() = HasBit(tile.m5(), 3); // monorail
 
					tile.m5() &= HasBit(tile.m5(), 3) ? 0x03 : 0x07 ; // direction, transport type (== 0 for rail)
 
				}
 
				break;
 

	
 
			case MP_OBJECT:
 
				_m[t].m2 = 0;
 
				_m[t].m3 = 0;
 
				tile.m2() = 0;
 
				tile.m3() = 0;
 
				break;
 

	
 
			default:
 
@@ -1471,10 +1475,10 @@ static bool LoadOldMapPart1(LoadgameStat
 
	}
 

	
 
	for (uint i = 0; i < OLD_MAP_SIZE; i++) {
 
		_m[i].m1 = ReadByte(ls);
 
		Tile(i).m1() = ReadByte(ls);
 
	}
 
	for (uint i = 0; i < OLD_MAP_SIZE; i++) {
 
		_m[i].m2 = ReadByte(ls);
 
		Tile(i).m2() = ReadByte(ls);
 
	}
 

	
 
	if (_savegame_type != SGT_TTO) {
 
@@ -1484,10 +1488,10 @@ static bool LoadOldMapPart1(LoadgameStat
 
		}
 
		for (uint i = 0; i < OLD_MAP_SIZE / 4; i++) {
 
			byte b = ReadByte(ls);
 
			_me[i * 4 + 0].m6 = GB(b, 0, 2);
 
			_me[i * 4 + 1].m6 = GB(b, 2, 2);
 
			_me[i * 4 + 2].m6 = GB(b, 4, 2);
 
			_me[i * 4 + 3].m6 = GB(b, 6, 2);
 
			Tile(i * 4 + 0).m6() = GB(b, 0, 2);
 
			Tile(i * 4 + 1).m6() = GB(b, 2, 2);
 
			Tile(i * 4 + 2).m6() = GB(b, 4, 2);
 
			Tile(i * 4 + 3).m6() = GB(b, 6, 2);
 
		}
 
	}
 

	
 
@@ -1499,10 +1503,10 @@ static bool LoadOldMapPart2(LoadgameStat
 
	uint i;
 

	
 
	for (i = 0; i < OLD_MAP_SIZE; i++) {
 
		_m[i].type = ReadByte(ls);
 
		Tile(i).type() = ReadByte(ls);
 
	}
 
	for (i = 0; i < OLD_MAP_SIZE; i++) {
 
		_m[i].m5 = ReadByte(ls);
 
		Tile(i).m5() = ReadByte(ls);
 
	}
 

	
 
	return true;
src/saveload/station_sl.cpp
Show inline comments
 
@@ -91,9 +91,10 @@ void MoveBuoysToWaypoints()
 
		if (train) {
 
			/* When we make a rail waypoint of the station, convert the map as well. */
 
			for (TileIndex t : train_st) {
 
				if (!IsTileType(t, MP_STATION) || GetStationIndex(t) != index) continue;
 
				Tile tile(t);
 
				if (!IsTileType(tile, MP_STATION) || GetStationIndex(tile) != index) continue;
 

	
 
				SB(_me[t].m6, 3, 3, STATION_WAYPOINT);
 
				SB(tile.m6(), 3, 3, STATION_WAYPOINT);
 
				wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
 
			}
 

	
src/saveload/waypoint_sl.cpp
Show inline comments
 
@@ -74,10 +74,11 @@ void MoveWaypointsToBaseStations()
 
			if (wp.delete_ctr != 0) continue; // The waypoint was deleted
 

	
 
			/* Waypoint indices were not added to the map prior to this. */
 
			_m[wp.xy].m2 = (StationID)wp.index;
 
			Tile tile = wp.xy;
 
			tile.m2() = (StationID)wp.index;
 

	
 
			if (HasBit(_m[wp.xy].m3, 4)) {
 
				wp.spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(_m[wp.xy].m4 + 1);
 
			if (HasBit(tile.m3(), 4)) {
 
				wp.spec = StationClass::Get(STAT_CLASS_WAYP)->GetSpec(tile.m4() + 1);
 
			}
 
		}
 
	} else {
 
@@ -102,10 +103,10 @@ void MoveWaypointsToBaseStations()
 
		TileIndex t = wp.xy;
 
		/* Sometimes waypoint (sign) locations became disconnected from their actual location in
 
		 * the map array. If this is the case, try to locate the actual location in the map array */
 
		if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || _m[t].m2 != wp.index) {
 
		if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || Tile(t).m2() != wp.index) {
 
			Debug(sl, 0, "Found waypoint tile {} with invalid position", t);
 
			for (t = 0; t < Map::Size(); t++) {
 
				if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp.index) {
 
				if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && Tile(t).m2() == wp.index) {
 
					Debug(sl, 0, "Found actual waypoint position at {}", t);
 
					break;
 
				}
 
@@ -125,19 +126,20 @@ void MoveWaypointsToBaseStations()
 
		new_wp->string_id  = STR_SV_STNAME_WAYPOINT;
 

	
 
		/* The tile might've been reserved! */
 
		bool reserved = !IsSavegameVersionBefore(SLV_100) && HasBit(_m[t].m5, 4);
 
		Tile tile(t);
 
		bool reserved = !IsSavegameVersionBefore(SLV_100) && HasBit(tile.m5(), 4);
 

	
 
		/* The tile really has our waypoint, so reassign the map array */
 
		MakeRailWaypoint(t, GetTileOwner(t), new_wp->index, (Axis)GB(_m[t].m5, 0, 1), 0, GetRailType(t));
 
		MakeRailWaypoint(tile, GetTileOwner(tile), new_wp->index, (Axis)GB(tile.m5(), 0, 1), 0, GetRailType(tile));
 
		new_wp->facilities |= FACIL_TRAIN;
 
		new_wp->owner = GetTileOwner(t);
 
		new_wp->owner = GetTileOwner(tile);
 

	
 
		SetRailStationReservation(t, reserved);
 
		SetRailStationReservation(tile, reserved);
 

	
 
		if (wp.spec != nullptr) {
 
			SetCustomStationSpecIndex(t, AllocateSpecToStation(wp.spec, new_wp, true));
 
			SetCustomStationSpecIndex(tile, AllocateSpecToStation(wp.spec, new_wp, true));
 
		}
 
		new_wp->rect.BeforeAddTile(t, StationRect::ADD_FORCE);
 
		new_wp->rect.BeforeAddTile(tile, StationRect::ADD_FORCE);
 

	
 
		wp.new_index = new_wp->index;
 
	}
src/script/api/script_story_page.cpp
Show inline comments
 
@@ -69,7 +69,7 @@ static inline bool StoryPageElementTypeR
 
		encoded_text = text->GetEncodedText();
 
		EnforcePreconditionEncodedText(STORY_PAGE_ELEMENT_INVALID, encoded_text);
 
	}
 
	EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_LOCATION || ::IsValidTile(reference));
 
	EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_LOCATION || ::IsValidTile((::TileIndex)reference));
 
	EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
 
	EnforcePrecondition(STORY_PAGE_ELEMENT_INVALID, type != SPET_GOAL || !(StoryPage::Get(story_page_id)->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
 

	
 
@@ -118,7 +118,7 @@ static inline bool StoryPageElementTypeR
 
		encoded_text = text->GetEncodedText();
 
		EnforcePreconditionEncodedText(false, encoded_text);
 
	}
 
	EnforcePrecondition(false, type != ::SPET_LOCATION || ::IsValidTile(reference));
 
	EnforcePrecondition(false, type != ::SPET_LOCATION || ::IsValidTile((::TileIndex)reference));
 
	EnforcePrecondition(false, type != ::SPET_GOAL || ScriptGoal::IsValidGoal((ScriptGoal::GoalID)reference));
 
	EnforcePrecondition(false, type != ::SPET_GOAL || !(p->company == INVALID_COMPANY && Goal::Get(reference)->company != INVALID_COMPANY));
 

	
src/station_cmd.cpp
Show inline comments
 
@@ -78,7 +78,7 @@
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a hangar.
 
 */
 
bool IsHangar(TileIndex t)
 
bool IsHangar(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 

	
 
@@ -89,7 +89,7 @@ bool IsHangar(TileIndex t)
 
	const AirportSpec *as = st->airport.GetSpec();
 

	
 
	for (uint i = 0; i < as->nof_depots; i++) {
 
		if (st->airport.GetHangarTile(i) == t) return true;
 
		if (st->airport.GetHangarTile(i) == TileIndex(t)) return true;
 
	}
 

	
 
	return false;
 
@@ -2462,11 +2462,12 @@ CommandCost CmdBuildAirport(DoCommandFla
 
		st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY);
 

	
 
		for (AirportTileTableIterator iter(as->table[layout], tile); iter != INVALID_TILE; ++iter) {
 
			MakeAirport(iter, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
 
			SetStationTileRandomBits(iter, GB(Random(), 0, 4));
 
			Tile t(iter);
 
			MakeAirport(t, st->owner, st->index, iter.GetStationGfx(), WATER_CLASS_INVALID);
 
			SetStationTileRandomBits(t, GB(Random(), 0, 4));
 
			st->airport.Add(iter);
 

	
 
			if (AirportTileSpec::Get(GetTranslatedAirportTileID(iter.GetStationGfx()))->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(iter);
 
			if (AirportTileSpec::Get(GetTranslatedAirportTileID(iter.GetStationGfx()))->animation.status != ANIM_STATUS_NO_ANIMATION) AddAnimatedTile(t);
 
		}
 

	
 
		/* Only call the animation trigger after all tiles have been built */
src/station_map.h
Show inline comments
 
@@ -25,10 +25,10 @@ typedef byte StationGfx; ///< Index of s
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return Station ID of the station at \a t
 
 */
 
static inline StationID GetStationIndex(TileIndex t)
 
static inline StationID GetStationIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return (StationID)_m[t].m2;
 
	return (StationID)t.m2();
 
}
 

	
 

	
 
@@ -41,10 +41,10 @@ static const int GFX_TRUCK_BUS_DRIVETHRO
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return the station type
 
 */
 
static inline StationType GetStationType(TileIndex t)
 
static inline StationType GetStationType(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return (StationType)GB(_me[t].m6, 3, 3);
 
	return (StationType)GB(t.m6(), 3, 3);
 
}
 

	
 
/**
 
@@ -53,7 +53,7 @@ static inline StationType GetStationType
 
 * @pre GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS
 
 * @return the road stop type
 
 */
 
static inline RoadStopType GetRoadStopType(TileIndex t)
 
static inline RoadStopType GetRoadStopType(Tile t)
 
{
 
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
 
	return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
 
@@ -65,10 +65,10 @@ static inline RoadStopType GetRoadStopTy
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return the station graphics
 
 */
 
static inline StationGfx GetStationGfx(TileIndex t)
 
static inline StationGfx GetStationGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return _m[t].m5;
 
	return t.m5();
 
}
 

	
 
/**
 
@@ -77,10 +77,10 @@ static inline StationGfx GetStationGfx(T
 
 * @param gfx the new graphics
 
 * @pre IsTileType(t, MP_STATION)
 
 */
 
static inline void SetStationGfx(TileIndex t, StationGfx gfx)
 
static inline void SetStationGfx(Tile t, StationGfx gfx)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	_m[t].m5 = gfx;
 
	t.m5() = gfx;
 
}
 

	
 
/**
 
@@ -89,7 +89,7 @@ static inline void SetStationGfx(TileInd
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a rail station
 
 */
 
static inline bool IsRailStation(TileIndex t)
 
static inline bool IsRailStation(Tile t)
 
{
 
	return GetStationType(t) == STATION_RAIL;
 
}
 
@@ -99,7 +99,7 @@ static inline bool IsRailStation(TileInd
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is a rail station
 
 */
 
static inline bool IsRailStationTile(TileIndex t)
 
static inline bool IsRailStationTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRailStation(t);
 
}
 
@@ -110,7 +110,7 @@ static inline bool IsRailStationTile(Til
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a rail waypoint
 
 */
 
static inline bool IsRailWaypoint(TileIndex t)
 
static inline bool IsRailWaypoint(Tile t)
 
{
 
	return GetStationType(t) == STATION_WAYPOINT;
 
}
 
@@ -120,7 +120,7 @@ static inline bool IsRailWaypoint(TileIn
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is a rail waypoint
 
 */
 
static inline bool IsRailWaypointTile(TileIndex t)
 
static inline bool IsRailWaypointTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
 
}
 
@@ -132,7 +132,7 @@ static inline bool IsRailWaypointTile(Ti
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile has rail
 
 */
 
static inline bool HasStationRail(TileIndex t)
 
static inline bool HasStationRail(Tile t)
 
{
 
	return IsRailStation(t) || IsRailWaypoint(t);
 
}
 
@@ -143,7 +143,7 @@ static inline bool HasStationRail(TileIn
 
 * @param t the tile to check
 
 * @return true if and only if the tile is a station tile and has rail
 
 */
 
static inline bool HasStationTileRail(TileIndex t)
 
static inline bool HasStationTileRail(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && HasStationRail(t);
 
}
 
@@ -154,7 +154,7 @@ static inline bool HasStationTileRail(Ti
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is an airport
 
 */
 
static inline bool IsAirport(TileIndex t)
 
static inline bool IsAirport(Tile t)
 
{
 
	return GetStationType(t) == STATION_AIRPORT;
 
}
 
@@ -164,12 +164,12 @@ static inline bool IsAirport(TileIndex t
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is an airport
 
 */
 
static inline bool IsAirportTile(TileIndex t)
 
static inline bool IsAirportTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsAirport(t);
 
}
 

	
 
bool IsHangar(TileIndex t);
 
bool IsHangar(Tile t);
 

	
 
/**
 
 * Is the station at \a t a truck stop?
 
@@ -177,7 +177,7 @@ bool IsHangar(TileIndex t);
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if station is a truck stop, \c false otherwise
 
 */
 
static inline bool IsTruckStop(TileIndex t)
 
static inline bool IsTruckStop(Tile t)
 
{
 
	return GetStationType(t) == STATION_TRUCK;
 
}
 
@@ -188,7 +188,7 @@ static inline bool IsTruckStop(TileIndex
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if station is a bus stop, \c false otherwise
 
 */
 
static inline bool IsBusStop(TileIndex t)
 
static inline bool IsBusStop(Tile t)
 
{
 
	return GetStationType(t) == STATION_BUS;
 
}
 
@@ -199,7 +199,7 @@ static inline bool IsBusStop(TileIndex t
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if station at the tile is a bus top or a truck stop, \c false otherwise
 
 */
 
static inline bool IsRoadStop(TileIndex t)
 
static inline bool IsRoadStop(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return IsTruckStop(t) || IsBusStop(t);
 
@@ -210,7 +210,7 @@ static inline bool IsRoadStop(TileIndex 
 
 * @param t Tile to check
 
 * @return \c true if the tile is a station tile and a road stop
 
 */
 
static inline bool IsRoadStopTile(TileIndex t)
 
static inline bool IsRoadStopTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRoadStop(t);
 
}
 
@@ -220,7 +220,7 @@ static inline bool IsRoadStopTile(TileIn
 
 * @param t Tile to check
 
 * @return \c true if the tile is a station tile and a standard road stop
 
 */
 
static inline bool IsStandardRoadStopTile(TileIndex t)
 
static inline bool IsStandardRoadStopTile(Tile t)
 
{
 
	return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 
}
 
@@ -230,7 +230,7 @@ static inline bool IsStandardRoadStopTil
 
 * @param t Tile to check
 
 * @return \c true if the tile is a station tile and a drive through road stop
 
 */
 
static inline bool IsDriveThroughStopTile(TileIndex t)
 
static inline bool IsDriveThroughStopTile(Tile t)
 
{
 
	return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 
}
 
@@ -243,7 +243,7 @@ StationGfx GetTranslatedAirportTileID(St
 
 * @pre IsAirport(t)
 
 * @return the station graphics
 
 */
 
static inline StationGfx GetAirportGfx(TileIndex t)
 
static inline StationGfx GetAirportGfx(Tile t)
 
{
 
	assert(IsAirport(t));
 
	return GetTranslatedAirportTileID(GetStationGfx(t));
 
@@ -255,7 +255,7 @@ static inline StationGfx GetAirportGfx(T
 
 * @pre IsRoadStopTile(t)
 
 * @return the direction of the entrance
 
 */
 
static inline DiagDirection GetRoadStopDir(TileIndex t)
 
static inline DiagDirection GetRoadStopDir(Tile t)
 
{
 
	StationGfx gfx = GetStationGfx(t);
 
	assert(IsRoadStopTile(t));
 
@@ -272,7 +272,7 @@ static inline DiagDirection GetRoadStopD
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is an oilrig tile
 
 */
 
static inline bool IsOilRig(TileIndex t)
 
static inline bool IsOilRig(Tile t)
 
{
 
	return GetStationType(t) == STATION_OILRIG;
 
}
 
@@ -283,7 +283,7 @@ static inline bool IsOilRig(TileIndex t)
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is a dock
 
 */
 
static inline bool IsDock(TileIndex t)
 
static inline bool IsDock(Tile t)
 
{
 
	return GetStationType(t) == STATION_DOCK;
 
}
 
@@ -293,7 +293,7 @@ static inline bool IsDock(TileIndex t)
 
 * @param t Tile to check
 
 * @return \c true if the tile is a dock
 
 */
 
static inline bool IsDockTile(TileIndex t)
 
static inline bool IsDockTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
 
}
 
@@ -304,7 +304,7 @@ static inline bool IsDockTile(TileIndex 
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is a buoy
 
 */
 
static inline bool IsBuoy(TileIndex t)
 
static inline bool IsBuoy(Tile t)
 
{
 
	return GetStationType(t) == STATION_BUOY;
 
}
 
@@ -314,7 +314,7 @@ static inline bool IsBuoy(TileIndex t)
 
 * @param t Tile to check
 
 * @return \c true if the tile is a buoy
 
 */
 
static inline bool IsBuoyTile(TileIndex t)
 
static inline bool IsBuoyTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsBuoy(t);
 
}
 
@@ -324,7 +324,7 @@ static inline bool IsBuoyTile(TileIndex 
 
 * @param t Tile to check
 
 * @return \c true if the tile is an hangar
 
 */
 
static inline bool IsHangarTile(TileIndex t)
 
static inline bool IsHangarTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsHangar(t);
 
}
 
@@ -335,7 +335,7 @@ static inline bool IsHangarTile(TileInde
 
 * @pre HasStationRail(t)
 
 * @return The direction of the rails on tile \a t.
 
 */
 
static inline Axis GetRailStationAxis(TileIndex t)
 
static inline Axis GetRailStationAxis(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
 
@@ -347,7 +347,7 @@ static inline Axis GetRailStationAxis(Ti
 
 * @pre HasStationRail(t)
 
 * @return The rail track of the rails on tile \a t.
 
 */
 
static inline Track GetRailStationTrack(TileIndex t)
 
static inline Track GetRailStationTrack(Tile t)
 
{
 
	return AxisToTrack(GetRailStationAxis(t));
 
}
 
@@ -358,7 +358,7 @@ static inline Track GetRailStationTrack(
 
 * @pre HasStationRail(t)
 
 * @return The trackbits of the rails on tile \a t.
 
 */
 
static inline TrackBits GetRailStationTrackBits(TileIndex t)
 
static inline TrackBits GetRailStationTrackBits(Tile t)
 
{
 
	return AxisToTrackBits(GetRailStationAxis(t));
 
}
 
@@ -376,7 +376,7 @@ static inline TrackBits GetRailStationTr
 
 * @pre IsRailStationTile(station_tile)
 
 * @return true if the two tiles are compatible
 
 */
 
static inline bool IsCompatibleTrainStationTile(TileIndex test_tile, TileIndex station_tile)
 
static inline bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
 
{
 
	assert(IsRailStationTile(station_tile));
 
	return IsRailStationTile(test_tile) && IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
 
@@ -391,10 +391,10 @@ static inline bool IsCompatibleTrainStat
 
 * @param t the station tile
 
 * @return reservation state
 
 */
 
static inline bool HasStationReservation(TileIndex t)
 
static inline bool HasStationReservation(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(_me[t].m6, 2);
 
	return HasBit(t.m6(), 2);
 
}
 

	
 
/**
 
@@ -403,10 +403,10 @@ static inline bool HasStationReservation
 
 * @param t the station tile
 
 * @param b the reservation state
 
 */
 
static inline void SetRailStationReservation(TileIndex t, bool b)
 
static inline void SetRailStationReservation(Tile t, bool b)
 
{
 
	assert(HasStationRail(t));
 
	SB(_me[t].m6, 2, 1, b ? 1 : 0);
 
	SB(t.m6(), 2, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
@@ -415,7 +415,7 @@ static inline void SetRailStationReserva
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetStationReservationTrackBits(TileIndex t)
 
static inline TrackBits GetStationReservationTrackBits(Tile t)
 
{
 
	return HasStationReservation(t) ? GetRailStationTrackBits(t) : TRACK_BIT_NONE;
 
}
 
@@ -427,7 +427,7 @@ static inline TrackBits GetStationReserv
 
 * @pre \a t is the land part of the dock
 
 * @return The direction of the dock on tile \a t.
 
 */
 
static inline DiagDirection GetDockDirection(TileIndex t)
 
static inline DiagDirection GetDockDirection(Tile t)
 
{
 
	StationGfx gfx = GetStationGfx(t);
 
	assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
 
@@ -441,7 +441,7 @@ static inline DiagDirection GetDockDirec
 
 * @pre IsBuoy(t) || IsOilRig(t) || IsDock(t)
 
 * @return The offset from this tile that should be used as destination for ships.
 
 */
 
static inline TileIndexDiffC GetDockOffset(TileIndex t)
 
static inline TileIndexDiffC GetDockOffset(Tile t)
 
{
 
	static const TileIndexDiffC buoy_offset = {0, 0};
 
	static const TileIndexDiffC oilrig_offset = {2, 0};
 
@@ -467,10 +467,10 @@ static inline TileIndexDiffC GetDockOffs
 
 * @pre HasStationTileRail(t)
 
 * @return True if this station is part of a newgrf station.
 
 */
 
static inline bool IsCustomStationSpecIndex(TileIndex t)
 
static inline bool IsCustomStationSpecIndex(Tile t)
 
{
 
	assert(HasStationTileRail(t));
 
	return _m[t].m4 != 0;
 
	return t.m4() != 0;
 
}
 

	
 
/**
 
@@ -479,10 +479,10 @@ static inline bool IsCustomStationSpecIn
 
 * @param specindex The new spec.
 
 * @pre HasStationTileRail(t)
 
 */
 
static inline void SetCustomStationSpecIndex(TileIndex t, byte specindex)
 
static inline void SetCustomStationSpecIndex(Tile t, byte specindex)
 
{
 
	assert(HasStationTileRail(t));
 
	_m[t].m4 = specindex;
 
	t.m4() = specindex;
 
}
 

	
 
/**
 
@@ -491,10 +491,10 @@ static inline void SetCustomStationSpecI
 
 * @pre HasStationTileRail(t)
 
 * @return The custom station spec of this tile.
 
 */
 
static inline uint GetCustomStationSpecIndex(TileIndex t)
 
static inline uint GetCustomStationSpecIndex(Tile t)
 
{
 
	assert(HasStationTileRail(t));
 
	return _m[t].m4;
 
	return t.m4();
 
}
 

	
 
/**
 
@@ -503,10 +503,10 @@ static inline uint GetCustomStationSpecI
 
 * @pre IsRoadStopTile(t)
 
 * @return True if this station is part of a newgrf station.
 
 */
 
static inline bool IsCustomRoadStopSpecIndex(TileIndex t)
 
static inline bool IsCustomRoadStopSpecIndex(Tile t)
 
{
 
	assert(IsRoadStopTile(t));
 
	return GB(_me[t].m8, 0, 6) != 0;
 
	return GB(t.m8(), 0, 6) != 0;
 
}
 

	
 
/**
 
@@ -515,10 +515,10 @@ static inline bool IsCustomRoadStopSpecI
 
 * @param specindex The new spec.
 
 * @pre IsRoadStopTile(t)
 
 */
 
static inline void SetCustomRoadStopSpecIndex(TileIndex t, byte specindex)
 
static inline void SetCustomRoadStopSpecIndex(Tile t, byte specindex)
 
{
 
	assert(IsRoadStopTile(t));
 
	SB(_me[t].m8, 0, 6, specindex);
 
	SB(t.m8(), 0, 6, specindex);
 
}
 

	
 
/**
 
@@ -527,10 +527,10 @@ static inline void SetCustomRoadStopSpec
 
 * @pre IsRoadStopTile(t)
 
 * @return The custom station spec of this tile.
 
 */
 
static inline uint GetCustomRoadStopSpecIndex(TileIndex t)
 
static inline uint GetCustomRoadStopSpecIndex(Tile t)
 
{
 
	assert(IsRoadStopTile(t));
 
	return GB(_me[t].m8, 0, 6);
 
	return GB(t.m8(), 0, 6);
 
}
 

	
 
/**
 
@@ -539,10 +539,10 @@ static inline uint GetCustomRoadStopSpec
 
 * @param random_bits The random bits.
 
 * @pre IsTileType(t, MP_STATION)
 
 */
 
static inline void SetStationTileRandomBits(TileIndex t, byte random_bits)
 
static inline void SetStationTileRandomBits(Tile t, byte random_bits)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	SB(_m[t].m3, 4, 4, random_bits);
 
	SB(t.m3(), 4, 4, random_bits);
 
}
 

	
 
/**
 
@@ -551,10 +551,10 @@ static inline void SetStationTileRandomB
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return The random bits for this station tile.
 
 */
 
static inline byte GetStationTileRandomBits(TileIndex t)
 
static inline byte GetStationTileRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return GB(_m[t].m3, 4, 4);
 
	return GB(t.m3(), 4, 4);
 
}
 

	
 
/**
 
@@ -566,20 +566,20 @@ static inline byte GetStationTileRandomB
 
 * @param section the StationGfx to be used for this tile
 
 * @param wc The water class of the station
 
 */
 
static inline void MakeStation(TileIndex t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WATER_CLASS_INVALID)
 
static inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WATER_CLASS_INVALID)
 
{
 
	SetTileType(t, MP_STATION);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, wc);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = sid;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = section;
 
	SB(_me[t].m6, 2, 1, 0);
 
	SB(_me[t].m6, 3, 3, st);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = 0;
 
	t.m2() = sid;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = section;
 
	SB(t.m6(), 2, 1, 0);
 
	SB(t.m6(), 3, 3, st);
 
	t.m7() = 0;
 
	t.m8() = 0;
 
}
 

	
 
/**
 
@@ -591,7 +591,7 @@ static inline void MakeStation(TileIndex
 
 * @param section the StationGfx to be used for this tile
 
 * @param rt the railtype of this tile
 
 */
 
static inline void MakeRailStation(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
static inline void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
{
 
	MakeStation(t, o, sid, STATION_RAIL, section + a);
 
	SetRailType(t, rt);
 
@@ -607,7 +607,7 @@ static inline void MakeRailStation(TileI
 
 * @param section the StationGfx to be used for this tile
 
 * @param rt the railtype of this tile
 
 */
 
static inline void MakeRailWaypoint(TileIndex t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
static inline void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
{
 
	MakeStation(t, o, sid, STATION_WAYPOINT, section + a);
 
	SetRailType(t, rt);
 
@@ -624,7 +624,7 @@ static inline void MakeRailWaypoint(Tile
 
 * @param tram_rt the tram roadtype on this tile
 
 * @param d the direction of the roadstop
 
 */
 
static inline void MakeRoadStop(TileIndex t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
 
static inline void MakeRoadStop(Tile t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
 
{
 
	MakeStation(t, o, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), d);
 
	SetRoadTypes(t, road_rt, tram_rt);
 
@@ -644,7 +644,7 @@ static inline void MakeRoadStop(TileInde
 
 * @param tram_rt the tram roadtype on this tile
 
 * @param a the direction of the roadstop
 
 */
 
static inline void MakeDriveThroughRoadStop(TileIndex t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
 
static inline void MakeDriveThroughRoadStop(Tile t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
 
{
 
	MakeStation(t, station, sid, (rst == ROADSTOP_BUS ? STATION_BUS : STATION_TRUCK), GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET + a);
 
	SetRoadTypes(t, road_rt, tram_rt);
 
@@ -660,7 +660,7 @@ static inline void MakeDriveThroughRoadS
 
 * @param section the StationGfx to be used for this tile
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeAirport(TileIndex t, Owner o, StationID sid, byte section, WaterClass wc)
 
static inline void MakeAirport(Tile t, Owner o, StationID sid, byte section, WaterClass wc)
 
{
 
	MakeStation(t, o, sid, STATION_AIRPORT, section, wc);
 
}
 
@@ -671,7 +671,7 @@ static inline void MakeAirport(TileIndex
 
 * @param sid the station to which this tile belongs
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeBuoy(TileIndex t, StationID sid, WaterClass wc)
 
static inline void MakeBuoy(Tile t, StationID sid, WaterClass wc)
 
{
 
	/* Make the owner of the buoy tile the same as the current owner of the
 
	 * water tile. In this way, we can reset the owner of the water to its
 
@@ -687,10 +687,10 @@ static inline void MakeBuoy(TileIndex t,
 
 * @param d the direction of the dock
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeDock(TileIndex t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
 
static inline void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
 
{
 
	MakeStation(t, o, sid, STATION_DOCK, d);
 
	MakeStation(t + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
 
	MakeStation(TileIndex(t) + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
 
}
 

	
 
/**
 
@@ -699,7 +699,7 @@ static inline void MakeDock(TileIndex t,
 
 * @param sid the station to which this tile belongs
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeOilrig(TileIndex t, StationID sid, WaterClass wc)
 
static inline void MakeOilrig(Tile t, StationID sid, WaterClass wc)
 
{
 
	MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0, wc);
 
}
src/tile_map.h
Show inline comments
 
@@ -26,10 +26,10 @@
 
 * @return the height of the tile
 
 * @pre tile < Map::Size()
 
 */
 
debug_inline static uint TileHeight(TileIndex tile)
 
debug_inline static uint TileHeight(Tile tile)
 
{
 
	assert(tile < Map::Size());
 
	return _m[tile].height;
 
	return tile.height();
 
}
 

	
 
/**
 
@@ -54,11 +54,11 @@ static inline uint TileHeightOutsideMap(
 
 * @pre tile < Map::Size()
 
 * @pre height <= MAX_TILE_HEIGHT
 
 */
 
static inline void SetTileHeight(TileIndex tile, uint height)
 
static inline void SetTileHeight(Tile tile, uint height)
 
{
 
	assert(tile < Map::Size());
 
	assert(height <= MAX_TILE_HEIGHT);
 
	_m[tile].height = height;
 
	tile.height() = height;
 
}
 

	
 
/**
 
@@ -69,7 +69,7 @@ static inline void SetTileHeight(TileInd
 
 * @param tile The tile to get the height
 
 * @return The height of the tile in pixel
 
 */
 
static inline uint TilePixelHeight(TileIndex tile)
 
static inline uint TilePixelHeight(Tile tile)
 
{
 
	return TileHeight(tile) * TILE_HEIGHT;
 
}
 
@@ -93,10 +93,10 @@ static inline uint TilePixelHeightOutsid
 
 * @return The tiletype of the tile
 
 * @pre tile < Map::Size()
 
 */
 
debug_inline static TileType GetTileType(TileIndex tile)
 
debug_inline static TileType GetTileType(Tile tile)
 
{
 
	assert(tile < Map::Size());
 
	return (TileType)GB(_m[tile].type, 4, 4);
 
	return (TileType)GB(tile.type(), 4, 4);
 
}
 

	
 
/**
 
@@ -106,7 +106,7 @@ debug_inline static TileType GetTileType
 
 * @return Whether the tile is in the interior of the map
 
 * @pre tile < Map::Size()
 
 */
 
static inline bool IsInnerTile(TileIndex tile)
 
static inline bool IsInnerTile(Tile tile)
 
{
 
	assert(tile < Map::Size());
 

	
 
@@ -128,14 +128,14 @@ static inline bool IsInnerTile(TileIndex
 
 * @pre tile < Map::Size()
 
 * @pre type MP_VOID <=> tile is on the south-east or south-west edge.
 
 */
 
static inline void SetTileType(TileIndex tile, TileType type)
 
static inline void SetTileType(Tile tile, TileType type)
 
{
 
	assert(tile < Map::Size());
 
	/* VOID tiles (and no others) are exactly allowed at the lower left and right
 
	 * edges of the map. If _settings_game.construction.freeform_edges is true,
 
	 * the upper edges of the map are also VOID tiles. */
 
	assert(IsInnerTile(tile) == (type != MP_VOID));
 
	SB(_m[tile].type, 4, 4, type);
 
	SB(tile.type(), 4, 4, type);
 
}
 

	
 
/**
 
@@ -147,7 +147,7 @@ static inline void SetTileType(TileIndex
 
 * @param type The type to check against
 
 * @return true If the type matches against the type of the tile
 
 */
 
debug_inline static bool IsTileType(TileIndex tile, TileType type)
 
debug_inline static bool IsTileType(Tile tile, TileType type)
 
{
 
	return GetTileType(tile) == type;
 
}
 
@@ -158,7 +158,7 @@ debug_inline static bool IsTileType(Tile
 
 * @param tile The tile to check
 
 * @return True if the tile is on the map and not one of MP_VOID.
 
 */
 
static inline bool IsValidTile(TileIndex tile)
 
static inline bool IsValidTile(Tile tile)
 
{
 
	return tile < Map::Size() && !IsTileType(tile, MP_VOID);
 
}
 
@@ -175,13 +175,13 @@ static inline bool IsValidTile(TileIndex
 
 * @pre IsValidTile(tile)
 
 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
 
 */
 
static inline Owner GetTileOwner(TileIndex tile)
 
static inline Owner GetTileOwner(Tile tile)
 
{
 
	assert(IsValidTile(tile));
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	return (Owner)GB(_m[tile].m1, 0, 5);
 
	return (Owner)GB(tile.m1(), 0, 5);
 
}
 

	
 
/**
 
@@ -195,13 +195,13 @@ static inline Owner GetTileOwner(TileInd
 
 * @pre IsValidTile(tile)
 
 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
 
 */
 
static inline void SetTileOwner(TileIndex tile, Owner owner)
 
static inline void SetTileOwner(Tile tile, Owner owner)
 
{
 
	assert(IsValidTile(tile));
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	SB(_m[tile].m1, 0, 5, owner);
 
	SB(tile.m1(), 0, 5, owner);
 
}
 

	
 
/**
 
@@ -211,7 +211,7 @@ static inline void SetTileOwner(TileInde
 
 * @param owner The owner to check against
 
 * @return True if a tile belongs the the given owner
 
 */
 
static inline bool IsTileOwner(TileIndex tile, Owner owner)
 
static inline bool IsTileOwner(Tile tile, Owner owner)
 
{
 
	return GetTileOwner(tile) == owner;
 
}
 
@@ -222,11 +222,11 @@ static inline bool IsTileOwner(TileIndex
 
 * @param type the new type
 
 * @pre tile < Map::Size()
 
 */
 
static inline void SetTropicZone(TileIndex tile, TropicZone type)
 
static inline void SetTropicZone(Tile tile, TropicZone type)
 
{
 
	assert(tile < Map::Size());
 
	assert(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL);
 
	SB(_m[tile].type, 0, 2, type);
 
	SB(tile.type(), 0, 2, type);
 
}
 

	
 
/**
 
@@ -235,10 +235,10 @@ static inline void SetTropicZone(TileInd
 
 * @pre tile < Map::Size()
 
 * @return the zone type
 
 */
 
static inline TropicZone GetTropicZone(TileIndex tile)
 
static inline TropicZone GetTropicZone(Tile tile)
 
{
 
	assert(tile < Map::Size());
 
	return (TropicZone)GB(_m[tile].type, 0, 2);
 
	return (TropicZone)GB(tile.type(), 0, 2);
 
}
 

	
 
/**
 
@@ -247,10 +247,10 @@ static inline TropicZone GetTropicZone(T
 
 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
 
 * @return frame number
 
 */
 
static inline byte GetAnimationFrame(TileIndex t)
 
static inline byte GetAnimationFrame(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	return _me[t].m7;
 
	return t.m7();
 
}
 

	
 
/**
 
@@ -259,10 +259,10 @@ static inline byte GetAnimationFrame(Til
 
 * @param frame the new frame number
 
 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
 
 */
 
static inline void SetAnimationFrame(TileIndex t, byte frame)
 
static inline void SetAnimationFrame(Tile t, byte frame)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	_me[t].m7 = frame;
 
	t.m7() = frame;
 
}
 

	
 
Slope GetTileSlope(TileIndex tile, int *h = nullptr);
src/town_map.h
Show inline comments
 
@@ -19,10 +19,10 @@
 
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
 
 * @return TownID
 
 */
 
static inline TownID GetTownIndex(TileIndex t)
 
static inline TownID GetTownIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
 
	return _m[t].m2;
 
	return t.m2();
 
}
 

	
 
/**
 
@@ -31,10 +31,10 @@ static inline TownID GetTownIndex(TileIn
 
 * @param index the index of the town
 
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
 
 */
 
static inline void SetTownIndex(TileIndex t, TownID index)
 
static inline void SetTownIndex(Tile t, TownID index)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
 
	_m[t].m2 = index;
 
	t.m2() = index;
 
}
 

	
 
/**
 
@@ -44,10 +44,10 @@ static inline void SetTownIndex(TileInde
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return house type
 
 */
 
static inline HouseID GetCleanHouseType(TileIndex t)
 
static inline HouseID GetCleanHouseType(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return _m[t].m4 | (GB(_m[t].m3, 6, 1) << 8);
 
	return t.m4() | (GB(t.m3(), 6, 1) << 8);
 
}
 

	
 
/**
 
@@ -56,7 +56,7 @@ static inline HouseID GetCleanHouseType(
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return house type
 
 */
 
static inline HouseID GetHouseType(TileIndex t)
 
static inline HouseID GetHouseType(Tile t)
 
{
 
	return GetTranslatedHouseID(GetCleanHouseType(t));
 
}
 
@@ -67,11 +67,11 @@ static inline HouseID GetHouseType(TileI
 
 * @param house_id the new house type
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseType(TileIndex t, HouseID house_id)
 
static inline void SetHouseType(Tile t, HouseID house_id)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	_m[t].m4 = GB(house_id, 0, 8);
 
	SB(_m[t].m3, 6, 1, GB(house_id, 8, 1));
 
	t.m4() = GB(house_id, 0, 8);
 
	SB(t.m3(), 6, 1, GB(house_id, 8, 1));
 
}
 

	
 
/**
 
@@ -79,9 +79,9 @@ static inline void SetHouseType(TileInde
 
 * @param t the tile
 
 * @return has destination
 
 */
 
static inline bool LiftHasDestination(TileIndex t)
 
static inline bool LiftHasDestination(Tile t)
 
{
 
	return HasBit(_me[t].m7, 0);
 
	return HasBit(t.m7(), 0);
 
}
 

	
 
/**
 
@@ -90,10 +90,10 @@ static inline bool LiftHasDestination(Ti
 
 * @param t the tile
 
 * @param dest new destination
 
 */
 
static inline void SetLiftDestination(TileIndex t, byte dest)
 
static inline void SetLiftDestination(Tile t, byte dest)
 
{
 
	SetBit(_me[t].m7, 0);
 
	SB(_me[t].m7, 1, 3, dest);
 
	SetBit(t.m7(), 0);
 
	SB(t.m7(), 1, 3, dest);
 
}
 

	
 
/**
 
@@ -101,9 +101,9 @@ static inline void SetLiftDestination(Ti
 
 * @param t the tile
 
 * @return destination
 
 */
 
static inline byte GetLiftDestination(TileIndex t)
 
static inline byte GetLiftDestination(Tile t)
 
{
 
	return GB(_me[t].m7, 1, 3);
 
	return GB(t.m7(), 1, 3);
 
}
 

	
 
/**
 
@@ -112,9 +112,9 @@ static inline byte GetLiftDestination(Ti
 
 * and the destination.
 
 * @param t the tile
 
 */
 
static inline void HaltLift(TileIndex t)
 
static inline void HaltLift(Tile t)
 
{
 
	SB(_me[t].m7, 0, 4, 0);
 
	SB(t.m7(), 0, 4, 0);
 
}
 

	
 
/**
 
@@ -122,9 +122,9 @@ static inline void HaltLift(TileIndex t)
 
 * @param t the tile
 
 * @return position, from 0 to 36
 
 */
 
static inline byte GetLiftPosition(TileIndex t)
 
static inline byte GetLiftPosition(Tile t)
 
{
 
	return GB(_me[t].m6, 2, 6);
 
	return GB(t.m6(), 2, 6);
 
}
 

	
 
/**
 
@@ -132,9 +132,9 @@ static inline byte GetLiftPosition(TileI
 
 * @param t the tile
 
 * @param pos position, from 0 to 36
 
 */
 
static inline void SetLiftPosition(TileIndex t, byte pos)
 
static inline void SetLiftPosition(Tile t, byte pos)
 
{
 
	SB(_me[t].m6, 2, 6, pos);
 
	SB(t.m6(), 2, 6, pos);
 
}
 

	
 
/**
 
@@ -142,10 +142,10 @@ static inline void SetLiftPosition(TileI
 
 * @param t the tile
 
 * @return true if it is, false if it is not
 
 */
 
static inline bool IsHouseCompleted(TileIndex t)
 
static inline bool IsHouseCompleted(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return HasBit(_m[t].m3, 7);
 
	return HasBit(t.m3(), 7);
 
}
 

	
 
/**
 
@@ -153,10 +153,10 @@ static inline bool IsHouseCompleted(Tile
 
 * @param t the tile
 
 * @param status
 
 */
 
static inline void SetHouseCompleted(TileIndex t, bool status)
 
static inline void SetHouseCompleted(Tile t, bool status)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(_m[t].m3, 7, 1, !!status);
 
	SB(t.m3(), 7, 1, !!status);
 
}
 

	
 
/**
 
@@ -180,10 +180,10 @@ static inline void SetHouseCompleted(Til
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return the building stage of the house
 
 */
 
static inline byte GetHouseBuildingStage(TileIndex t)
 
static inline byte GetHouseBuildingStage(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(_m[t].m5, 3, 2);
 
	return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(t.m5(), 3, 2);
 
}
 

	
 
/**
 
@@ -192,10 +192,10 @@ static inline byte GetHouseBuildingStage
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return the construction stage of the house
 
 */
 
static inline byte GetHouseConstructionTick(TileIndex t)
 
static inline byte GetHouseConstructionTick(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? 0 : GB(_m[t].m5, 0, 3);
 
	return IsHouseCompleted(t) ? 0 : GB(t.m5(), 0, 3);
 
}
 

	
 
/**
 
@@ -205,12 +205,12 @@ static inline byte GetHouseConstructionT
 
 * @param t the tile of the house to increment the construction stage of
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void IncHouseConstructionTick(TileIndex t)
 
static inline void IncHouseConstructionTick(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	AB(_m[t].m5, 0, 5, 1);
 
	AB(t.m5(), 0, 5, 1);
 

	
 
	if (GB(_m[t].m5, 3, 2) == TOWN_HOUSE_COMPLETED) {
 
	if (GB(t.m5(), 3, 2) == TOWN_HOUSE_COMPLETED) {
 
		/* House is now completed.
 
		 * Store the year of construction as well, for newgrf house purpose */
 
		SetHouseCompleted(t, true);
 
@@ -223,10 +223,10 @@ static inline void IncHouseConstructionT
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
 
 */
 
static inline void ResetHouseAge(TileIndex t)
 
static inline void ResetHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
 
	_m[t].m5 = 0;
 
	t.m5() = 0;
 
}
 

	
 
/**
 
@@ -234,10 +234,10 @@ static inline void ResetHouseAge(TileInd
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void IncrementHouseAge(TileIndex t)
 
static inline void IncrementHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	if (IsHouseCompleted(t) && _m[t].m5 < 0xFF) _m[t].m5++;
 
	if (IsHouseCompleted(t) && t.m5() < 0xFF) t.m5()++;
 
}
 

	
 
/**
 
@@ -246,10 +246,10 @@ static inline void IncrementHouseAge(Til
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return year
 
 */
 
static inline Year GetHouseAge(TileIndex t)
 
static inline Year GetHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? _m[t].m5 : 0;
 
	return IsHouseCompleted(t) ? t.m5() : 0;
 
}
 

	
 
/**
 
@@ -259,10 +259,10 @@ static inline Year GetHouseAge(TileIndex
 
 * @param random the new random bits
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseRandomBits(TileIndex t, byte random)
 
static inline void SetHouseRandomBits(Tile t, byte random)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	_m[t].m1 = random;
 
	t.m1() = random;
 
}
 

	
 
/**
 
@@ -272,10 +272,10 @@ static inline void SetHouseRandomBits(Ti
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return random bits
 
 */
 
static inline byte GetHouseRandomBits(TileIndex t)
 
static inline byte GetHouseRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return _m[t].m1;
 
	return t.m1();
 
}
 

	
 
/**
 
@@ -285,10 +285,10 @@ static inline byte GetHouseRandomBits(Ti
 
 * @param triggers the activated triggers
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseTriggers(TileIndex t, byte triggers)
 
static inline void SetHouseTriggers(Tile t, byte triggers)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(_m[t].m3, 0, 5, triggers);
 
	SB(t.m3(), 0, 5, triggers);
 
}
 

	
 
/**
 
@@ -298,10 +298,10 @@ static inline void SetHouseTriggers(Tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return triggers
 
 */
 
static inline byte GetHouseTriggers(TileIndex t)
 
static inline byte GetHouseTriggers(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return GB(_m[t].m3, 0, 5);
 
	return GB(t.m3(), 0, 5);
 
}
 

	
 
/**
 
@@ -310,10 +310,10 @@ static inline byte GetHouseTriggers(Tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return time remaining
 
 */
 
static inline byte GetHouseProcessingTime(TileIndex t)
 
static inline byte GetHouseProcessingTime(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return GB(_me[t].m6, 2, 6);
 
	return GB(t.m6(), 2, 6);
 
}
 

	
 
/**
 
@@ -322,10 +322,10 @@ static inline byte GetHouseProcessingTim
 
 * @param time the time to be set
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseProcessingTime(TileIndex t, byte time)
 
static inline void SetHouseProcessingTime(Tile t, byte time)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(_me[t].m6, 2, 6, time);
 
	SB(t.m6(), 2, 6, time);
 
}
 

	
 
/**
 
@@ -333,10 +333,10 @@ static inline void SetHouseProcessingTim
 
 * @param t the house tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void DecHouseProcessingTime(TileIndex t)
 
static inline void DecHouseProcessingTime(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	_me[t].m6 -= 1 << 2;
 
	t.m6() -= 1 << 2;
 
}
 

	
 
/**
 
@@ -349,17 +349,17 @@ static inline void DecHouseProcessingTim
 
 * @param random_bits required for newgrf houses
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void MakeHouseTile(TileIndex t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
 
static inline void MakeHouseTile(Tile t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 

	
 
	SetTileType(t, MP_HOUSE);
 
	_m[t].m1 = random_bits;
 
	_m[t].m2 = tid;
 
	_m[t].m3 = 0;
 
	t.m1() = random_bits;
 
	t.m2() = tid;
 
	t.m3() = 0;
 
	SetHouseType(t, type);
 
	SetHouseCompleted(t, stage == TOWN_HOUSE_COMPLETED);
 
	_m[t].m5 = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
 
	t.m5() = IsHouseCompleted(t) ? 0 : (stage << 3 | counter);
 
	SetAnimationFrame(t, 0);
 
	SetHouseProcessingTime(t, HouseSpec::Get(type)->processing_time);
 
}
src/tree_map.h
Show inline comments
 
@@ -70,10 +70,10 @@ enum TreeGround {
 
 * @return The treetype of the given tile with trees
 
 * @pre Tile t must be of type MP_TREES
 
 */
 
static inline TreeType GetTreeType(TileIndex t)
 
static inline TreeType GetTreeType(Tile t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return (TreeType)_m[t].m3;
 
	return (TreeType)t.m3();
 
}
 

	
 
/**
 
@@ -85,10 +85,10 @@ static inline TreeType GetTreeType(TileI
 
 * @return The groundtype of the tile
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline TreeGround GetTreeGround(TileIndex t)
 
static inline TreeGround GetTreeGround(Tile t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return (TreeGround)GB(_m[t].m2, 6, 3);
 
	return (TreeGround)GB(t.m2(), 6, 3);
 
}
 

	
 
/**
 
@@ -110,10 +110,10 @@ static inline TreeGround GetTreeGround(T
 
 * @pre Tile must be of type MP_TREES
 
 * @see GetTreeCount
 
 */
 
static inline uint GetTreeDensity(TileIndex t)
 
static inline uint GetTreeDensity(Tile t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return GB(_m[t].m2, 4, 2);
 
	return GB(t.m2(), 4, 2);
 
}
 

	
 
/**
 
@@ -127,11 +127,11 @@ static inline uint GetTreeDensity(TileIn
 
 * @param d The density to save with
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline void SetTreeGroundDensity(TileIndex t, TreeGround g, uint d)
 
static inline void SetTreeGroundDensity(Tile t, TreeGround g, uint d)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	SB(_m[t].m2, 4, 2, d);
 
	SB(_m[t].m2, 6, 3, g);
 
	SB(t.m2(), 4, 2, d);
 
	SB(t.m2(), 6, 3, g);
 
	SetWaterClass(t, g == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
 
}
 

	
 
@@ -146,10 +146,10 @@ static inline void SetTreeGroundDensity(
 
 * @return The number of trees (1-4)
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline uint GetTreeCount(TileIndex t)
 
static inline uint GetTreeCount(Tile t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return GB(_m[t].m5, 6, 2) + 1;
 
	return GB(t.m5(), 6, 2) + 1;
 
}
 

	
 
/**
 
@@ -163,10 +163,10 @@ static inline uint GetTreeCount(TileInde
 
 * @param c The value to add (or reduce) on the tree-count value
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline void AddTreeCount(TileIndex t, int c)
 
static inline void AddTreeCount(Tile t, int c)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	_m[t].m5 += c << 6;
 
	t.m5() += c << 6;
 
}
 

	
 
/**
 
@@ -178,10 +178,10 @@ static inline void AddTreeCount(TileInde
 
 * @return The tree growth status
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline uint GetTreeGrowth(TileIndex t)
 
static inline uint GetTreeGrowth(Tile t)
 
{
 
	assert(IsTileType(t, MP_TREES));
 
	return GB(_m[t].m5, 0, 3);
 
	return GB(t.m5(), 0, 3);
 
}
 

	
 
/**
 
@@ -193,10 +193,10 @@ static inline uint GetTreeGrowth(TileInd
 
 * @param a The value to add on the tree growth status
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline void AddTreeGrowth(TileIndex t, int a)
 
static inline void AddTreeGrowth(Tile t, int a)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	_m[t].m5 += a;
 
	t.m5() += a;
 
}
 

	
 
/**
 
@@ -209,10 +209,10 @@ static inline void AddTreeGrowth(TileInd
 
 * @param g The new value
 
 * @pre Tile must be of type MP_TREES
 
 */
 
static inline void SetTreeGrowth(TileIndex t, uint g)
 
static inline void SetTreeGrowth(Tile t, uint g)
 
{
 
	assert(IsTileType(t, MP_TREES)); // XXX incomplete
 
	SB(_m[t].m5, 0, 3, g);
 
	SB(t.m5(), 0, 3, g);
 
}
 

	
 
/**
 
@@ -227,17 +227,17 @@ static inline void SetTreeGrowth(TileInd
 
 * @param ground the ground type
 
 * @param density the density (not the number of trees)
 
 */
 
static inline void MakeTree(TileIndex t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
 
static inline void MakeTree(Tile t, TreeType type, uint count, uint growth, TreeGround ground, uint density)
 
{
 
	SetTileType(t, MP_TREES);
 
	SetTileOwner(t, OWNER_NONE);
 
	SetWaterClass(t, ground == TREE_GROUND_SHORE ? WATER_CLASS_SEA : WATER_CLASS_INVALID);
 
	_m[t].m2 = ground << 6 | density << 4 | 0;
 
	_m[t].m3 = type;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	_m[t].m5 = count << 6 | growth;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = ground << 6 | density << 4 | 0;
 
	t.m3() = type;
 
	t.m4() = 0 << 5 | 0 << 2;
 
	t.m5() = count << 6 | growth;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
#endif /* TREE_MAP_H */
src/tunnel_map.h
Show inline comments
 
@@ -20,10 +20,10 @@
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if and only if this tile is a tunnel (entrance)
 
 */
 
static inline bool IsTunnel(TileIndex t)
 
static inline bool IsTunnel(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return !HasBit(_m[t].m5, 7);
 
	return !HasBit(t.m5(), 7);
 
}
 

	
 
/**
 
@@ -31,7 +31,7 @@ static inline bool IsTunnel(TileIndex t)
 
 * @param t the tile that might be a tunnel
 
 * @return true if and only if this tile is a tunnel (entrance)
 
 */
 
static inline bool IsTunnelTile(TileIndex t)
 
static inline bool IsTunnelTile(Tile t)
 
{
 
	return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
 
}
 
@@ -47,17 +47,17 @@ bool IsTunnelInWayDir(TileIndex tile, in
 
 * @param d the direction facing out of the tunnel
 
 * @param r the road type used in the tunnel
 
 */
 
static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 
static inline void MakeRoadTunnel(Tile t, Owner o, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 
{
 
	SetTileType(t, MP_TUNNELBRIDGE);
 
	SetTileOwner(t, o);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = TRANSPORT_ROAD << 2 | d;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = TRANSPORT_ROAD << 2 | d;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	t.m8() = 0;
 
	SetRoadOwner(t, RTT_ROAD, o);
 
	if (o != OWNER_TOWN) SetRoadOwner(t, RTT_TRAM, o);
 
	SetRoadTypes(t, road_rt, tram_rt);
 
@@ -70,17 +70,17 @@ static inline void MakeRoadTunnel(TileIn
 
 * @param d the direction facing out of the tunnel
 
 * @param r the rail type used in the tunnel
 
 */
 
static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
 
static inline void MakeRailTunnel(Tile t, Owner o, DiagDirection d, RailType r)
 
{
 
	SetTileType(t, MP_TUNNELBRIDGE);
 
	SetTileOwner(t, o);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = TRANSPORT_RAIL << 2 | d;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	_me[t].m8 = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = TRANSPORT_RAIL << 2 | d;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
	t.m8() = 0;
 
	SetRailType(t, r);
 
	SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
 
}
src/tunnelbridge_map.h
Show inline comments
 
@@ -23,10 +23,10 @@
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return the above mentioned direction
 
 */
 
static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
 
static inline DiagDirection GetTunnelBridgeDirection(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return (DiagDirection)GB(_m[t].m5, 0, 2);
 
	return (DiagDirection)GB(t.m5(), 0, 2);
 
}
 

	
 
/**
 
@@ -36,10 +36,10 @@ static inline DiagDirection GetTunnelBri
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return the transport type in the tunnel/bridge
 
 */
 
static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
 
static inline TransportType GetTunnelBridgeTransportType(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return (TransportType)GB(_m[t].m5, 2, 2);
 
	return (TransportType)GB(t.m5(), 2, 2);
 
}
 

	
 
/**
 
@@ -49,10 +49,10 @@ static inline TransportType GetTunnelBri
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if and only if the tile is in a snowy/desert area
 
 */
 
static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
 
static inline bool HasTunnelBridgeSnowOrDesert(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return HasBit(_me[t].m7, 5);
 
	return HasBit(t.m7(), 5);
 
}
 

	
 
/**
 
@@ -63,10 +63,10 @@ static inline bool HasTunnelBridgeSnowOr
 
 *                       not in snow and not in desert false
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 */
 
static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
 
static inline void SetTunnelBridgeSnowOrDesert(Tile t, bool snow_or_desert)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	SB(_me[t].m7, 5, 1, snow_or_desert);
 
	SB(t.m7(), 5, 1, snow_or_desert);
 
}
 

	
 
/**
 
@@ -75,7 +75,7 @@ static inline void SetTunnelBridgeSnowOr
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return other end
 
 */
 
static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
 
static inline TileIndex GetOtherTunnelBridgeEnd(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
 
@@ -88,11 +88,11 @@ static inline TileIndex GetOtherTunnelBr
 
 * @param t the tile
 
 * @return reservation state
 
 */
 
static inline bool HasTunnelBridgeReservation(TileIndex t)
 
static inline bool HasTunnelBridgeReservation(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
 
	return HasBit(_m[t].m5, 4);
 
	return HasBit(t.m5(), 4);
 
}
 

	
 
/**
 
@@ -101,11 +101,11 @@ static inline bool HasTunnelBridgeReserv
 
 * @param t the tile
 
 * @param b the reservation state
 
 */
 
static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
 
static inline void SetTunnelBridgeReservation(Tile t, bool b)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
 
	SB(_m[t].m5, 4, 1, b ? 1 : 0);
 
	SB(t.m5(), 4, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
@@ -114,7 +114,7 @@ static inline void SetTunnelBridgeReserv
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
 
static inline TrackBits GetTunnelBridgeReservationTrackBits(Tile t)
 
{
 
	return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
 
}
src/void_map.h
Show inline comments
 
@@ -16,17 +16,17 @@
 
 * Make a nice void tile ;)
 
 * @param t the tile to make void
 
 */
 
static inline void MakeVoid(TileIndex t)
 
static inline void MakeVoid(Tile t)
 
{
 
	SetTileType(t, MP_VOID);
 
	SetTileHeight(t, 0);
 
	_m[t].m1 = 0;
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = 0;
 
	_me[t].m6 = 0;
 
	_me[t].m7 = 0;
 
	t.m1() = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = 0;
 
	t.m6() = 0;
 
	t.m7() = 0;
 
}
 

	
 
#endif /* VOID_MAP_H */
src/water_cmd.cpp
Show inline comments
 
@@ -158,7 +158,7 @@ CommandCost CmdBuildShipDepot(DoCommandF
 
	return cost;
 
}
 

	
 
bool IsPossibleDockingTile(TileIndex t)
 
bool IsPossibleDockingTile(Tile t)
 
{
 
	assert(IsValidTile(t));
 
	switch (GetTileType(t)) {
src/water_map.h
Show inline comments
 
@@ -78,19 +78,19 @@ enum LockPart {
 
	LOCK_PART_UPPER  = 2, ///< Upper part of a lock.
 
};
 

	
 
bool IsPossibleDockingTile(TileIndex t);
 
bool IsPossibleDockingTile(Tile t);
 

	
 
/**
 
 * Get the water tile type at a tile.
 
 * @param t Water tile to query.
 
 * @return Water tile type at the tile.
 
 */
 
static inline WaterTileType GetWaterTileType(TileIndex t)
 
static inline WaterTileType GetWaterTileType(Tile t)
 
{
 
	assert(IsTileType(t, MP_WATER));
 

	
 
	switch (GB(_m[t].m5, WBL_TYPE_BEGIN, WBL_TYPE_COUNT)) {
 
		case WBL_TYPE_NORMAL: return HasBit(_m[t].m5, WBL_COAST_FLAG) ? WATER_TILE_COAST : WATER_TILE_CLEAR;
 
	switch (GB(t.m5(), WBL_TYPE_BEGIN, WBL_TYPE_COUNT)) {
 
		case WBL_TYPE_NORMAL: return HasBit(t.m5(), WBL_COAST_FLAG) ? WATER_TILE_COAST : WATER_TILE_CLEAR;
 
		case WBL_TYPE_LOCK:   return WATER_TILE_LOCK;
 
		case WBL_TYPE_DEPOT:  return WATER_TILE_DEPOT;
 
		default: NOT_REACHED();
 
@@ -103,7 +103,7 @@ static inline WaterTileType GetWaterTile
 
 * @param t Tile to query.
 
 * @return True if the tiletype has a waterclass.
 
 */
 
static inline bool HasTileWaterClass(TileIndex t)
 
static inline bool HasTileWaterClass(Tile t)
 
{
 
	return IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_TREES);
 
}
 
@@ -114,10 +114,10 @@ static inline bool HasTileWaterClass(Til
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 * @return Water class at the tile.
 
 */
 
static inline WaterClass GetWaterClass(TileIndex t)
 
static inline WaterClass GetWaterClass(Tile t)
 
{
 
	assert(HasTileWaterClass(t));
 
	return (WaterClass)GB(_m[t].m1, 5, 2);
 
	return (WaterClass)GB(t.m1(), 5, 2);
 
}
 

	
 
/**
 
@@ -126,10 +126,10 @@ static inline WaterClass GetWaterClass(T
 
 * @param wc New water class.
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 */
 
static inline void SetWaterClass(TileIndex t, WaterClass wc)
 
static inline void SetWaterClass(Tile t, WaterClass wc)
 
{
 
	assert(HasTileWaterClass(t));
 
	SB(_m[t].m1, 5, 2, wc);
 
	SB(t.m1(), 5, 2, wc);
 
}
 

	
 
/**
 
@@ -138,7 +138,7 @@ static inline void SetWaterClass(TileInd
 
 * @pre IsTileType(t, MP_WATER) || IsTileType(t, MP_STATION) || IsTileType(t, MP_INDUSTRY) || IsTileType(t, MP_OBJECT)
 
 * @return true iff on water
 
 */
 
static inline bool IsTileOnWater(TileIndex t)
 
static inline bool IsTileOnWater(Tile t)
 
{
 
	return (GetWaterClass(t) != WATER_CLASS_INVALID);
 
}
 
@@ -149,7 +149,7 @@ static inline bool IsTileOnWater(TileInd
 
 * @return \c true if any type of clear water like ocean, river, or canal.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsWater(TileIndex t)
 
static inline bool IsWater(Tile t)
 
{
 
	return GetWaterTileType(t) == WATER_TILE_CLEAR;
 
}
 
@@ -160,7 +160,7 @@ static inline bool IsWater(TileIndex t)
 
 * @return \c true if it is a sea water tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsSea(TileIndex t)
 
static inline bool IsSea(Tile t)
 
{
 
	return IsWater(t) && GetWaterClass(t) == WATER_CLASS_SEA;
 
}
 
@@ -171,7 +171,7 @@ static inline bool IsSea(TileIndex t)
 
 * @return \c true if it is a canal tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsCanal(TileIndex t)
 
static inline bool IsCanal(Tile t)
 
{
 
	return IsWater(t) && GetWaterClass(t) == WATER_CLASS_CANAL;
 
}
 
@@ -182,7 +182,7 @@ static inline bool IsCanal(TileIndex t)
 
 * @return \c true if it is a river water tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsRiver(TileIndex t)
 
static inline bool IsRiver(Tile t)
 
{
 
	return IsWater(t) && GetWaterClass(t) == WATER_CLASS_RIVER;
 
}
 
@@ -192,7 +192,7 @@ static inline bool IsRiver(TileIndex t)
 
 * @param t Tile to query.
 
 * @return \c true if it is a plain water tile.
 
 */
 
static inline bool IsWaterTile(TileIndex t)
 
static inline bool IsWaterTile(Tile t)
 
{
 
	return IsTileType(t, MP_WATER) && IsWater(t);
 
}
 
@@ -203,7 +203,7 @@ static inline bool IsWaterTile(TileIndex
 
 * @return \c true if it is a sea water tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsCoast(TileIndex t)
 
static inline bool IsCoast(Tile t)
 
{
 
	return GetWaterTileType(t) == WATER_TILE_COAST;
 
}
 
@@ -213,7 +213,7 @@ static inline bool IsCoast(TileIndex t)
 
 * @param t Tile to query.
 
 * @return \c true if it is a coast.
 
 */
 
static inline bool IsCoastTile(TileIndex t)
 
static inline bool IsCoastTile(Tile t)
 
{
 
	return (IsTileType(t, MP_WATER) && IsCoast(t)) || (IsTileType(t, MP_TREES) && GetWaterClass(t) != WATER_CLASS_INVALID);
 
}
 
@@ -224,7 +224,7 @@ static inline bool IsCoastTile(TileIndex
 
 * @return \c true if it is a ship depot tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsShipDepot(TileIndex t)
 
static inline bool IsShipDepot(Tile t)
 
{
 
	return GetWaterTileType(t) == WATER_TILE_DEPOT;
 
}
 
@@ -234,7 +234,7 @@ static inline bool IsShipDepot(TileIndex
 
 * @param t Tile to query.
 
 * @return \c true if it is a ship depot tile.
 
 */
 
static inline bool IsShipDepotTile(TileIndex t)
 
static inline bool IsShipDepotTile(Tile t)
 
{
 
	return IsTileType(t, MP_WATER) && IsShipDepot(t);
 
}
 
@@ -245,10 +245,10 @@ static inline bool IsShipDepotTile(TileI
 
 * @return Axis of the depot.
 
 * @pre IsShipDepotTile(t)
 
 */
 
static inline Axis GetShipDepotAxis(TileIndex t)
 
static inline Axis GetShipDepotAxis(Tile t)
 
{
 
	assert(IsShipDepotTile(t));
 
	return (Axis)GB(_m[t].m5, WBL_DEPOT_AXIS, 1);
 
	return (Axis)GB(t.m5(), WBL_DEPOT_AXIS, 1);
 
}
 

	
 
/**
 
@@ -257,10 +257,10 @@ static inline Axis GetShipDepotAxis(Tile
 
 * @return Part of the depot.
 
 * @pre IsShipDepotTile(t)
 
 */
 
static inline DepotPart GetShipDepotPart(TileIndex t)
 
static inline DepotPart GetShipDepotPart(Tile t)
 
{
 
	assert(IsShipDepotTile(t));
 
	return (DepotPart)GB(_m[t].m5, WBL_DEPOT_PART, 1);
 
	return (DepotPart)GB(t.m5(), WBL_DEPOT_PART, 1);
 
}
 

	
 
/**
 
@@ -269,7 +269,7 @@ static inline DepotPart GetShipDepotPart
 
 * @return Direction of the depot.
 
 * @pre IsShipDepotTile(t)
 
 */
 
static inline DiagDirection GetShipDepotDirection(TileIndex t)
 
static inline DiagDirection GetShipDepotDirection(Tile t)
 
{
 
	return XYNSToDiagDir(GetShipDepotAxis(t), GetShipDepotPart(t));
 
}
 
@@ -280,9 +280,9 @@ static inline DiagDirection GetShipDepot
 
 * @return Tile containing the other section of the depot.
 
 * @pre IsShipDepotTile(t)
 
 */
 
static inline TileIndex GetOtherShipDepotTile(TileIndex t)
 
static inline TileIndex GetOtherShipDepotTile(Tile t)
 
{
 
	return t + (GetShipDepotPart(t) != DEPOT_PART_NORTH ? -1 : 1) * (GetShipDepotAxis(t) != AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
 
	return TileIndex(t) + (GetShipDepotPart(t) != DEPOT_PART_NORTH ? -1 : 1) * (GetShipDepotAxis(t) != AXIS_X ? TileDiffXY(0, 1) : TileDiffXY(1, 0));
 
}
 

	
 
/**
 
@@ -291,12 +291,12 @@ static inline TileIndex GetOtherShipDepo
 
 * @return The northern tile of the depot.
 
 * @pre IsShipDepotTile(t)
 
 */
 
static inline TileIndex GetShipDepotNorthTile(TileIndex t)
 
static inline TileIndex GetShipDepotNorthTile(Tile t)
 
{
 
	assert(IsShipDepot(t));
 
	TileIndex tile2 = GetOtherShipDepotTile(t);
 

	
 
	return t < tile2 ? t : tile2;
 
	return t < tile2 ? TileIndex(t) : tile2;
 
}
 

	
 
/**
 
@@ -305,7 +305,7 @@ static inline TileIndex GetShipDepotNort
 
 * @return \c true if it is a water lock tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline bool IsLock(TileIndex t)
 
static inline bool IsLock(Tile t)
 
{
 
	return GetWaterTileType(t) == WATER_TILE_LOCK;
 
}
 
@@ -316,10 +316,10 @@ static inline bool IsLock(TileIndex t)
 
 * @return Direction of the lock.
 
 * @pre IsTileType(t, MP_WATER) && IsLock(t)
 
 */
 
static inline DiagDirection GetLockDirection(TileIndex t)
 
static inline DiagDirection GetLockDirection(Tile t)
 
{
 
	assert(IsLock(t));
 
	return (DiagDirection)GB(_m[t].m5, WBL_LOCK_ORIENT_BEGIN, WBL_LOCK_ORIENT_COUNT);
 
	return (DiagDirection)GB(t.m5(), WBL_LOCK_ORIENT_BEGIN, WBL_LOCK_ORIENT_COUNT);
 
}
 

	
 
/**
 
@@ -328,10 +328,10 @@ static inline DiagDirection GetLockDirec
 
 * @return The part.
 
 * @pre IsTileType(t, MP_WATER) && IsLock(t)
 
 */
 
static inline byte GetLockPart(TileIndex t)
 
static inline byte GetLockPart(Tile t)
 
{
 
	assert(IsLock(t));
 
	return GB(_m[t].m5, WBL_LOCK_PART_BEGIN, WBL_LOCK_PART_COUNT);
 
	return GB(t.m5(), WBL_LOCK_PART_BEGIN, WBL_LOCK_PART_COUNT);
 
}
 

	
 
/**
 
@@ -340,10 +340,10 @@ static inline byte GetLockPart(TileIndex
 
 * @return Random bits of the tile.
 
 * @pre IsTileType(t, MP_WATER)
 
 */
 
static inline byte GetWaterTileRandomBits(TileIndex t)
 
static inline byte GetWaterTileRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_WATER));
 
	return _m[t].m4;
 
	return t.m4();
 
}
 

	
 
/**
 
@@ -352,7 +352,7 @@ static inline byte GetWaterTileRandomBit
 
 * @return true iff the tile has water at the ground.
 
 * @note Coast tiles are not considered waterish, even if there is water on a halftile.
 
 */
 
static inline bool HasTileWaterGround(TileIndex t)
 
static inline bool HasTileWaterGround(Tile t)
 
{
 
	return HasTileWaterClass(t) && IsTileOnWater(t) && !IsCoastTile(t);
 
}
 
@@ -363,19 +363,19 @@ static inline bool HasTileWaterGround(Ti
 
 * @param t the tile
 
 * @param b the docking tile state
 
 */
 
static inline void SetDockingTile(TileIndex t, bool b)
 
static inline void SetDockingTile(Tile t, bool b)
 
{
 
	assert(IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
 
	SB(_m[t].m1, 7, 1, b ? 1 : 0);
 
	SB(t.m1(), 7, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Checks whether the tile is marked as a dockling tile.
 
 * @return true iff the tile is marked as a docking tile.
 
 */
 
static inline bool IsDockingTile(TileIndex t)
 
static inline bool IsDockingTile(Tile t)
 
{
 
	return (IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE)) && HasBit(_m[t].m1, 7);
 
	return (IsTileType(t, MP_WATER) || IsTileType(t, MP_RAILWAY) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE)) && HasBit(t.m1(), 7);
 
}
 

	
 

	
 
@@ -383,18 +383,18 @@ static inline bool IsDockingTile(TileInd
 
 * Helper function to make a coast tile.
 
 * @param t The tile to change into water
 
 */
 
static inline void MakeShore(TileIndex t)
 
static inline void MakeShore(Tile t)
 
{
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, OWNER_WATER);
 
	SetWaterClass(t, WATER_CLASS_SEA);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = WBL_TYPE_NORMAL << WBL_TYPE_BEGIN | 1 << WBL_COAST_FLAG;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = WBL_TYPE_NORMAL << WBL_TYPE_BEGIN | 1 << WBL_COAST_FLAG;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
/**
 
@@ -404,25 +404,25 @@ static inline void MakeShore(TileIndex t
 
 * @param wc The class of water the tile has to be
 
 * @param random_bits Eventual random bits to be set for this tile
 
 */
 
static inline void MakeWater(TileIndex t, Owner o, WaterClass wc, uint8 random_bits)
 
static inline void MakeWater(Tile t, Owner o, WaterClass wc, uint8 random_bits)
 
{
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, wc);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = random_bits;
 
	_m[t].m5 = WBL_TYPE_NORMAL << WBL_TYPE_BEGIN;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = random_bits;
 
	t.m5() = WBL_TYPE_NORMAL << WBL_TYPE_BEGIN;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
/**
 
 * Make a sea tile.
 
 * @param t The tile to change into sea
 
 */
 
static inline void MakeSea(TileIndex t)
 
static inline void MakeSea(Tile t)
 
{
 
	MakeWater(t, OWNER_WATER, WATER_CLASS_SEA, 0);
 
}
 
@@ -432,7 +432,7 @@ static inline void MakeSea(TileIndex t)
 
 * @param t The tile to change into river
 
 * @param random_bits Random bits to be set for this tile
 
 */
 
static inline void MakeRiver(TileIndex t, uint8 random_bits)
 
static inline void MakeRiver(Tile t, uint8 random_bits)
 
{
 
	MakeWater(t, OWNER_WATER, WATER_CLASS_RIVER, random_bits);
 
}
 
@@ -443,7 +443,7 @@ static inline void MakeRiver(TileIndex t
 
 * @param o The owner of the canal
 
 * @param random_bits Random bits to be set for this tile
 
 */
 
static inline void MakeCanal(TileIndex t, Owner o, uint8 random_bits)
 
static inline void MakeCanal(Tile t, Owner o, uint8 random_bits)
 
{
 
	assert(o != OWNER_WATER);
 
	MakeWater(t, o, WATER_CLASS_CANAL, random_bits);
 
@@ -458,18 +458,18 @@ static inline void MakeCanal(TileIndex t
 
 * @param a    Axis of the depot.
 
 * @param original_water_class Original water class.
 
 */
 
static inline void MakeShipDepot(TileIndex t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class)
 
static inline void MakeShipDepot(Tile t, Owner o, DepotID did, DepotPart part, Axis a, WaterClass original_water_class)
 
{
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, original_water_class);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = did;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = WBL_TYPE_DEPOT << WBL_TYPE_BEGIN | part << WBL_DEPOT_PART | a << WBL_DEPOT_AXIS;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = did;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = WBL_TYPE_DEPOT << WBL_TYPE_BEGIN | part << WBL_DEPOT_PART | a << WBL_DEPOT_AXIS;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
/**
 
@@ -481,18 +481,18 @@ static inline void MakeShipDepot(TileInd
 
 * @param original_water_class Original water class.
 
 * @see MakeLock
 
 */
 
static inline void MakeLockTile(TileIndex t, Owner o, LockPart part, DiagDirection dir, WaterClass original_water_class)
 
static inline void MakeLockTile(Tile t, Owner o, LockPart part, DiagDirection dir, WaterClass original_water_class)
 
{
 
	SetTileType(t, MP_WATER);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, original_water_class);
 
	SetDockingTile(t, false);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0;
 
	_m[t].m5 = WBL_TYPE_LOCK << WBL_TYPE_BEGIN | part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
 
	SB(_me[t].m6, 2, 4, 0);
 
	_me[t].m7 = 0;
 
	t.m2() = 0;
 
	t.m3() = 0;
 
	t.m4() = 0;
 
	t.m5() = WBL_TYPE_LOCK << WBL_TYPE_BEGIN | part << WBL_LOCK_PART_BEGIN | dir << WBL_LOCK_ORIENT_BEGIN;
 
	SB(t.m6(), 2, 4, 0);
 
	t.m7() = 0;
 
}
 

	
 
/**
 
@@ -504,15 +504,17 @@ static inline void MakeLockTile(TileInde
 
 * @param wc_upper Original water class of the upper part.
 
 * @param wc_middle Original water class of the middle part.
 
 */
 
static inline void MakeLock(TileIndex t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle)
 
static inline void MakeLock(Tile t, Owner o, DiagDirection d, WaterClass wc_lower, WaterClass wc_upper, WaterClass wc_middle)
 
{
 
	TileIndexDiff delta = TileOffsByDiagDir(d);
 
	Tile lower_tile = TileIndex(t) - delta;
 
	Tile upper_tile = TileIndex(t) + delta;
 

	
 
	/* Keep the current waterclass and owner for the tiles.
 
	 * It allows to restore them after the lock is deleted */
 
	MakeLockTile(t, o, LOCK_PART_MIDDLE, d, wc_middle);
 
	MakeLockTile(t - delta, IsWaterTile(t - delta) ? GetTileOwner(t - delta) : o, LOCK_PART_LOWER, d, wc_lower);
 
	MakeLockTile(t + delta, IsWaterTile(t + delta) ? GetTileOwner(t + delta) : o, LOCK_PART_UPPER, d, wc_upper);
 
	MakeLockTile(lower_tile, IsWaterTile(lower_tile) ? GetTileOwner(lower_tile) : o, LOCK_PART_LOWER, d, wc_lower);
 
	MakeLockTile(upper_tile, IsWaterTile(upper_tile) ? GetTileOwner(upper_tile) : o, LOCK_PART_UPPER, d, wc_upper);
 
}
 

	
 
#endif /* WATER_MAP_H */
0 comments (0 inline, 0 general)