Changeset - r28410:d9c73d685bbc
[Not reviewed]
master
! ! !
Rubidium - 11 months ago 2024-01-06 11:19:27
rubidium@openttd.org
Codechange: replace static inline with static for non-class functions
72 files changed:
src/rail.h
10
10
src/road.h
10
10
Changeset was too big and was cut off... Show full diff anyway
0 comments (0 inline, 0 general)
src/3rdparty/squirrel/include/squirrel.h
Show inline comments
 
@@ -235,13 +235,13 @@ SQUserPointer sq_newuserdata(HSQUIRRELVM
 
void sq_newtable(HSQUIRRELVM v);
 
void sq_newarray(HSQUIRRELVM v,SQInteger size);
 
void sq_newclosure(HSQUIRRELVM v,SQFUNCTION func,SQUnsignedInteger nfreevars);
 
SQRESULT sq_setparamscheck(HSQUIRRELVM v,SQInteger nparamscheck,const SQChar *typemask);
 
SQRESULT sq_bindenv(HSQUIRRELVM v,SQInteger idx);
 
void sq_pushstring(HSQUIRRELVM v,const SQChar *s,SQInteger len);
 
static inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
 
inline void sq_pushstring(HSQUIRRELVM v, const std::string &str, SQInteger len = -1) { sq_pushstring(v, str.data(), len == -1 ? str.size() : len); }
 
void sq_pushfloat(HSQUIRRELVM v,SQFloat f);
 
void sq_pushinteger(HSQUIRRELVM v,SQInteger n);
 
void sq_pushbool(HSQUIRRELVM v,SQBool b);
 
void sq_pushuserpointer(HSQUIRRELVM v,SQUserPointer p);
 
void sq_pushnull(HSQUIRRELVM v);
 
SQObjectType sq_gettype(HSQUIRRELVM v,SQInteger idx);
 
@@ -305,13 +305,13 @@ SQRESULT sq_clear(HSQUIRRELVM v,SQIntege
 
/*calls*/
 
SQRESULT sq_call(HSQUIRRELVM v,SQInteger params,SQBool retval,SQBool raiseerror, int suspend = -1);
 
SQRESULT sq_resume(HSQUIRRELVM v,SQBool retval,SQBool raiseerror);
 
const SQChar *sq_getlocal(HSQUIRRELVM v,SQUnsignedInteger level,SQUnsignedInteger idx);
 
const SQChar *sq_getfreevariable(HSQUIRRELVM v,SQInteger idx,SQUnsignedInteger nval);
 
SQRESULT sq_throwerror(HSQUIRRELVM v,const SQChar *err, SQInteger len = -1);
 
static inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
 
inline SQRESULT sq_throwerror(HSQUIRRELVM v, const std::string_view err) { return sq_throwerror(v, err.data(), err.size()); }
 
void sq_reseterror(HSQUIRRELVM v);
 
void sq_getlasterror(HSQUIRRELVM v);
 

	
 
/*raw object handling*/
 
SQRESULT sq_getstackobj(HSQUIRRELVM v,SQInteger idx,HSQOBJECT *po);
 
void sq_pushobject(HSQUIRRELVM v,HSQOBJECT obj);
src/autoreplace_func.h
Show inline comments
 
@@ -19,13 +19,13 @@ CommandCost AddEngineReplacement(EngineR
 
CommandCost RemoveEngineReplacement(EngineRenewList *erl, EngineID engine, GroupID group, DoCommandFlag flags);
 

	
 
/**
 
 * Remove all engine replacement settings for the given company.
 
 * @param c the company.
 
 */
 
static inline void RemoveAllEngineReplacementForCompany(Company *c)
 
inline void RemoveAllEngineReplacementForCompany(Company *c)
 
{
 
	RemoveAllEngineReplacement(&c->engine_renew_list);
 
}
 

	
 
/**
 
 * Retrieve the engine replacement for the given company and original engine type.
 
@@ -33,37 +33,37 @@ static inline void RemoveAllEngineReplac
 
 * @param engine Engine type.
 
 * @param group The group related to this replacement.
 
 * @param[out] replace_when_old Set to true if the replacement should be done when old.
 
 * @return The engine type to replace with, or INVALID_ENGINE if no
 
 * replacement is in the list.
 
 */
 
static inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
 
inline EngineID EngineReplacementForCompany(const Company *c, EngineID engine, GroupID group, bool *replace_when_old = nullptr)
 
{
 
	return EngineReplacement(c->engine_renew_list, engine, group, replace_when_old);
 
}
 

	
 
/**
 
 * Check if a company has a replacement set up for the given engine.
 
 * @param c Company.
 
 * @param engine Engine type to be replaced.
 
 * @param group The group related to this replacement.
 
 * @return true if a replacement was set up, false otherwise.
 
 */
 
static inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
 
inline bool EngineHasReplacementForCompany(const Company *c, EngineID engine, GroupID group)
 
{
 
	return EngineReplacementForCompany(c, engine, group) != INVALID_ENGINE;
 
}
 

	
 
/**
 
 * Check if a company has a replacement set up for the given engine when it gets old.
 
 * @param c Company.
 
 * @param engine Engine type to be replaced.
 
 * @param group The group related to this replacement.
 
 * @return True if a replacement when old was set up, false otherwise.
 
 */
 
static inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
 
inline bool EngineHasReplacementWhenOldForCompany(const Company *c, EngineID engine, GroupID group)
 
{
 
	bool replace_when_old;
 
	EngineReplacement(c->engine_renew_list, engine, group, &replace_when_old);
 
	return replace_when_old;
 
}
 

	
 
@@ -74,26 +74,26 @@ static inline bool EngineHasReplacementW
 
 * @param new_engine The replacement engine type.
 
 * @param group The group related to this replacement.
 
 * @param replace_when_old Replace when old or always?
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
static inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
 
inline CommandCost AddEngineReplacementForCompany(Company *c, EngineID old_engine, EngineID new_engine, GroupID group, bool replace_when_old, DoCommandFlag flags)
 
{
 
	return AddEngineReplacement(&c->engine_renew_list, old_engine, new_engine, group, replace_when_old, flags);
 
}
 

	
 
/**
 
 * Remove an engine replacement for the company.
 
 * @param c Company.
 
 * @param engine The original engine type.
 
 * @param group The group related to this replacement.
 
 * @param flags The calling command flags.
 
 * @return 0 on success, CMD_ERROR on failure.
 
 */
 
static inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
 
inline CommandCost RemoveEngineReplacementForCompany(Company *c, EngineID engine, GroupID group, DoCommandFlag flags)
 
{
 
	return RemoveEngineReplacement(&c->engine_renew_list, engine, group, flags);
 
}
 

	
 
bool CheckAutoreplaceValidity(EngineID from, EngineID to, CompanyID company);
 

	
src/autoslope.h
Show inline comments
 
@@ -25,26 +25,26 @@
 
 * @param tile The tile.
 
 * @param z_new New TileZ.
 
 * @param tileh_new New TileSlope.
 
 * @param entrance Entrance edge.
 
 * @return true iff terraforming is allowed.
 
 */
 
static inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
 
inline bool AutoslopeCheckForEntranceEdge(TileIndex tile, int z_new, Slope tileh_new, DiagDirection entrance)
 
{
 
	if (GetTileMaxZ(tile) != z_new + GetSlopeMaxZ(tileh_new)) return false;
 
	return ((tileh_new == SLOPE_FLAT) || CanBuildDepotByTileh(entrance, tileh_new));
 
}
 

	
 
/**
 
 * Tests if autoslope is enabled for _current_company.
 
 *
 
 * Autoslope is disabled for town/industry construction.
 
 *
 
 * @return true iff autoslope is enabled.
 
 */
 
static inline bool AutoslopeEnabled()
 
inline bool AutoslopeEnabled()
 
{
 
	return (_settings_game.construction.autoslope &&
 
	        (_current_company < MAX_COMPANIES ||
 
	         (_current_company == OWNER_NONE && _game_mode == GM_EDITOR)));
 
}
 

	
src/blitter/32bpp_sse_func.hpp
Show inline comments
 
@@ -10,35 +10,35 @@
 
#ifndef BLITTER_32BPP_SSE_FUNC_HPP
 
#define BLITTER_32BPP_SSE_FUNC_HPP
 

	
 
#ifdef WITH_SSE
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void InsertFirstUint32(const uint32_t value, __m128i &into)
 
inline void InsertFirstUint32(const uint32_t value, __m128i &into)
 
{
 
#if (SSE_VERSION >= 4)
 
	into = _mm_insert_epi32(into, value, 0);
 
#else
 
	into = _mm_insert_epi16(into, value, 0);
 
	into = _mm_insert_epi16(into, value >> 16, 1);
 
#endif
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void InsertSecondUint32(const uint32_t value, __m128i &into)
 
inline void InsertSecondUint32(const uint32_t value, __m128i &into)
 
{
 
#if (SSE_VERSION >= 4)
 
	into = _mm_insert_epi32(into, value, 1);
 
#else
 
	into = _mm_insert_epi16(into, value, 2);
 
	into = _mm_insert_epi16(into, value >> 16, 3);
 
#endif
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline void LoadUint64(const uint64_t value, __m128i &into)
 
inline void LoadUint64(const uint64_t value, __m128i &into)
 
{
 
#ifdef POINTER_IS_64BIT
 
	into = _mm_cvtsi64_si128(value);
 
#else
 
	#if (SSE_VERSION >= 4)
 
		into = _mm_cvtsi32_si128(value);
 
@@ -47,36 +47,36 @@ static inline void LoadUint64(const uint
 
		(*(um128i*) &into).m128i_u64[0] = value;
 
	#endif
 
#endif
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
 
inline __m128i PackUnsaturated(__m128i from, const __m128i &mask)
 
{
 
#if (SSE_VERSION == 2)
 
	from = _mm_and_si128(from, mask);    // PAND, wipe high bytes to keep low bytes when packing
 
	return _mm_packus_epi16(from, from); // PACKUSWB, pack 2 colours (with saturation)
 
#else
 
	return _mm_shuffle_epi8(from, mask);
 
#endif
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
 
inline __m128i DistributeAlpha(const __m128i from, const __m128i &mask)
 
{
 
#if (SSE_VERSION == 2)
 
	__m128i alphaAB = _mm_shufflelo_epi16(from, 0x3F); // PSHUFLW, put alpha1 in front of each rgb1
 
	alphaAB = _mm_shufflehi_epi16(alphaAB, 0x3F);      // PSHUFHW, put alpha2 in front of each rgb2
 
	return _mm_andnot_si128(mask, alphaAB);            // PANDN, set alpha fields to 0
 
#else
 
	return _mm_shuffle_epi8(from, mask);
 
#endif
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
 
inline __m128i AlphaBlendTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &pack_mask, const __m128i &alpha_mask)
 
{
 
	__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());   // PUNPCKLBW, expand each uint8_t into uint16
 
	__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
 

	
 
	__m128i alphaMaskAB = _mm_cmpgt_epi16(srcAB, _mm_setzero_si128()); // PCMPGTW (alpha > 0) ? 0xFFFF : 0
 
	__m128i alphaAB = _mm_sub_epi16(srcAB, alphaMaskAB);               // if (alpha > 0) a++;
 
@@ -94,13 +94,13 @@ static inline __m128i AlphaBlendTwoPixel
 
}
 

	
 
/* Darken 2 pixels.
 
 * rgb = rgb * ((256/4) * 4 - (alpha/4)) / ((256/4) * 4)
 
 */
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
 
inline __m128i DarkenTwoPixels(__m128i src, __m128i dst, const __m128i &distribution_mask, const __m128i &tr_nom_base)
 
{
 
	__m128i srcAB = _mm_unpacklo_epi8(src, _mm_setzero_si128());
 
	__m128i dstAB = _mm_unpacklo_epi8(dst, _mm_setzero_si128());
 
	__m128i alphaAB = DistributeAlpha(srcAB, distribution_mask);
 
	alphaAB = _mm_srli_epi16(alphaAB, 2); // Reduce to 64 levels of shades so the max value fits in 16 bits.
 
	__m128i nom = _mm_sub_epi16(tr_nom_base, alphaAB);
 
@@ -142,22 +142,22 @@ static Colour ReallyAdjustBrightness(Col
 
}
 
IGNORE_UNINITIALIZED_WARNING_STOP
 

	
 
/** ReallyAdjustBrightness() is not called that often.
 
 * Inlining this function implies a far jump, which has a huge latency.
 
 */
 
static inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
 
inline Colour AdjustBrightneSSE(Colour colour, uint8_t brightness)
 
{
 
	/* Shortcut for normal brightness. */
 
	if (brightness == Blitter_32bppBase::DEFAULT_BRIGHTNESS) return colour;
 

	
 
	return ReallyAdjustBrightness(colour, brightness);
 
}
 

	
 
GNU_TARGET(SSE_TARGET)
 
static inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
 
inline __m128i AdjustBrightnessOfTwoPixels([[maybe_unused]] __m128i from, [[maybe_unused]] uint32_t brightness)
 
{
 
#if (SSE_VERSION < 3)
 
	NOT_REACHED();
 
#else
 
	/* The following dataflow differs from the one of AdjustBrightness() only for alpha.
 
	 * In order to keep alpha in colAB, insert a 1 in a unused brightness byte (a*1->a).
src/bridge.h
Show inline comments
 
@@ -60,13 +60,13 @@ bool HasBridgeFlatRamp(Slope tileh, Axis
 

	
 
/**
 
 * Get the specification of a bridge type.
 
 * @param i The type of bridge to get the specification for.
 
 * @return The specification.
 
 */
 
static inline const BridgeSpec *GetBridgeSpec(BridgeType i)
 
inline const BridgeSpec *GetBridgeSpec(BridgeType i)
 
{
 
	assert(i < lengthof(_bridge));
 
	return &_bridge[i];
 
}
 

	
 
void DrawBridgeMiddle(const TileInfo *ti);
src/bridge_map.h
Show inline comments
 
@@ -18,57 +18,57 @@
 
/**
 
 * Checks if this is a bridge, instead of a tunnel
 
 * @param t The tile to analyze
 
 * @pre IsTileType(t, MP_TUNNELBRIDGE)
 
 * @return true if the structure is a bridge one
 
 */
 
static inline bool IsBridge(Tile t)
 
inline bool IsBridge(Tile t)
 
{
 
	assert(IsTileType(t, MP_TUNNELBRIDGE));
 
	return HasBit(t.m5(), 7);
 
}
 

	
 
/**
 
 * checks if there is a bridge on this tile
 
 * @param t The tile to analyze
 
 * @return true if a bridge is present
 
 */
 
static inline bool IsBridgeTile(Tile t)
 
inline bool IsBridgeTile(Tile t)
 
{
 
	return IsTileType(t, MP_TUNNELBRIDGE) && IsBridge(t);
 
}
 

	
 
/**
 
 * checks if a bridge is set above the ground of this tile
 
 * @param t The tile to analyze
 
 * @return true if a bridge is detected above
 
 */
 
static inline bool IsBridgeAbove(Tile t)
 
inline bool IsBridgeAbove(Tile t)
 
{
 
	return GB(t.type(), 2, 2) != 0;
 
}
 

	
 
/**
 
 * Determines the type of bridge on a tile
 
 * @param t The tile to analyze
 
 * @pre IsBridgeTile(t)
 
 * @return The bridge type
 
 */
 
static inline BridgeType GetBridgeType(Tile t)
 
inline BridgeType GetBridgeType(Tile t)
 
{
 
	assert(IsBridgeTile(t));
 
	return GB(t.m6(), 2, 4);
 
}
 

	
 
/**
 
 * Get the axis of the bridge that goes over the tile. Not the axis or the ramp.
 
 * @param t The tile to analyze
 
 * @pre IsBridgeAbove(t)
 
 * @return the above mentioned axis
 
 */
 
static inline Axis GetBridgeAxis(Tile t)
 
inline Axis GetBridgeAxis(Tile t)
 
{
 
	assert(IsBridgeAbove(t));
 
	return (Axis)(GB(t.type(), 2, 2) - 1);
 
}
 

	
 
TileIndex GetNorthernBridgeEnd(TileIndex t);
 
@@ -78,43 +78,43 @@ TileIndex GetOtherBridgeEnd(TileIndex t)
 
int GetBridgeHeight(TileIndex tile);
 
/**
 
 * Get the height ('z') of a bridge in pixels.
 
 * @param tile the bridge ramp tile to get the bridge height from
 
 * @return the height of the bridge in pixels
 
 */
 
static inline int GetBridgePixelHeight(TileIndex tile)
 
inline int GetBridgePixelHeight(TileIndex tile)
 
{
 
	return GetBridgeHeight(tile) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Remove the bridge over the given axis.
 
 * @param t the tile to remove the bridge from
 
 * @param a the axis of the bridge to remove
 
 */
 
static inline void ClearSingleBridgeMiddle(Tile t, Axis a)
 
inline void ClearSingleBridgeMiddle(Tile t, Axis 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(Tile t)
 
inline void ClearBridgeMiddle(Tile t)
 
{
 
	ClearSingleBridgeMiddle(t, AXIS_X);
 
	ClearSingleBridgeMiddle(t, AXIS_Y);
 
}
 

	
 
/**
 
 * Set that there is a bridge over the given axis.
 
 * @param t the tile to add the bridge to
 
 * @param a the axis of the bridge to add
 
 */
 
static inline void SetBridgeMiddle(Tile t, Axis a)
 
inline void SetBridgeMiddle(Tile t, Axis a)
 
{
 
	SetBit(t.type(), 2 + a);
 
}
 

	
 
/**
 
 * Generic part to make a bridge ramp for both roads and rails.
 
@@ -122,13 +122,13 @@ static inline void SetBridgeMiddle(Tile 
 
 * @param o          the new owner of the bridge ramp
 
 * @param bridgetype the type of bridge this bridge ramp belongs to
 
 * @param d          the direction this ramp must be facing
 
 * @param tt         the transport type of the bridge
 
 * @note this function should not be called directly.
 
 */
 
static inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
 
inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, TransportType tt)
 
{
 
	SetTileType(t, MP_TUNNELBRIDGE);
 
	SetTileOwner(t, o);
 
	SetDockingTile(t, false);
 
	t.m2() = 0;
 
	t.m3() = 0;
 
@@ -147,13 +147,13 @@ static inline void MakeBridgeRamp(Tile t
 
 * @param owner_tram the new owner of the tram on the bridge
 
 * @param bridgetype the type of bridge this bridge ramp belongs to
 
 * @param d          the direction this ramp must be facing
 
 * @param road_rt    the road type of the bridge
 
 * @param tram_rt    the tram type of the bridge
 
 */
 
static inline void MakeRoadBridgeRamp(Tile t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadType road_rt, RoadType tram_rt)
 
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);
 
	if (owner_tram != OWNER_TOWN) SetRoadOwner(t, RTT_TRAM, owner_tram);
 
	SetRoadTypes(t, road_rt, tram_rt);
 
}
 
@@ -163,24 +163,24 @@ static inline void MakeRoadBridgeRamp(Ti
 
 * @param t          the tile to make a bridge ramp
 
 * @param o          the new owner of the bridge ramp
 
 * @param bridgetype the type of bridge this bridge ramp belongs to
 
 * @param d          the direction this ramp must be facing
 
 * @param rt         the rail type of the bridge
 
 */
 
static inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
 
inline void MakeRailBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection d, RailType rt)
 
{
 
	MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_RAIL);
 
	SetRailType(t, rt);
 
}
 

	
 
/**
 
 * Make a bridge ramp for aqueducts.
 
 * @param t          the tile to make a bridge ramp
 
 * @param o          the new owner of the bridge ramp
 
 * @param d          the direction this ramp must be facing
 
 */
 
static inline void MakeAqueductBridgeRamp(Tile t, Owner o, DiagDirection d)
 
inline void MakeAqueductBridgeRamp(Tile t, Owner o, DiagDirection d)
 
{
 
	MakeBridgeRamp(t, o, 0, d, TRANSPORT_WATER);
 
}
 

	
 
#endif /* BRIDGE_MAP_H */
src/cargomonitor.h
Show inline comments
 
@@ -55,13 +55,13 @@ static_assert(MAX_COMPANIES <= (1 << CCB
 
 * Encode a cargo monitor for pickup or delivery at an industry.
 
 * @param company Company performing the transport.
 
 * @param ctype Cargo type being transported.
 
 * @param ind %Industry providing or accepting the cargo.
 
 * @return The encoded cargo/company/industry number.
 
 */
 
static inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
 
inline CargoMonitorID EncodeCargoIndustryMonitor(CompanyID company, CargoID ctype, IndustryID ind)
 
{
 
	assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
 
	assert(company < (1 << CCB_COMPANY_LENGTH));
 

	
 
	uint32_t ret = 0;
 
	SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, ind);
 
@@ -75,13 +75,13 @@ static inline CargoMonitorID EncodeCargo
 
 * Encode a cargo monitoring number for pickup or delivery at a town.
 
 * @param company %Company performing the transport.
 
 * @param ctype Cargo type being transported.
 
 * @param town %Town providing or accepting the cargo.
 
 * @return The encoded cargo/company/town number.
 
 */
 
static inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
 
inline CargoMonitorID EncodeCargoTownMonitor(CompanyID company, CargoID ctype, TownID town)
 
{
 
	assert(ctype < (1 << CCB_CARGO_TYPE_LENGTH));
 
	assert(company < (1 << CCB_COMPANY_LENGTH));
 

	
 
	uint32_t ret = 0;
 
	SB(ret, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH, town);
 
@@ -92,54 +92,54 @@ static inline CargoMonitorID EncodeCargo
 

	
 
/**
 
 * Extract the company from the cargo monitor.
 
 * @param num Cargo monitoring number to decode.
 
 * @return The extracted company id.
 
 */
 
static inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
 
inline CompanyID DecodeMonitorCompany(CargoMonitorID num)
 
{
 
	return static_cast<CompanyID>(GB(num, CCB_COMPANY_START, CCB_COMPANY_LENGTH));
 
}
 

	
 
/**
 
 * Extract the cargo type from the cargo monitor.
 
 * @param num Cargo monitoring number to decode.
 
 * @return The extracted cargo type.
 
 */
 
static inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
 
inline CargoID DecodeMonitorCargoType(CargoMonitorID num)
 
{
 
	return GB(num, CCB_CARGO_TYPE_START, CCB_CARGO_TYPE_LENGTH);
 
}
 

	
 
/**
 
 * Does the cargo number monitor an industry or a town?
 
 * @param num Cargo monitoring number to decode.
 
 * @return true if monitoring an industry, false if monitoring a town.
 
 */
 
static inline bool MonitorMonitorsIndustry(CargoMonitorID num)
 
inline bool MonitorMonitorsIndustry(CargoMonitorID num)
 
{
 
	return HasBit(num, CCB_IS_INDUSTRY_BIT);
 
}
 

	
 
/**
 
 * Extract the industry number from the cargo monitor.
 
 * @param num Cargo monitoring number to decode.
 
 * @return The extracted industry id, or #INVALID_INDUSTRY if the number does not monitor an industry.
 
 */
 
static inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
 
inline IndustryID DecodeMonitorIndustry(CargoMonitorID num)
 
{
 
	if (!MonitorMonitorsIndustry(num)) return INVALID_INDUSTRY;
 
	return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
 
}
 

	
 
/**
 
 * Extract the town number from the cargo monitor.
 
 * @param num Cargo monitoring number to decode.
 
 * @return The extracted town id, or #INVALID_TOWN if the number does not monitor a town.
 
 */
 
static inline TownID DecodeMonitorTown(CargoMonitorID num)
 
inline TownID DecodeMonitorTown(CargoMonitorID num)
 
{
 
	if (MonitorMonitorsIndustry(num)) return INVALID_TOWN;
 
	return GB(num, CCB_TOWN_IND_NUMBER_START, CCB_TOWN_IND_NUMBER_LENGTH);
 
}
 

	
 
void ClearCargoPickupMonitoring(CompanyID company = INVALID_OWNER);
src/cargotype.h
Show inline comments
 
@@ -195,13 +195,13 @@ extern span<const CargoSpec *> _sorted_s
 
/**
 
 * Does cargo \a c have cargo class \a cc?
 
 * @param c  Cargo type.
 
 * @param cc Cargo class.
 
 * @return The type fits in the class.
 
 */
 
static inline bool IsCargoInClass(CargoID c, CargoClass cc)
 
inline bool IsCargoInClass(CargoID c, CargoClass cc)
 
{
 
	return (CargoSpec::Get(c)->classes & cc) != 0;
 
}
 

	
 
using SetCargoBitIterator = SetBitIterator<CargoID, CargoTypes>;
 

	
src/clear_map.h
Show inline comments
 
@@ -29,122 +29,122 @@ enum ClearGround {
 
/**
 
 * Test if a tile is covered with snow.
 
 * @param t the tile to check
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return whether the tile is covered with snow.
 
 */
 
static inline bool IsSnowTile(Tile t)
 
inline bool IsSnowTile(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return HasBit(t.m3(), 4);
 
}
 

	
 
/**
 
 * Get the type of clear tile but never return CLEAR_SNOW.
 
 * @param t the tile to get the clear ground type of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetRawClearGround(Tile t)
 
inline ClearGround GetRawClearGround(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return (ClearGround)GB(t.m5(), 2, 3);
 
}
 

	
 
/**
 
 * Get the type of clear tile.
 
 * @param t the tile to get the clear ground type of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the ground type
 
 */
 
static inline ClearGround GetClearGround(Tile t)
 
inline ClearGround GetClearGround(Tile t)
 
{
 
	if (IsSnowTile(t)) return CLEAR_SNOW;
 
	return GetRawClearGround(t);
 
}
 

	
 
/**
 
 * Set the type of clear tile.
 
 * @param t  the tile to set the clear ground type of
 
 * @param ct the ground type
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline bool IsClearGround(Tile t, ClearGround ct)
 
inline bool IsClearGround(Tile t, ClearGround ct)
 
{
 
	return GetClearGround(t) == ct;
 
}
 

	
 

	
 
/**
 
 * Get the density of a non-field clear tile.
 
 * @param t the tile to get the density of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the density
 
 */
 
static inline uint GetClearDensity(Tile t)
 
inline uint GetClearDensity(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return GB(t.m5(), 0, 2);
 
}
 

	
 
/**
 
 * Increment the density of a non-field clear tile.
 
 * @param t the tile to increment the density of
 
 * @param d the amount to increment the density with
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void AddClearDensity(Tile t, int d)
 
inline void AddClearDensity(Tile t, int d)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	t.m5() += d;
 
}
 

	
 
/**
 
 * Set the density of a non-field clear tile.
 
 * @param t the tile to set the density of
 
 * @param d the new density
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearDensity(Tile t, uint d)
 
inline void SetClearDensity(Tile t, uint d)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	SB(t.m5(), 0, 2, d);
 
}
 

	
 

	
 
/**
 
 * Get the counter used to advance to the next clear density/field type.
 
 * @param t the tile to get the counter of
 
 * @pre IsTileType(t, MP_CLEAR)
 
 * @return the value of the counter
 
 */
 
static inline uint GetClearCounter(Tile t)
 
inline uint GetClearCounter(Tile t)
 
{
 
	assert(IsTileType(t, MP_CLEAR));
 
	return GB(t.m5(), 5, 3);
 
}
 

	
 
/**
 
 * Increments the counter used to advance to the next clear density/field type.
 
 * @param t the tile to increment the counter of
 
 * @param c the amount to increment the counter with
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void AddClearCounter(Tile t, int c)
 
inline void AddClearCounter(Tile t, int c)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	t.m5() += c << 5;
 
}
 

	
 
/**
 
 * Sets the counter used to advance to the next clear density/field type.
 
 * @param t the tile to set the counter of
 
 * @param c the amount to set the counter to
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearCounter(Tile t, uint c)
 
inline void SetClearCounter(Tile t, uint c)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	SB(t.m5(), 5, 3, c);
 
}
 

	
 

	
 
@@ -152,62 +152,62 @@ static inline void SetClearCounter(Tile 
 
 * Sets ground type and density in one go, also sets the counter to 0
 
 * @param t       the tile to set the ground type and density for
 
 * @param type    the new ground type of the tile
 
 * @param density the density of the ground tile
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void SetClearGroundDensity(Tile t, ClearGround type, uint density)
 
inline void SetClearGroundDensity(Tile t, ClearGround type, uint density)
 
{
 
	assert(IsTileType(t, MP_CLEAR)); // XXX incomplete
 
	t.m5() = 0 << 5 | type << 2 | density;
 
}
 

	
 

	
 
/**
 
 * Get the field type (production stage) of the field
 
 * @param t the field to get the type of
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 * @return the field type
 
 */
 
static inline uint GetFieldType(Tile t)
 
inline uint GetFieldType(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	return GB(t.m3(), 0, 4);
 
}
 

	
 
/**
 
 * Set the field type (production stage) of the field
 
 * @param t the field to get the type of
 
 * @param f the field type
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 */
 
static inline void SetFieldType(Tile t, uint f)
 
inline void SetFieldType(Tile t, uint f)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS); // XXX incomplete
 
	SB(t.m3(), 0, 4, f);
 
}
 

	
 
/**
 
 * Get the industry (farm) that made the field
 
 * @param t the field to get creating industry of
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 * @return the industry that made the field
 
 */
 
static inline IndustryID GetIndustryIndexOfField(Tile t)
 
inline IndustryID GetIndustryIndexOfField(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	return(IndustryID) t.m2();
 
}
 

	
 
/**
 
 * Set the industry (farm) that made the field
 
 * @param t the field to get creating industry of
 
 * @param i the industry that made the field
 
 * @pre GetClearGround(t) == CLEAR_FIELDS
 
 */
 
static inline void SetIndustryIndexOfField(Tile t, IndustryID i)
 
inline void SetIndustryIndexOfField(Tile t, IndustryID i)
 
{
 
	assert(GetClearGround(t) == CLEAR_FIELDS);
 
	t.m2() = i;
 
}
 

	
 

	
 
@@ -215,13 +215,13 @@ static inline void SetIndustryIndexOfFie
 
 * Is there a fence at the given border?
 
 * @param t the tile to check for fences
 
 * @param side the border to check
 
 * @pre IsClearGround(t, CLEAR_FIELDS)
 
 * @return 0 if there is no fence, otherwise the fence type
 
 */
 
static inline uint GetFence(Tile t, DiagDirection side)
 
inline uint GetFence(Tile t, DiagDirection side)
 
{
 
	assert(IsClearGround(t, CLEAR_FIELDS));
 
	switch (side) {
 
		default: NOT_REACHED();
 
		case DIAGDIR_SE: return GB(t.m4(), 2, 3);
 
		case DIAGDIR_SW: return GB(t.m4(), 5, 3);
 
@@ -234,13 +234,13 @@ static inline uint GetFence(Tile t, Diag
 
 * Sets the type of fence (and whether there is one) for the given border.
 
 * @param t the tile to check for fences
 
 * @param side the border to check
 
 * @param h 0 if there is no fence, otherwise the fence type
 
 * @pre IsClearGround(t, CLEAR_FIELDS)
 
 */
 
static inline void SetFence(Tile t, DiagDirection side, uint h)
 
inline void SetFence(Tile t, DiagDirection side, uint h)
 
{
 
	assert(IsClearGround(t, CLEAR_FIELDS));
 
	switch (side) {
 
		default: NOT_REACHED();
 
		case DIAGDIR_SE: SB(t.m4(), 2, 3, h); break;
 
		case DIAGDIR_SW: SB(t.m4(), 5, 3, h); break;
 
@@ -253,13 +253,13 @@ static inline void SetFence(Tile t, Diag
 
/**
 
 * Make a clear tile.
 
 * @param t       the tile to make a clear tile
 
 * @param g       the type of ground
 
 * @param density the density of the grass/snow/desert etc
 
 */
 
static inline void MakeClear(Tile t, ClearGround g, uint density)
 
inline void MakeClear(Tile t, ClearGround g, uint density)
 
{
 
	SetTileType(t, MP_CLEAR);
 
	t.m1() = 0;
 
	SetTileOwner(t, OWNER_NONE);
 
	t.m2() = 0;
 
	t.m3() = 0;
 
@@ -274,13 +274,13 @@ static inline void MakeClear(Tile t, Cle
 
/**
 
 * Make a (farm) field tile.
 
 * @param t          the tile to make a farm field
 
 * @param field_type the 'growth' level of the field
 
 * @param industry   the industry this tile belongs to
 
 */
 
static inline void MakeField(Tile t, uint field_type, IndustryID industry)
 
inline void MakeField(Tile t, uint field_type, IndustryID industry)
 
{
 
	SetTileType(t, MP_CLEAR);
 
	t.m1() = 0;
 
	SetTileOwner(t, OWNER_NONE);
 
	t.m2() = industry;
 
	t.m3() = field_type;
 
@@ -294,13 +294,13 @@ static inline void MakeField(Tile t, uin
 
/**
 
 * Make a snow tile.
 
 * @param t the tile to make snowy
 
 * @param density The density of snowiness.
 
 * @pre GetClearGround(t) != CLEAR_SNOW
 
 */
 
static inline void MakeSnow(Tile t, uint density = 0)
 
inline void MakeSnow(Tile t, uint density = 0)
 
{
 
	assert(GetClearGround(t) != CLEAR_SNOW);
 
	SetBit(t.m3(), 4);
 
	if (GetRawClearGround(t) == CLEAR_FIELDS) {
 
		SetClearGroundDensity(t, CLEAR_GRASS, density);
 
	} else {
 
@@ -310,13 +310,13 @@ static inline void MakeSnow(Tile t, uint
 

	
 
/**
 
 * Clear the snow from a tile and return it to its previous type.
 
 * @param t the tile to clear of snow
 
 * @pre GetClearGround(t) == CLEAR_SNOW
 
 */
 
static inline void ClearSnow(Tile t)
 
inline void ClearSnow(Tile t)
 
{
 
	assert(GetClearGround(t) == CLEAR_SNOW);
 
	ClrBit(t.m3(), 4);
 
	SetClearDensity(t, 3);
 
}
 

	
src/company_func.h
Show inline comments
 
@@ -39,23 +39,23 @@ extern Colours _company_colours[MAX_COMP
 
extern CompanyManagerFace _company_manager_face;
 

	
 
/**
 
 * Is the current company the local company?
 
 * @return \c true of the current company is the local company, \c false otherwise.
 
 */
 
static inline bool IsLocalCompany()
 
inline bool IsLocalCompany()
 
{
 
	return _local_company == _current_company;
 
}
 

	
 
/**
 
 * Is the user representing \a company?
 
 * @param company Company where interaction is needed with.
 
 * @return Gives \c true if the user can answer questions interactively as representative of \a company, else \c false
 
 */
 
static inline bool IsInteractiveCompany(CompanyID company)
 
inline bool IsInteractiveCompany(CompanyID company)
 
{
 
	return company == _local_company;
 
}
 

	
 
int CompanyServiceInterval(const Company *c, VehicleType type);
 
CompanyID GetFirstPlayableCompanyID();
src/company_manager_face.h
Show inline comments
 
@@ -90,13 +90,13 @@ static_assert(lengthof(_cmf_info) == CMF
 
 * @param cmf  the face to extract the bits from
 
 * @param cmfv the face variable to get the data of
 
 * @param ge   the gender and ethnicity of the face
 
 * @pre _cmf_info[cmfv].valid_values[ge] != 0
 
 * @return the requested bits
 
 */
 
static inline uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge)
 
inline uint GetCompanyManagerFaceBits(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge)
 
{
 
	assert(_cmf_info[cmfv].valid_values[ge] != 0);
 

	
 
	return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
 
}
 

	
 
@@ -105,13 +105,13 @@ static inline uint GetCompanyManagerFace
 
 * @param cmf  the face to write the bits to
 
 * @param cmfv the face variable to write the data of
 
 * @param ge   the gender and ethnicity of the face
 
 * @param val  the new value
 
 * @pre val < _cmf_info[cmfv].valid_values[ge]
 
 */
 
static inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge, uint val)
 
inline void SetCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, [[maybe_unused]] GenderEthnicity ge, uint val)
 
{
 
	assert(val < _cmf_info[cmfv].valid_values[ge]);
 

	
 
	SB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length, val);
 
}
 

	
 
@@ -124,13 +124,13 @@ static inline void SetCompanyManagerFace
 
 * @param cmfv   the company manager face variable to write the data of
 
 * @param ge     the gender and ethnicity of the company manager's face
 
 * @param amount the amount which change the value
 
 *
 
 * @pre 0 <= val < _cmf_info[cmfv].valid_values[ge]
 
 */
 
static inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount)
 
inline void IncreaseCompanyManagerFaceBits(CompanyManagerFace &cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge, int8_t amount)
 
{
 
	int8_t val = GetCompanyManagerFaceBits(cmf, cmfv, ge) + amount; // the new value for the cmfv
 

	
 
	/* scales the new value to the correct scope */
 
	if (val >= _cmf_info[cmfv].valid_values[ge]) {
 
		val = 0;
 
@@ -145,38 +145,38 @@ static inline void IncreaseCompanyManage
 
 * Checks whether the company manager's face bits have a valid range
 
 * @param cmf  the face to extract the bits from
 
 * @param cmfv the face variable to get the data of
 
 * @param ge   the gender and ethnicity of the face
 
 * @return true if and only if the bits are valid
 
 */
 
static inline bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
 
inline bool AreCompanyManagerFaceBitsValid(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
 
{
 
	return GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length) < _cmf_info[cmfv].valid_values[ge];
 
}
 

	
 
/**
 
 * Scales a company manager's face bits variable to the correct scope
 
 * @param cmfv the face variable to write the data of
 
 * @param ge  the gender and ethnicity of the face
 
 * @param val the to value to scale
 
 * @pre val < (1U << _cmf_info[cmfv].length), i.e. val has a value of 0..2^(bits used for this variable)-1
 
 * @return the scaled value
 
 */
 
static inline uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
 
inline uint ScaleCompanyManagerFaceValue(CompanyManagerFaceVariable cmfv, GenderEthnicity ge, uint val)
 
{
 
	assert(val < (1U << _cmf_info[cmfv].length));
 

	
 
	return (val * _cmf_info[cmfv].valid_values[ge]) >> _cmf_info[cmfv].length;
 
}
 

	
 
/**
 
 * Scales all company manager's face bits to the correct scope
 
 *
 
 * @param cmf the company manager's face to write the bits to
 
 */
 
static inline void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
 
inline void ScaleAllCompanyManagerFaceBits(CompanyManagerFace &cmf)
 
{
 
	IncreaseCompanyManagerFaceBits(cmf, CMFV_ETHNICITY, GE_WM, 0); // scales the ethnicity
 

	
 
	GenderEthnicity ge = (GenderEthnicity)GB(cmf, _cmf_info[CMFV_GEN_ETHN].offset, _cmf_info[CMFV_GEN_ETHN].length); // gender & ethnicity of the face
 

	
 
	/* Is a male face with moustache. Need to reduce CPU load in the loop. */
 
@@ -200,13 +200,13 @@ static inline void ScaleAllCompanyManage
 
 * @param ge  the gender and ethnicity of the old company manager's face
 
 * @param adv if it for the advanced company manager's face window
 
 * @param randomizer the source of random to use for creating the manager face
 
 *
 
 * @pre scale 'ge' to a valid gender/ethnicity combination
 
 */
 
static inline void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer)
 
inline void RandomCompanyManagerFaceBits(CompanyManagerFace &cmf, GenderEthnicity ge, bool adv, Randomizer &randomizer)
 
{
 
	cmf = randomizer.Next(); // random all company manager's face bits
 

	
 
	/* scale ge: 0 == GE_WM, 1 == GE_WF, 2 == GE_BM, 3 == GE_BF (and maybe in future: ...) */
 
	ge = (GenderEthnicity)((uint)ge % GE_END);
 

	
 
@@ -226,13 +226,13 @@ static inline void RandomCompanyManagerF
 
 * @param cmf  the face to extract the data from
 
 * @param cmfv the face variable to get the sprite of
 
 * @param ge   the gender and ethnicity of the face
 
 * @pre _cmf_info[cmfv].valid_values[ge] != 0
 
 * @return sprite to draw
 
 */
 
static inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
 
inline SpriteID GetCompanyManagerFaceSprite(CompanyManagerFace cmf, CompanyManagerFaceVariable cmfv, GenderEthnicity ge)
 
{
 
	assert(_cmf_info[cmfv].valid_values[ge] != 0);
 

	
 
	return _cmf_info[cmfv].first_sprite[ge] + GB(cmf, _cmf_info[cmfv].offset, _cmf_info[cmfv].length);
 
}
 

	
src/console_func.h
Show inline comments
 
@@ -36,13 +36,13 @@ void IConsolePrint(TextColour colour_cod
 
 * @param other_args The other arguments to the format.
 
 * @tparam T The type of formatting parameter.
 
 * @tparam A The type of the first argument.
 
 * @tparam Args The types of the other arguments.
 
 */
 
template <typename T, typename A, typename ... Args>
 
static inline void IConsolePrint(TextColour colour_code, const T &format, A first_arg, Args&&... other_args)
 
inline void IConsolePrint(TextColour colour_code, const T &format, A first_arg, Args&&... other_args)
 
{
 
	/* The separate first_arg argument is added to aid overloading.
 
	 * Otherwise the calls that do no need formatting will still use this function. */
 
	IConsolePrint(colour_code, fmt::format(format, first_arg, other_args...));
 
}
 

	
src/core/alloc_func.hpp
Show inline comments
 
@@ -23,25 +23,25 @@ void NORETURN ReallocError(size_t size);
 
/**
 
 * Checks whether allocating memory would overflow size_t.
 
 *
 
 * @param element_size Size of the structure to allocate.
 
 * @param num_elements Number of elements to allocate.
 
 */
 
static inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
 
inline void CheckAllocationConstraints(size_t element_size, size_t num_elements)
 
{
 
	if (num_elements > SIZE_MAX / element_size) MallocError(SIZE_MAX);
 
}
 

	
 
/**
 
 * Checks whether allocating memory would overflow size_t.
 
 *
 
 * @tparam T Structure to allocate.
 
 * @param num_elements Number of elements to allocate.
 
 */
 
template <typename T>
 
static inline void CheckAllocationConstraints(size_t num_elements)
 
inline void CheckAllocationConstraints(size_t num_elements)
 
{
 
	CheckAllocationConstraints(sizeof(T), num_elements);
 
}
 

	
 
/**
 
 * Simplified allocation function that allocates the specified number of
 
@@ -51,13 +51,13 @@ static inline void CheckAllocationConstr
 
 * @note the memory contains garbage data (i.e. possibly non-zero values).
 
 * @tparam T the type of the variable(s) to allocation.
 
 * @param num_elements the number of elements to allocate of the given type.
 
 * @return nullptr when num_elements == 0, non-nullptr otherwise.
 
 */
 
template <typename T>
 
static inline T *MallocT(size_t num_elements)
 
inline T *MallocT(size_t num_elements)
 
{
 
	/*
 
	 * MorphOS cannot handle 0 elements allocations, or rather that always
 
	 * returns nullptr. So we do that for *all* allocations, thus causing it
 
	 * to behave the same on all OSes.
 
	 */
 
@@ -79,13 +79,13 @@ static inline T *MallocT(size_t num_elem
 
 * @note the memory contains all zero values.
 
 * @tparam T the type of the variable(s) to allocation.
 
 * @param num_elements the number of elements to allocate of the given type.
 
 * @return nullptr when num_elements == 0, non-nullptr otherwise.
 
 */
 
template <typename T>
 
static inline T *CallocT(size_t num_elements)
 
inline T *CallocT(size_t num_elements)
 
{
 
	/*
 
	 * MorphOS cannot handle 0 elements allocations, or rather that always
 
	 * returns nullptr. So we do that for *all* allocations, thus causing it
 
	 * to behave the same on all OSes.
 
	 */
 
@@ -105,13 +105,13 @@ static inline T *CallocT(size_t num_elem
 
 * @tparam T the type of the variable(s) to allocation.
 
 * @param t_ptr the previous allocation to extend/shrink.
 
 * @param num_elements the number of elements to allocate of the given type.
 
 * @return nullptr when num_elements == 0, non-nullptr otherwise.
 
 */
 
template <typename T>
 
static inline T *ReallocT(T *t_ptr, size_t num_elements)
 
inline T *ReallocT(T *t_ptr, size_t num_elements)
 
{
 
	/*
 
	 * MorphOS cannot handle 0 elements allocations, or rather that always
 
	 * returns nullptr. So we do that for *all* allocations, thus causing it
 
	 * to behave the same on all OSes.
 
	 */
src/core/bitmath_func.hpp
Show inline comments
 
@@ -52,13 +52,13 @@ debug_inline constexpr static uint GB(co
 
 * @param d The actually new bits to save in the defined position.
 
 * @pre n < sizeof(T) * 8
 
 * @pre s + n <= sizeof(T) * 8
 
 * @return The new value of \a x
 
 */
 
template <typename T, typename U>
 
static inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
 
inline T SB(T &x, const uint8_t s, const uint8_t n, const U d)
 
{
 
	x &= (T)(~((((T)1U << n) - 1) << s));
 
	x |= (T)(d << s);
 
	return x;
 
}
 

	
 
@@ -77,13 +77,13 @@ static inline T SB(T &x, const uint8_t s
 
 * @pre n < sizeof(T) * 8
 
 * @pre s + n <= sizeof(T) * 8
 
 * @param i The value to add at the given start position in the given window.
 
 * @return The new value of \a x
 
 */
 
template <typename T, typename U>
 
static inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
 
inline T AB(T &x, const uint8_t s, const uint8_t n, const U i)
 
{
 
	const T mask = ((((T)1U << n) - 1) << s);
 
	x = (T)((x & ~mask) | ((x + (i << s)) & mask));
 
	return x;
 
}
 

	
 
@@ -115,13 +115,13 @@ debug_inline static bool HasBit(const T 
 
 * @param x The variable to set a bit
 
 * @param y The bit position to set
 
 * @pre y < sizeof(T) * 8
 
 * @return The new value of the old value with the bit set
 
 */
 
template <typename T>
 
static inline T SetBit(T &x, const uint8_t y)
 
inline T SetBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x | ((T)1U << y));
 
}
 

	
 
/**
 
 * Sets several bits in a variable.
 
@@ -145,13 +145,13 @@ static inline T SetBit(T &x, const uint8
 
 * @param x The variable to clear the bit
 
 * @param y The bit position to clear
 
 * @pre y < sizeof(T) * 8
 
 * @return The new value of the old value with the bit cleared
 
 */
 
template <typename T>
 
static inline T ClrBit(T &x, const uint8_t y)
 
inline T ClrBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x & ~((T)1U << y));
 
}
 

	
 
/**
 
 * Clears several bits in a variable.
 
@@ -175,13 +175,13 @@ static inline T ClrBit(T &x, const uint8
 
 * @param x The variable to toggle the bit
 
 * @param y The bit position to toggle
 
 * @pre y < sizeof(T) * 8
 
 * @return The new value of the old value with the bit toggled
 
 */
 
template <typename T>
 
static inline T ToggleBit(T &x, const uint8_t y)
 
inline T ToggleBit(T &x, const uint8_t y)
 
{
 
	return x = (T)(x ^ ((T)1U << y));
 
}
 

	
 

	
 
/** Lookup table to check which bit is set in a 6 bit variable */
 
@@ -210,13 +210,13 @@ extern const uint8_t _ffb_64[64];
 
 * be also zero to check the bits at 0x3F00.
 
 *
 
 * @param value The value to check the first bits
 
 * @return The position of the first bit which is set
 
 * @see FIND_FIRST_BIT
 
 */
 
static inline uint8_t FindFirstBit2x64(const int value)
 
inline uint8_t FindFirstBit2x64(const int value)
 
{
 
	if ((value & 0xFF) == 0) {
 
		return FIND_FIRST_BIT((value >> 8) & 0x3F) + 8;
 
	} else {
 
		return FIND_FIRST_BIT(value & 0x3F);
 
	}
 
@@ -233,25 +233,25 @@ uint8_t FindLastBit(uint64_t x);
 
 * So, 110100 returns 110000, 000001 returns 000000, etc.
 
 *
 
 * @param value The value to clear the first bit
 
 * @return The new value with the first bit cleared
 
 */
 
template <typename T>
 
static inline T KillFirstBit(T value)
 
inline T KillFirstBit(T value)
 
{
 
	return value &= (T)(value - 1);
 
}
 

	
 
/**
 
 * Counts the number of set bits in a variable.
 
 *
 
 * @param value the value to count the number of bits in.
 
 * @return the number of bits.
 
 */
 
template <typename T>
 
static inline uint CountBits(T value)
 
inline uint CountBits(T value)
 
{
 
	uint num;
 

	
 
	/* This loop is only called once for every bit set by clearing the lowest
 
	 * bit in each loop. The number of bits is therefore equal to the number of
 
	 * times the loop was called. It was found at the following website:
 
@@ -268,25 +268,25 @@ static inline uint CountBits(T value)
 
 * Test whether \a value has exactly 1 bit set
 
 *
 
 * @param value the value to test.
 
 * @return does \a value have exactly 1 bit set?
 
 */
 
template <typename T>
 
static inline bool HasExactlyOneBit(T value)
 
inline bool HasExactlyOneBit(T value)
 
{
 
	return value != 0 && (value & (value - 1)) == 0;
 
}
 

	
 
/**
 
 * Test whether \a value has at most 1 bit set
 
 *
 
 * @param value the value to test.
 
 * @return does \a value have at most 1 bit set?
 
 */
 
template <typename T>
 
static inline bool HasAtMostOneBit(T value)
 
inline bool HasAtMostOneBit(T value)
 
{
 
	return (value & (value - 1)) == 0;
 
}
 

	
 
/**
 
 * ROtate \a x Left by \a n
 
@@ -295,13 +295,13 @@ static inline bool HasAtMostOneBit(T val
 
 * @param x The value which we want to rotate
 
 * @param n The number how many we want to rotate
 
 * @pre n < sizeof(T) * 8
 
 * @return A bit rotated number
 
 */
 
template <typename T>
 
static inline T ROL(const T x, const uint8_t n)
 
inline T ROL(const T x, const uint8_t n)
 
{
 
	if (n == 0) return x;
 
	return (T)(x << n | x >> (sizeof(x) * 8 - n));
 
}
 

	
 
/**
 
@@ -311,13 +311,13 @@ static inline T ROL(const T x, const uin
 
 * @param x The value which we want to rotate
 
 * @param n The number how many we want to rotate
 
 * @pre n < sizeof(T) * 8
 
 * @return A bit rotated number
 
 */
 
template <typename T>
 
static inline T ROR(const T x, const uint8_t n)
 
inline T ROR(const T x, const uint8_t n)
 
{
 
	if (n == 0) return x;
 
	return (T)(x >> n | x << (sizeof(x) * 8 - n));
 
}
 

	
 
 /**
src/core/endian_func.hpp
Show inline comments
 
@@ -35,18 +35,18 @@
 
#	define FROM_LE32(x) (x)
 
#	define TO_LE16(x)   (x)
 
#	define TO_LE32(x)   (x)
 
#	define TO_LE32X(x)  (x)
 
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */
 

	
 
static inline uint16_t ReadLE16Aligned(const void *x)
 
inline uint16_t ReadLE16Aligned(const void *x)
 
{
 
	return FROM_LE16(*(const uint16_t*)x);
 
}
 

	
 
static inline uint16_t ReadLE16Unaligned(const void *x)
 
inline uint16_t ReadLE16Unaligned(const void *x)
 
{
 
#if OTTD_ALIGNMENT == 1
 
	return ((const byte*)x)[0] | ((const byte*)x)[1] << 8;
 
#else
 
	return FROM_LE16(*(const uint16_t*)x);
 
#endif /* OTTD_ALIGNMENT == 1 */
src/core/geometry_func.hpp
Show inline comments
 
@@ -16,13 +16,13 @@ Dimension maxdim(const Dimension &d1, co
 

	
 
/**
 
 * Check if a rectangle is empty.
 
 * @param r Rectangle to check.
 
 * @return True if and only if the rectangle doesn't define space.
 
 */
 
static inline bool IsEmptyRect(const Rect &r)
 
inline bool IsEmptyRect(const Rect &r)
 
{
 
	return (r.left | r.top | r.right | r.bottom) == 0;
 
}
 

	
 
Rect BoundingRect(const Rect &r1, const Rect &r2);
 

	
src/core/math_func.hpp
Show inline comments
 
@@ -17,13 +17,13 @@
 
 *
 
 * @note assumes variable to be signed
 
 * @param a The value we want to unsign
 
 * @return The unsigned value
 
 */
 
template <typename T>
 
static inline T abs(const T a)
 
inline T abs(const T a)
 
{
 
	return (a < (T)0) ? -a : a;
 
}
 

	
 
/**
 
 * Return the smallest multiple of n equal or greater than x
 
@@ -31,13 +31,13 @@ static inline T abs(const T a)
 
 * @note n must be a power of 2
 
 * @param x The min value
 
 * @param n The base of the number we are searching
 
 * @return The smallest multiple of n equal or greater than x
 
 */
 
template <typename T>
 
static inline T Align(const T x, uint n)
 
inline T Align(const T x, uint n)
 
{
 
	assert((n & (n - 1)) == 0 && n != 0);
 
	n--;
 
	return (T)((x + n) & ~((T)n));
 
}
 

	
 
@@ -49,13 +49,13 @@ static inline T Align(const T x, uint n)
 
 * @param x The min value
 
 * @param n The base of the number we are searching
 
 * @return The smallest multiple of n equal or greater than x
 
 * @see Align()
 
 */
 
template <typename T>
 
static inline T *AlignPtr(T *x, uint n)
 
inline T *AlignPtr(T *x, uint n)
 
{
 
	static_assert(sizeof(size_t) == sizeof(void *));
 
	return reinterpret_cast<T *>(Align((size_t)x, n));
 
}
 

	
 
/**
 
@@ -73,13 +73,13 @@ static inline T *AlignPtr(T *x, uint n)
 
 * @param max the maximum of the interval.
 
 * @returns A value between min and max which is closest to a.
 
 * @see ClampU(uint, uint, uint)
 
 * @see Clamp(int, int, int)
 
 */
 
template <typename T>
 
static inline T Clamp(const T a, const T min, const T max)
 
inline T Clamp(const T a, const T min, const T max)
 
{
 
	assert(min <= max);
 
	if (a <= min) return min;
 
	if (a >= max) return max;
 
	return a;
 
}
 
@@ -96,13 +96,13 @@ static inline T Clamp(const T a, const T
 
 * @param a The value to clamp/truncate.
 
 * @param min The minimum of the interval.
 
 * @param max the maximum of the interval.
 
 * @returns A value between min and max which is closest to a.
 
 */
 
template <typename T>
 
static inline T SoftClamp(const T a, const T min, const T max)
 
inline T SoftClamp(const T a, const T min, const T max)
 
{
 
	if (min > max) {
 
		using U = std::make_unsigned_t<T>;
 
		return min - (U(min) - max) / 2;
 
	}
 
	if (a <= min) return min;
 
@@ -123,13 +123,13 @@ static inline T SoftClamp(const T a, con
 
 * @param a The value to clamp/truncate.
 
 * @param min The minimum of the interval.
 
 * @param max the maximum of the interval.
 
 * @returns A value between min and max which is closest to a.
 
 * @see ClampU(uint, uint, uint)
 
 */
 
static inline int Clamp(const int a, const int min, const int max)
 
inline int Clamp(const int a, const int min, const int max)
 
{
 
	return Clamp<int>(a, min, max);
 
}
 

	
 
/**
 
 * Clamp an unsigned integer between an interval.
 
@@ -144,13 +144,13 @@ static inline int Clamp(const int a, con
 
 * @param a The value to clamp/truncate.
 
 * @param min The minimum of the interval.
 
 * @param max the maximum of the interval.
 
 * @returns A value between min and max which is closest to a.
 
 * @see Clamp(int, int, int)
 
 */
 
static inline uint ClampU(const uint a, const uint min, const uint max)
 
inline uint ClampU(const uint a, const uint min, const uint max)
 
{
 
	return Clamp<uint>(a, min, max);
 
}
 

	
 
/**
 
 * Clamp the given value down to lie within the requested type.
 
@@ -228,13 +228,13 @@ constexpr To ClampTo(From value)
 
 *
 
 * @param a The first scalar
 
 * @param b The second scalar
 
 * @return The absolute difference between the given scalars
 
 */
 
template <typename T>
 
static inline T Delta(const T a, const T b)
 
inline T Delta(const T a, const T b)
 
{
 
	return (a < b) ? b - a : a - b;
 
}
 

	
 
/**
 
 * Checks if a value is between a window started at some base point.
 
@@ -246,13 +246,13 @@ static inline T Delta(const T a, const T
 
 * @param x The value to check
 
 * @param base The base value of the interval
 
 * @param size The size of the interval
 
 * @return True if the value is in the interval, false else.
 
 */
 
template <typename T>
 
static inline bool IsInsideBS(const T x, const size_t base, const size_t size)
 
inline bool IsInsideBS(const T x, const size_t base, const size_t size)
 
{
 
	return (size_t)(x - base) < size;
 
}
 

	
 
/**
 
 * Checks if a value is in an interval.
 
@@ -277,36 +277,36 @@ static constexpr inline bool IsInsideMM(
 
/**
 
 * Type safe swap operation
 
 * @param a variable to swap with b
 
 * @param b variable to swap with a
 
 */
 
template <typename T>
 
static inline void Swap(T &a, T &b)
 
inline void Swap(T &a, T &b)
 
{
 
	T t = a;
 
	a = b;
 
	b = t;
 
}
 

	
 
/**
 
 * Converts a "fract" value 0..255 to "percent" value 0..100
 
 * @param i value to convert, range 0..255
 
 * @return value in range 0..100
 
 */
 
static inline uint ToPercent8(uint i)
 
inline uint ToPercent8(uint i)
 
{
 
	assert(i < 256);
 
	return i * 101 >> 8;
 
}
 

	
 
/**
 
 * Converts a "fract" value 0..65535 to "percent" value 0..100
 
 * @param i value to convert, range 0..65535
 
 * @return value in range 0..100
 
 */
 
static inline uint ToPercent16(uint i)
 
inline uint ToPercent16(uint i)
 
{
 
	assert(i < 65536);
 
	return i * 101 >> 16;
 
}
 

	
 
int LeastCommonMultiple(int a, int b);
 
@@ -316,35 +316,35 @@ int DivideApprox(int a, int b);
 
/**
 
 * Computes ceil(a / b) for non-negative a and b.
 
 * @param a Numerator
 
 * @param b Denominator
 
 * @return Quotient, rounded up
 
 */
 
static inline uint CeilDiv(uint a, uint b)
 
inline uint CeilDiv(uint a, uint b)
 
{
 
	return (a + b - 1) / b;
 
}
 

	
 
/**
 
 * Computes ceil(a / b) * b for non-negative a and b.
 
 * @param a Numerator
 
 * @param b Denominator
 
 * @return a rounded up to the nearest multiple of b.
 
 */
 
static inline uint Ceil(uint a, uint b)
 
inline uint Ceil(uint a, uint b)
 
{
 
	return CeilDiv(a, b) * b;
 
}
 

	
 
/**
 
 * Computes round(a / b) for signed a and unsigned b.
 
 * @param a Numerator
 
 * @param b Denominator
 
 * @return Quotient, rounded to nearest
 
 */
 
static inline int RoundDivSU(int a, uint b)
 
inline int RoundDivSU(int a, uint b)
 
{
 
	if (a > 0) {
 
		/* 0.5 is rounded to 1 */
 
		return (a + static_cast<int>(b) / 2) / static_cast<int>(b);
 
	} else {
 
		/* -0.5 is rounded to 0 */
 
@@ -355,13 +355,13 @@ static inline int RoundDivSU(int a, uint
 
/**
 
 * Computes (a / b) rounded away from zero.
 
 * @param a Numerator
 
 * @param b Denominator
 
 * @return Quotient, rounded away from zero
 
 */
 
static inline int DivAwayFromZero(int a, uint b)
 
inline int DivAwayFromZero(int a, uint b)
 
{
 
	const int _b = static_cast<int>(b);
 
	if (a > 0) {
 
		return (a + _b - 1) / _b;
 
	} else {
 
		/* Note: Behaviour of negative numerator division is truncation toward zero. */
src/core/mem_func.hpp
Show inline comments
 
@@ -17,39 +17,39 @@
 
 *
 
 * @param destination Pointer to the destination buffer
 
 * @param source Pointer to the source buffer
 
 * @param num number of items to be copied. (!not number of bytes!)
 
 */
 
template <typename T>
 
static inline void MemCpyT(T *destination, const T *source, size_t num = 1)
 
inline void MemCpyT(T *destination, const T *source, size_t num = 1)
 
{
 
	memcpy(destination, source, num * sizeof(T));
 
}
 

	
 
/**
 
 * Type-safe version of memmove().
 
 *
 
 * @param destination Pointer to the destination buffer
 
 * @param source Pointer to the source buffer
 
 * @param num number of items to be copied. (!not number of bytes!)
 
 */
 
template <typename T>
 
static inline void MemMoveT(T *destination, const T *source, size_t num = 1)
 
inline void MemMoveT(T *destination, const T *source, size_t num = 1)
 
{
 
	memmove(destination, source, num * sizeof(T));
 
}
 

	
 
/**
 
 * Type-safe version of memset().
 
 *
 
 * @param ptr Pointer to the destination buffer
 
 * @param value Value to be set
 
 * @param num number of items to be set (!not number of bytes!)
 
 */
 
template <typename T>
 
static inline void MemSetT(T *ptr, byte value, size_t num = 1)
 
inline void MemSetT(T *ptr, byte value, size_t num = 1)
 
{
 
	memset(ptr, value, num * sizeof(T));
 
}
 

	
 
/**
 
 * Type-safe version of memcmp().
 
@@ -57,12 +57,12 @@ static inline void MemSetT(T *ptr, byte 
 
 * @param ptr1 Pointer to the first buffer
 
 * @param ptr2 Pointer to the second buffer
 
 * @param num Number of items to compare. (!not number of bytes!)
 
 * @return an int value indicating the relationship between the content of the two buffers
 
 */
 
template <typename T>
 
static inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
 
inline int MemCmpT(const T *ptr1, const T *ptr2, size_t num = 1)
 
{
 
	return memcmp(ptr1, ptr2, num * sizeof(T));
 
}
 

	
 
#endif /* MEM_FUNC_HPP */
src/core/random_func.hpp
Show inline comments
 
@@ -36,23 +36,23 @@ struct SavedRandomSeeds {
 
};
 

	
 
/**
 
 * Saves the current seeds
 
 * @param storage Storage for saving
 
 */
 
static inline void SaveRandomSeeds(SavedRandomSeeds *storage)
 
inline void SaveRandomSeeds(SavedRandomSeeds *storage)
 
{
 
	storage->random = _random;
 
	storage->interactive_random = _interactive_random;
 
}
 

	
 
/**
 
 * Restores previously saved seeds
 
 * @param storage Storage where SaveRandomSeeds() stored th seeds
 
 */
 
static inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
 
inline void RestoreRandomSeeds(const SavedRandomSeeds &storage)
 
{
 
	_random = storage.random;
 
	_interactive_random = storage.interactive_random;
 
}
 

	
 
void SetRandomSeed(uint32_t seed);
 
@@ -81,18 +81,18 @@ void SetRandomSeed(uint32_t seed);
 
	static inline uint32_t RandomRange(uint32_t limit)
 
	{
 
		return _random.Next(limit);
 
	}
 
#endif
 

	
 
static inline uint32_t InteractiveRandom()
 
inline uint32_t InteractiveRandom()
 
{
 
	return _interactive_random.Next();
 
}
 

	
 
static inline uint32_t InteractiveRandomRange(uint32_t limit)
 
inline uint32_t InteractiveRandomRange(uint32_t limit)
 
{
 
	return _interactive_random.Next(limit);
 
}
 

	
 
/**
 
 * Checks if a given randomize-number is below a given probability.
 
@@ -106,13 +106,13 @@ static inline uint32_t InteractiveRandom
 
 *
 
 * @param a The numerator of the fraction
 
 * @param b The denominator of the fraction, must of course not be null
 
 * @param r The given randomize-number
 
 * @return True if the probability given by r is less or equal to (a/b)
 
 */
 
static inline bool Chance16I(const uint a, const uint b, const uint32_t r)
 
inline bool Chance16I(const uint a, const uint b, const uint32_t r)
 
{
 
	assert(b != 0);
 
	return (((uint16_t)r * b + b / 2) >> 16) < a;
 
}
 

	
 
/**
 
@@ -125,13 +125,13 @@ static inline bool Chance16I(const uint 
 
 * @param b The denominator of the fraction
 
 * @return True with (a/b) probability
 
 */
 
#ifdef RANDOM_DEBUG
 
#	define Chance16(a, b) Chance16I(a, b, DoRandom(__LINE__, __FILE__))
 
#else
 
static inline bool Chance16(const uint a, const uint b)
 
inline bool Chance16(const uint a, const uint b)
 
{
 
	return Chance16I(a, b, Random());
 
}
 
#endif /* RANDOM_DEBUG */
 

	
 
/**
 
@@ -149,13 +149,13 @@ static inline bool Chance16(const uint a
 
 * @param r The variable to save the randomize-number from Random()
 
 * @return True in (a/b) percent
 
 */
 
#ifdef RANDOM_DEBUG
 
#	define Chance16R(a, b, r) (r = DoRandom(__LINE__, __FILE__), Chance16I(a, b, r))
 
#else
 
static inline bool Chance16R(const uint a, const uint b, uint32_t &r)
 
inline bool Chance16R(const uint a, const uint b, uint32_t &r)
 
{
 
	r = Random();
 
	return Chance16I(a, b, r);
 
}
 
#endif /* RANDOM_DEBUG */
 

	
src/depot_func.h
Show inline comments
 
@@ -21,13 +21,13 @@ void DeleteDepotHighlightOfVehicle(const
 
/**
 
 * Find out if the slope of the tile is suitable to build a depot of given direction
 
 * @param direction The direction in which the depot's exit points
 
 * @param tileh The slope of the tile in question
 
 * @return true if the construction is possible
 
 */
 
static inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
 
inline bool CanBuildDepotByTileh(DiagDirection direction, Slope tileh)
 
{
 
	assert(tileh != SLOPE_FLAT);
 
	Slope entrance_corners = InclinedSlope(direction);
 
	/* For steep slopes both entrance corners must be raised (i.e. neither of them is the lowest corner),
 
	 * For non-steep slopes at least one corner must be raised. */
 
	return IsSteepSlope(tileh) ? (tileh & entrance_corners) == entrance_corners : (tileh & entrance_corners) != 0;
src/depot_map.h
Show inline comments
 
@@ -12,13 +12,13 @@
 

	
 
#include "station_map.h"
 

	
 
/**
 
 * Check if a tile is a depot and it is a depot of the given type.
 
 */
 
static inline bool IsDepotTypeTile(Tile tile, TransportType type)
 
inline bool IsDepotTypeTile(Tile tile, TransportType type)
 
{
 
	switch (type) {
 
		default: NOT_REACHED();
 
		case TRANSPORT_RAIL:
 
			return IsRailDepotTile(tile);
 

	
 
@@ -35,37 +35,37 @@ static inline bool IsDepotTypeTile(Tile 
 

	
 
/**
 
 * Is the given tile a tile with a depot on it?
 
 * @param tile the tile to check
 
 * @return true if and only if there is a depot on the tile.
 
 */
 
static inline bool IsDepotTile(Tile tile)
 
inline bool IsDepotTile(Tile tile)
 
{
 
	return IsRailDepotTile(tile) || IsRoadDepotTile(tile) || IsShipDepotTile(tile) || IsHangarTile(tile);
 
}
 

	
 
/**
 
 * Get the index of which depot is attached to the tile.
 
 * @param t the tile
 
 * @pre IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t)
 
 * @return DepotID
 
 */
 
static inline DepotID GetDepotIndex(Tile t)
 
inline DepotID GetDepotIndex(Tile t)
 
{
 
	/* Hangars don't have a Depot class, thus store no DepotID. */
 
	assert(IsRailDepotTile(t) || IsRoadDepotTile(t) || IsShipDepotTile(t));
 
	return t.m2();
 
}
 

	
 
/**
 
 * Get the type of vehicles that can use a depot
 
 * @param t The tile
 
 * @pre IsDepotTile(t)
 
 * @return the type of vehicles that can use the depot
 
 */
 
static inline VehicleType GetDepotVehicleType(Tile t)
 
inline VehicleType GetDepotVehicleType(Tile t)
 
{
 
	switch (GetTileType(t)) {
 
		default: NOT_REACHED();
 
		case MP_RAILWAY: return VEH_TRAIN;
 
		case MP_ROAD:    return VEH_ROAD;
 
		case MP_WATER:   return VEH_SHIP;
src/direction_func.h
Show inline comments
 
@@ -15,46 +15,46 @@
 
/**
 
 * Checks if an integer value is a valid DiagDirection
 
 *
 
 * @param d The value to check
 
 * @return True if the value belongs to a DiagDirection, else false
 
 */
 
static inline bool IsValidDiagDirection(DiagDirection d)
 
inline bool IsValidDiagDirection(DiagDirection d)
 
{
 
	return d < DIAGDIR_END;
 
}
 

	
 
/**
 
 * Checks if an integer value is a valid Direction
 
 *
 
 * @param d The value to check
 
 * @return True if the value belongs to a Direction, else false
 
 */
 
static inline bool IsValidDirection(Direction d)
 
inline bool IsValidDirection(Direction d)
 
{
 
	return d < DIR_END;
 
}
 

	
 
/**
 
 * Checks if an integer value is a valid Axis
 
 *
 
 * @param d The value to check
 
 * @return True if the value belongs to an Axis, else false
 
 */
 
static inline bool IsValidAxis(Axis d)
 
inline bool IsValidAxis(Axis d)
 
{
 
	return d < AXIS_END;
 
}
 

	
 
/**
 
 * Return the reverse of a direction
 
 *
 
 * @param d The direction to get the reverse from
 
 * @return The reverse Direction
 
 */
 
static inline Direction ReverseDir(Direction d)
 
inline Direction ReverseDir(Direction d)
 
{
 
	assert(IsValidDirection(d));
 
	return (Direction)(4 ^ d);
 
}
 

	
 

	
 
@@ -62,13 +62,13 @@ static inline Direction ReverseDir(Direc
 
 * Calculate the difference between two directions
 
 *
 
 * @param d0 The first direction as the base
 
 * @param d1 The second direction as the offset from the base
 
 * @return The difference how the second direction drifts of the first one.
 
 */
 
static inline DirDiff DirDifference(Direction d0, Direction d1)
 
inline DirDiff DirDifference(Direction d0, Direction d1)
 
{
 
	assert(IsValidDirection(d0));
 
	assert(IsValidDirection(d1));
 
	/* Cast to uint so compiler can use bitmask. If the difference is negative
 
	 * and we used int instead of uint, further "+ 8" would have to be added. */
 
	return (DirDiff)((uint)(d0 - d1) % 8);
 
@@ -82,13 +82,13 @@ static inline DirDiff DirDifference(Dire
 
 * DIRDIFF_SAME difference.
 
 *
 
 * @param d The first difference
 
 * @param delta The second difference to add on
 
 * @return The resulting difference
 
 */
 
static inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
 
inline DirDiff ChangeDirDiff(DirDiff d, DirDiff delta)
 
{
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (DirDiff)((uint)(d + delta) % 8);
 
}
 

	
 
/**
 
@@ -98,13 +98,13 @@ static inline DirDiff ChangeDirDiff(DirD
 
 * which is rotated by the given difference.
 
 *
 
 * @param d The direction to get a new direction from
 
 * @param delta The offset/drift applied to the direction
 
 * @return The new direction
 
 */
 
static inline Direction ChangeDir(Direction d, DirDiff delta)
 
inline Direction ChangeDir(Direction d, DirDiff delta)
 
{
 
	assert(IsValidDirection(d));
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (Direction)((uint)(d + delta) % 8);
 
}
 

	
 
@@ -112,26 +112,26 @@ static inline Direction ChangeDir(Direct
 
/**
 
 * Returns the reverse direction of the given DiagDirection
 
 *
 
 * @param d The DiagDirection to get the reverse from
 
 * @return The reverse direction
 
 */
 
static inline DiagDirection ReverseDiagDir(DiagDirection d)
 
inline DiagDirection ReverseDiagDir(DiagDirection d)
 
{
 
	assert(IsValidDiagDirection(d));
 
	return (DiagDirection)(2 ^ d);
 
}
 

	
 
/**
 
 * Calculate the difference between two DiagDirection values
 
 *
 
 * @param d0 The first direction as the base
 
 * @param d1 The second direction as the offset from the base
 
 * @return The difference how the second direction drifts of the first one.
 
 */
 
static inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
 
inline DiagDirDiff DiagDirDifference(DiagDirection d0, DiagDirection d1)
 
{
 
	assert(IsValidDiagDirection(d0));
 
	assert(IsValidDiagDirection(d1));
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (DiagDirDiff)((uint)(d0 - d1) % 4);
 
}
 
@@ -143,13 +143,13 @@ static inline DiagDirDiff DiagDirDiffere
 
 * the new DiagDirection.
 
 *
 
 * @param d The DiagDirection
 
 * @param delta The difference to apply on
 
 * @return The new direction which was calculated
 
 */
 
static inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
 
inline DiagDirection ChangeDiagDir(DiagDirection d, DiagDirDiff delta)
 
{
 
	assert(IsValidDiagDirection(d));
 
	/* Cast to uint so compiler can use bitmask. Result can never be negative. */
 
	return (DiagDirection)((uint)(d + delta) % 4);
 
}
 

	
 
@@ -160,13 +160,13 @@ static inline DiagDirection ChangeDiagDi
 
 * the 4-way DiagDirection. If the direction cannot be mapped its
 
 * "rounded clockwise". So DIR_N becomes DIAGDIR_NE.
 
 *
 
 * @param dir The direction to convert
 
 * @return The resulting DiagDirection, maybe "rounded clockwise".
 
 */
 
static inline DiagDirection DirToDiagDir(Direction dir)
 
inline DiagDirection DirToDiagDir(Direction dir)
 
{
 
	assert(IsValidDirection(dir));
 
	return (DiagDirection)(dir >> 1);
 
}
 

	
 
/**
 
@@ -176,13 +176,13 @@ static inline DiagDirection DirToDiagDir
 
 * to the 8-way Direction. As 4-way are less than 8-way not all
 
 * possible directions can be calculated.
 
 *
 
 * @param dir The direction to convert
 
 * @return The resulting Direction
 
 */
 
static inline Direction DiagDirToDir(DiagDirection dir)
 
inline Direction DiagDirToDir(DiagDirection dir)
 
{
 
	assert(IsValidDiagDirection(dir));
 
	return (Direction)(dir * 2 + 1);
 
}
 

	
 

	
 
@@ -191,13 +191,13 @@ static inline Direction DiagDirToDir(Dia
 
 *
 
 * This is basically the not-operator for the axis.
 
 *
 
 * @param a The given axis
 
 * @return The other axis
 
 */
 
static inline Axis OtherAxis(Axis a)
 
inline Axis OtherAxis(Axis a)
 
{
 
	assert(IsValidAxis(a));
 
	return (Axis)(a ^ 1);
 
}
 

	
 

	
 
@@ -208,13 +208,13 @@ static inline Axis OtherAxis(Axis a)
 
 * DiagDirection. The axis X belongs to the DiagDirection
 
 * north-east and south-west.
 
 *
 
 * @param d The DiagDirection
 
 * @return The axis which belongs to the direction
 
 */
 
static inline Axis DiagDirToAxis(DiagDirection d)
 
inline Axis DiagDirToAxis(DiagDirection d)
 
{
 
	assert(IsValidDiagDirection(d));
 
	return (Axis)(d & 1);
 
}
 

	
 

	
 
@@ -226,13 +226,13 @@ static inline Axis DiagDirToAxis(DiagDir
 
 * this function returns the one which points to south,
 
 * either south-west (on X axis) or south-east (on Y axis)
 
 *
 
 * @param a The axis
 
 * @return The direction pointed to south
 
 */
 
static inline DiagDirection AxisToDiagDir(Axis a)
 
inline DiagDirection AxisToDiagDir(Axis a)
 
{
 
	assert(IsValidAxis(a));
 
	return (DiagDirection)(2 - a);
 
}
 

	
 
/**
 
@@ -243,37 +243,37 @@ static inline DiagDirection AxisToDiagDi
 
 * this function returns the one which points to south,
 
 * either south-west (on X axis) or south-east (on Y axis)
 
 *
 
 * @param a The axis
 
 * @return The direction pointed to south
 
 */
 
static inline Direction AxisToDirection(Axis a)
 
inline Direction AxisToDirection(Axis a)
 
{
 
	assert(IsValidAxis(a));
 
	return (Direction)(5 - 2 * a);
 
}
 

	
 
/**
 
 * Convert an axis and a flag for north/south into a DiagDirection
 
 * @param xy axis to convert
 
 * @param ns north -> 0, south -> 1
 
 * @return the desired DiagDirection
 
 */
 
static inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
 
inline DiagDirection XYNSToDiagDir(Axis xy, uint ns)
 
{
 
	assert(IsValidAxis(xy));
 
	return (DiagDirection)(xy * 3 ^ ns * 2);
 
}
 

	
 
/**
 
 * Checks if a given Direction is diagonal.
 
 *
 
 * @param dir The given direction.
 
 * @return True if the direction is diagonal.
 
 */
 
static inline bool IsDiagonalDirection(Direction dir)
 
inline bool IsDiagonalDirection(Direction dir)
 
{
 
	assert(IsValidDirection(dir));
 
	return (dir & 1) != 0;
 
}
 

	
 
#endif /* DIRECTION_FUNC_H */
src/economy_func.h
Show inline comments
 
@@ -41,12 +41,12 @@ void RecomputePrices();
 
bool AddInflation(bool check_year = true);
 

	
 
/**
 
 * Is the economy in recession?
 
 * @return \c True if economy is in recession, \c false otherwise.
 
 */
 
static inline bool EconomyIsInRecession()
 
inline bool EconomyIsInRecession()
 
{
 
	return _economy.fluct <= 0;
 
}
 

	
 
#endif /* ECONOMY_FUNC_H */
src/elrail_func.h
Show inline comments
 
@@ -15,22 +15,22 @@
 
#include "transparency.h"
 

	
 
/**
 
 * Test if a rail type has catenary
 
 * @param rt Rail type to test
 
 */
 
static inline bool HasRailCatenary(RailType rt)
 
inline bool HasRailCatenary(RailType rt)
 
{
 
	return HasBit(GetRailTypeInfo(rt)->flags, RTF_CATENARY);
 
}
 

	
 
/**
 
 * Test if we should draw rail catenary
 
 * @param rt Rail type to test
 
 */
 
static inline bool HasRailCatenaryDrawn(RailType rt)
 
inline bool HasRailCatenaryDrawn(RailType rt)
 
{
 
	return HasRailCatenary(rt) && !IsInvisibilitySet(TO_CATENARY) && !_settings_game.vehicle.disable_elrails;
 
}
 

	
 
void DrawRailCatenary(const TileInfo *ti);
 
void DrawRailCatenaryOnTunnel(const TileInfo *ti);
src/engine_base.h
Show inline comments
 
@@ -208,32 +208,32 @@ struct EngineOverrideManager : std::vect
 

	
 
	static bool ResetToCurrentNewGRFConfig();
 
};
 

	
 
extern EngineOverrideManager _engine_mngr;
 

	
 
static inline const EngineInfo *EngInfo(EngineID e)
 
inline const EngineInfo *EngInfo(EngineID e)
 
{
 
	return &Engine::Get(e)->info;
 
}
 

	
 
static inline const RailVehicleInfo *RailVehInfo(EngineID e)
 
inline const RailVehicleInfo *RailVehInfo(EngineID e)
 
{
 
	return &Engine::Get(e)->u.rail;
 
}
 

	
 
static inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
 
inline const RoadVehicleInfo *RoadVehInfo(EngineID e)
 
{
 
	return &Engine::Get(e)->u.road;
 
}
 

	
 
static inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
 
inline const ShipVehicleInfo *ShipVehInfo(EngineID e)
 
{
 
	return &Engine::Get(e)->u.ship;
 
}
 

	
 
static inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
 
inline const AircraftVehicleInfo *AircraftVehInfo(EngineID e)
 
{
 
	return &Engine::Get(e)->u.air;
 
}
 

	
 
#endif /* ENGINE_BASE_H */
src/fileio_func.h
Show inline comments
 
@@ -105,13 +105,13 @@ int closedir(DIR *d);
 
 * A wrapper around opendir() which will convert the string from
 
 * OPENTTD encoding to that of the filesystem. For all purposes this
 
 * function behaves the same as the original opendir function
 
 * @param path string to open directory of
 
 * @return DIR pointer
 
 */
 
static inline DIR *ttd_opendir(const char *path)
 
inline DIR *ttd_opendir(const char *path)
 
{
 
	return opendir(OTTD2FS(path).c_str());
 
}
 

	
 

	
 
/** Auto-close a file upon scope exit. */
src/fontcache.h
Show inline comments
 
@@ -160,47 +160,47 @@ public:
 
	 * Is this a built-in sprite font?
 
	 */
 
	virtual bool IsBuiltInFont() = 0;
 
};
 

	
 
/** Map a SpriteID to the font size and key */
 
static inline void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
 
inline void SetUnicodeGlyph(FontSize size, char32_t key, SpriteID sprite)
 
{
 
	FontCache::Get(size)->SetUnicodeGlyph(key, sprite);
 
}
 

	
 
/** Initialize the glyph map */
 
static inline void InitializeUnicodeGlyphMap()
 
inline void InitializeUnicodeGlyphMap()
 
{
 
	for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
 
		FontCache::Get(fs)->InitializeUnicodeGlyphMap();
 
	}
 
}
 

	
 
static inline void ClearFontCache()
 
inline void ClearFontCache()
 
{
 
	for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) {
 
		FontCache::Get(fs)->ClearFontCache();
 
	}
 
}
 

	
 
/** Get the Sprite for a glyph */
 
static inline const Sprite *GetGlyph(FontSize size, char32_t key)
 
inline const Sprite *GetGlyph(FontSize size, char32_t key)
 
{
 
	FontCache *fc = FontCache::Get(size);
 
	return fc->GetGlyph(fc->MapCharToGlyph(key));
 
}
 

	
 
/** Get the width of a glyph */
 
static inline uint GetGlyphWidth(FontSize size, char32_t key)
 
inline uint GetGlyphWidth(FontSize size, char32_t key)
 
{
 
	FontCache *fc = FontCache::Get(size);
 
	return fc->GetGlyphWidth(fc->MapCharToGlyph(key));
 
}
 

	
 
static inline bool GetDrawGlyphShadow(FontSize size)
 
inline bool GetDrawGlyphShadow(FontSize size)
 
{
 
	return FontCache::Get(size)->GetDrawGlyphShadow();
 
}
 

	
 
/** Settings for a single font. */
 
struct FontCacheSubSetting {
 
@@ -223,13 +223,13 @@ extern FontCacheSettings _fcsettings;
 

	
 
/**
 
 * Get the settings of a given font size.
 
 * @param fs The font size to look up.
 
 * @return The settings.
 
 */
 
static inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
 
inline FontCacheSubSetting *GetFontCacheSubSetting(FontSize fs)
 
{
 
	switch (fs) {
 
		default: NOT_REACHED();
 
		case FS_SMALL:  return &_fcsettings.small;
 
		case FS_NORMAL: return &_fcsettings.medium;
 
		case FS_LARGE:  return &_fcsettings.large;
src/gfx_func.h
Show inline comments
 
@@ -103,33 +103,33 @@ void GfxFillRect(int left, int top, int 
 
void GfxFillPolygon(const std::vector<Point> &shape, int colour, FillRectMode mode = FILLRECT_OPAQUE);
 
void GfxDrawLine(int left, int top, int right, int bottom, int colour, int width = 1, int dash = 0);
 
void DrawBox(int x, int y, int dx1, int dy1, int dx2, int dy2, int dx3, int dy3);
 
void DrawRectOutline(const Rect &r, int colour, int width = 1, int dash = 0);
 

	
 
/* Versions of DrawString/DrawStringMultiLine that accept a Rect instead of separate left, right, top and bottom parameters. */
 
static inline int DrawString(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
inline int DrawString(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
inline int DrawString(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = SA_LEFT, bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawString(r.left, r.right, r.top, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawStringMultiLine(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
inline int DrawStringMultiLine(const Rect &r, std::string_view str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
inline int DrawStringMultiLine(const Rect &r, StringID str, TextColour colour = TC_FROMSTRING, StringAlignment align = (SA_TOP | SA_LEFT), bool underline = false, FontSize fontsize = FS_NORMAL)
 
{
 
	return DrawStringMultiLine(r.left, r.right, r.top, r.bottom, str, colour, align, underline, fontsize);
 
}
 

	
 
static inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
 
inline void GfxFillRect(const Rect &r, int colour, FillRectMode mode = FILLRECT_OPAQUE)
 
{
 
	GfxFillRect(r.left, r.top, r.right, r.bottom, colour, mode);
 
}
 

	
 
Dimension GetStringBoundingBox(std::string_view str, FontSize start_fontsize = FS_NORMAL);
 
Dimension GetStringBoundingBox(StringID strid, FontSize start_fontsize = FS_NORMAL);
 
@@ -148,25 +148,25 @@ void AddDirtyBlock(int left, int top, in
 
void MarkWholeScreenDirty();
 

	
 
void CheckBlitter();
 

	
 
bool FillDrawPixelInfo(DrawPixelInfo *n, int left, int top, int width, int height);
 

	
 
static inline bool FillDrawPixelInfo(DrawPixelInfo *n, const Rect &r)
 
inline bool FillDrawPixelInfo(DrawPixelInfo *n, const Rect &r)
 
{
 
	return FillDrawPixelInfo(n, r.left, r.top, r.Width(), r.Height());
 
}
 

	
 
/**
 
 * Determine where to draw a centred object inside a widget.
 
 * @param min The top or left coordinate.
 
 * @param max The bottom or right coordinate.
 
 * @param size The height or width of the object to draw.
 
 * @return Offset of where to start drawing the object.
 
 */
 
static inline int CenterBounds(int min, int max, int size)
 
inline int CenterBounds(int min, int max, int size)
 
{
 
	return (min + max - size + 1) / 2;
 
}
 

	
 
/* window.cpp */
 
void DrawOverlappedWindowForAll(int left, int top, int right, int bottom);
src/gfx_type.h
Show inline comments
 
@@ -207,13 +207,13 @@ enum FontSize {
 
	FS_END,
 

	
 
	FS_BEGIN = FS_NORMAL, ///< First font.
 
};
 
DECLARE_POSTFIX_INCREMENT(FontSize)
 

	
 
static inline const char *FontSizeToName(FontSize fs)
 
inline const char *FontSizeToName(FontSize fs)
 
{
 
	static const char *SIZE_TO_NAME[] = { "medium", "small", "large", "mono" };
 
	assert(fs < FS_END);
 
	return SIZE_TO_NAME[fs];
 
}
 

	
src/group.h
Show inline comments
 
@@ -84,23 +84,23 @@ struct Group : GroupPool::PoolItem<&_gro
 
	GroupID parent;             ///< Parent group
 

	
 
	Group(CompanyID owner = INVALID_COMPANY);
 
};
 

	
 

	
 
static inline bool IsDefaultGroupID(GroupID index)
 
inline bool IsDefaultGroupID(GroupID index)
 
{
 
	return index == DEFAULT_GROUP;
 
}
 

	
 
/**
 
 * Checks if a GroupID stands for all vehicles of a company
 
 * @param id_g The GroupID to check
 
 * @return true is id_g is identical to ALL_GROUP
 
 */
 
static inline bool IsAllGroupID(GroupID id_g)
 
inline bool IsAllGroupID(GroupID id_g)
 
{
 
	return id_g == ALL_GROUP;
 
}
 

	
 

	
 
uint GetGroupNumEngines(CompanyID company, GroupID id_g, EngineID id_e);
src/house.h
Show inline comments
 
@@ -134,13 +134,13 @@ struct HouseSpec {
 

	
 
/**
 
 * Do HouseID translation for NewGRFs.
 
 * @param hid the HouseID to get the override for.
 
 * @return the HouseID to actually work with.
 
 */
 
static inline HouseID GetTranslatedHouseID(HouseID hid)
 
inline HouseID GetTranslatedHouseID(HouseID hid)
 
{
 
	const HouseSpec *hs = HouseSpec::Get(hid);
 
	return hs->grf_prop.override == INVALID_HOUSE_ID ? hid : hs->grf_prop.override;
 
}
 

	
 
#endif /* HOUSE_H */
src/industry_map.h
Show inline comments
 
@@ -57,200 +57,200 @@ enum IndustryGraphics {
 
/**
 
 * Get the industry ID of the given tile
 
 * @param t the tile to get the industry ID from
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the industry ID
 
 */
 
static inline IndustryID GetIndustryIndex(Tile t)
 
inline IndustryID GetIndustryIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return t.m2();
 
}
 

	
 
/**
 
 * Is this industry tile fully built?
 
 * @param t the tile to analyze
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return true if and only if the industry tile is fully built
 
 */
 
static inline bool IsIndustryCompleted(Tile t)
 
inline bool IsIndustryCompleted(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return HasBit(t.m1(), 7);
 
}
 

	
 
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(Tile tile)
 
inline void SetIndustryCompleted(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(tile.m1(), 7, 1, 1);
 
}
 

	
 
/**
 
 * Returns the industry construction stage of the specified tile
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return the construction stage
 
 */
 
static inline byte GetIndustryConstructionStage(Tile tile)
 
inline byte GetIndustryConstructionStage(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return IsIndustryCompleted(tile) ? (byte)INDUSTRY_COMPLETED : GB(tile.m1(), 0, 2);
 
}
 

	
 
/**
 
 * Sets the industry construction stage of the specified tile
 
 * @param tile the tile to query
 
 * @param value the new construction stage
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryConstructionStage(Tile tile, byte value)
 
inline void SetIndustryConstructionStage(Tile tile, byte value)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(tile.m1(), 0, 2, value);
 
}
 

	
 
/**
 
 * Get the industry graphics ID for the given industry tile as
 
 * stored in the without translation.
 
 * @param t the tile to get the gfx for
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the gfx ID
 
 */
 
static inline IndustryGfx GetCleanIndustryGfx(Tile t)
 
inline IndustryGfx GetCleanIndustryGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return t.m5() | (GB(t.m6(), 2, 1) << 8);
 
}
 

	
 
/**
 
 * Get the industry graphics ID for the given industry tile
 
 * @param t the tile to get the gfx for
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @return the gfx ID
 
 */
 
static inline IndustryGfx GetIndustryGfx(Tile t)
 
inline IndustryGfx GetIndustryGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	return GetTranslatedIndustryTileID(GetCleanIndustryGfx(t));
 
}
 

	
 
/**
 
 * Set the industry graphics ID for the given industry tile
 
 * @param t   the tile to set the gfx for
 
 * @pre IsTileType(t, MP_INDUSTRY)
 
 * @param gfx the graphics ID
 
 */
 
static inline void SetIndustryGfx(Tile t, IndustryGfx gfx)
 
inline void SetIndustryGfx(Tile t, IndustryGfx gfx)
 
{
 
	assert(IsTileType(t, MP_INDUSTRY));
 
	t.m5() = GB(gfx, 0, 8);
 
	SB(t.m6(), 2, 1, GB(gfx, 8, 1));
 
}
 

	
 
/**
 
 * Returns this industry tile's construction counter value
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 * @return the construction counter
 
 */
 
static inline byte GetIndustryConstructionCounter(Tile tile)
 
inline byte GetIndustryConstructionCounter(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return GB(tile.m1(), 2, 2);
 
}
 

	
 
/**
 
 * Sets this industry tile's construction counter value
 
 * @param tile the tile to query
 
 * @param value the new value for the construction counter
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryConstructionCounter(Tile tile, byte value)
 
inline void SetIndustryConstructionCounter(Tile tile, byte value)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(tile.m1(), 2, 2, value);
 
}
 

	
 
/**
 
 * Reset the construction stage counter of the industry,
 
 * as well as the completion bit.
 
 * In fact, it is the same as restarting construction frmo ground up
 
 * @param tile the tile to query
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void ResetIndustryConstructionStage(Tile tile)
 
inline void ResetIndustryConstructionStage(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(tile.m1(), 0, 4, 0);
 
	SB(tile.m1(), 7, 1, 0);
 
}
 

	
 
/**
 
 * Get the animation loop number
 
 * @param tile the tile to get the animation loop number of
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline byte GetIndustryAnimationLoop(Tile tile)
 
inline byte GetIndustryAnimationLoop(Tile tile)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	return tile.m4();
 
}
 

	
 
/**
 
 * Set the animation loop number
 
 * @param tile the tile to set the animation loop number of
 
 * @param count the new animation frame number
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryAnimationLoop(Tile tile, byte count)
 
inline void SetIndustryAnimationLoop(Tile tile, byte count)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	tile.m4() = count;
 
}
 

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

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

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

	
 

	
 
@@ -258,13 +258,13 @@ static inline byte GetIndustryTriggers(T
 
 * Set the activated triggers bits for this industry tile
 
 * Used for grf callbacks
 
 * @param tile the tile to query
 
 * @param triggers the triggers to set
 
 * @pre IsTileType(tile, MP_INDUSTRY)
 
 */
 
static inline void SetIndustryTriggers(Tile tile, byte triggers)
 
inline void SetIndustryTriggers(Tile tile, byte triggers)
 
{
 
	assert(IsTileType(tile, MP_INDUSTRY));
 
	SB(tile.m6(), 3, 3, triggers);
 
}
 

	
 
/**
 
@@ -272,13 +272,13 @@ static inline void SetIndustryTriggers(T
 
 * @param t      the tile to make an industry tile
 
 * @param index  the industry this tile belongs to
 
 * @param gfx    the graphics to use for the tile
 
 * @param random the random value
 
 * @param wc     the water class for this industry; only useful when build on water
 
 */
 
static inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc)
 
inline void MakeIndustry(Tile t, IndustryID index, IndustryGfx gfx, uint8_t random, WaterClass wc)
 
{
 
	SetTileType(t, MP_INDUSTRY);
 
	t.m1() = 0;
 
	t.m2() = index;
 
	SetIndustryRandomBits(t, random); // m3
 
	t.m4() = 0;
src/industrytype.h
Show inline comments
 
@@ -186,13 +186,13 @@ extern std::array<IndustryType, NUM_INDU
 

	
 
/**
 
 * Do industry gfx ID translation for NewGRFs.
 
 * @param gfx the type to get the override for.
 
 * @return the gfx to actually work with.
 
 */
 
static inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
 
inline IndustryGfx GetTranslatedIndustryTileID(IndustryGfx gfx)
 
{
 
	/* the 0xFF should be GFX_WATERTILE_SPECIALCHECK but for reasons of include mess,
 
	 * we'll simplify the writing.
 
	 * Basically, the first test is required since the GFX_WATERTILE_SPECIALCHECK value
 
	 * will never be assigned as a tile index and is only required in order to do some
 
	 * tests while building the industry (as in WATER REQUIRED */
src/landscape.h
Show inline comments
 
@@ -47,26 +47,26 @@ void GetSlopePixelZOnEdge(Slope tileh, D
 
 * @pre The slope must not be a halftile slope.
 
 *
 
 * @param tileh The slope.
 
 * @param corner The corner.
 
 * @return Z position of corner relative to TileZ.
 
 */
 
static inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
 
inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
 
{
 
	return GetSlopeZInCorner(tileh, corner) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Get slope of a tile on top of a (possible) foundation
 
 * If a tile does not have a foundation, the function returns the same as GetTilePixelSlope.
 
 *
 
 * @param tile The tile of interest.
 
 * @param z returns the z of the foundation slope. (Can be nullptr, if not needed)
 
 * @return The slope on top of the foundation.
 
 */
 
static inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
 
inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
 
{
 
	assert(z != nullptr);
 
	Slope s = GetFoundationSlope(tile, z);
 
	*z *= TILE_HEIGHT;
 
	return s;
 
}
 
@@ -76,13 +76,13 @@ static inline Slope GetFoundationPixelSl
 
 * @param x X world or tile coordinate (runs in SW direction in the 2D view).
 
 * @param y Y world or tile coordinate (runs in SE direction in the 2D view).
 
 * @param z Z world or tile coordinate (runs in N direction in the 2D view).
 
 * @return Equivalent coordinate in the 2D view.
 
 * @see RemapCoords2
 
 */
 
static inline Point RemapCoords(int x, int y, int z)
 
inline Point RemapCoords(int x, int y, int z)
 
{
 
	Point pt;
 
	pt.x = (y - x) * 2 * ZOOM_LVL_BASE;
 
	pt.y = (y + x - z) * ZOOM_LVL_BASE;
 
	return pt;
 
}
 
@@ -92,13 +92,13 @@ static inline Point RemapCoords(int x, i
 
 * Same as #RemapCoords, except the Z coordinate is read from the map.
 
 * @param x X world or tile coordinate (runs in SW direction in the 2D view).
 
 * @param y Y world or tile coordinate (runs in SE direction in the 2D view).
 
 * @return Equivalent coordinate in the 2D view.
 
 * @see RemapCoords
 
 */
 
static inline Point RemapCoords2(int x, int y)
 
inline Point RemapCoords2(int x, int y)
 
{
 
	return RemapCoords(x, y, GetSlopePixelZ(x, y, false));
 
}
 

	
 
/**
 
 * Map 2D viewport or smallmap coordinate to 3D world or tile coordinate.
 
@@ -106,13 +106,13 @@ static inline Point RemapCoords2(int x, 
 
 * @param x X coordinate of the 2D coordinate.
 
 * @param y Y coordinate of the 2D coordinate.
 
 * @return X and Y components of equivalent world or tile coordinate.
 
 * @note Inverse of #RemapCoords function. Smaller values may get rounded.
 
 * @see InverseRemapCoords2
 
 */
 
static inline Point InverseRemapCoords(int x, int y)
 
inline Point InverseRemapCoords(int x, int y)
 
{
 
	Point pt = {(y * 2 - x) >> (2 + ZOOM_LVL_SHIFT), (y * 2 + x) >> (2 + ZOOM_LVL_SHIFT)};
 
	return pt;
 
}
 

	
 
Point InverseRemapCoords2(int x, int y, bool clamp_to_map = false, bool *clamped = nullptr);
 
@@ -123,13 +123,13 @@ uint ApplyFoundationToSlope(Foundation f
 
 *
 
 * @pre      Foundation and slope must be valid combined.
 
 * @param f  The #Foundation.
 
 * @param s  The #Slope to modify.
 
 * @return   Increment to the tile Z coordinate.
 
 */
 
static inline uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
 
inline uint ApplyPixelFoundationToSlope(Foundation f, Slope *s)
 
{
 
	return ApplyFoundationToSlope(f, s) * TILE_HEIGHT;
 
}
 

	
 
void DrawFoundation(TileInfo *ti, Foundation f);
 
bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here);
src/map_func.h
Show inline comments
 
@@ -395,13 +395,13 @@ debug_inline static TileIndex TileXY(uin
 
 *
 
 * @param x The offset in x direction
 
 * @param y The offset in y direction
 
 * @return The resulting offset value of the given coordinate
 
 * @see ToTileIndexDiff(TileIndexDiffC)
 
 */
 
static inline TileIndexDiff TileDiffXY(int x, int y)
 
inline TileIndexDiff TileDiffXY(int x, int y)
 
{
 
	/* Multiplication gives much better optimization on MSVC than shifting.
 
	 * 0 << shift isn't optimized to 0 properly.
 
	 * Typically x and y are constants, and then this doesn't result
 
	 * in any actual multiplication in the assembly code.. */
 
	return (y * Map::SizeX()) + x;
 
@@ -446,13 +446,13 @@ debug_inline static uint TileY(TileIndex
 
 * difference between two tiles.
 
 *
 
 * @param tidc The coordinate of the offset as TileIndexDiffC
 
 * @return The difference between two tiles.
 
 * @see TileDiffXY(int, int)
 
 */
 
static inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
 
inline TileIndexDiff ToTileIndexDiff(TileIndexDiffC tidc)
 
{
 
	return (tidc.y << Map::LogX()) + tidc.x;
 
}
 

	
 

	
 
#ifndef _DEBUG
 
@@ -484,13 +484,13 @@ TileIndex TileAddWrap(TileIndex tile, in
 
/**
 
 * Returns the TileIndexDiffC offset from a DiagDirection.
 
 *
 
 * @param dir The given direction
 
 * @return The offset as TileIndexDiffC value
 
 */
 
static inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
 
inline TileIndexDiffC TileIndexDiffCByDiagDir(DiagDirection dir)
 
{
 
	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
 

	
 
	assert(IsValidDiagDirection(dir));
 
	return _tileoffs_by_diagdir[dir];
 
}
 
@@ -498,13 +498,13 @@ static inline TileIndexDiffC TileIndexDi
 
/**
 
 * Returns the TileIndexDiffC offset from a Direction.
 
 *
 
 * @param dir The given direction
 
 * @return The offset as TileIndexDiffC value
 
 */
 
static inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
 
inline TileIndexDiffC TileIndexDiffCByDir(Direction dir)
 
{
 
	extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
 

	
 
	assert(IsValidDirection(dir));
 
	return _tileoffs_by_dir[dir];
 
}
 
@@ -516,13 +516,13 @@ static inline TileIndexDiffC TileIndexDi
 
 * outside of the map, INVALID_TILE is returned instead.
 
 *
 
 * @param tile The base tile to add the offset on
 
 * @param diff The offset to add on the tile
 
 * @return The resulting TileIndex
 
 */
 
static inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
 
inline TileIndex AddTileIndexDiffCWrap(TileIndex tile, TileIndexDiffC diff)
 
{
 
	int x = TileX(tile) + diff.x;
 
	int y = TileY(tile) + diff.y;
 
	/* Negative value will become big positive value after cast */
 
	if ((uint)x >= Map::SizeX() || (uint)y >= Map::SizeY()) return INVALID_TILE;
 
	return TileXY(x, y);
 
@@ -532,13 +532,13 @@ static inline TileIndex AddTileIndexDiff
 
 * Returns the diff between two tiles
 
 *
 
 * @param tile_a from tile
 
 * @param tile_b to tile
 
 * @return the difference between tila_a and tile_b
 
 */
 
static inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
 
inline TileIndexDiffC TileIndexToTileIndexDiffC(TileIndex tile_a, TileIndex tile_b)
 
{
 
	TileIndexDiffC difference;
 

	
 
	difference.x = TileX(tile_a) - TileX(tile_b);
 
	difference.y = TileY(tile_a) - TileY(tile_b);
 

	
 
@@ -557,13 +557,13 @@ uint DistanceFromEdgeDir(TileIndex, Diag
 
 * Convert a DiagDirection to a TileIndexDiff
 
 *
 
 * @param dir The DiagDirection
 
 * @return The resulting TileIndexDiff
 
 * @see TileIndexDiffCByDiagDir
 
 */
 
static inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
 
inline TileIndexDiff TileOffsByDiagDir(DiagDirection dir)
 
{
 
	extern const TileIndexDiffC _tileoffs_by_diagdir[DIAGDIR_END];
 

	
 
	assert(IsValidDiagDirection(dir));
 
	return ToTileIndexDiff(_tileoffs_by_diagdir[dir]);
 
}
 
@@ -571,13 +571,13 @@ static inline TileIndexDiff TileOffsByDi
 
/**
 
 * Convert a Direction to a TileIndexDiff.
 
 *
 
 * @param dir The direction to convert from
 
 * @return The resulting TileIndexDiff
 
 */
 
static inline TileIndexDiff TileOffsByDir(Direction dir)
 
inline TileIndexDiff TileOffsByDir(Direction dir)
 
{
 
	extern const TileIndexDiffC _tileoffs_by_dir[DIR_END];
 

	
 
	assert(IsValidDirection(dir));
 
	return ToTileIndexDiff(_tileoffs_by_dir[dir]);
 
}
 
@@ -586,37 +586,37 @@ static inline TileIndexDiff TileOffsByDi
 
 * Adds a Direction to a tile.
 
 *
 
 * @param tile The current tile
 
 * @param dir The direction in which we want to step
 
 * @return the moved tile
 
 */
 
static inline TileIndex TileAddByDir(TileIndex tile, Direction dir)
 
inline TileIndex TileAddByDir(TileIndex tile, Direction dir)
 
{
 
	return TILE_ADD(tile, TileOffsByDir(dir));
 
}
 

	
 
/**
 
 * Adds a DiagDir to a tile.
 
 *
 
 * @param tile The current tile
 
 * @param dir The direction in which we want to step
 
 * @return the moved tile
 
 */
 
static inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
 
inline TileIndex TileAddByDiagDir(TileIndex tile, DiagDirection dir)
 
{
 
	return TILE_ADD(tile, TileOffsByDiagDir(dir));
 
}
 

	
 
/**
 
 * Determines the DiagDirection to get from one tile to another.
 
 * The tiles do not necessarily have to be adjacent.
 
 * @param tile_from Origin tile
 
 * @param tile_to Destination tile
 
 * @return DiagDirection from tile_from towards tile_to, or INVALID_DIAGDIR if the tiles are not on an axis
 
 */
 
static inline DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
 
inline DiagDirection DiagdirBetweenTiles(TileIndex tile_from, TileIndex tile_to)
 
{
 
	int dx = (int)TileX(tile_to) - (int)TileX(tile_from);
 
	int dy = (int)TileY(tile_to) - (int)TileY(tile_from);
 
	if (dx == 0) {
 
		if (dy == 0) return INVALID_DIAGDIR;
 
		return (dy < 0 ? DIAGDIR_NW : DIAGDIR_SE);
 
@@ -640,13 +640,13 @@ bool CircularTileSearch(TileIndex *tile,
 

	
 
/**
 
 * Get a random tile out of a given seed.
 
 * @param r the random 'seed'
 
 * @return a valid tile
 
 */
 
static inline TileIndex RandomTileSeed(uint32_t r)
 
inline TileIndex RandomTileSeed(uint32_t r)
 
{
 
	return Map::WrapToMap(r);
 
}
 

	
 
/**
 
 * Get a valid random tile.
src/network/core/os_abstraction.h
Show inline comments
 
@@ -118,13 +118,13 @@ typedef unsigned long in_addr_t;
 
 *
 
 * https://github.com/emscripten-core/emscripten/issues/12996
 
 *
 
 * @param address The address returned by those four functions.
 
 * @return The correct value for addrlen.
 
 */
 
static inline socklen_t FixAddrLenForEmscripten(struct sockaddr_storage &address)
 
inline socklen_t FixAddrLenForEmscripten(struct sockaddr_storage &address)
 
{
 
	switch (address.ss_family) {
 
		case AF_INET6: return sizeof(struct sockaddr_in6);
 
		case AF_INET: return sizeof(struct sockaddr_in);
 
		default: NOT_REACHED();
 
	}
src/newgrf.h
Show inline comments
 
@@ -183,13 +183,13 @@ struct GRFLoadedFeatures {
 

	
 
/**
 
 * Check for grf miscellaneous bits
 
 * @param bit The bit to check.
 
 * @return Whether the bit is set.
 
 */
 
static inline bool HasGrfMiscBit(GrfMiscBit bit)
 
inline bool HasGrfMiscBit(GrfMiscBit bit)
 
{
 
	extern byte _misc_grf_features;
 
	return HasBit(_misc_grf_features, bit);
 
}
 

	
 
/* Indicates which are the newgrf features currently loaded ingame */
src/newgrf_commons.h
Show inline comments
 
@@ -68,13 +68,13 @@ DECLARE_ENUM_AS_BIT_SET(TileLayoutFlags)
 
/**
 
 * Determines which sprite to use from a spriteset for a specific construction stage.
 
 * @param construction_stage Construction stage 0 - 3.
 
 * @param num_sprites Number of available sprites to select stage from.
 
 * @return Sprite to use
 
 */
 
static inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites)
 
inline uint GetConstructionStageOffset(uint construction_stage, uint num_sprites)
 
{
 
	assert(num_sprites > 0);
 
	if (num_sprites > 4) num_sprites = 4;
 
	switch (construction_stage) {
 
		case 0: return 0;
 
		case 1: return num_sprites > 2 ? 1 : 0;
src/newgrf_generic.h
Show inline comments
 
@@ -48,13 +48,13 @@ void ResetGenericCallbacks();
 
void AddGenericCallback(uint8_t feature, const GRFFile *file, const SpriteGroup *group);
 

	
 
uint16_t GetAiPurchaseCallbackResult(uint8_t feature, CargoID cargo_type, uint8_t default_selection, IndustryType src_industry, IndustryType dst_industry, uint8_t distance, AIConstructionEvent event, uint8_t count, uint8_t station_size, const GRFFile **file);
 
void AmbientSoundEffectCallback(TileIndex tile);
 

	
 
/** Play an ambient sound effect for an empty tile. */
 
static inline void AmbientSoundEffect(TileIndex tile)
 
inline void AmbientSoundEffect(TileIndex tile)
 
{
 
	/* Only run callback if enabled. */
 
	if (!HasGrfMiscBit(GMB_AMBIENT_SOUND_CALLBACK)) return;
 

	
 
	AmbientSoundEffectCallback(tile);
 
}
src/newgrf_spritegroup.h
Show inline comments
 
@@ -23,13 +23,13 @@
 
/**
 
 * Gets the value of a so-called newgrf "register".
 
 * @param i index of the register
 
 * @pre i < 0x110
 
 * @return the value of the register
 
 */
 
static inline uint32_t GetRegister(uint i)
 
inline uint32_t GetRegister(uint i)
 
{
 
	extern TemporaryStorageArray<int32_t, 0x110> _temp_store;
 
	return _temp_store.GetValue(i);
 
}
 

	
 
/* List of different sprite group types */
src/news_func.h
Show inline comments
 
@@ -14,43 +14,43 @@
 
#include "vehicle_type.h"
 
#include "station_type.h"
 
#include "industry_type.h"
 

	
 
void AddNewsItem(StringID string, NewsType type, NewsFlag flags, NewsReferenceType reftype1 = NR_NONE, uint32_t ref1 = UINT32_MAX, NewsReferenceType reftype2 = NR_NONE, uint32_t ref2 = UINT32_MAX, const NewsAllocatedData *data = nullptr);
 

	
 
static inline void AddCompanyNewsItem(StringID string, CompanyNewsInformation *cni)
 
inline void AddCompanyNewsItem(StringID string, CompanyNewsInformation *cni)
 
{
 
	AddNewsItem(string, NT_COMPANY_INFO, NF_COMPANY, NR_NONE, UINT32_MAX, NR_NONE, UINT32_MAX, cni);
 
}
 

	
 
/**
 
 * Adds a newsitem referencing a vehicle.
 
 *
 
 * @warning The DParams may not reference the vehicle due to autoreplace stuff. See AddVehicleAdviceNewsItem for how that can be done.
 
 */
 
static inline void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle, StationID station = INVALID_STATION)
 
inline void AddVehicleNewsItem(StringID string, NewsType type, VehicleID vehicle, StationID station = INVALID_STATION)
 
{
 
	AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_VEHICLE, vehicle, station == INVALID_STATION ? NR_NONE : NR_STATION, station);
 
}
 

	
 
/**
 
 * Adds a vehicle-advice news item.
 
 *
 
 * @warning DParam 0 must reference the vehicle!
 
 */
 
static inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
 
inline void AddVehicleAdviceNewsItem(StringID string, VehicleID vehicle)
 
{
 
	AddNewsItem(string, NT_ADVICE, NF_INCOLOUR | NF_SMALL | NF_VEHICLE_PARAM0, NR_VEHICLE, vehicle);
 
}
 

	
 
static inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, const NewsAllocatedData *data = nullptr, StationID station = INVALID_STATION)
 
inline void AddTileNewsItem(StringID string, NewsType type, TileIndex tile, const NewsAllocatedData *data = nullptr, StationID station = INVALID_STATION)
 
{
 
	AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_TILE, tile.base(), station == INVALID_STATION ? NR_NONE : NR_STATION, station, data);
 
}
 

	
 
static inline void AddIndustryNewsItem(StringID string, NewsType type, IndustryID industry, const NewsAllocatedData *data = nullptr)
 
inline void AddIndustryNewsItem(StringID string, NewsType type, IndustryID industry, const NewsAllocatedData *data = nullptr)
 
{
 
	AddNewsItem(string, type, NF_NO_TRANSPARENT | NF_SHADE | NF_THIN, NR_INDUSTRY, industry, NR_NONE, UINT32_MAX, data);
 
}
 

	
 
void NewsLoop();
 
void InitNewsItemStructs();
src/object_map.h
Show inline comments
 
@@ -19,47 +19,47 @@ ObjectType GetObjectType(Tile t);
 
 * Check whether the object on a tile is of a specific type.
 
 * @param t Tile to test.
 
 * @param type Type to test.
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return True if type matches.
 
 */
 
static inline bool IsObjectType(Tile t, ObjectType type)
 
inline bool IsObjectType(Tile t, ObjectType type)
 
{
 
	return GetObjectType(t) == type;
 
}
 

	
 
/**
 
 * Check whether a tile is a object tile of a specific type.
 
 * @param t Tile to test.
 
 * @param type Type to test.
 
 * @return True if type matches.
 
 */
 
static inline bool IsObjectTypeTile(Tile t, ObjectType type)
 
inline bool IsObjectTypeTile(Tile t, ObjectType type)
 
{
 
	return IsTileType(t, MP_OBJECT) && GetObjectType(t) == type;
 
}
 

	
 
/**
 
 * Get the index of which object this tile is attached to.
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return The ObjectID of the object.
 
 */
 
static inline ObjectID GetObjectIndex(Tile t)
 
inline ObjectID GetObjectIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return t.m2() | t.m5() << 16;
 
}
 

	
 
/**
 
 * Get the random bits of this tile.
 
 * @param t The tile to get the bits for.
 
 * @pre IsTileType(t, MP_OBJECT)
 
 * @return The random bits.
 
 */
 
static inline byte GetObjectRandomBits(Tile t)
 
inline byte GetObjectRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_OBJECT));
 
	return t.m3();
 
}
 

	
 

	
 
@@ -68,13 +68,13 @@ static inline byte GetObjectRandomBits(T
 
 * @param t      The tile to make and object tile.
 
 * @param o      The new owner of the tile.
 
 * @param index  Index to the object.
 
 * @param wc     Water class for this object.
 
 * @param random Random data to store on the tile
 
 */
 
static inline void MakeObject(Tile t, Owner o, ObjectID index, WaterClass wc, byte random)
 
inline void MakeObject(Tile t, Owner o, ObjectID index, WaterClass wc, byte random)
 
{
 
	SetTileType(t, MP_OBJECT);
 
	SetTileOwner(t, o);
 
	SetWaterClass(t, wc);
 
	t.m2() = index;
 
	t.m3() = random;
src/os/macosx/macos.h
Show inline comments
 
@@ -19,13 +19,13 @@ void GetMacOSVersion(int *return_major, 
 
 * Check if we are at least running on the specified version of Mac OS.
 
 * @param major major version of the os. This would be 10 in the case of 10.4.11.
 
 * @param minor minor version of the os. This would be 4 in the case of 10.4.11.
 
 * @param bugfix bugfix version of the os. This would be 11 in the case of 10.4.11.
 
 * @return true if the running os is at least what we asked, false otherwise.
 
 */
 
static inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
 
inline bool MacOSVersionIsAtLeast(long major, long minor, long bugfix)
 
{
 
	int version_major, version_minor, version_bugfix;
 
	GetMacOSVersion(&version_major, &version_minor, &version_bugfix);
 

	
 
	if (version_major < major) return false;
 
	if (version_major == major && version_minor < minor) return false;
src/palette_func.h
Show inline comments
 
@@ -18,24 +18,24 @@ extern Palette _cur_palette; ///< Curren
 

	
 
bool CopyPalette(Palette &local_palette, bool force_copy = false);
 
void GfxInitPalettes();
 

	
 
uint8_t GetNearestColourIndex(uint8_t r, uint8_t g, uint8_t b);
 

	
 
static inline uint8_t GetNearestColourIndex(const Colour colour)
 
inline uint8_t GetNearestColourIndex(const Colour colour)
 
{
 
	return GetNearestColourIndex(colour.r, colour.g, colour.b);
 
}
 

	
 
/**
 
 * Checks if a Colours value is valid.
 
 *
 
 * @param colours The value to check
 
 * @return true if the given value is a valid Colours.
 
 */
 
static inline bool IsValidColours(Colours colours)
 
inline bool IsValidColours(Colours colours)
 
{
 
	return colours < COLOUR_END;
 
}
 

	
 
TextColour GetContrastColour(uint8_t background, uint8_t threshold = 128);
 

	
src/pathfinder/pathfinder_func.h
Show inline comments
 
@@ -19,13 +19,13 @@
 
 * as defined by its tile are (st->train_station)
 
 * @param station The station to calculate the distance to
 
 * @param tile The tile from where to calculate the distance
 
 * @param station_type the station type to get the closest tile of
 
 * @return The closest station tile to the given tile.
 
 */
 
static inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile, StationType station_type)
 
inline TileIndex CalcClosestStationTile(StationID station, TileIndex tile, StationType station_type)
 
{
 
	const BaseStation *st = BaseStation::Get(station);
 
	TileArea ta;
 
	st->GetTileArea(&ta, station_type);
 

	
 
	/* If the rail station is (temporarily) not present, use the station sign to drive near the station */
 
@@ -54,13 +54,13 @@ static inline TileIndex CalcClosestStati
 
 * This tile, however, is a valid tile for trams, one on which they can
 
 * reverse safely. To "fix" this, pretend that if we are on a half-tile, we
 
 * are in fact on a straight tram track tile. CFollowTrackT will make sure
 
 * the pathfinders cannot exit on the wrong side and allows reversing on such
 
 * tiles.
 
 */
 
static inline TrackdirBits GetTrackdirBitsForRoad(TileIndex tile, RoadTramType rtt)
 
inline TrackdirBits GetTrackdirBitsForRoad(TileIndex tile, RoadTramType rtt)
 
{
 
	TrackdirBits bits = TrackStatusToTrackdirBits(GetTileTrackStatus(tile, TRANSPORT_ROAD, rtt));
 

	
 
	if (rtt == RTT_TRAM && bits == TRACKDIR_BIT_NONE) {
 
		if (IsNormalRoadTile(tile)) {
 
			RoadBits rb = GetRoadBits(tile, RTT_TRAM);
src/pbs.h
Show inline comments
 
@@ -52,12 +52,12 @@ Train *GetTrainForReservation(TileIndex 
 
 * Check whether some of tracks is reserved on a tile.
 
 *
 
 * @param tile the tile
 
 * @param tracks the tracks to test
 
 * @return true if at least on of tracks is reserved
 
 */
 
static inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
 
inline bool HasReservedTracks(TileIndex tile, TrackBits tracks)
 
{
 
	return (GetReservedTrackbits(tile) & tracks) != TRACK_BIT_NONE;
 
}
 

	
 
#endif /* PBS_H */
src/progress.h
Show inline comments
 
@@ -11,13 +11,13 @@
 
#define PROGRESS_H
 

	
 
/**
 
 * Check if we are currently in a modal progress state.
 
 * @return Are we in the modal state?
 
 */
 
static inline bool HasModalProgress()
 
inline bool HasModalProgress()
 
{
 
	extern bool _in_modal_progress;
 
	return _in_modal_progress;
 
}
 

	
 
void SetModalProgress(bool state);
src/rail.h
Show inline comments
 
@@ -298,13 +298,13 @@ public:
 

	
 
/**
 
 * Returns a pointer to the Railtype information for a given railtype
 
 * @param railtype the rail type which the information is requested for
 
 * @return The pointer to the RailTypeInfo
 
 */
 
static inline const RailTypeInfo *GetRailTypeInfo(RailType railtype)
 
inline const RailTypeInfo *GetRailTypeInfo(RailType railtype)
 
{
 
	extern RailTypeInfo _railtypes[RAILTYPE_END];
 
	assert(railtype < RAILTYPE_END);
 
	return &_railtypes[railtype];
 
}
 

	
 
@@ -313,48 +313,48 @@ static inline const RailTypeInfo *GetRai
 
 * RailType. This would normally just be an equality check, but for electric
 
 * rails (which also support non-electric engines).
 
 * @return Whether the engine can drive on this tile.
 
 * @param  enginetype The RailType of the engine we are considering.
 
 * @param  tiletype   The RailType of the tile we are considering.
 
 */
 
static inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
 
inline bool IsCompatibleRail(RailType enginetype, RailType tiletype)
 
{
 
	return HasBit(GetRailTypeInfo(enginetype)->compatible_railtypes, tiletype);
 
}
 

	
 
/**
 
 * Checks if an engine of the given RailType got power on a tile with a given
 
 * RailType. This would normally just be an equality check, but for electric
 
 * rails (which also support non-electric engines).
 
 * @return Whether the engine got power on this tile.
 
 * @param  enginetype The RailType of the engine we are considering.
 
 * @param  tiletype   The RailType of the tile we are considering.
 
 */
 
static inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
 
inline bool HasPowerOnRail(RailType enginetype, RailType tiletype)
 
{
 
	return HasBit(GetRailTypeInfo(enginetype)->powered_railtypes, tiletype);
 
}
 

	
 
/**
 
 * Test if a RailType disallows build of level crossings.
 
 * @param rt The RailType to check.
 
 * @return Whether level crossings are not allowed.
 
 */
 
static inline bool RailNoLevelCrossings(RailType rt)
 
inline bool RailNoLevelCrossings(RailType rt)
 
{
 
	return HasBit(GetRailTypeInfo(rt)->flags, RTF_NO_LEVEL_CROSSING);
 
}
 

	
 
/**
 
 * Test if 90 degree turns are disallowed between two railtypes.
 
 * @param rt1 First railtype to test for.
 
 * @param rt2 Second railtype to test for.
 
 * @param def Default value to use if the rail type doesn't specify anything.
 
 * @return True if 90 degree turns are disallowed between the two rail types.
 
 */
 
static inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
 
inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
 
{
 
	if (rt1 == INVALID_RAILTYPE || rt2 == INVALID_RAILTYPE) return def;
 

	
 
	const RailTypeInfo *rti1 = GetRailTypeInfo(rt1);
 
	const RailTypeInfo *rti2 = GetRailTypeInfo(rt2);
 

	
 
@@ -366,24 +366,24 @@ static inline bool Rail90DegTurnDisallow
 

	
 
/**
 
 * Returns the cost of building the specified railtype.
 
 * @param railtype The railtype being built.
 
 * @return The cost multiplier.
 
 */
 
static inline Money RailBuildCost(RailType railtype)
 
inline Money RailBuildCost(RailType railtype)
 
{
 
	assert(railtype < RAILTYPE_END);
 
	return (_price[PR_BUILD_RAIL] * GetRailTypeInfo(railtype)->cost_multiplier) >> 3;
 
}
 

	
 
/**
 
 * Returns the 'cost' of clearing the specified railtype.
 
 * @param railtype The railtype being removed.
 
 * @return The cost.
 
 */
 
static inline Money RailClearCost(RailType railtype)
 
inline Money RailClearCost(RailType railtype)
 
{
 
	/* Clearing rail in fact earns money, but if the build cost is set
 
	 * very low then a loophole exists where money can be made.
 
	 * In this case we limit the removal earnings to 3/4s of the build
 
	 * cost.
 
	 */
 
@@ -394,13 +394,13 @@ static inline Money RailClearCost(RailTy
 
/**
 
 * Calculates the cost of rail conversion
 
 * @param from The railtype we are converting from
 
 * @param to   The railtype we are converting to
 
 * @return Cost per TrackBit
 
 */
 
static inline Money RailConvertCost(RailType from, RailType to)
 
inline Money RailConvertCost(RailType from, RailType to)
 
{
 
	/* Get the costs for removing and building anew
 
	 * A conversion can never be more costly */
 
	Money rebuildcost = RailBuildCost(to) + RailClearCost(from);
 

	
 
	/* Conversion between somewhat compatible railtypes:
 
@@ -421,24 +421,24 @@ static inline Money RailConvertCost(Rail
 
 * Calculates the maintenance cost of a number of track bits.
 
 * @param railtype The railtype to get the cost of.
 
 * @param num Number of track bits of this railtype.
 
 * @param total_num Total number of track bits of all railtypes.
 
 * @return Total cost.
 
 */
 
static inline Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
 
inline Money RailMaintenanceCost(RailType railtype, uint32_t num, uint32_t total_num)
 
{
 
	assert(railtype < RAILTYPE_END);
 
	return (_price[PR_INFRASTRUCTURE_RAIL] * GetRailTypeInfo(railtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 11; // 4 bits fraction for the multiplier and 7 bits scaling.
 
}
 

	
 
/**
 
 * Calculates the maintenance cost of a number of signals.
 
 * @param num Number of signals.
 
 * @return Total cost.
 
 */
 
static inline Money SignalMaintenanceCost(uint32_t num)
 
inline Money SignalMaintenanceCost(uint32_t num)
 
{
 
	return (_price[PR_INFRASTRUCTURE_RAIL] * 15 * num * (1 + IntSqrt(num))) >> 8; // 1 bit fraction for the multiplier and 7 bits scaling.
 
}
 

	
 
void DrawTrainDepotSprite(int x, int y, int image, RailType railtype);
 
int TicksToLeaveDepot(const Train *v);
src/rail_map.h
Show inline comments
 
@@ -66,24 +66,24 @@ debug_inline static bool IsPlainRailTile
 
/**
 
 * Checks if a rail tile has signals.
 
 * @param t the tile to get the information from
 
 * @pre IsTileType(t, MP_RAILWAY)
 
 * @return true if and only if the tile has signals
 
 */
 
static inline bool HasSignals(Tile t)
 
inline bool HasSignals(Tile t)
 
{
 
	return GetRailTileType(t) == RAIL_TILE_SIGNALS;
 
}
 

	
 
/**
 
 * Add/remove the 'has signal' bit from the RailTileType
 
 * @param tile the tile to add/remove the signals to/from
 
 * @param signals whether the rail tile should have signals or not
 
 * @pre IsPlainRailTile(tile)
 
 */
 
static inline void SetHasSignals(Tile tile, bool signals)
 
inline void SetHasSignals(Tile tile, bool signals)
 
{
 
	assert(IsPlainRailTile(tile));
 
	SB(tile.m5(), 6, 1, signals);
 
}
 

	
 
/**
 
@@ -109,92 +109,92 @@ debug_inline static bool IsRailDepotTile
 

	
 
/**
 
 * Gets the rail type of the given tile
 
 * @param t the tile to get the rail type from
 
 * @return the rail type of the tile
 
 */
 
static inline RailType GetRailType(Tile t)
 
inline RailType GetRailType(Tile t)
 
{
 
	return (RailType)GB(t.m8(), 0, 6);
 
}
 

	
 
/**
 
 * Sets the rail type of the given tile
 
 * @param t the tile to set the rail type of
 
 * @param r the new rail type for the tile
 
 */
 
static inline void SetRailType(Tile t, RailType r)
 
inline void SetRailType(Tile t, RailType r)
 
{
 
	SB(t.m8(), 0, 6, r);
 
}
 

	
 

	
 
/**
 
 * Gets the track bits of the given tile
 
 * @param tile the tile to get the track bits from
 
 * @return the track bits of the tile
 
 */
 
static inline TrackBits GetTrackBits(Tile tile)
 
inline TrackBits GetTrackBits(Tile tile)
 
{
 
	assert(IsPlainRailTile(tile));
 
	return (TrackBits)GB(tile.m5(), 0, 6);
 
}
 

	
 
/**
 
 * Sets the track bits of the given tile
 
 * @param t the tile to set the track bits of
 
 * @param b the new track bits for the tile
 
 */
 
static inline void SetTrackBits(Tile t, TrackBits b)
 
inline void SetTrackBits(Tile t, TrackBits b)
 
{
 
	assert(IsPlainRailTile(t));
 
	SB(t.m5(), 0, 6, b);
 
}
 

	
 
/**
 
 * Returns whether the given track is present on the given tile.
 
 * @param tile  the tile to check the track presence of
 
 * @param track the track to search for on the tile
 
 * @pre IsPlainRailTile(tile)
 
 * @return true if and only if the given track exists on the tile
 
 */
 
static inline bool HasTrack(Tile tile, Track track)
 
inline bool HasTrack(Tile tile, Track track)
 
{
 
	return HasBit(GetTrackBits(tile), track);
 
}
 

	
 
/**
 
 * Returns the direction the depot is facing to
 
 * @param t the tile to get the depot facing from
 
 * @pre IsRailDepotTile(t)
 
 * @return the direction the depot is facing
 
 */
 
static inline DiagDirection GetRailDepotDirection(Tile t)
 
inline DiagDirection GetRailDepotDirection(Tile t)
 
{
 
	return (DiagDirection)GB(t.m5(), 0, 2);
 
}
 

	
 
/**
 
 * Returns the track of a depot, ignoring direction
 
 * @pre IsRailDepotTile(t)
 
 * @param t the tile to get the depot track from
 
 * @return the track of the depot
 
 */
 
static inline Track GetRailDepotTrack(Tile t)
 
inline Track GetRailDepotTrack(Tile t)
 
{
 
	return DiagDirToDiagTrack(GetRailDepotDirection(t));
 
}
 

	
 

	
 
/**
 
 * Returns the reserved track bits of the tile
 
 * @pre IsPlainRailTile(t)
 
 * @param t the tile to query
 
 * @return the track bits
 
 */
 
static inline TrackBits GetRailReservationTrackBits(Tile t)
 
inline TrackBits GetRailReservationTrackBits(Tile t)
 
{
 
	assert(IsPlainRailTile(t));
 
	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(t.m2(), 11) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
 
@@ -203,13 +203,13 @@ static inline TrackBits GetRailReservati
 
/**
 
 * Sets the reserved track bits of the tile
 
 * @pre IsPlainRailTile(t) && !TracksOverlap(b)
 
 * @param t the tile to change
 
 * @param b the track bits
 
 */
 
static inline void SetTrackReservation(Tile t, TrackBits b)
 
inline void SetTrackReservation(Tile t, TrackBits b)
 
{
 
	assert(IsPlainRailTile(t));
 
	assert(b != INVALID_TRACK_BIT);
 
	assert(!TracksOverlap(b));
 
	Track track = RemoveFirstTrack(&b);
 
	SB(t.m2(), 8, 3, track == INVALID_TRACK ? 0 : track + 1);
 
@@ -220,13 +220,13 @@ static inline void SetTrackReservation(T
 
 * Try to reserve a specific track on a tile
 
 * @pre IsPlainRailTile(t) && HasTrack(tile, t)
 
 * @param tile the tile
 
 * @param t the rack to reserve
 
 * @return true if successful
 
 */
 
static inline bool TryReserveTrack(Tile tile, Track t)
 
inline bool TryReserveTrack(Tile tile, Track t)
 
{
 
	assert(HasTrack(tile, t));
 
	TrackBits bits = TrackToTrackBits(t);
 
	TrackBits res = GetRailReservationTrackBits(tile);
 
	if ((res & bits) != TRACK_BIT_NONE) return false;  // already reserved
 
	res |= bits;
 
@@ -238,13 +238,13 @@ static inline bool TryReserveTrack(Tile 
 
/**
 
 * Lift the reservation of a specific track on a tile
 
 * @pre IsPlainRailTile(t) && HasTrack(tile, t)
 
 * @param tile the tile
 
 * @param t the track to free
 
 */
 
static inline void UnreserveTrack(Tile tile, Track t)
 
inline void UnreserveTrack(Tile tile, Track t)
 
{
 
	assert(HasTrack(tile, t));
 
	TrackBits res = GetRailReservationTrackBits(tile);
 
	res &= ~TrackToTrackBits(t);
 
	SetTrackReservation(tile, res);
 
}
 
@@ -252,204 +252,204 @@ static inline void UnreserveTrack(Tile t
 
/**
 
 * Get the reservation state of the depot
 
 * @pre IsRailDepot(t)
 
 * @param t the depot tile
 
 * @return reservation state
 
 */
 
static inline bool HasDepotReservation(Tile t)
 
inline bool HasDepotReservation(Tile t)
 
{
 
	assert(IsRailDepot(t));
 
	return HasBit(t.m5(), 4);
 
}
 

	
 
/**
 
 * Set the reservation state of the depot
 
 * @pre IsRailDepot(t)
 
 * @param t the depot tile
 
 * @param b the reservation state
 
 */
 
static inline void SetDepotReservation(Tile t, bool b)
 
inline void SetDepotReservation(Tile t, bool b)
 
{
 
	assert(IsRailDepot(t));
 
	SB(t.m5(), 4, 1, (byte)b);
 
}
 

	
 
/**
 
 * Get the reserved track bits for a depot
 
 * @pre IsRailDepot(t)
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetDepotReservationTrackBits(Tile t)
 
inline TrackBits GetDepotReservationTrackBits(Tile t)
 
{
 
	return HasDepotReservation(t) ? TrackToTrackBits(GetRailDepotTrack(t)) : TRACK_BIT_NONE;
 
}
 

	
 

	
 
static inline bool IsPbsSignal(SignalType s)
 
inline bool IsPbsSignal(SignalType s)
 
{
 
	return s == SIGTYPE_PBS || s == SIGTYPE_PBS_ONEWAY;
 
}
 

	
 
static inline SignalType GetSignalType(Tile t, Track track)
 
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(t.m2(), pos, 3);
 
}
 

	
 
static inline void SetSignalType(Tile t, Track track, SignalType s)
 
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(t.m2(), pos, 3, s);
 
	if (track == INVALID_TRACK) SB(t.m2(), 4, 3, s);
 
}
 

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

	
 
static inline bool IsPresignalExit(Tile t, Track track)
 
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(Tile t, Track track)
 
inline bool IsOnewaySignal(Tile t, Track track)
 
{
 
	return GetSignalType(t, track) != SIGTYPE_PBS;
 
}
 

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

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

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

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

	
 
/**
 
 * Set the states of the signals (Along/AgainstTrackDir)
 
 * @param tile  the tile to set the states for
 
 * @param state the new state
 
 */
 
static inline void SetSignalStates(Tile tile, uint state)
 
inline void SetSignalStates(Tile tile, uint state)
 
{
 
	SB(tile.m4(), 4, 4, state);
 
}
 

	
 
/**
 
 * Set the states of the signals (Along/AgainstTrackDir)
 
 * @param tile  the tile to set the states for
 
 * @return the state of the signals
 
 */
 
static inline uint GetSignalStates(Tile tile)
 
inline uint GetSignalStates(Tile tile)
 
{
 
	return GB(tile.m4(), 4, 4);
 
}
 

	
 
/**
 
 * Get the state of a single signal
 
 * @param t         the tile to get the signal state for
 
 * @param signalbit the signal
 
 * @return the state of the signal
 
 */
 
static inline SignalState GetSingleSignalState(Tile t, byte signalbit)
 
inline SignalState GetSingleSignalState(Tile t, byte signalbit)
 
{
 
	return (SignalState)HasBit(GetSignalStates(t), signalbit);
 
}
 

	
 
/**
 
 * Set whether the given signals are present (Along/AgainstTrackDir)
 
 * @param tile    the tile to set the present signals for
 
 * @param signals the signals that have to be present
 
 */
 
static inline void SetPresentSignals(Tile tile, uint signals)
 
inline void SetPresentSignals(Tile tile, uint signals)
 
{
 
	SB(tile.m3(), 4, 4, signals);
 
}
 

	
 
/**
 
 * Get whether the given signals are present (Along/AgainstTrackDir)
 
 * @param tile the tile to get the present signals for
 
 * @return the signals that are present
 
 */
 
static inline uint GetPresentSignals(Tile tile)
 
inline uint GetPresentSignals(Tile tile)
 
{
 
	return GB(tile.m3(), 4, 4);
 
}
 

	
 
/**
 
 * Checks whether the given signals is present
 
 * @param t         the tile to check on
 
 * @param signalbit the signal
 
 * @return true if and only if the signal is present
 
 */
 
static inline bool IsSignalPresent(Tile t, byte signalbit)
 
inline bool IsSignalPresent(Tile t, byte signalbit)
 
{
 
	return HasBit(GetPresentSignals(t), signalbit);
 
}
 

	
 
/**
 
 * Checks for the presence of signals (either way) on the given track on the
 
 * given rail tile.
 
 */
 
static inline bool HasSignalOnTrack(Tile tile, Track track)
 
inline bool HasSignalOnTrack(Tile tile, Track track)
 
{
 
	assert(IsValidTrack(track));
 
	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && (GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
 
}
 

	
 
/**
 
 * Checks for the presence of signals along the given trackdir on the given
 
 * rail 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(Tile tile, Trackdir trackdir)
 
inline bool HasSignalOnTrackdir(Tile tile, Trackdir trackdir)
 
{
 
	assert (IsValidTrackdir(trackdir));
 
	return GetRailTileType(tile) == RAIL_TILE_SIGNALS && GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
 
}
 

	
 
/**
 
 * Gets the state of the signal along the given trackdir.
 
 *
 
 * 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(Tile tile, Trackdir trackdir)
 
inline SignalState GetSignalStateByTrackdir(Tile tile, Trackdir trackdir)
 
{
 
	assert(IsValidTrackdir(trackdir));
 
	assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
 
	return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
 
		SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
 
}
 

	
 
/**
 
 * Sets the state of the signal along the given trackdir.
 
 */
 
static inline void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
 
inline void SetSignalStateByTrackdir(Tile tile, Trackdir trackdir, SignalState state)
 
{
 
	if (state == SIGNAL_STATE_GREEN) { // set 1
 
		SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
 
	} else {
 
		SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir));
 
	}
 
@@ -457,25 +457,25 @@ static inline void SetSignalStateByTrack
 

	
 
/**
 
 * Is a pbs signal present along the trackdir?
 
 * @param tile the tile to check
 
 * @param td the trackdir to check
 
 */
 
static inline bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
 
inline bool HasPbsSignalOnTrackdir(Tile tile, Trackdir td)
 
{
 
	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, td) &&
 
			IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
 
}
 

	
 
/**
 
 * Is a one-way signal blocking the trackdir? A one-way signal on the
 
 * trackdir against will block, but signals on both trackdirs won't.
 
 * @param tile the tile to check
 
 * @param td the trackdir to check
 
 */
 
static inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
 
inline bool HasOnewaySignalBlockingTrackdir(Tile tile, Trackdir td)
 
{
 
	return IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
 
			!HasSignalOnTrackdir(tile, td) && IsOnewaySignal(tile, TrackdirToTrack(td));
 
}
 

	
 

	
 
@@ -497,29 +497,29 @@ enum RailGroundType {
 
	RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
 
	RAIL_GROUND_ICE_DESERT   = 12, ///< Icy or sandy
 
	RAIL_GROUND_WATER        = 13, ///< Grass with a fence and shore or water on the free halftile
 
	RAIL_GROUND_HALF_SNOW    = 14, ///< Snow only on higher part of slope (steep or one corner raised)
 
};
 

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

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

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

	
 

	
 
static inline void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
 
inline void MakeRailNormal(Tile t, Owner o, TrackBits b, RailType r)
 
{
 
	SetTileType(t, MP_RAILWAY);
 
	SetTileOwner(t, o);
 
	SetDockingTile(t, false);
 
	t.m2() = 0;
 
	t.m3() = 0;
 
@@ -532,13 +532,13 @@ static inline void MakeRailNormal(Tile t
 

	
 
/**
 
 * Sets the exit direction of a rail depot.
 
 * @param tile Tile of the depot.
 
 * @param dir  Direction of the depot exit.
 
 */
 
static inline void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
 
inline void SetRailDepotExitDirection(Tile tile, DiagDirection dir)
 
{
 
	assert(IsRailDepotTile(tile));
 
	SB(tile.m5(), 0, 2, dir);
 
}
 

	
 
/**
 
@@ -546,13 +546,13 @@ static inline void SetRailDepotExitDirec
 
 * @param tile      Tile to make a depot on.
 
 * @param owner     New owner of the depot.
 
 * @param depot_id  New depot ID.
 
 * @param dir       Direction of the depot exit.
 
 * @param rail_type Rail type of the depot.
 
 */
 
static inline void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
 
inline void MakeRailDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RailType rail_type)
 
{
 
	SetTileType(tile, MP_RAILWAY);
 
	SetTileOwner(tile, owner);
 
	SetDockingTile(tile, false);
 
	tile.m2() = depot_id;
 
	tile.m3() = 0;
src/road.h
Show inline comments
 
@@ -193,38 +193,38 @@ public:
 
		return this->group[ROTSG_GROUND] != nullptr;
 
	}
 
};
 

	
 
extern RoadTypes _roadtypes_type;
 

	
 
static inline bool RoadTypeIsRoad(RoadType roadtype)
 
inline bool RoadTypeIsRoad(RoadType roadtype)
 
{
 
	return !HasBit(_roadtypes_type, roadtype);
 
}
 

	
 
static inline bool RoadTypeIsTram(RoadType roadtype)
 
inline bool RoadTypeIsTram(RoadType roadtype)
 
{
 
	return HasBit(_roadtypes_type, roadtype);
 
}
 

	
 
static inline RoadTramType GetRoadTramType(RoadType roadtype)
 
inline RoadTramType GetRoadTramType(RoadType roadtype)
 
{
 
	return RoadTypeIsTram(roadtype) ? RTT_TRAM : RTT_ROAD;
 
}
 

	
 
static inline RoadTramType OtherRoadTramType(RoadTramType rtt)
 
inline RoadTramType OtherRoadTramType(RoadTramType rtt)
 
{
 
	return rtt == RTT_ROAD ? RTT_TRAM : RTT_ROAD;
 
}
 

	
 
/**
 
 * Returns a pointer to the Roadtype information for a given roadtype
 
 * @param roadtype the road type which the information is requested for
 
 * @return The pointer to the RoadTypeInfo
 
 */
 
static inline const RoadTypeInfo *GetRoadTypeInfo(RoadType roadtype)
 
inline const RoadTypeInfo *GetRoadTypeInfo(RoadType roadtype)
 
{
 
	extern RoadTypeInfo _roadtypes[ROADTYPE_END];
 
	assert(roadtype < ROADTYPE_END);
 
	return &_roadtypes[roadtype];
 
}
 

	
 
@@ -233,34 +233,34 @@ static inline const RoadTypeInfo *GetRoa
 
 * RoadType. This would normally just be an equality check, but for electrified
 
 * roads (which also support non-electric vehicles).
 
 * @return Whether the engine got power on this tile.
 
 * @param  enginetype The RoadType of the engine we are considering.
 
 * @param  tiletype   The RoadType of the tile we are considering.
 
 */
 
static inline bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
 
inline bool HasPowerOnRoad(RoadType enginetype, RoadType tiletype)
 
{
 
	return HasBit(GetRoadTypeInfo(enginetype)->powered_roadtypes, tiletype);
 
}
 

	
 
/**
 
 * Returns the cost of building the specified roadtype.
 
 * @param roadtype The roadtype being built.
 
 * @return The cost multiplier.
 
 */
 
static inline Money RoadBuildCost(RoadType roadtype)
 
inline Money RoadBuildCost(RoadType roadtype)
 
{
 
	assert(roadtype < ROADTYPE_END);
 
	return (_price[PR_BUILD_ROAD] * GetRoadTypeInfo(roadtype)->cost_multiplier) >> 3;
 
}
 

	
 
/**
 
 * Returns the cost of clearing the specified roadtype.
 
 * @param roadtype The roadtype being removed.
 
 * @return The cost.
 
 */
 
static inline Money RoadClearCost(RoadType roadtype)
 
inline Money RoadClearCost(RoadType roadtype)
 
{
 
	assert(roadtype < ROADTYPE_END);
 

	
 
	/* Flat fee for removing road. */
 
	if (RoadTypeIsRoad(roadtype)) return _price[PR_CLEAR_ROAD];
 

	
 
@@ -272,13 +272,13 @@ static inline Money RoadClearCost(RoadTy
 
/**
 
 * Calculates the cost of road conversion
 
 * @param from The roadtype we are converting from
 
 * @param to   The roadtype we are converting to
 
 * @return Cost per RoadBit
 
 */
 
static inline Money RoadConvertCost(RoadType from, RoadType to)
 
inline Money RoadConvertCost(RoadType from, RoadType to)
 
{
 
	/* Don't apply convert costs when converting to the same roadtype (ex. building a roadstop over existing road) */
 
	if (from == to) return (Money)0;
 

	
 
	/* Same cost as removing and then building. */
 
	return RoadBuildCost(to) + RoadClearCost(from);
 
@@ -286,13 +286,13 @@ static inline Money RoadConvertCost(Road
 

	
 
/**
 
 * Test if road disallows level crossings
 
 * @param roadtype The roadtype we are testing
 
 * @return True iff the roadtype disallows level crossings
 
 */
 
static inline bool RoadNoLevelCrossing(RoadType roadtype)
 
inline bool RoadNoLevelCrossing(RoadType roadtype)
 
{
 
	assert(roadtype < ROADTYPE_END);
 
	return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_NO_LEVEL_CROSSING);
 
}
 

	
 
RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels = true);
src/road_func.h
Show inline comments
 
@@ -17,13 +17,13 @@
 

	
 
/**
 
 * Whether the given roadtype is valid.
 
 * @param r the roadtype to check for validness
 
 * @return true if and only if valid
 
 */
 
static inline bool IsValidRoadBits(RoadBits r)
 
inline bool IsValidRoadBits(RoadBits r)
 
{
 
	return r < ROAD_END;
 
}
 

	
 
/**
 
 * Calculate the complement of a RoadBits value
 
@@ -31,13 +31,13 @@ static inline bool IsValidRoadBits(RoadB
 
 * Simply flips all bits in the RoadBits value to get the complement
 
 * of the RoadBits.
 
 *
 
 * @param r The given RoadBits value
 
 * @return the complement
 
 */
 
static inline RoadBits ComplementRoadBits(RoadBits r)
 
inline RoadBits ComplementRoadBits(RoadBits r)
 
{
 
	assert(IsValidRoadBits(r));
 
	return (RoadBits)(ROAD_ALL ^ r);
 
}
 

	
 
/**
 
@@ -45,13 +45,13 @@ static inline RoadBits ComplementRoadBit
 
 *
 
 * Simply move the bits to their new position.
 
 *
 
 * @param r The given RoadBits value
 
 * @return the mirrored
 
 */
 
static inline RoadBits MirrorRoadBits(RoadBits r)
 
inline RoadBits MirrorRoadBits(RoadBits r)
 
{
 
	assert(IsValidRoadBits(r));
 
	return (RoadBits)(GB(r, 0, 2) << 2 | GB(r, 2, 2));
 
}
 

	
 
/**
 
@@ -60,13 +60,13 @@ static inline RoadBits MirrorRoadBits(Ro
 
 * Move the Roadbits clockwise until they are in their final position.
 
 *
 
 * @param r The given RoadBits value
 
 * @param rot The given Rotation angle
 
 * @return the rotated
 
 */
 
static inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
 
inline RoadBits RotateRoadBits(RoadBits r, DiagDirDiff rot)
 
{
 
	assert(IsValidRoadBits(r));
 
	for (; rot > (DiagDirDiff)0; rot--) {
 
		r = (RoadBits)(GB(r, 0, 1) << 3 | GB(r, 1, 3));
 
	}
 
	return r;
 
@@ -75,13 +75,13 @@ static inline RoadBits RotateRoadBits(Ro
 
/**
 
 * Check if we've got a straight road
 
 *
 
 * @param r The given RoadBits
 
 * @return true if we've got a straight road
 
 */
 
static inline bool IsStraightRoad(RoadBits r)
 
inline bool IsStraightRoad(RoadBits r)
 
{
 
	assert(IsValidRoadBits(r));
 
	return (r == ROAD_X || r == ROAD_Y);
 
}
 

	
 
/**
 
@@ -90,13 +90,13 @@ static inline bool IsStraightRoad(RoadBi
 
 * This function returns a RoadBits value which belongs to
 
 * the given DiagDirection.
 
 *
 
 * @param d The DiagDirection
 
 * @return The result RoadBits which the selected road-part set
 
 */
 
static inline RoadBits DiagDirToRoadBits(DiagDirection d)
 
inline RoadBits DiagDirToRoadBits(DiagDirection d)
 
{
 
	assert(IsValidDiagDirection(d));
 
	return (RoadBits)(ROAD_NW << (3 ^ d));
 
}
 

	
 
/**
 
@@ -105,13 +105,13 @@ static inline RoadBits DiagDirToRoadBits
 
 * This function returns a RoadBits value which belongs to
 
 * the given Axis.
 
 *
 
 * @param a The Axis
 
 * @return The result RoadBits which the selected road-part set
 
 */
 
static inline RoadBits AxisToRoadBits(Axis a)
 
inline RoadBits AxisToRoadBits(Axis a)
 
{
 
	assert(IsValidAxis(a));
 
	return a == AXIS_X ? ROAD_X : ROAD_Y;
 
}
 

	
 

	
 
@@ -119,33 +119,33 @@ static inline RoadBits AxisToRoadBits(Ax
 
 * Calculates the maintenance cost of a number of road bits.
 
 * @param roadtype Road type to get the cost for.
 
 * @param num Number of road bits.
 
 * @param total_num Total number of road bits of all road/tram-types.
 
 * @return Total cost.
 
 */
 
static inline Money RoadMaintenanceCost(RoadType roadtype, uint32_t num, uint32_t total_num)
 
inline Money RoadMaintenanceCost(RoadType roadtype, uint32_t num, uint32_t total_num)
 
{
 
	assert(roadtype < ROADTYPE_END);
 
	return (_price[PR_INFRASTRUCTURE_ROAD] * GetRoadTypeInfo(roadtype)->maintenance_multiplier * num * (1 + IntSqrt(total_num))) >> 12;
 
}
 

	
 
/**
 
 * Test if a road type has catenary
 
 * @param roadtype Road type to test
 
 */
 
static inline bool HasRoadCatenary(RoadType roadtype)
 
inline bool HasRoadCatenary(RoadType roadtype)
 
{
 
	assert(roadtype < ROADTYPE_END);
 
	return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_CATENARY);
 
}
 

	
 
/**
 
 * Test if we should draw road catenary
 
 * @param roadtype Road type to test
 
 */
 
static inline bool HasRoadCatenaryDrawn(RoadType roadtype)
 
inline bool HasRoadCatenaryDrawn(RoadType roadtype)
 
{
 
	return HasRoadCatenary(roadtype) && !IsInvisibilitySet(TO_CATENARY);
 
}
 

	
 
bool HasRoadTypeAvail(CompanyID company, RoadType roadtype);
 
bool ValParamRoadType(RoadType roadtype);
src/road_map.h
Show inline comments
 
@@ -27,13 +27,13 @@ enum RoadTileType {
 

	
 
/**
 
 * Test whether a tile can have road/tram types.
 
 * @param t Tile to query.
 
 * @return true if tile can be queried about road/tram types.
 
 */
 
static inline bool MayHaveRoad(Tile t)
 
inline bool MayHaveRoad(Tile t)
 
{
 
	switch (GetTileType(t)) {
 
		case MP_ROAD:
 
		case MP_STATION:
 
		case MP_TUNNELBRIDGE:
 
			return true;
 
@@ -79,23 +79,23 @@ debug_inline static bool IsNormalRoadTil
 
/**
 
 * Return whether a tile is a level crossing.
 
 * @param t Tile to query.
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return True if level crossing.
 
 */
 
static inline bool IsLevelCrossing(Tile t)
 
inline bool IsLevelCrossing(Tile t)
 
{
 
	return GetRoadTileType(t) == ROAD_TILE_CROSSING;
 
}
 

	
 
/**
 
 * Return whether a tile is a level crossing tile.
 
 * @param t Tile to query.
 
 * @return True if level crossing tile.
 
 */
 
static inline bool IsLevelCrossingTile(Tile t)
 
inline bool IsLevelCrossingTile(Tile t)
 
{
 
	return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
 
}
 

	
 
/**
 
 * Return whether a tile is a road depot.
 
@@ -122,119 +122,119 @@ debug_inline static bool IsRoadDepotTile
 
 * Get the present road bits for a specific road type.
 
 * @param t  The tile to query.
 
 * @param rt Road type.
 
 * @pre IsNormalRoad(t)
 
 * @return The present road bits for the road type.
 
 */
 
static inline RoadBits GetRoadBits(Tile t, RoadTramType rtt)
 
inline RoadBits GetRoadBits(Tile t, RoadTramType rtt)
 
{
 
	assert(IsNormalRoad(t));
 
	if (rtt == RTT_TRAM) return (RoadBits)GB(t.m3(), 0, 4);
 
	return (RoadBits)GB(t.m5(), 0, 4);
 
}
 

	
 
/**
 
 * Get all set RoadBits on the given tile
 
 *
 
 * @param tile The tile from which we want to get the RoadBits
 
 * @return all set RoadBits of the tile
 
 */
 
static inline RoadBits GetAllRoadBits(Tile tile)
 
inline RoadBits GetAllRoadBits(Tile tile)
 
{
 
	return GetRoadBits(tile, RTT_ROAD) | GetRoadBits(tile, RTT_TRAM);
 
}
 

	
 
/**
 
 * Set the present road bits for a specific road type.
 
 * @param t  The tile to change.
 
 * @param r  The new road bits.
 
 * @param rt Road type.
 
 * @pre IsNormalRoad(t)
 
 */
 
static inline void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
 
inline void SetRoadBits(Tile t, RoadBits r, RoadTramType rtt)
 
{
 
	assert(IsNormalRoad(t)); // XXX incomplete
 
	if (rtt == RTT_TRAM) {
 
		SB(t.m3(), 0, 4, r);
 
	} else {
 
		SB(t.m5(), 0, 4, r);
 
	}
 
}
 

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

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

	
 
static inline RoadType GetRoadType(Tile t, RoadTramType rtt)
 
inline RoadType GetRoadType(Tile t, RoadTramType rtt)
 
{
 
	return (rtt == RTT_TRAM) ? GetRoadTypeTram(t) : GetRoadTypeRoad(t);
 
}
 

	
 
/**
 
 * Get the present road types of a tile.
 
 * @param t The tile to query.
 
 * @return Present road types.
 
 */
 
static inline RoadTypes GetPresentRoadTypes(Tile t)
 
inline RoadTypes GetPresentRoadTypes(Tile t)
 
{
 
	RoadTypes result = ROADTYPES_NONE;
 
	if (MayHaveRoad(t)) {
 
		if (GetRoadTypeRoad(t) != INVALID_ROADTYPE) SetBit(result, GetRoadTypeRoad(t));
 
		if (GetRoadTypeTram(t) != INVALID_ROADTYPE) SetBit(result, GetRoadTypeTram(t));
 
	}
 
	return result;
 
}
 

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

	
 
static inline bool HasRoadTypeTram(Tile t)
 
inline bool HasRoadTypeTram(Tile t)
 
{
 
	return GetRoadTypeTram(t) != INVALID_ROADTYPE;
 
}
 

	
 
/**
 
 * Check if a tile has a road or a tram road type.
 
 * @param t  The tile to check.
 
 * @param tram True to check tram, false to check road.
 
 * @return True if the tile has the specified road type.
 
 */
 
static inline bool HasTileRoadType(Tile t, RoadTramType rtt)
 
inline bool HasTileRoadType(Tile t, RoadTramType rtt)
 
{
 
	return GetRoadType(t, rtt) != INVALID_ROADTYPE;
 
}
 

	
 
/**
 
 * Check if a tile has one of the specified road types.
 
 * @param t  The tile to check.
 
 * @param rts Allowed road types.
 
 * @return True if the tile has one of the specified road types.
 
 */
 
static inline bool HasTileAnyRoadType(Tile t, RoadTypes rts)
 
inline bool HasTileAnyRoadType(Tile t, RoadTypes rts)
 
{
 
	if (!MayHaveRoad(t)) return false;
 
	return (GetPresentRoadTypes(t) & rts);
 
}
 

	
 
/**
 
 * Get the owner of a specific road type.
 
 * @param t  The tile to query.
 
 * @param rtt RoadTramType.
 
 * @return Owner of the given road type.
 
 */
 
static inline Owner GetRoadOwner(Tile t, RoadTramType rtt)
 
inline Owner GetRoadOwner(Tile t, RoadTramType rtt)
 
{
 
	assert(MayHaveRoad(t));
 
	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 */
 
@@ -245,13 +245,13 @@ static inline Owner GetRoadOwner(Tile t,
 
/**
 
 * Set the owner of a specific road type.
 
 * @param t  The tile to change.
 
 * @param rtt RoadTramType.
 
 * @param o  New owner of the given road type.
 
 */
 
static inline void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
inline void SetRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
{
 
	if (rtt == RTT_ROAD) {
 
		SB(IsNormalRoadTile(t) ? t.m1() : t.m7(), 0, 5, o);
 
	} else {
 
		SB(t.m3(), 4, 4, o == OWNER_NONE ? OWNER_TOWN : o);
 
	}
 
@@ -262,215 +262,215 @@ static inline void SetRoadOwner(Tile t, 
 
 * @param t  The tile to query.
 
 * @param tram True to check tram, false to check road.
 
 * @param o  Owner to compare with.
 
 * @pre HasTileRoadType(t, rt)
 
 * @return True if the road type is owned by the given owner.
 
 */
 
static inline bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
inline bool IsRoadOwner(Tile t, RoadTramType rtt, Owner o)
 
{
 
	assert(HasTileRoadType(t, rtt));
 
	return (GetRoadOwner(t, rtt) == o);
 
}
 

	
 
/**
 
 * Checks if given tile has town owned road
 
 * @param t tile to check
 
 * @pre IsTileType(t, MP_ROAD)
 
 * @return true iff tile has road and the road is owned by a town
 
 */
 
static inline bool HasTownOwnedRoad(Tile t)
 
inline bool HasTownOwnedRoad(Tile t)
 
{
 
	return HasTileRoadType(t, RTT_ROAD) && IsRoadOwner(t, RTT_ROAD, OWNER_TOWN);
 
}
 

	
 
/**
 
 * Checks if a DisallowedRoadDirections is valid.
 
 *
 
 * @param wc The value to check
 
 * @return true if the given value is a valid DisallowedRoadDirections.
 
 */
 
static inline bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
 
inline bool IsValidDisallowedRoadDirections(DisallowedRoadDirections drt)
 
{
 
	return drt < DRD_END;
 
}
 

	
 
/**
 
 * Gets the disallowed directions
 
 * @param t the tile to get the directions from
 
 * @return the disallowed directions
 
 */
 
static inline DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
 
inline DisallowedRoadDirections GetDisallowedRoadDirections(Tile t)
 
{
 
	assert(IsNormalRoad(t));
 
	return (DisallowedRoadDirections)GB(t.m5(), 4, 2);
 
}
 

	
 
/**
 
 * Sets the disallowed directions
 
 * @param t   the tile to set the directions for
 
 * @param drd the disallowed directions
 
 */
 
static inline void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
 
inline void SetDisallowedRoadDirections(Tile t, DisallowedRoadDirections drd)
 
{
 
	assert(IsNormalRoad(t));
 
	assert(drd < DRD_END);
 
	SB(t.m5(), 4, 2, drd);
 
}
 

	
 
/**
 
 * Get the road axis of a level crossing.
 
 * @param t The tile to query.
 
 * @pre IsLevelCrossing(t)
 
 * @return The axis of the road.
 
 */
 
static inline Axis GetCrossingRoadAxis(Tile t)
 
inline Axis GetCrossingRoadAxis(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return (Axis)GB(t.m5(), 0, 1);
 
}
 

	
 
/**
 
 * Get the rail axis of a level crossing.
 
 * @param t The tile to query.
 
 * @pre IsLevelCrossing(t)
 
 * @return The axis of the rail.
 
 */
 
static inline Axis GetCrossingRailAxis(Tile t)
 
inline Axis GetCrossingRailAxis(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return OtherAxis((Axis)GetCrossingRoadAxis(t));
 
}
 

	
 
/**
 
 * Get the road bits of a level crossing.
 
 * @param tile The tile to query.
 
 * @return The present road bits.
 
 */
 
static inline RoadBits GetCrossingRoadBits(Tile tile)
 
inline RoadBits GetCrossingRoadBits(Tile tile)
 
{
 
	return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
 
}
 

	
 
/**
 
 * Get the rail track of a level crossing.
 
 * @param tile The tile to query.
 
 * @return The rail track.
 
 */
 
static inline Track GetCrossingRailTrack(Tile tile)
 
inline Track GetCrossingRailTrack(Tile tile)
 
{
 
	return AxisToTrack(GetCrossingRailAxis(tile));
 
}
 

	
 
/**
 
 * Get the rail track bits of a level crossing.
 
 * @param tile The tile to query.
 
 * @return The rail track bits.
 
 */
 
static inline TrackBits GetCrossingRailBits(Tile tile)
 
inline TrackBits GetCrossingRailBits(Tile tile)
 
{
 
	return AxisToTrackBits(GetCrossingRailAxis(tile));
 
}
 

	
 

	
 
/**
 
 * Get the reservation state of the rail crossing
 
 * @param t the crossing tile
 
 * @return reservation state
 
 * @pre IsLevelCrossingTile(t)
 
 */
 
static inline bool HasCrossingReservation(Tile t)
 
inline bool HasCrossingReservation(Tile t)
 
{
 
	assert(IsLevelCrossingTile(t));
 
	return HasBit(t.m5(), 4);
 
}
 

	
 
/**
 
 * Set the reservation state of the rail crossing
 
 * @note Works for both waypoints and rail depots
 
 * @param t the crossing tile
 
 * @param b the reservation state
 
 * @pre IsLevelCrossingTile(t)
 
 */
 
static inline void SetCrossingReservation(Tile t, bool b)
 
inline void SetCrossingReservation(Tile t, bool b)
 
{
 
	assert(IsLevelCrossingTile(t));
 
	SB(t.m5(), 4, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Get the reserved track bits for a rail crossing
 
 * @param t the tile
 
 * @pre IsLevelCrossingTile(t)
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetCrossingReservationTrackBits(Tile t)
 
inline TrackBits GetCrossingReservationTrackBits(Tile t)
 
{
 
	return HasCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
 
}
 

	
 
/**
 
 * Check if the level crossing is barred.
 
 * @param t The tile to query.
 
 * @pre IsLevelCrossing(t)
 
 * @return True if the level crossing is barred.
 
 */
 
static inline bool IsCrossingBarred(Tile t)
 
inline bool IsCrossingBarred(Tile t)
 
{
 
	assert(IsLevelCrossing(t));
 
	return HasBit(t.m5(), 5);
 
}
 

	
 
/**
 
 * Set the bar state of a level crossing.
 
 * @param t The tile to modify.
 
 * @param barred True if the crossing should be barred, false otherwise.
 
 * @pre IsLevelCrossing(t)
 
 */
 
static inline void SetCrossingBarred(Tile t, bool barred)
 
inline void SetCrossingBarred(Tile t, bool barred)
 
{
 
	assert(IsLevelCrossing(t));
 
	SB(t.m5(), 5, 1, barred ? 1 : 0);
 
}
 

	
 
/**
 
 * Unbar a level crossing.
 
 * @param t The tile to change.
 
 */
 
static inline void UnbarCrossing(Tile t)
 
inline void UnbarCrossing(Tile t)
 
{
 
	SetCrossingBarred(t, false);
 
}
 

	
 
/**
 
 * Bar a level crossing.
 
 * @param t The tile to change.
 
 */
 
static inline void BarCrossing(Tile t)
 
inline void BarCrossing(Tile t)
 
{
 
	SetCrossingBarred(t, true);
 
}
 

	
 
/** Check if a road tile has snow/desert. */
 
#define IsOnDesert IsOnSnow
 
/**
 
 * Check if a road tile has snow/desert.
 
 * @param t The tile to query.
 
 * @return True if the tile has snow/desert.
 
 */
 
static inline bool IsOnSnow(Tile t)
 
inline bool IsOnSnow(Tile t)
 
{
 
	return HasBit(t.m7(), 5);
 
}
 

	
 
/** Toggle the snow/desert state of a road tile. */
 
#define ToggleDesert ToggleSnow
 
/**
 
 * Toggle the snow/desert state of a road tile.
 
 * @param t The tile to change.
 
 */
 
static inline void ToggleSnow(Tile t)
 
inline void ToggleSnow(Tile t)
 
{
 
	ToggleBit(t.m7(), 5);
 
}
 

	
 

	
 
/** The possible road side decorations. */
 
@@ -487,55 +487,55 @@ enum Roadside {
 

	
 
/**
 
 * Get the decorations of a road.
 
 * @param tile The tile to query.
 
 * @return The road decoration of the tile.
 
 */
 
static inline Roadside GetRoadside(Tile tile)
 
inline Roadside GetRoadside(Tile tile)
 
{
 
	return (Roadside)GB(tile.m6(), 3, 3);
 
}
 

	
 
/**
 
 * Set the decorations of a road.
 
 * @param tile The tile to change.
 
 * @param s    The new road decoration of the tile.
 
 */
 
static inline void SetRoadside(Tile tile, Roadside s)
 
inline void SetRoadside(Tile tile, Roadside s)
 
{
 
	SB(tile.m6(), 3, 3, s);
 
}
 

	
 
/**
 
 * Check if a tile has road works.
 
 * @param t The tile to check.
 
 * @return True if the tile has road works in progress.
 
 */
 
static inline bool HasRoadWorks(Tile t)
 
inline bool HasRoadWorks(Tile t)
 
{
 
	return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
 
}
 

	
 
/**
 
 * Increase the progress counter of road works.
 
 * @param t The tile to modify.
 
 * @return True if the road works are in the last stage.
 
 */
 
static inline bool IncreaseRoadWorksCounter(Tile t)
 
inline bool IncreaseRoadWorksCounter(Tile t)
 
{
 
	AB(t.m7(), 0, 4, 1);
 

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

	
 
/**
 
 * Start road works on a tile.
 
 * @param t The tile to start the work on.
 
 * @pre !HasRoadWorks(t)
 
 */
 
static inline void StartRoadWorks(Tile t)
 
inline void StartRoadWorks(Tile t)
 
{
 
	assert(!HasRoadWorks(t));
 
	/* Remove any trees or lamps in case or roadwork */
 
	switch (GetRoadside(t)) {
 
		case ROADSIDE_BARREN:
 
		case ROADSIDE_GRASS:  SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
 
@@ -545,13 +545,13 @@ static inline void StartRoadWorks(Tile t
 

	
 
/**
 
 * Terminate road works on a tile.
 
 * @param t Tile to stop the road works on.
 
 * @pre HasRoadWorks(t)
 
 */
 
static inline void TerminateRoadWorks(Tile t)
 
inline void TerminateRoadWorks(Tile t)
 
{
 
	assert(HasRoadWorks(t));
 
	SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
 
	/* Stop the counter */
 
	SB(t.m7(), 0, 4, 0);
 
}
 
@@ -559,13 +559,13 @@ static inline void TerminateRoadWorks(Ti
 

	
 
/**
 
 * Get the direction of the exit of a road depot.
 
 * @param t The tile to query.
 
 * @return Diagonal direction of the depot exit.
 
 */
 
static inline DiagDirection GetRoadDepotDirection(Tile t)
 
inline DiagDirection GetRoadDepotDirection(Tile t)
 
{
 
	assert(IsRoadDepot(t));
 
	return (DiagDirection)GB(t.m5(), 0, 2);
 
}
 

	
 

	
 
@@ -573,38 +573,38 @@ RoadBits GetAnyRoadBits(Tile tile, RoadT
 

	
 
/**
 
 * 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(Tile t, RoadType rt)
 
inline void SetRoadTypeRoad(Tile t, RoadType rt)
 
{
 
	assert(MayHaveRoad(t));
 
	assert(rt == INVALID_ROADTYPE || RoadTypeIsRoad(rt));
 
	SB(t.m4(), 0, 6, rt);
 
}
 

	
 
/**
 
 * Set the tram road type of a tile.
 
 * @param t The tile to change.
 
 * @param rt The road type to set.
 
 */
 
static inline void SetRoadTypeTram(Tile t, RoadType rt)
 
inline void SetRoadTypeTram(Tile t, RoadType rt)
 
{
 
	assert(MayHaveRoad(t));
 
	assert(rt == INVALID_ROADTYPE || RoadTypeIsTram(rt));
 
	SB(t.m8(), 6, 6, rt);
 
}
 

	
 
/**
 
 * Set the road type of a tile.
 
 * @param t The tile to change.
 
 * @param rtt Set road or tram type.
 
 * @param rt The road type to set.
 
 */
 
static inline void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
 
inline void SetRoadType(Tile t, RoadTramType rtt, RoadType rt)
 
{
 
	if (rtt == RTT_TRAM) {
 
		SetRoadTypeTram(t, rt);
 
	} else {
 
		SetRoadTypeRoad(t, rt);
 
	}
 
@@ -613,13 +613,13 @@ static inline void SetRoadType(Tile t, R
 
/**
 
 * Set the present road types of a tile.
 
 * @param t  The tile to change.
 
 * @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(Tile t, RoadType road_rt, RoadType tram_rt)
 
inline void SetRoadTypes(Tile t, RoadType road_rt, RoadType tram_rt)
 
{
 
	SetRoadTypeRoad(t, road_rt);
 
	SetRoadTypeTram(t, tram_rt);
 
}
 

	
 
/**
 
@@ -629,13 +629,13 @@ static inline void SetRoadTypes(Tile t, 
 
 * @param road_rt The road roadtype to set for the tile.
 
 * @param tram_rt The tram roadtype to set for the tile.
 
 * @param town    Town ID if the road is a town-owned road.
 
 * @param road    New owner of road.
 
 * @param tram    New owner of tram tracks.
 
 */
 
static inline void MakeRoadNormal(Tile t, RoadBits bits, RoadType road_rt, RoadType tram_rt, TownID town, Owner road, Owner tram)
 
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);
 
	t.m2() = town;
 
	t.m3() = (tram_rt != INVALID_ROADTYPE ? bits : 0);
 
	t.m5() = (road_rt != INVALID_ROADTYPE ? bits : 0) | ROAD_TILE_NORMAL << 6;
 
@@ -654,13 +654,13 @@ static inline void MakeRoadNormal(Tile t
 
 * @param roaddir Axis of the road.
 
 * @param rat     New rail type.
 
 * @param road_rt The road roadtype to set for the tile.
 
 * @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(Tile t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadType road_rt, RoadType tram_rt, uint town)
 
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);
 
	t.m2() = town;
 
	t.m3() = 0;
 
	t.m4() = INVALID_ROADTYPE;
 
@@ -674,13 +674,13 @@ static inline void MakeRoadCrossing(Tile
 

	
 
/**
 
 * Sets the exit direction of a road depot.
 
 * @param tile Tile of the depot.
 
 * @param dir  Direction of the depot exit.
 
 */
 
static inline void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
 
inline void SetRoadDepotExitDirection(Tile tile, DiagDirection dir)
 
{
 
	assert(IsRoadDepotTile(tile));
 
	SB(tile.m5(), 0, 2, dir);
 
}
 

	
 
/**
 
@@ -688,13 +688,13 @@ static inline void SetRoadDepotExitDirec
 
 * @param tile      Tile to make a depot on.
 
 * @param owner     New owner of the depot.
 
 * @param depot_id  New depot ID.
 
 * @param dir       Direction of the depot exit.
 
 * @param rt        Road type of the depot.
 
 */
 
static inline void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
 
inline void MakeRoadDepot(Tile tile, Owner owner, DepotID depot_id, DiagDirection dir, RoadType rt)
 
{
 
	SetTileType(tile, MP_ROAD);
 
	SetTileOwner(tile, owner);
 
	tile.m2() = depot_id;
 
	tile.m3() = 0;
 
	tile.m4() = INVALID_ROADTYPE;
src/saveload/oldloader.h
Show inline comments
 
@@ -97,19 +97,19 @@ extern uint _bump_assert_value;
 
byte ReadByte(LoadgameState *ls);
 
bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks);
 

	
 
bool LoadTTDMain(LoadgameState *ls);
 
bool LoadTTOMain(LoadgameState *ls);
 

	
 
static inline uint16_t ReadUint16(LoadgameState *ls)
 
inline uint16_t ReadUint16(LoadgameState *ls)
 
{
 
	byte x = ReadByte(ls);
 
	return x | ReadByte(ls) << 8;
 
}
 

	
 
static inline uint32_t ReadUint32(LoadgameState *ls)
 
inline uint32_t ReadUint32(LoadgameState *ls)
 
{
 
	uint16_t x = ReadUint16(ls);
 
	return x | ReadUint16(ls) << 16;
 
}
 

	
 
/* Help:
src/saveload/saveload.h
Show inline comments
 
@@ -713,44 +713,44 @@ struct SaveLoadCompat {
 
/**
 
 * Get the NumberType of a setting. This describes the integer type
 
 * as it is represented in memory
 
 * @param type VarType holding information about the variable-type
 
 * @return the SLE_VAR_* part of a variable-type description
 
 */
 
static inline constexpr VarType GetVarMemType(VarType type)
 
inline constexpr VarType GetVarMemType(VarType type)
 
{
 
	return GB(type, 4, 4) << 4;
 
}
 

	
 
/**
 
 * Get the FileType of a setting. This describes the integer type
 
 * as it is represented in a savegame/file
 
 * @param type VarType holding information about the file-type
 
 * @return the SLE_FILE_* part of a variable-type description
 
 */
 
static inline constexpr VarType GetVarFileType(VarType type)
 
inline constexpr VarType GetVarFileType(VarType type)
 
{
 
	return GB(type, 0, 4);
 
}
 

	
 
/**
 
 * Check if the given saveload type is a numeric type.
 
 * @param conv the type to check
 
 * @return True if it's a numeric type.
 
 */
 
static inline constexpr bool IsNumericType(VarType conv)
 
inline constexpr bool IsNumericType(VarType conv)
 
{
 
	return GetVarMemType(conv) <= SLE_VAR_U64;
 
}
 

	
 
/**
 
 * Return expect size in bytes of a VarType
 
 * @param type VarType to get size of.
 
 * @return size of type in bytes.
 
 */
 
static inline constexpr size_t SlVarSize(VarType type)
 
inline constexpr size_t SlVarSize(VarType type)
 
{
 
	switch (GetVarMemType(type)) {
 
		case SLE_VAR_BL: return sizeof(bool);
 
		case SLE_VAR_I8: return sizeof(int8_t);
 
		case SLE_VAR_U8: return sizeof(uint8_t);
 
		case SLE_VAR_I16: return sizeof(int16_t);
 
@@ -772,13 +772,13 @@ static inline constexpr size_t SlVarSize
 
 * @param cmd SaveLoadType of entry.
 
 * @param type VarType of entry.
 
 * @param length Array length of entry.
 
 * @param size Actual size of variable.
 
 * @return true iff the sizes match.
 
 */
 
static inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t length, size_t size)
 
inline constexpr bool SlCheckVarSize(SaveLoadType cmd, VarType type, size_t length, size_t size)
 
{
 
	switch (cmd) {
 
		case SL_VAR: return SlVarSize(type) == size;
 
		case SL_REF: return sizeof(void *) == size;
 
		case SL_STDSTR: return SlVarSize(type) == size;
 
		case SL_ARR: return SlVarSize(type) * length <= size; // Partial load of array is permitted.
 
@@ -1188,13 +1188,13 @@ static inline constexpr bool SlCheckVarS
 
/**
 
 * Checks whether the savegame is below \a major.\a minor.
 
 * @param major Major number of the version to check against.
 
 * @param minor Minor number of the version to check against. If \a minor is 0 or not specified, only the major number is checked.
 
 * @return Savegame version is earlier than the specified version.
 
 */
 
static inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
 
inline bool IsSavegameVersionBefore(SaveLoadVersion major, byte minor = 0)
 
{
 
	extern SaveLoadVersion _sl_version;
 
	extern byte            _sl_minor_version;
 
	return _sl_version < major || (minor > 0 && _sl_version == major && _sl_minor_version < minor);
 
}
 

	
 
@@ -1202,37 +1202,37 @@ static inline bool IsSavegameVersionBefo
 
 * Checks whether the savegame is below or at \a major. This should be used to repair data from existing
 
 * savegames which is no longer corrupted in new savegames, but for which otherwise no savegame
 
 * bump is required.
 
 * @param major Major number of the version to check against.
 
 * @return Savegame version is at most the specified version.
 
 */
 
static inline bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
 
inline bool IsSavegameVersionBeforeOrAt(SaveLoadVersion major)
 
{
 
	extern SaveLoadVersion _sl_version;
 
	return _sl_version <= major;
 
}
 

	
 
/**
 
 * Checks if some version from/to combination falls within the range of the
 
 * active savegame version.
 
 * @param version_from Inclusive savegame version lower bound.
 
 * @param version_to   Exclusive savegame version upper bound. SL_MAX_VERSION if no upper bound.
 
 * @return Active savegame version falls within the given range.
 
 */
 
static inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
 
inline bool SlIsObjectCurrentlyValid(SaveLoadVersion version_from, SaveLoadVersion version_to)
 
{
 
	extern const SaveLoadVersion SAVEGAME_VERSION;
 
	return version_from <= SAVEGAME_VERSION && SAVEGAME_VERSION < version_to;
 
}
 

	
 
/**
 
 * Get the address of the variable. Null-variables don't have an address,
 
 * everything else has a callback function that returns the address based
 
 * on the saveload data and the current object for non-globals.
 
 */
 
static inline void *GetVariableAddress(const void *object, const SaveLoad &sld)
 
inline void *GetVariableAddress(const void *object, const SaveLoad &sld)
 
{
 
	/* Entry is a null-variable, mostly used to read old savegames etc. */
 
	if (GetVarMemType(sld.conv) == SLE_VAR_NULL) {
 
		assert(sld.address_proc == nullptr);
 
		return nullptr;
 
	}
 
@@ -1270,13 +1270,13 @@ bool SaveloadCrashWithMissingNewGRFs();
 

	
 
/**
 
 * Read in bytes from the file/data structure but don't do
 
 * anything with them, discarding them in effect
 
 * @param length The amount of bytes that is being treated this way
 
 */
 
static inline void SlSkipBytes(size_t length)
 
inline void SlSkipBytes(size_t length)
 
{
 
	for (; length != 0; length--) SlReadByte();
 
}
 

	
 
extern std::string _savegame_format;
 
extern bool _do_autosave;
src/saveload/saveload_error.hpp
Show inline comments
 
@@ -23,12 +23,12 @@ void NORETURN SlErrorCorrupt(const std::
 
 * @tparam T The type of formatting parameter.
 
 * @tparam Args The types of the fmt arguments.
 
 * @note This function does never return as it throws an exception to
 
 *       break out of all the saveload code.
 
 */
 
template <typename T, typename ... Args>
 
static inline void NORETURN SlErrorCorruptFmt(const T &format, Args&&... fmt_args)
 
inline void NORETURN SlErrorCorruptFmt(const T &format, Args&&... fmt_args)
 
{
 
	SlErrorCorrupt(fmt::format(format, fmt_args...));
 
}
 

	
 
#endif /* SAVELOAD_ERROR_HPP */
src/settings_type.h
Show inline comments
 
@@ -643,12 +643,12 @@ extern GameSettings _settings_newgame;
 
extern VehicleDefaultSettings _old_vds;
 

	
 
/**
 
 * Get the settings-object applicable for the current situation: the newgame settings
 
 * when we're in the main menu and otherwise the settings of the current game.
 
 */
 
static inline GameSettings &GetGameSettings()
 
inline GameSettings &GetGameSettings()
 
{
 
	return (_game_mode == GM_MENU) ? _settings_newgame : _settings_game;
 
}
 

	
 
#endif /* SETTINGS_TYPE_H */
src/signal_func.h
Show inline comments
 
@@ -16,33 +16,33 @@
 
#include "company_type.h"
 

	
 
/**
 
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
 
 * direction along with the trackdir.
 
 */
 
static inline byte SignalAlongTrackdir(Trackdir trackdir)
 
inline byte SignalAlongTrackdir(Trackdir trackdir)
 
{
 
	extern const byte _signal_along_trackdir[TRACKDIR_END];
 
	return _signal_along_trackdir[trackdir];
 
}
 

	
 
/**
 
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
 
 * direction against the trackdir.
 
 */
 
static inline byte SignalAgainstTrackdir(Trackdir trackdir)
 
inline byte SignalAgainstTrackdir(Trackdir trackdir)
 
{
 
	extern const byte _signal_against_trackdir[TRACKDIR_END];
 
	return _signal_against_trackdir[trackdir];
 
}
 

	
 
/**
 
 * Maps a Track to the bits that store the status of the two signals that can
 
 * be present on the given track.
 
 */
 
static inline byte SignalOnTrack(Track track)
 
inline byte SignalOnTrack(Track track)
 
{
 
	extern const byte _signal_on_track[TRACK_END];
 
	return _signal_on_track[track];
 
}
 

	
 
/** State of the signal segment */
src/slope_func.h
Show inline comments
 
@@ -70,36 +70,36 @@ static constexpr inline Slope RemoveHalf
 
 * slope.
 
 *
 
 * @pre The slope must neither be steep nor a halftile slope.
 
 * @param s The #Slope to get the complement.
 
 * @return a complement Slope of the given slope.
 
 */
 
static inline Slope ComplementSlope(Slope s)
 
inline Slope ComplementSlope(Slope s)
 
{
 
	assert(!IsSteepSlope(s) && !IsHalftileSlope(s));
 
	return s ^ SLOPE_ELEVATED;
 
}
 

	
 
/**
 
 * Tests if a specific slope has exactly one corner raised.
 
 *
 
 * @param s The #Slope
 
 * @return true iff exactly one corner is raised
 
 */
 
static inline bool IsSlopeWithOneCornerRaised(Slope s)
 
inline bool IsSlopeWithOneCornerRaised(Slope s)
 
{
 
	return (s == SLOPE_W) || (s == SLOPE_S) || (s == SLOPE_E) || (s == SLOPE_N);
 
}
 

	
 
/**
 
 * Returns the slope with a specific corner raised.
 
 *
 
 * @param corner The #Corner.
 
 * @return The #Slope with corner "corner" raised.
 
 */
 
static inline Slope SlopeWithOneCornerRaised(Corner corner)
 
inline Slope SlopeWithOneCornerRaised(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Slope)(1 << corner);
 
}
 

	
 
/**
 
@@ -107,26 +107,26 @@ static inline Slope SlopeWithOneCornerRa
 
 *
 
 * Note: A halftile slope is ignored.
 
 *
 
 * @param s The #Slope.
 
 * @return  true iff the slope has a highest corner.
 
 */
 
static inline bool HasSlopeHighestCorner(Slope s)
 
inline bool HasSlopeHighestCorner(Slope s)
 
{
 
	s = RemoveHalftileSlope(s);
 
	return IsSteepSlope(s) || IsSlopeWithOneCornerRaised(s);
 
}
 

	
 
/**
 
 * Returns the highest corner of a slope (one corner raised or a steep slope).
 
 *
 
 * @pre      The slope must be a slope with one corner raised or a steep slope. A halftile slope is ignored.
 
 * @param s  The #Slope.
 
 * @return   Highest corner.
 
 */
 
static inline Corner GetHighestSlopeCorner(Slope s)
 
inline Corner GetHighestSlopeCorner(Slope s)
 
{
 
	switch (RemoveHalftileSlope(s)) {
 
		case SLOPE_W:
 
		case SLOPE_STEEP_W: return CORNER_W;
 
		case SLOPE_S:
 
		case SLOPE_STEEP_S: return CORNER_S;
 
@@ -178,68 +178,68 @@ static constexpr inline int GetSlopeMaxP
 
/**
 
 * Returns the opposite corner.
 
 *
 
 * @param corner A #Corner.
 
 * @return The opposite corner to "corner".
 
 */
 
static inline Corner OppositeCorner(Corner corner)
 
inline Corner OppositeCorner(Corner corner)
 
{
 
	return (Corner)(corner ^ 2);
 
}
 

	
 
/**
 
 * Tests if a specific slope has exactly three corners raised.
 
 *
 
 * @param s The #Slope
 
 * @return true iff exactly three corners are raised
 
 */
 
static inline bool IsSlopeWithThreeCornersRaised(Slope s)
 
inline bool IsSlopeWithThreeCornersRaised(Slope s)
 
{
 
	return !IsHalftileSlope(s) && !IsSteepSlope(s) && IsSlopeWithOneCornerRaised(ComplementSlope(s));
 
}
 

	
 
/**
 
 * Returns the slope with all except one corner raised.
 
 *
 
 * @param corner The #Corner.
 
 * @return The #Slope with all corners but "corner" raised.
 
 */
 
static inline Slope SlopeWithThreeCornersRaised(Corner corner)
 
inline Slope SlopeWithThreeCornersRaised(Corner corner)
 
{
 
	return ComplementSlope(SlopeWithOneCornerRaised(corner));
 
}
 

	
 
/**
 
 * Returns a specific steep slope
 
 *
 
 * @param corner A #Corner.
 
 * @return The steep #Slope with "corner" as highest corner.
 
 */
 
static inline Slope SteepSlope(Corner corner)
 
inline Slope SteepSlope(Corner corner)
 
{
 
	return SLOPE_STEEP | SlopeWithThreeCornersRaised(OppositeCorner(corner));
 
}
 

	
 
/**
 
 * Tests if a specific slope is an inclined slope.
 
 *
 
 * @param s The #Slope
 
 * @return true iff the slope is inclined.
 
 */
 
static inline bool IsInclinedSlope(Slope s)
 
inline bool IsInclinedSlope(Slope s)
 
{
 
	return (s == SLOPE_NW) || (s == SLOPE_SW) || (s == SLOPE_SE) || (s == SLOPE_NE);
 
}
 

	
 
/**
 
 * Returns the direction of an inclined slope.
 
 *
 
 * @param s A #Slope
 
 * @return The direction the slope goes up in. Or INVALID_DIAGDIR if the slope is not an inclined slope.
 
 */
 
static inline DiagDirection GetInclinedSlopeDirection(Slope s)
 
inline DiagDirection GetInclinedSlopeDirection(Slope s)
 
{
 
	switch (s) {
 
		case SLOPE_NE: return DIAGDIR_NE;
 
		case SLOPE_SE: return DIAGDIR_SE;
 
		case SLOPE_SW: return DIAGDIR_SW;
 
		case SLOPE_NW: return DIAGDIR_NW;
 
@@ -250,13 +250,13 @@ static inline DiagDirection GetInclinedS
 
/**
 
 * Returns the slope that is inclined in a specific direction.
 
 *
 
 * @param dir A #DiagDirection
 
 * @return The #Slope that goes up in direction dir.
 
 */
 
static inline Slope InclinedSlope(DiagDirection dir)
 
inline Slope InclinedSlope(DiagDirection dir)
 
{
 
	switch (dir) {
 
		case DIAGDIR_NE: return SLOPE_NE;
 
		case DIAGDIR_SE: return SLOPE_SE;
 
		case DIAGDIR_SW: return SLOPE_SW;
 
		case DIAGDIR_NW: return SLOPE_NW;
 
@@ -281,141 +281,141 @@ static constexpr inline Slope HalftileSl
 
/**
 
 * Tests for FOUNDATION_NONE.
 
 *
 
 * @param f  Maybe a #Foundation.
 
 * @return   true iff f is a foundation.
 
 */
 
static inline bool IsFoundation(Foundation f)
 
inline bool IsFoundation(Foundation f)
 
{
 
	return f != FOUNDATION_NONE;
 
}
 

	
 
/**
 
 * Tests if the foundation is a leveled foundation.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a leveled foundation.
 
 */
 
static inline bool IsLeveledFoundation(Foundation f)
 
inline bool IsLeveledFoundation(Foundation f)
 
{
 
	return f == FOUNDATION_LEVELED;
 
}
 

	
 
/**
 
 * Tests if the foundation is an inclined foundation.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is an inclined foundation.
 
 */
 
static inline bool IsInclinedFoundation(Foundation f)
 
inline bool IsInclinedFoundation(Foundation f)
 
{
 
	return (f == FOUNDATION_INCLINED_X) || (f == FOUNDATION_INCLINED_Y);
 
}
 

	
 
/**
 
 * Tests if a foundation is a non-continuous foundation, i.e. halftile-foundation or FOUNDATION_STEEP_BOTH.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a non-continuous foundation
 
 */
 
static inline bool IsNonContinuousFoundation(Foundation f)
 
inline bool IsNonContinuousFoundation(Foundation f)
 
{
 
	return IsInsideMM(f, FOUNDATION_STEEP_BOTH, FOUNDATION_HALFTILE_N + 1);
 
}
 

	
 
/**
 
 * Returns the halftile corner of a halftile-foundation
 
 *
 
 * @pre f != FOUNDATION_STEEP_BOTH
 
 *
 
 * @param f  The #Foundation.
 
 * @return   The #Corner with track.
 
 */
 
static inline Corner GetHalftileFoundationCorner(Foundation f)
 
inline Corner GetHalftileFoundationCorner(Foundation f)
 
{
 
	assert(IsInsideMM(f, FOUNDATION_HALFTILE_W, FOUNDATION_HALFTILE_N + 1));
 
	return (Corner)(f - FOUNDATION_HALFTILE_W);
 
}
 

	
 
/**
 
 * Tests if a foundation is a special rail foundation for single horizontal/vertical track.
 
 *
 
 * @param f  The #Foundation.
 
 * @return   true iff f is a special rail foundation for single horizontal/vertical track.
 
 */
 
static inline bool IsSpecialRailFoundation(Foundation f)
 
inline bool IsSpecialRailFoundation(Foundation f)
 
{
 
	return IsInsideMM(f, FOUNDATION_RAIL_W, FOUNDATION_RAIL_N + 1);
 
}
 

	
 
/**
 
 * Returns the track corner of a special rail foundation
 
 *
 
 * @param f  The #Foundation.
 
 * @return   The #Corner with track.
 
 */
 
static inline Corner GetRailFoundationCorner(Foundation f)
 
inline Corner GetRailFoundationCorner(Foundation f)
 
{
 
	assert(IsSpecialRailFoundation(f));
 
	return (Corner)(f - FOUNDATION_RAIL_W);
 
}
 

	
 
/**
 
 * Returns the foundation needed to flatten a slope.
 
 * The returned foundation is either FOUNDATION_NONE if the tile was already flat, or FOUNDATION_LEVELED.
 
 *
 
 * @param s  The current #Slope.
 
 * @return   The needed #Foundation.
 
 */
 
static inline Foundation FlatteningFoundation(Slope s)
 
inline Foundation FlatteningFoundation(Slope s)
 
{
 
	return (s == SLOPE_FLAT ? FOUNDATION_NONE : FOUNDATION_LEVELED);
 
}
 

	
 
/**
 
 * Returns the along a specific axis inclined foundation.
 
 *
 
 * @param axis  The #Axis.
 
 * @return      The needed #Foundation.
 
 */
 
static inline Foundation InclinedFoundation(Axis axis)
 
inline Foundation InclinedFoundation(Axis axis)
 
{
 
	return (axis == AXIS_X ? FOUNDATION_INCLINED_X : FOUNDATION_INCLINED_Y);
 
}
 

	
 
/**
 
 * Returns the halftile foundation for single horizontal/vertical track.
 
 *
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
static inline Foundation HalftileFoundation(Corner corner)
 
inline Foundation HalftileFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_HALFTILE_W + corner);
 
}
 

	
 
/**
 
 * Returns the special rail foundation for single horizontal/vertical track.
 
 *
 
 * @param corner The #Corner with the track.
 
 * @return       The wanted #Foundation.
 
 */
 
static inline Foundation SpecialRailFoundation(Corner corner)
 
inline Foundation SpecialRailFoundation(Corner corner)
 
{
 
	assert(IsValidCorner(corner));
 
	return (Foundation)(FOUNDATION_RAIL_W + corner);
 
}
 

	
 
/**
 
 * Returns the #Sprite offset for a given #Slope.
 
 *
 
 * @param s The #Slope to get the offset for.
 
 * @return The sprite offset for this #Slope.
 
 */
 
static inline uint SlopeToSpriteOffset(Slope s)
 
inline uint SlopeToSpriteOffset(Slope s)
 
{
 
	extern const byte _slope_to_sprite_offset[32];
 
	return _slope_to_sprite_offset[s];
 
}
 

	
 
#endif /* SLOPE_FUNC_H */
src/sprite.h
Show inline comments
 
@@ -83,57 +83,57 @@ void DrawCommonTileSeqInGUI(int x, int y
 

	
 
/**
 
 * Draw tile sprite sequence on tile with railroad specifics.
 
 * @param total_offset Spriteoffset from normal rail to current railtype.
 
 * @param newgrf_offset Startsprite of the Action1 to use.
 
 */
 
static inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 
inline void DrawRailTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 
{
 
	DrawCommonTileSeq(ti, dts, to, total_offset, newgrf_offset, default_palette, false);
 
}
 

	
 
/**
 
 * Draw tile sprite sequence in GUI with railroad specifics.
 
 * @param total_offset Spriteoffset from normal rail to current railtype.
 
 * @param newgrf_offset Startsprite of the Action1 to use.
 
 */
 
static inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 
inline void DrawRailTileSeqInGUI(int x, int y, const DrawTileSprites *dts, int32_t total_offset, uint32_t newgrf_offset, PaletteID default_palette)
 
{
 
	DrawCommonTileSeqInGUI(x, y, dts, total_offset, newgrf_offset, default_palette, false);
 
}
 

	
 
/**
 
 * Draw TTD sprite sequence on tile.
 
 */
 
static inline void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
 
inline void DrawOrigTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, PaletteID default_palette)
 
{
 
	DrawCommonTileSeq(ti, dts, to, 0, 0, default_palette, false);
 
}
 

	
 
/**
 
 * Draw TTD sprite sequence in GUI.
 
 */
 
static inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
 
inline void DrawOrigTileSeqInGUI(int x, int y, const DrawTileSprites *dts, PaletteID default_palette)
 
{
 
	DrawCommonTileSeqInGUI(x, y, dts, 0, 0, default_palette, false);
 
}
 

	
 
/**
 
 * Draw NewGRF industrytile or house sprite layout
 
 * @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage.
 
 */
 
static inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette)
 
inline void DrawNewGRFTileSeq(const struct TileInfo *ti, const DrawTileSprites *dts, TransparencyOption to, uint32_t stage, PaletteID default_palette)
 
{
 
	DrawCommonTileSeq(ti, dts, to, 0, stage, default_palette, true);
 
}
 

	
 
/**
 
 * Draw NewGRF object in GUI
 
 * @param stage Sprite inside the Action1 spritesets to use, i.e. construction stage.
 
 */
 
static inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32_t stage, PaletteID default_palette)
 
inline void DrawNewGRFTileSeqInGUI(int x, int y, const DrawTileSprites *dts, uint32_t stage, PaletteID default_palette)
 
{
 
	DrawCommonTileSeqInGUI(x, y, dts, 0, stage, default_palette, true);
 
}
 

	
 
/**
 
 * Applies PALETTE_MODIFIER_TRANSPARENT and PALETTE_MODIFIER_COLOUR to a palette entry of a sprite layout entry
 
@@ -143,13 +143,13 @@ static inline void DrawNewGRFTileSeqInGU
 
 *
 
 * @param image The sprite to draw
 
 * @param pal The palette from the sprite layout
 
 * @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
 
 * @return The palette to use
 
 */
 
static inline PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
 
inline PaletteID SpriteLayoutPaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
 
{
 
	if (HasBit(image, PALETTE_MODIFIER_TRANSPARENT) || HasBit(image, PALETTE_MODIFIER_COLOUR)) {
 
		return (pal != 0 ? pal : default_pal);
 
	} else {
 
		return PAL_NONE;
 
	}
 
@@ -162,13 +162,13 @@ static inline PaletteID SpriteLayoutPale
 
 *
 
 * @param image The sprite to draw
 
 * @param pal The palette from the sprite layout
 
 * @param default_pal The default recolour sprite to use (typically company colour resp. random industry/house colour)
 
 * @return The palette to use
 
 */
 
static inline PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
 
inline PaletteID GroundSpritePaletteTransform(SpriteID image, PaletteID pal, PaletteID default_pal)
 
{
 
	if (HasBit(image, PALETTE_MODIFIER_COLOUR)) {
 
		return (pal != 0 ? pal : default_pal);
 
	} else {
 
		return PAL_NONE;
 
	}
src/spritecache.h
Show inline comments
 
@@ -41,19 +41,19 @@ SpriteType GetSpriteType(SpriteID sprite
 
SpriteFile *GetOriginFile(SpriteID sprite);
 
uint32_t GetSpriteLocalID(SpriteID sprite);
 
uint GetSpriteCountForFile(const std::string &filename, SpriteID begin, SpriteID end);
 
uint GetMaxSpriteID();
 

	
 

	
 
static inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
 
inline const Sprite *GetSprite(SpriteID sprite, SpriteType type)
 
{
 
	assert(type != SpriteType::Recolour);
 
	return (Sprite*)GetRawSprite(sprite, type);
 
}
 

	
 
static inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
 
inline const byte *GetNonSprite(SpriteID sprite, SpriteType type)
 
{
 
	assert(type == SpriteType::Recolour);
 
	return (byte*)GetRawSprite(sprite, type);
 
}
 

	
 
void GfxInitSpriteMem();
src/spritecache_internal.h
Show inline comments
 
@@ -28,13 +28,13 @@ struct SpriteCache {
 
	int16_t lru;
 
	SpriteType type;     ///< In some cases a single sprite is misused by two NewGRFs. Once as real sprite and once as recolour sprite. If the recolour sprite gets into the cache it might be drawn as real sprite which causes enormous trouble.
 
	bool warned;         ///< True iff the user has been warned about incorrect use of this sprite
 
	byte control_flags;  ///< Control flags, see SpriteCacheCtrlFlags
 
};
 

	
 
static inline bool IsMapgenSpriteID(SpriteID sprite)
 
inline bool IsMapgenSpriteID(SpriteID sprite)
 
{
 
	return IsInsideMM(sprite, SPR_MAPGEN_BEGIN, SPR_MAPGEN_END);
 
}
 

	
 
void *AllocSprite(size_t mem_req);
 
SpriteCache *AllocateSpriteCache(uint index);
src/station_func.h
Show inline comments
 
@@ -53,13 +53,13 @@ void RerouteCargo(Station *st, CargoID c
 

	
 
/**
 
 * Calculates the maintenance cost of a number of station tiles.
 
 * @param num Number of station tiles.
 
 * @return Total cost.
 
 */
 
static inline Money StationMaintenanceCost(uint32_t num)
 
inline Money StationMaintenanceCost(uint32_t num)
 
{
 
	return (_price[PR_INFRASTRUCTURE_STATION] * num * (1 + IntSqrt(num))) >> 7; // 7 bits scaling.
 
}
 

	
 
Money AirportMaintenanceCost(Owner owner);
 

	
src/station_map.h
Show inline comments
 
@@ -22,13 +22,13 @@ typedef byte StationGfx; ///< Index of s
 
/**
 
 * Get StationID from a tile
 
 * @param t Tile to query station ID from
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return Station ID of the station at \a t
 
 */
 
static inline StationID GetStationIndex(Tile t)
 
inline StationID GetStationIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return (StationID)t.m2();
 
}
 

	
 

	
 
@@ -38,227 +38,227 @@ static const int GFX_TRUCK_BUS_DRIVETHRO
 
/**
 
 * Get the station type of this tile
 
 * @param t the tile to query
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return the station type
 
 */
 
static inline StationType GetStationType(Tile t)
 
inline StationType GetStationType(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return (StationType)GB(t.m6(), 3, 3);
 
}
 

	
 
/**
 
 * Get the road stop type of this tile
 
 * @param t the tile to query
 
 * @pre GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS
 
 * @return the road stop type
 
 */
 
static inline RoadStopType GetRoadStopType(Tile t)
 
inline RoadStopType GetRoadStopType(Tile t)
 
{
 
	assert(GetStationType(t) == STATION_TRUCK || GetStationType(t) == STATION_BUS);
 
	return GetStationType(t) == STATION_TRUCK ? ROADSTOP_TRUCK : ROADSTOP_BUS;
 
}
 

	
 
/**
 
 * Get the station graphics of this tile
 
 * @param t the tile to query
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return the station graphics
 
 */
 
static inline StationGfx GetStationGfx(Tile t)
 
inline StationGfx GetStationGfx(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return t.m5();
 
}
 

	
 
/**
 
 * Set the station graphics of this tile
 
 * @param t the tile to update
 
 * @param gfx the new graphics
 
 * @pre IsTileType(t, MP_STATION)
 
 */
 
static inline void SetStationGfx(Tile t, StationGfx gfx)
 
inline void SetStationGfx(Tile t, StationGfx gfx)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	t.m5() = gfx;
 
}
 

	
 
/**
 
 * Is this station tile a rail station?
 
 * @param t the tile to get the information from
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a rail station
 
 */
 
static inline bool IsRailStation(Tile t)
 
inline bool IsRailStation(Tile t)
 
{
 
	return GetStationType(t) == STATION_RAIL;
 
}
 

	
 
/**
 
 * Is this tile a station tile and a rail station?
 
 * @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(Tile t)
 
inline bool IsRailStationTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRailStation(t);
 
}
 

	
 
/**
 
 * Is this station tile a rail waypoint?
 
 * @param t the tile to get the information from
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is a rail waypoint
 
 */
 
static inline bool IsRailWaypoint(Tile t)
 
inline bool IsRailWaypoint(Tile t)
 
{
 
	return GetStationType(t) == STATION_WAYPOINT;
 
}
 

	
 
/**
 
 * Is this tile a station tile and a rail waypoint?
 
 * @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(Tile t)
 
inline bool IsRailWaypointTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRailWaypoint(t);
 
}
 

	
 
/**
 
 * Has this station tile a rail? In other words, is this station
 
 * tile a rail station or rail waypoint?
 
 * @param t the tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile has rail
 
 */
 
static inline bool HasStationRail(Tile t)
 
inline bool HasStationRail(Tile t)
 
{
 
	return IsRailStation(t) || IsRailWaypoint(t);
 
}
 

	
 
/**
 
 * Has this station tile a rail? In other words, is this station
 
 * tile a rail station or rail waypoint?
 
 * @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(Tile t)
 
inline bool HasStationTileRail(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && HasStationRail(t);
 
}
 

	
 
/**
 
 * Is this station tile an airport?
 
 * @param t the tile to get the information from
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return true if and only if the tile is an airport
 
 */
 
static inline bool IsAirport(Tile t)
 
inline bool IsAirport(Tile t)
 
{
 
	return GetStationType(t) == STATION_AIRPORT;
 
}
 

	
 
/**
 
 * Is this tile a station tile and an airport tile?
 
 * @param t the tile to get the information from
 
 * @return true if and only if the tile is an airport
 
 */
 
static inline bool IsAirportTile(Tile t)
 
inline bool IsAirportTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsAirport(t);
 
}
 

	
 
bool IsHangar(Tile t);
 

	
 
/**
 
 * Is the station at \a t a truck stop?
 
 * @param t Tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if station is a truck stop, \c false otherwise
 
 */
 
static inline bool IsTruckStop(Tile t)
 
inline bool IsTruckStop(Tile t)
 
{
 
	return GetStationType(t) == STATION_TRUCK;
 
}
 

	
 
/**
 
 * Is the station at \a t a bus stop?
 
 * @param t Tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if station is a bus stop, \c false otherwise
 
 */
 
static inline bool IsBusStop(Tile t)
 
inline bool IsBusStop(Tile t)
 
{
 
	return GetStationType(t) == STATION_BUS;
 
}
 

	
 
/**
 
 * Is the station at \a t a road station?
 
 * @param t Tile to check
 
 * @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(Tile t)
 
inline bool IsRoadStop(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return IsTruckStop(t) || IsBusStop(t);
 
}
 

	
 
/**
 
 * Is tile \a t a road stop station?
 
 * @param t Tile to check
 
 * @return \c true if the tile is a station tile and a road stop
 
 */
 
static inline bool IsRoadStopTile(Tile t)
 
inline bool IsRoadStopTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsRoadStop(t);
 
}
 

	
 
/**
 
 * Is tile \a t a bay (non-drive through) road stop station?
 
 * @param t Tile to check
 
 * @return \c true if the tile is a station tile and a bay road stop
 
 */
 
static inline bool IsBayRoadStopTile(Tile t)
 
inline bool IsBayRoadStopTile(Tile t)
 
{
 
	return IsRoadStopTile(t) && GetStationGfx(t) < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 
}
 

	
 
/**
 
 * Is tile \a t a drive through road stop station?
 
 * @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(Tile t)
 
inline bool IsDriveThroughStopTile(Tile t)
 
{
 
	return IsRoadStopTile(t) && GetStationGfx(t) >= GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET;
 
}
 

	
 
StationGfx GetTranslatedAirportTileID(StationGfx gfx);
 

	
 
/**
 
 * Get the station graphics of this airport tile
 
 * @param t the tile to query
 
 * @pre IsAirport(t)
 
 * @return the station graphics
 
 */
 
static inline StationGfx GetAirportGfx(Tile t)
 
inline StationGfx GetAirportGfx(Tile t)
 
{
 
	assert(IsAirport(t));
 
	return GetTranslatedAirportTileID(GetStationGfx(t));
 
}
 

	
 
/**
 
 * Gets the direction the road stop entrance points towards.
 
 * @param t the tile of the road stop
 
 * @pre IsRoadStopTile(t)
 
 * @return the direction of the entrance
 
 */
 
static inline DiagDirection GetRoadStopDir(Tile t)
 
inline DiagDirection GetRoadStopDir(Tile t)
 
{
 
	StationGfx gfx = GetStationGfx(t);
 
	assert(IsRoadStopTile(t));
 
	if (gfx < GFX_TRUCK_BUS_DRIVETHROUGH_OFFSET) {
 
		return (DiagDirection)(gfx);
 
	} else {
 
@@ -269,171 +269,171 @@ static inline DiagDirection GetRoadStopD
 
/**
 
 * Is tile \a t part of an oilrig?
 
 * @param t Tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is an oilrig tile
 
 */
 
static inline bool IsOilRig(Tile t)
 
inline bool IsOilRig(Tile t)
 
{
 
	return GetStationType(t) == STATION_OILRIG;
 
}
 

	
 
/**
 
 * Is tile \a t a dock tile?
 
 * @param t Tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is a dock
 
 */
 
static inline bool IsDock(Tile t)
 
inline bool IsDock(Tile t)
 
{
 
	return GetStationType(t) == STATION_DOCK;
 
}
 

	
 
/**
 
 * Is tile \a t a dock tile?
 
 * @param t Tile to check
 
 * @return \c true if the tile is a dock
 
 */
 
static inline bool IsDockTile(Tile t)
 
inline bool IsDockTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && GetStationType(t) == STATION_DOCK;
 
}
 

	
 
/**
 
 * Is tile \a t a buoy tile?
 
 * @param t Tile to check
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return \c true if the tile is a buoy
 
 */
 
static inline bool IsBuoy(Tile t)
 
inline bool IsBuoy(Tile t)
 
{
 
	return GetStationType(t) == STATION_BUOY;
 
}
 

	
 
/**
 
 * Is tile \a t a buoy tile?
 
 * @param t Tile to check
 
 * @return \c true if the tile is a buoy
 
 */
 
static inline bool IsBuoyTile(Tile t)
 
inline bool IsBuoyTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsBuoy(t);
 
}
 

	
 
/**
 
 * Is tile \a t an hangar tile?
 
 * @param t Tile to check
 
 * @return \c true if the tile is an hangar
 
 */
 
static inline bool IsHangarTile(Tile t)
 
inline bool IsHangarTile(Tile t)
 
{
 
	return IsTileType(t, MP_STATION) && IsHangar(t);
 
}
 

	
 
/**
 
 * Is tile \a t a blocked tile?
 
 * @pre HasStationRail(t)
 
 * @param t Tile to check
 
 * @return \c true if the tile is blocked
 
 */
 
static inline bool IsStationTileBlocked(Tile t)
 
inline bool IsStationTileBlocked(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(t.m6(), 0);
 
}
 

	
 
/**
 
 * Set the blocked state of the rail station
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @param b the blocked state
 
 */
 
static inline void SetStationTileBlocked(Tile t, bool b)
 
inline void SetStationTileBlocked(Tile t, bool b)
 
{
 
	assert(HasStationRail(t));
 
	SB(t.m6(), 0, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Can tile \a t have catenary wires?
 
 * @pre HasStationRail(t)
 
 * @param t Tile to check
 
 * @return \c true if the tile can have catenary wires
 
 */
 
static inline bool CanStationTileHaveWires(Tile t)
 
inline bool CanStationTileHaveWires(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(t.m6(), 6);
 
}
 

	
 
/**
 
 * Set the catenary wires state of the rail station
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @param b the catenary wires state
 
 */
 
static inline void SetStationTileHaveWires(Tile t, bool b)
 
inline void SetStationTileHaveWires(Tile t, bool b)
 
{
 
	assert(HasStationRail(t));
 
	SB(t.m6(), 6, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Can tile \a t have catenary pylons?
 
 * @pre HasStationRail(t)
 
 * @param t Tile to check
 
 * @return \c true if the tile can have catenary pylons
 
 */
 
static inline bool CanStationTileHavePylons(Tile t)
 
inline bool CanStationTileHavePylons(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(t.m6(), 7);
 
}
 

	
 
/**
 
 * Set the catenary pylon state of the rail station
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @param b the catenary pylons state
 
 */
 
static inline void SetStationTileHavePylons(Tile t, bool b)
 
inline void SetStationTileHavePylons(Tile t, bool b)
 
{
 
	assert(HasStationRail(t));
 
	SB(t.m6(), 7, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Get the rail direction of a rail station.
 
 * @param t Tile to query
 
 * @pre HasStationRail(t)
 
 * @return The direction of the rails on tile \a t.
 
 */
 
static inline Axis GetRailStationAxis(Tile t)
 
inline Axis GetRailStationAxis(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(GetStationGfx(t), 0) ? AXIS_Y : AXIS_X;
 
}
 

	
 
/**
 
 * Get the rail track of a rail station tile.
 
 * @param t Tile to query
 
 * @pre HasStationRail(t)
 
 * @return The rail track of the rails on tile \a t.
 
 */
 
static inline Track GetRailStationTrack(Tile t)
 
inline Track GetRailStationTrack(Tile t)
 
{
 
	return AxisToTrack(GetRailStationAxis(t));
 
}
 

	
 
/**
 
 * Get the trackbits of a rail station tile.
 
 * @param t Tile to query
 
 * @pre HasStationRail(t)
 
 * @return The trackbits of the rails on tile \a t.
 
 */
 
static inline TrackBits GetRailStationTrackBits(Tile t)
 
inline TrackBits GetRailStationTrackBits(Tile t)
 
{
 
	return AxisToTrackBits(GetRailStationAxis(t));
 
}
 

	
 
/**
 
 * Check if a tile is a valid continuation to a railstation tile.
 
@@ -445,13 +445,13 @@ static inline TrackBits GetRailStationTr
 
 * \li \a test_tile is not blocked (@see IsStationTileBlocked)
 
 * @param test_tile Tile to test
 
 * @param station_tile Station tile to compare with
 
 * @pre IsRailStationTile(station_tile)
 
 * @return true if the two tiles are compatible
 
 */
 
static inline bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
 
inline bool IsCompatibleTrainStationTile(Tile test_tile, Tile station_tile)
 
{
 
	assert(IsRailStationTile(station_tile));
 
	return IsRailStationTile(test_tile) && !IsStationTileBlocked(test_tile) &&
 
			IsCompatibleRail(GetRailType(test_tile), GetRailType(station_tile)) &&
 
			GetRailStationAxis(test_tile) == GetRailStationAxis(station_tile) &&
 
			GetStationIndex(test_tile) == GetStationIndex(station_tile);
 
@@ -460,156 +460,156 @@ static inline bool IsCompatibleTrainStat
 
/**
 
 * Get the reservation state of the rail station
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @return reservation state
 
 */
 
static inline bool HasStationReservation(Tile t)
 
inline bool HasStationReservation(Tile t)
 
{
 
	assert(HasStationRail(t));
 
	return HasBit(t.m6(), 2);
 
}
 

	
 
/**
 
 * Set the reservation state of the rail station
 
 * @pre HasStationRail(t)
 
 * @param t the station tile
 
 * @param b the reservation state
 
 */
 
static inline void SetRailStationReservation(Tile t, bool b)
 
inline void SetRailStationReservation(Tile t, bool b)
 
{
 
	assert(HasStationRail(t));
 
	SB(t.m6(), 2, 1, b ? 1 : 0);
 
}
 

	
 
/**
 
 * Get the reserved track bits for a waypoint
 
 * @pre HasStationRail(t)
 
 * @param t the tile
 
 * @return reserved track bits
 
 */
 
static inline TrackBits GetStationReservationTrackBits(Tile t)
 
inline TrackBits GetStationReservationTrackBits(Tile t)
 
{
 
	return HasStationReservation(t) ? GetRailStationTrackBits(t) : TRACK_BIT_NONE;
 
}
 

	
 
/**
 
 * Get the direction of a dock.
 
 * @param t Tile to query
 
 * @pre IsDock(t)
 
 * @pre \a t is the land part of the dock
 
 * @return The direction of the dock on tile \a t.
 
 */
 
static inline DiagDirection GetDockDirection(Tile t)
 
inline DiagDirection GetDockDirection(Tile t)
 
{
 
	StationGfx gfx = GetStationGfx(t);
 
	assert(IsDock(t) && gfx < GFX_DOCK_BASE_WATER_PART);
 
	return (DiagDirection)(gfx);
 
}
 

	
 
/**
 
 * Check whether a dock tile is the tile on water.
 
 */
 
static inline bool IsDockWaterPart(Tile t)
 
inline bool IsDockWaterPart(Tile t)
 
{
 
	assert(IsDockTile(t));
 
	StationGfx gfx = GetStationGfx(t);
 
	return gfx >= GFX_DOCK_BASE_WATER_PART;
 
}
 

	
 
/**
 
 * Is there a custom rail station spec on this tile?
 
 * @param t Tile to query
 
 * @pre HasStationTileRail(t)
 
 * @return True if this station is part of a newgrf station.
 
 */
 
static inline bool IsCustomStationSpecIndex(Tile t)
 
inline bool IsCustomStationSpecIndex(Tile t)
 
{
 
	assert(HasStationTileRail(t));
 
	return t.m4() != 0;
 
}
 

	
 
/**
 
 * Set the custom station spec for this tile.
 
 * @param t Tile to set the stationspec of.
 
 * @param specindex The new spec.
 
 * @pre HasStationTileRail(t)
 
 */
 
static inline void SetCustomStationSpecIndex(Tile t, byte specindex)
 
inline void SetCustomStationSpecIndex(Tile t, byte specindex)
 
{
 
	assert(HasStationTileRail(t));
 
	t.m4() = specindex;
 
}
 

	
 
/**
 
 * Get the custom station spec for this tile.
 
 * @param t Tile to query
 
 * @pre HasStationTileRail(t)
 
 * @return The custom station spec of this tile.
 
 */
 
static inline uint GetCustomStationSpecIndex(Tile t)
 
inline uint GetCustomStationSpecIndex(Tile t)
 
{
 
	assert(HasStationTileRail(t));
 
	return t.m4();
 
}
 

	
 
/**
 
 * Is there a custom road stop spec on this tile?
 
 * @param t Tile to query
 
 * @pre IsRoadStopTile(t)
 
 * @return True if this station is part of a newgrf station.
 
 */
 
static inline bool IsCustomRoadStopSpecIndex(Tile t)
 
inline bool IsCustomRoadStopSpecIndex(Tile t)
 
{
 
	assert(IsRoadStopTile(t));
 
	return GB(t.m8(), 0, 6) != 0;
 
}
 

	
 
/**
 
 * Set the custom road stop spec for this tile.
 
 * @param t Tile to set the stationspec of.
 
 * @param specindex The new spec.
 
 * @pre IsRoadStopTile(t)
 
 */
 
static inline void SetCustomRoadStopSpecIndex(Tile t, byte specindex)
 
inline void SetCustomRoadStopSpecIndex(Tile t, byte specindex)
 
{
 
	assert(IsRoadStopTile(t));
 
	SB(t.m8(), 0, 6, specindex);
 
}
 

	
 
/**
 
 * Get the custom road stop spec for this tile.
 
 * @param t Tile to query
 
 * @pre IsRoadStopTile(t)
 
 * @return The custom station spec of this tile.
 
 */
 
static inline uint GetCustomRoadStopSpecIndex(Tile t)
 
inline uint GetCustomRoadStopSpecIndex(Tile t)
 
{
 
	assert(IsRoadStopTile(t));
 
	return GB(t.m8(), 0, 6);
 
}
 

	
 
/**
 
 * Set the random bits for a station tile.
 
 * @param t Tile to set random bits for.
 
 * @param random_bits The random bits.
 
 * @pre IsTileType(t, MP_STATION)
 
 */
 
static inline void SetStationTileRandomBits(Tile t, byte random_bits)
 
inline void SetStationTileRandomBits(Tile t, byte random_bits)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	SB(t.m3(), 4, 4, random_bits);
 
}
 

	
 
/**
 
 * Get the random bits of a station tile.
 
 * @param t Tile to query
 
 * @pre IsTileType(t, MP_STATION)
 
 * @return The random bits for this station tile.
 
 */
 
static inline byte GetStationTileRandomBits(Tile t)
 
inline byte GetStationTileRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_STATION));
 
	return GB(t.m3(), 4, 4);
 
}
 

	
 
/**
 
@@ -618,13 +618,13 @@ static inline byte GetStationTileRandomB
 
 * @param o the owner of the station
 
 * @param sid the station to which this tile belongs
 
 * @param st the type this station tile
 
 * @param section the StationGfx to be used for this tile
 
 * @param wc The water class of the station
 
 */
 
static inline void MakeStation(Tile t, Owner o, StationID sid, StationType st, byte section, WaterClass wc = WATER_CLASS_INVALID)
 
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);
 
	t.m2() = sid;
 
@@ -643,13 +643,13 @@ static inline void MakeStation(Tile t, O
 
 * @param o the owner of the station
 
 * @param sid the station to which this tile belongs
 
 * @param a the axis of this tile
 
 * @param section the StationGfx to be used for this tile
 
 * @param rt the railtype of this tile
 
 */
 
static inline void MakeRailStation(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
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);
 
	SetRailStationReservation(t, false);
 
}
 

	
 
@@ -659,13 +659,13 @@ static inline void MakeRailStation(Tile 
 
 * @param o the owner of the waypoint
 
 * @param sid the waypoint to which this tile belongs
 
 * @param a the axis of this tile
 
 * @param section the StationGfx to be used for this tile
 
 * @param rt the railtype of this tile
 
 */
 
static inline void MakeRailWaypoint(Tile t, Owner o, StationID sid, Axis a, byte section, RailType rt)
 
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);
 
	SetRailStationReservation(t, false);
 
}
 

	
 
@@ -676,13 +676,13 @@ static inline void MakeRailWaypoint(Tile
 
 * @param sid the station to which this tile belongs
 
 * @param rst the type of roadstop to make this tile
 
 * @param road_rt the road roadtype on this tile
 
 * @param tram_rt the tram roadtype on this tile
 
 * @param d the direction of the roadstop
 
 */
 
static inline void MakeRoadStop(Tile t, Owner o, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, DiagDirection d)
 
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);
 
	SetRoadOwner(t, RTT_ROAD, o);
 
	SetRoadOwner(t, RTT_TRAM, o);
 
}
 
@@ -696,13 +696,13 @@ static inline void MakeRoadStop(Tile t, 
 
 * @param sid the station to which this tile belongs
 
 * @param rst the type of roadstop to make this tile
 
 * @param road_rt the road roadtype on this tile
 
 * @param tram_rt the tram roadtype on this tile
 
 * @param a the direction of the roadstop
 
 */
 
static inline void MakeDriveThroughRoadStop(Tile t, Owner station, Owner road, Owner tram, StationID sid, RoadStopType rst, RoadType road_rt, RoadType tram_rt, Axis a)
 
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);
 
	SetRoadOwner(t, RTT_ROAD, road);
 
	SetRoadOwner(t, RTT_TRAM, tram);
 
}
 
@@ -712,24 +712,24 @@ static inline void MakeDriveThroughRoadS
 
 * @param t the tile to make a airport
 
 * @param o the owner of the airport
 
 * @param sid the station to which this tile belongs
 
 * @param section the StationGfx to be used for this tile
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeAirport(Tile t, Owner o, StationID sid, byte section, WaterClass wc)
 
inline void MakeAirport(Tile t, Owner o, StationID sid, byte section, WaterClass wc)
 
{
 
	MakeStation(t, o, sid, STATION_AIRPORT, section, wc);
 
}
 

	
 
/**
 
 * Make the given tile a buoy tile.
 
 * @param t the tile to make a buoy
 
 * @param sid the station to which this tile belongs
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeBuoy(Tile t, StationID sid, WaterClass wc)
 
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
 
	 * original state when the buoy gets removed. */
 
	MakeStation(t, GetTileOwner(t), sid, STATION_BUOY, 0, wc);
 
}
 
@@ -739,24 +739,24 @@ static inline void MakeBuoy(Tile t, Stat
 
 * @param t the tile to make a dock
 
 * @param o the owner of the dock
 
 * @param sid the station to which this tile belongs
 
 * @param d the direction of the dock
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
 
inline void MakeDock(Tile t, Owner o, StationID sid, DiagDirection d, WaterClass wc)
 
{
 
	MakeStation(t, o, sid, STATION_DOCK, d);
 
	MakeStation(TileIndex(t) + TileOffsByDiagDir(d), o, sid, STATION_DOCK, GFX_DOCK_BASE_WATER_PART + DiagDirToAxis(d), wc);
 
}
 

	
 
/**
 
 * Make the given tile an oilrig tile.
 
 * @param t the tile to make an oilrig
 
 * @param sid the station to which this tile belongs
 
 * @param wc the type of water on this tile
 
 */
 
static inline void MakeOilrig(Tile t, StationID sid, WaterClass wc)
 
inline void MakeOilrig(Tile t, StationID sid, WaterClass wc)
 
{
 
	MakeStation(t, OWNER_NONE, sid, STATION_OILRIG, 0, wc);
 
}
 

	
 
#endif /* STATION_MAP_H */
src/stdafx.h
Show inline comments
 
@@ -408,13 +408,13 @@ void NORETURN AssertFailedError(int line
 
#endif
 

	
 
/**
 
 * Version of the standard free that accepts const pointers.
 
 * @param ptr The data to free.
 
 */
 
static inline void free(const void *ptr)
 
inline void free(const void *ptr)
 
{
 
	free(const_cast<void *>(ptr));
 
}
 

	
 
/**
 
 * The largest value that can be entered in a variable
src/story_base.h
Show inline comments
 
@@ -110,13 +110,13 @@ enum StoryPageButtonCursor : byte {
 
/**
 
 * Checks if a StoryPageButtonCursor value is valid.
 
 *
 
 * @param wc The value to check
 
 * @return true if the given value is a valid StoryPageButtonCursor.
 
 */
 
static inline bool IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor)
 
inline bool IsValidStoryPageButtonCursor(StoryPageButtonCursor cursor)
 
{
 
	return cursor < SPBC_END;
 
}
 

	
 
/** Helper to construct packed "id" values for button-type StoryPageElement */
 
struct StoryPageButtonData {
src/string_func.h
Show inline comments
 
@@ -51,25 +51,25 @@ struct CaseInsensitiveComparator {
 
 * Check if a string buffer is empty.
 
 *
 
 * @param s The pointer to the first element of the buffer
 
 * @return true if the buffer starts with the terminating null-character or
 
 *         if the given pointer points to nullptr else return false
 
 */
 
static inline bool StrEmpty(const char *s)
 
inline bool StrEmpty(const char *s)
 
{
 
	return s == nullptr || s[0] == '\0';
 
}
 

	
 
/**
 
 * Get the length of a string, within a limited buffer.
 
 *
 
 * @param str The pointer to the first element of the buffer
 
 * @param maxlen The maximum size of the buffer
 
 * @return The length of the string
 
 */
 
static inline size_t ttd_strnlen(const char *str, size_t maxlen)
 
inline size_t ttd_strnlen(const char *str, size_t maxlen)
 
{
 
	const char *t;
 
	for (t = str; (size_t)(t - str) < maxlen && *t != '\0'; t++) {}
 
	return t - str;
 
}
 

	
 
@@ -79,33 +79,33 @@ size_t Utf8Decode(char32_t *c, const cha
 
size_t Utf8Encode(char *buf, char32_t c);
 
size_t Utf8Encode(std::ostreambuf_iterator<char> &buf, char32_t c);
 
size_t Utf8Encode(std::back_insert_iterator<std::string> &buf, char32_t c);
 
size_t Utf8TrimString(char *s, size_t maxlen);
 

	
 

	
 
static inline char32_t Utf8Consume(const char **s)
 
inline char32_t Utf8Consume(const char **s)
 
{
 
	char32_t c;
 
	*s += Utf8Decode(&c, *s);
 
	return c;
 
}
 

	
 
template <class Titr>
 
static inline char32_t Utf8Consume(Titr &s)
 
inline char32_t Utf8Consume(Titr &s)
 
{
 
	char32_t c;
 
	s += Utf8Decode(&c, &*s);
 
	return c;
 
}
 

	
 
/**
 
 * Return the length of a UTF-8 encoded character.
 
 * @param c Unicode character.
 
 * @return Length of UTF-8 encoding for character.
 
 */
 
static inline int8_t Utf8CharLen(char32_t c)
 
inline int8_t Utf8CharLen(char32_t c)
 
{
 
	if (c < 0x80)       return 1;
 
	if (c < 0x800)      return 2;
 
	if (c < 0x10000)    return 3;
 
	if (c < 0x110000)   return 4;
 

	
 
@@ -118,45 +118,45 @@ static inline int8_t Utf8CharLen(char32_
 
 * Return the length of an UTF-8 encoded value based on a single char. This
 
 * char should be the first byte of the UTF-8 encoding. If not, or encoding
 
 * is invalid, return value is 0
 
 * @param c char to query length of
 
 * @return requested size
 
 */
 
static inline int8_t Utf8EncodedCharLen(char c)
 
inline int8_t Utf8EncodedCharLen(char c)
 
{
 
	if (GB(c, 3, 5) == 0x1E) return 4;
 
	if (GB(c, 4, 4) == 0x0E) return 3;
 
	if (GB(c, 5, 3) == 0x06) return 2;
 
	if (GB(c, 7, 1) == 0x00) return 1;
 

	
 
	/* Invalid UTF8 start encoding */
 
	return 0;
 
}
 

	
 

	
 
/* Check if the given character is part of a UTF8 sequence */
 
static inline bool IsUtf8Part(char c)
 
inline bool IsUtf8Part(char c)
 
{
 
	return GB(c, 6, 2) == 2;
 
}
 

	
 
/**
 
 * Retrieve the previous UNICODE character in an UTF-8 encoded string.
 
 * @param s char pointer pointing to (the first char of) the next character
 
 * @return a pointer in 's' to the previous UNICODE character's first byte
 
 * @note The function should not be used to determine the length of the previous
 
 * encoded char because it might be an invalid/corrupt start-sequence
 
 */
 
static inline char *Utf8PrevChar(char *s)
 
inline char *Utf8PrevChar(char *s)
 
{
 
	char *ret = s;
 
	while (IsUtf8Part(*--ret)) {}
 
	return ret;
 
}
 

	
 
static inline const char *Utf8PrevChar(const char *s)
 
inline const char *Utf8PrevChar(const char *s)
 
{
 
	const char *ret = s;
 
	while (IsUtf8Part(*--ret)) {}
 
	return ret;
 
}
 

	
 
@@ -165,44 +165,44 @@ size_t Utf8StringLength(const std::strin
 

	
 
/**
 
 * Is the given character a lead surrogate code point?
 
 * @param c The character to test.
 
 * @return True if the character is a lead surrogate code point.
 
 */
 
static inline bool Utf16IsLeadSurrogate(uint c)
 
inline bool Utf16IsLeadSurrogate(uint c)
 
{
 
	return c >= 0xD800 && c <= 0xDBFF;
 
}
 

	
 
/**
 
 * Is the given character a lead surrogate code point?
 
 * @param c The character to test.
 
 * @return True if the character is a lead surrogate code point.
 
 */
 
static inline bool Utf16IsTrailSurrogate(uint c)
 
inline bool Utf16IsTrailSurrogate(uint c)
 
{
 
	return c >= 0xDC00 && c <= 0xDFFF;
 
}
 

	
 
/**
 
 * Convert an UTF-16 surrogate pair to the corresponding Unicode character.
 
 * @param lead Lead surrogate code point.
 
 * @param trail Trail surrogate code point.
 
 * @return Decoded Unicode character.
 
 */
 
static inline char32_t Utf16DecodeSurrogate(uint lead, uint trail)
 
inline char32_t Utf16DecodeSurrogate(uint lead, uint trail)
 
{
 
	return 0x10000 + (((lead - 0xD800) << 10) | (trail - 0xDC00));
 
}
 

	
 
/**
 
 * Decode an UTF-16 character.
 
 * @param c Pointer to one or two UTF-16 code points.
 
 * @return Decoded Unicode character.
 
 */
 
static inline char32_t Utf16DecodeChar(const uint16_t *c)
 
inline char32_t Utf16DecodeChar(const uint16_t *c)
 
{
 
	if (Utf16IsLeadSurrogate(c[0])) {
 
		return Utf16DecodeSurrogate(c[0], c[1]);
 
	} else {
 
		return *c;
 
	}
 
@@ -211,13 +211,13 @@ static inline char32_t Utf16DecodeChar(c
 
/**
 
 * Is the given character a text direction character.
 
 * @param c The character to test.
 
 * @return true iff the character is used to influence
 
 *         the text direction.
 
 */
 
static inline bool IsTextDirectionChar(char32_t c)
 
inline bool IsTextDirectionChar(char32_t c)
 
{
 
	switch (c) {
 
		case CHAR_TD_LRM:
 
		case CHAR_TD_RLM:
 
		case CHAR_TD_LRE:
 
		case CHAR_TD_RLE:
 
@@ -228,13 +228,13 @@ static inline bool IsTextDirectionChar(c
 

	
 
		default:
 
			return false;
 
	}
 
}
 

	
 
static inline bool IsPrintable(char32_t c)
 
inline bool IsPrintable(char32_t c)
 
{
 
	if (c < 0x20)   return false;
 
	if (c < 0xE000) return true;
 
	if (c < 0xE200) return false;
 
	return true;
 
}
 
@@ -243,13 +243,13 @@ static inline bool IsPrintable(char32_t 
 
 * Check whether UNICODE character is whitespace or not, i.e. whether
 
 * this is a potential line-break character.
 
 * @param c UNICODE character to check
 
 * @return a boolean value whether 'c' is a whitespace character or not
 
 * @see http://www.fileformat.info/info/unicode/category/Zs/list.htm
 
 */
 
static inline bool IsWhitespace(char32_t c)
 
inline bool IsWhitespace(char32_t c)
 
{
 
	return c == 0x0020 /* SPACE */ || c == 0x3000; /* IDEOGRAPHIC SPACE */
 
}
 

	
 
/* Needed for NetBSD version (so feature) testing */
 
#if defined(__NetBSD__) || defined(__FreeBSD__)
src/strings_func.h
Show inline comments
 
@@ -20,37 +20,37 @@
 

	
 
/**
 
 * Extract the StringTab from a StringID.
 
 * @param str String identifier
 
 * @return StringTab from \a str
 
 */
 
static inline StringTab GetStringTab(StringID str)
 
inline StringTab GetStringTab(StringID str)
 
{
 
	StringTab result = (StringTab)(str >> TAB_SIZE_BITS);
 
	if (result >= TEXT_TAB_NEWGRF_START) return TEXT_TAB_NEWGRF_START;
 
	if (result >= TEXT_TAB_GAMESCRIPT_START) return TEXT_TAB_GAMESCRIPT_START;
 
	return result;
 
}
 

	
 
/**
 
 * Extract the StringIndex from a StringID.
 
 * @param str String identifier
 
 * @return StringIndex from \a str
 
 */
 
static inline uint GetStringIndex(StringID str)
 
inline uint GetStringIndex(StringID str)
 
{
 
	return str - (GetStringTab(str) << TAB_SIZE_BITS);
 
}
 

	
 
/**
 
 * Create a StringID
 
 * @param tab StringTab
 
 * @param index StringIndex
 
 * @return StringID composed from \a tab and \a index
 
 */
 
static inline StringID MakeStringID(StringTab tab, uint index)
 
inline StringID MakeStringID(StringTab tab, uint index)
 
{
 
	if (tab == TEXT_TAB_NEWGRF_START) {
 
		assert(index < TAB_SIZE_NEWGRF);
 
	} else if (tab == TEXT_TAB_GAMESCRIPT_START) {
 
		assert(index < TAB_SIZE_GAMESCRIPT);
 
	} else {
 
@@ -69,13 +69,13 @@ uint ConvertDisplaySpeedToKmhishSpeed(ui
 
/**
 
 * Pack velocity and vehicle type for use with SCC_VELOCITY string parameter.
 
 * @param speed Display speed for parameter.
 
 * @param type Type of vehicle for parameter.
 
 * @return Bit-packed velocity and vehicle type, for use with SetDParam().
 
 */
 
static inline int64_t PackVelocity(uint speed, VehicleType type)
 
inline int64_t PackVelocity(uint speed, VehicleType type)
 
{
 
	/* Vehicle type is a byte, so packed into the top 8 bits of the 64-bit
 
	 * parameter, although only values from 0-3 are relevant. */
 
	return speed | (static_cast<uint64_t>(type) << 56);
 
}
 

	
src/tile_cmd.h
Show inline comments
 
@@ -176,35 +176,35 @@ extern const TileTypeProcs * const _tile
 

	
 
TrackStatus GetTileTrackStatus(TileIndex tile, TransportType mode, uint sub_mode, DiagDirection side = INVALID_DIAGDIR);
 
VehicleEnterTileStatus VehicleEnterTile(Vehicle *v, TileIndex tile, int x, int y);
 
void ChangeTileOwner(TileIndex tile, Owner old_owner, Owner new_owner);
 
void GetTileDesc(TileIndex tile, TileDesc *td);
 

	
 
static inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted)
 
inline void AddAcceptedCargo(TileIndex tile, CargoArray &acceptance, CargoTypes *always_accepted)
 
{
 
	AddAcceptedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_accepted_cargo_proc;
 
	if (proc == nullptr) return;
 
	CargoTypes dummy = 0; // use dummy bitmask so there don't need to be several 'always_accepted != nullptr' checks
 
	proc(tile, acceptance, always_accepted == nullptr ? &dummy : always_accepted);
 
}
 

	
 
static inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
 
inline void AddProducedCargo(TileIndex tile, CargoArray &produced)
 
{
 
	AddProducedCargoProc *proc = _tile_type_procs[GetTileType(tile)]->add_produced_cargo_proc;
 
	if (proc == nullptr) return;
 
	proc(tile, produced);
 
}
 

	
 
static inline void AnimateTile(TileIndex tile)
 
inline void AnimateTile(TileIndex tile)
 
{
 
	AnimateTileProc *proc = _tile_type_procs[GetTileType(tile)]->animate_tile_proc;
 
	assert(proc != nullptr);
 
	proc(tile);
 
}
 

	
 
static inline bool ClickTile(TileIndex tile)
 
inline bool ClickTile(TileIndex tile)
 
{
 
	ClickTileProc *proc = _tile_type_procs[GetTileType(tile)]->click_tile_proc;
 
	if (proc == nullptr) return false;
 
	return proc(tile);
 
}
 

	
src/tile_map.h
Show inline comments
 
@@ -36,13 +36,13 @@ debug_inline static uint TileHeight(Tile
 
 * Returns the height of a tile, also for tiles outside the map (virtual "black" tiles).
 
 *
 
 * @param x X coordinate of the tile, may be outside the map.
 
 * @param y Y coordinate of the tile, may be outside the map.
 
 * @return The height in the same unit as TileHeight.
 
 */
 
static inline uint TileHeightOutsideMap(int x, int y)
 
inline uint TileHeightOutsideMap(int x, int y)
 
{
 
	return TileHeight(TileXY(Clamp(x, 0, Map::MaxX()), Clamp(y, 0, Map::MaxY())));
 
}
 

	
 
/**
 
 * Sets the height of a tile.
 
@@ -51,13 +51,13 @@ static inline uint TileHeightOutsideMap(
 
 *
 
 * @param tile The tile to change the height
 
 * @param height The new height value of the tile
 
 * @pre tile < Map::Size()
 
 * @pre height <= MAX_TILE_HEIGHT
 
 */
 
static inline void SetTileHeight(Tile tile, uint height)
 
inline void SetTileHeight(Tile tile, uint height)
 
{
 
	assert(tile < Map::Size());
 
	assert(height <= MAX_TILE_HEIGHT);
 
	tile.height() = height;
 
}
 

	
 
@@ -66,25 +66,25 @@ static inline void SetTileHeight(Tile ti
 
 *
 
 * This function returns the height of the northern corner of a tile in pixels.
 
 *
 
 * @param tile The tile to get the height
 
 * @return The height of the tile in pixel
 
 */
 
static inline uint TilePixelHeight(Tile tile)
 
inline uint TilePixelHeight(Tile tile)
 
{
 
	return TileHeight(tile) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Returns the height of a tile in pixels, also for tiles outside the map (virtual "black" tiles).
 
 *
 
 * @param x X coordinate of the tile, may be outside the map.
 
 * @param y Y coordinate of the tile, may be outside the map.
 
 * @return The height in pixels in the same unit as TilePixelHeight.
 
 */
 
static inline uint TilePixelHeightOutsideMap(int x, int y)
 
inline uint TilePixelHeightOutsideMap(int x, int y)
 
{
 
	return TileHeightOutsideMap(x, y) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Get the tiletype of a given tile.
 
@@ -103,13 +103,13 @@ debug_inline static TileType GetTileType
 
 * Check if a tile is within the map (not a border)
 
 *
 
 * @param tile The tile to check
 
 * @return Whether the tile is in the interior of the map
 
 * @pre tile < Map::Size()
 
 */
 
static inline bool IsInnerTile(Tile tile)
 
inline bool IsInnerTile(Tile tile)
 
{
 
	assert(tile < Map::Size());
 

	
 
	uint x = TileX(tile);
 
	uint y = TileY(tile);
 

	
 
@@ -125,13 +125,13 @@ static inline bool IsInnerTile(Tile tile
 
 *
 
 * @param tile The tile to save the new type
 
 * @param type The type to save
 
 * @pre tile < Map::Size()
 
 * @pre type MP_VOID <=> tile is on the south-east or south-west edge.
 
 */
 
static inline void SetTileType(Tile tile, TileType type)
 
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));
 
@@ -155,13 +155,13 @@ debug_inline static bool IsTileType(Tile
 
/**
 
 * Checks if a tile is valid
 
 *
 
 * @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(Tile tile)
 
inline bool IsValidTile(Tile tile)
 
{
 
	return tile < Map::Size() && !IsTileType(tile, MP_VOID);
 
}
 

	
 
/**
 
 * Returns the owner of a tile
 
@@ -172,13 +172,13 @@ static inline bool IsValidTile(Tile tile
 
 *
 
 * @param tile The tile to check
 
 * @return The owner of the tile
 
 * @pre IsValidTile(tile)
 
 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
 
 */
 
static inline Owner GetTileOwner(Tile tile)
 
inline Owner GetTileOwner(Tile tile)
 
{
 
	assert(IsValidTile(tile));
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	return (Owner)GB(tile.m1(), 0, 5);
 
@@ -192,13 +192,13 @@ static inline Owner GetTileOwner(Tile ti
 
 *
 
 * @param tile The tile to change the owner status.
 
 * @param owner The new owner.
 
 * @pre IsValidTile(tile)
 
 * @pre The type of the tile must not be MP_HOUSE and MP_INDUSTRY
 
 */
 
static inline void SetTileOwner(Tile tile, Owner owner)
 
inline void SetTileOwner(Tile tile, Owner owner)
 
{
 
	assert(IsValidTile(tile));
 
	assert(!IsTileType(tile, MP_HOUSE));
 
	assert(!IsTileType(tile, MP_INDUSTRY));
 

	
 
	SB(tile.m1(), 0, 5, owner);
 
@@ -208,61 +208,61 @@ static inline void SetTileOwner(Tile til
 
 * Checks if a tile belongs to the given owner
 
 *
 
 * @param tile The tile to check
 
 * @param owner The owner to check against
 
 * @return True if a tile belongs the the given owner
 
 */
 
static inline bool IsTileOwner(Tile tile, Owner owner)
 
inline bool IsTileOwner(Tile tile, Owner owner)
 
{
 
	return GetTileOwner(tile) == owner;
 
}
 

	
 
/**
 
 * Set the tropic zone
 
 * @param tile the tile to set the zone of
 
 * @param type the new type
 
 * @pre tile < Map::Size()
 
 */
 
static inline void SetTropicZone(Tile tile, TropicZone type)
 
inline void SetTropicZone(Tile tile, TropicZone type)
 
{
 
	assert(tile < Map::Size());
 
	assert(!IsTileType(tile, MP_VOID) || type == TROPICZONE_NORMAL);
 
	SB(tile.type(), 0, 2, type);
 
}
 

	
 
/**
 
 * Get the tropic zone
 
 * @param tile the tile to get the zone of
 
 * @pre tile < Map::Size()
 
 * @return the zone type
 
 */
 
static inline TropicZone GetTropicZone(Tile tile)
 
inline TropicZone GetTropicZone(Tile tile)
 
{
 
	assert(tile < Map::Size());
 
	return (TropicZone)GB(tile.type(), 0, 2);
 
}
 

	
 
/**
 
 * Get the current animation frame
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION)
 
 * @return frame number
 
 */
 
static inline byte GetAnimationFrame(Tile t)
 
inline byte GetAnimationFrame(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	return t.m7();
 
}
 

	
 
/**
 
 * Set a new animation frame
 
 * @param t the tile
 
 * @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(Tile t, byte frame)
 
inline void SetAnimationFrame(Tile t, byte frame)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || IsTileType(t, MP_OBJECT) || IsTileType(t, MP_INDUSTRY) ||IsTileType(t, MP_STATION));
 
	t.m7() = frame;
 
}
 

	
 
Slope GetTileSlope(TileIndex tile, int *h = nullptr);
 
@@ -274,13 +274,13 @@ bool IsTileFlat(TileIndex tile, int *h =
 
/**
 
 * Return the slope of a given tile
 
 * @param tile Tile to compute slope of
 
 * @param h    If not \c nullptr, pointer to storage of z height
 
 * @return Slope of the tile, except for the HALFTILE part
 
 */
 
static inline Slope GetTilePixelSlope(TileIndex tile, int *h)
 
inline Slope GetTilePixelSlope(TileIndex tile, int *h)
 
{
 
	Slope s = GetTileSlope(tile, h);
 
	if (h != nullptr) *h *= TILE_HEIGHT;
 
	return s;
 
}
 

	
 
@@ -288,35 +288,35 @@ Slope GetTilePixelSlopeOutsideMap(int x,
 

	
 
/**
 
 * Get bottom height of the tile
 
 * @param tile Tile to compute height of
 
 * @return Minimum height of the tile
 
 */
 
static inline int GetTilePixelZ(TileIndex tile)
 
inline int GetTilePixelZ(TileIndex tile)
 
{
 
	return GetTileZ(tile) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Get top height of the tile
 
 * @param tile Tile to compute height of
 
 * @return Maximum height of the tile
 
 */
 
static inline int GetTileMaxPixelZ(TileIndex tile)
 
inline int GetTileMaxPixelZ(TileIndex tile)
 
{
 
	return GetTileMaxZ(tile) * TILE_HEIGHT;
 
}
 

	
 
/**
 
 * Calculate a hash value from a tile position
 
 *
 
 * @param x The X coordinate
 
 * @param y The Y coordinate
 
 * @return The hash of the tile
 
 */
 
static inline uint TileHash(uint x, uint y)
 
inline uint TileHash(uint x, uint y)
 
{
 
	uint hash = x >> 4;
 
	hash ^= x >> 6;
 
	hash ^= y >> 4;
 
	hash -= y >> 6;
 
	return hash;
 
@@ -328,12 +328,12 @@ static inline uint TileHash(uint x, uint
 
 *
 
 * @see TileHash()
 
 * @param x The X coordinate
 
 * @param y The Y coordinate
 
 * @return The last two bits from hash of the tile
 
 */
 
static inline uint TileHash2Bit(uint x, uint y)
 
inline uint TileHash2Bit(uint x, uint y)
 
{
 
	return GB(TileHash(x, y), 0, 2);
 
}
 

	
 
#endif /* TILE_MAP_H */
src/tile_type.h
Show inline comments
 
@@ -89,9 +89,9 @@ using TileIndex = StrongType::Typedef<ui
 
/* Make sure the size is as expected. */
 
static_assert(sizeof(TileIndex) == 4);
 

	
 
/**
 
 * The very nice invalid tile marker
 
 */
 
static inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 };
 
inline constexpr TileIndex INVALID_TILE = TileIndex{ (uint32_t)-1 };
 

	
 
#endif /* TILE_TYPE_H */
src/town.h
Show inline comments
 
@@ -301,13 +301,13 @@ void MakeDefaultName(T *obj)
 
}
 

	
 
/*
 
 * Converts original town ticks counters to plain game ticks. Note that
 
 * tick 0 is a valid tick so actual amount is one more than the counter value.
 
 */
 
static inline uint16_t TownTicksToGameTicks(uint16_t ticks)
 
inline uint16_t TownTicksToGameTicks(uint16_t ticks)
 
{
 
	return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1;
 
}
 

	
 

	
 
RoadType GetTownRoadType();
src/town_map.h
Show inline comments
 
@@ -17,147 +17,147 @@
 
/**
 
 * Get the index of which town this house/street is attached to.
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE) or IsTileType(t, MP_ROAD) but not a road depot
 
 * @return TownID
 
 */
 
static inline TownID GetTownIndex(Tile t)
 
inline TownID GetTownIndex(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
 
	return t.m2();
 
}
 

	
 
/**
 
 * Set the town index for a road or house tile.
 
 * @param t the tile
 
 * @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(Tile t, TownID index)
 
inline void SetTownIndex(Tile t, TownID index)
 
{
 
	assert(IsTileType(t, MP_HOUSE) || (IsTileType(t, MP_ROAD) && !IsRoadDepot(t)));
 
	t.m2() = index;
 
}
 

	
 
/**
 
 * Get the type of this house, which is an index into the house spec array
 
 * without doing any NewGRF related translations.
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return house type
 
 */
 
static inline HouseID GetCleanHouseType(Tile t)
 
inline HouseID GetCleanHouseType(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return t.m4() | (GB(t.m3(), 6, 1) << 8);
 
}
 

	
 
/**
 
 * Get the type of this house, which is an index into the house spec array
 
 * @param t the tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return house type
 
 */
 
static inline HouseID GetHouseType(Tile t)
 
inline HouseID GetHouseType(Tile t)
 
{
 
	return GetTranslatedHouseID(GetCleanHouseType(t));
 
}
 

	
 
/**
 
 * Set the house type.
 
 * @param t the tile
 
 * @param house_id the new house type
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseType(Tile t, HouseID house_id)
 
inline void SetHouseType(Tile t, HouseID house_id)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	t.m4() = GB(house_id, 0, 8);
 
	SB(t.m3(), 6, 1, GB(house_id, 8, 1));
 
}
 

	
 
/**
 
 * Check if the lift of this animated house has a destination
 
 * @param t the tile
 
 * @return has destination
 
 */
 
static inline bool LiftHasDestination(Tile t)
 
inline bool LiftHasDestination(Tile t)
 
{
 
	return HasBit(t.m7(), 0);
 
}
 

	
 
/**
 
 * Set the new destination of the lift for this animated house, and activate
 
 * the LiftHasDestination bit.
 
 * @param t the tile
 
 * @param dest new destination
 
 */
 
static inline void SetLiftDestination(Tile t, byte dest)
 
inline void SetLiftDestination(Tile t, byte dest)
 
{
 
	SetBit(t.m7(), 0);
 
	SB(t.m7(), 1, 3, dest);
 
}
 

	
 
/**
 
 * Get the current destination for this lift
 
 * @param t the tile
 
 * @return destination
 
 */
 
static inline byte GetLiftDestination(Tile t)
 
inline byte GetLiftDestination(Tile t)
 
{
 
	return GB(t.m7(), 1, 3);
 
}
 

	
 
/**
 
 * Stop the lift of this animated house from moving.
 
 * Clears the first 4 bits of m7 at once, clearing the LiftHasDestination bit
 
 * and the destination.
 
 * @param t the tile
 
 */
 
static inline void HaltLift(Tile t)
 
inline void HaltLift(Tile t)
 
{
 
	SB(t.m7(), 0, 4, 0);
 
}
 

	
 
/**
 
 * Get the position of the lift on this animated house
 
 * @param t the tile
 
 * @return position, from 0 to 36
 
 */
 
static inline byte GetLiftPosition(Tile t)
 
inline byte GetLiftPosition(Tile t)
 
{
 
	return GB(t.m6(), 2, 6);
 
}
 

	
 
/**
 
 * Set the position of the lift on this animated house
 
 * @param t the tile
 
 * @param pos position, from 0 to 36
 
 */
 
static inline void SetLiftPosition(Tile t, byte pos)
 
inline void SetLiftPosition(Tile t, byte pos)
 
{
 
	SB(t.m6(), 2, 6, pos);
 
}
 

	
 
/**
 
 * Get the completion of this house
 
 * @param t the tile
 
 * @return true if it is, false if it is not
 
 */
 
static inline bool IsHouseCompleted(Tile t)
 
inline bool IsHouseCompleted(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return HasBit(t.m3(), 7);
 
}
 

	
 
/**
 
 * Mark this house as been completed
 
 * @param t the tile
 
 * @param status
 
 */
 
static inline void SetHouseCompleted(Tile t, bool status)
 
inline void SetHouseCompleted(Tile t, bool status)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(t.m3(), 7, 1, !!status);
 
}
 

	
 
/**
 
@@ -178,38 +178,38 @@ static inline void SetHouseCompleted(Til
 
 * fool the system by returning the TOWN_HOUSE_COMPLETE (3),
 
 * thus showing a beautiful complete house.
 
 * @param t the tile of the house to get the building stage of
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return the building stage of the house
 
 */
 
static inline byte GetHouseBuildingStage(Tile t)
 
inline byte GetHouseBuildingStage(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? (byte)TOWN_HOUSE_COMPLETED : GB(t.m5(), 3, 2);
 
}
 

	
 
/**
 
 * Gets the construction stage of a house
 
 * @param t the tile of the house to get the construction stage of
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return the construction stage of the house
 
 */
 
static inline byte GetHouseConstructionTick(Tile t)
 
inline byte GetHouseConstructionTick(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? 0 : GB(t.m5(), 0, 3);
 
}
 

	
 
/**
 
 * Sets the increment stage of a house
 
 * It is working with the whole counter + stage 5 bits, making it
 
 * easier to work:  the wraparound is automatic.
 
 * @param t the tile of the house to increment the construction stage of
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void IncHouseConstructionTick(Tile t)
 
inline void IncHouseConstructionTick(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	AB(t.m5(), 0, 5, 1);
 

	
 
	if (GB(t.m5(), 3, 2) == TOWN_HOUSE_COMPLETED) {
 
		/* House is now completed.
 
@@ -221,123 +221,123 @@ static inline void IncHouseConstructionT
 
/**
 
 * Sets the age of the house to zero.
 
 * Needs to be called after the house is completed. During construction stages the map space is used otherwise.
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE) && IsHouseCompleted(t)
 
 */
 
static inline void ResetHouseAge(Tile t)
 
inline void ResetHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE) && IsHouseCompleted(t));
 
	t.m5() = 0;
 
}
 

	
 
/**
 
 * Increments the age of the house.
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void IncrementHouseAge(Tile t)
 
inline void IncrementHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	if (IsHouseCompleted(t) && t.m5() < 0xFF) t.m5()++;
 
}
 

	
 
/**
 
 * Get the age of the house
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return year
 
 */
 
static inline TimerGameCalendar::Year GetHouseAge(Tile t)
 
inline TimerGameCalendar::Year GetHouseAge(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return IsHouseCompleted(t) ? t.m5() : 0;
 
}
 

	
 
/**
 
 * Set the random bits for this house.
 
 * This is required for newgrf house
 
 * @param t      the tile of this house
 
 * @param random the new random bits
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseRandomBits(Tile t, byte random)
 
inline void SetHouseRandomBits(Tile t, byte random)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	t.m1() = random;
 
}
 

	
 
/**
 
 * Get the random bits for this house.
 
 * This is required for newgrf house
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return random bits
 
 */
 
static inline byte GetHouseRandomBits(Tile t)
 
inline byte GetHouseRandomBits(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return t.m1();
 
}
 

	
 
/**
 
 * Set the activated triggers bits for this house.
 
 * This is required for newgrf house
 
 * @param t        the tile of this house
 
 * @param triggers the activated triggers
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseTriggers(Tile t, byte triggers)
 
inline void SetHouseTriggers(Tile t, byte triggers)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(t.m3(), 0, 5, triggers);
 
}
 

	
 
/**
 
 * Get the already activated triggers bits for this house.
 
 * This is required for newgrf house
 
 * @param t the tile of this house
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return triggers
 
 */
 
static inline byte GetHouseTriggers(Tile t)
 
inline byte GetHouseTriggers(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return GB(t.m3(), 0, 5);
 
}
 

	
 
/**
 
 * Get the amount of time remaining before the tile loop processes this tile.
 
 * @param t the house tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 * @return time remaining
 
 */
 
static inline byte GetHouseProcessingTime(Tile t)
 
inline byte GetHouseProcessingTime(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	return GB(t.m6(), 2, 6);
 
}
 

	
 
/**
 
 * Set the amount of time remaining before the tile loop processes this tile.
 
 * @param t the house tile
 
 * @param time the time to be set
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void SetHouseProcessingTime(Tile t, byte time)
 
inline void SetHouseProcessingTime(Tile t, byte time)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	SB(t.m6(), 2, 6, time);
 
}
 

	
 
/**
 
 * Decrease the amount of time remaining before the tile loop processes this tile.
 
 * @param t the house tile
 
 * @pre IsTileType(t, MP_HOUSE)
 
 */
 
static inline void DecHouseProcessingTime(Tile t)
 
inline void DecHouseProcessingTime(Tile t)
 
{
 
	assert(IsTileType(t, MP_HOUSE));
 
	t.m6() -= 1 << 2;
 
}
 

	
 
/**
 
@@ -347,13 +347,13 @@ static inline void DecHouseProcessingTim
 
 * @param counter of construction step
 
 * @param stage of construction (used for drawing)
 
 * @param type of house.  Index into house specs array
 
 * @param random_bits required for newgrf houses
 
 * @pre IsTileType(t, MP_CLEAR)
 
 */
 
static inline void MakeHouseTile(Tile t, TownID tid, byte counter, byte stage, HouseID type, byte random_bits)
 
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);
 
	t.m1() = random_bits;
 
	t.m2() = tid;

Changeset was too big and was cut off... Show full diff anyway

0 comments (0 inline, 0 general)