mirror of https://github.com/OpenTTD/OpenTTD
(svn r26876) -Codechange: move 'has bride above' data from m6 to type
parent
47852f119e
commit
0ac2d3b324
|
@ -52,13 +52,11 @@ static inline bool MayHaveBridgeAbove(TileIndex t)
|
||||||
/**
|
/**
|
||||||
* checks if a bridge is set above the ground of this tile
|
* checks if a bridge is set above the ground of this tile
|
||||||
* @param t The tile to analyze
|
* @param t The tile to analyze
|
||||||
* @pre MayHaveBridgeAbove(t)
|
|
||||||
* @return true if a bridge is detected above
|
* @return true if a bridge is detected above
|
||||||
*/
|
*/
|
||||||
static inline bool IsBridgeAbove(TileIndex t)
|
static inline bool IsBridgeAbove(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(MayHaveBridgeAbove(t));
|
return GB(_m[t].type, 2, 2) != 0;
|
||||||
return GB(_m[t].m6, 6, 2) != 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -82,7 +80,7 @@ static inline BridgeType GetBridgeType(TileIndex t)
|
||||||
static inline Axis GetBridgeAxis(TileIndex t)
|
static inline Axis GetBridgeAxis(TileIndex t)
|
||||||
{
|
{
|
||||||
assert(IsBridgeAbove(t));
|
assert(IsBridgeAbove(t));
|
||||||
return (Axis)(GB(_m[t].m6, 6, 2) - 1);
|
return (Axis)(GB(_m[t].type, 2, 2) - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
TileIndex GetNorthernBridgeEnd(TileIndex t);
|
TileIndex GetNorthernBridgeEnd(TileIndex t);
|
||||||
|
@ -104,18 +102,15 @@ static inline int GetBridgePixelHeight(TileIndex tile)
|
||||||
* Remove the bridge over the given axis.
|
* Remove the bridge over the given axis.
|
||||||
* @param t the tile to remove the bridge from
|
* @param t the tile to remove the bridge from
|
||||||
* @param a the axis of the bridge to remove
|
* @param a the axis of the bridge to remove
|
||||||
* @pre MayHaveBridgeAbove(t)
|
|
||||||
*/
|
*/
|
||||||
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
|
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
|
||||||
{
|
{
|
||||||
assert(MayHaveBridgeAbove(t));
|
ClrBit(_m[t].type, 2 + a);
|
||||||
ClrBit(_m[t].m6, 6 + a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes bridges from the given, that is bridges along the X and Y axis.
|
* Removes bridges from the given, that is bridges along the X and Y axis.
|
||||||
* @param t the tile to remove the bridge from
|
* @param t the tile to remove the bridge from
|
||||||
* @pre MayHaveBridgeAbove(t)
|
|
||||||
*/
|
*/
|
||||||
static inline void ClearBridgeMiddle(TileIndex t)
|
static inline void ClearBridgeMiddle(TileIndex t)
|
||||||
{
|
{
|
||||||
|
@ -127,12 +122,10 @@ static inline void ClearBridgeMiddle(TileIndex t)
|
||||||
* Set that there is a bridge over the given axis.
|
* Set that there is a bridge over the given axis.
|
||||||
* @param t the tile to add the bridge to
|
* @param t the tile to add the bridge to
|
||||||
* @param a the axis of the bridge to add
|
* @param a the axis of the bridge to add
|
||||||
* @pre MayHaveBridgeAbove(t)
|
|
||||||
*/
|
*/
|
||||||
static inline void SetBridgeMiddle(TileIndex t, Axis a)
|
static inline void SetBridgeMiddle(TileIndex t, Axis a)
|
||||||
{
|
{
|
||||||
assert(MayHaveBridgeAbove(t));
|
SetBit(_m[t].type, 2 + a);
|
||||||
SetBit(_m[t].m6, 6 + a);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -260,10 +260,6 @@ static inline void SetFence(TileIndex t, DiagDirection side, uint h)
|
||||||
*/
|
*/
|
||||||
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
|
static inline void MakeClear(TileIndex t, ClearGround g, uint density)
|
||||||
{
|
{
|
||||||
/* If this is a non-bridgeable tile, clear the bridge bits while the rest
|
|
||||||
* of the tile information is still here. */
|
|
||||||
if (!MayHaveBridgeAbove(t)) SB(_m[t].m6, 6, 2, 0);
|
|
||||||
|
|
||||||
SetTileType(t, MP_CLEAR);
|
SetTileType(t, MP_CLEAR);
|
||||||
_m[t].m1 = 0;
|
_m[t].m1 = 0;
|
||||||
SetTileOwner(t, OWNER_NONE);
|
SetTileOwner(t, OWNER_NONE);
|
||||||
|
@ -271,7 +267,7 @@ static inline void MakeClear(TileIndex t, ClearGround g, uint density)
|
||||||
_m[t].m3 = 0;
|
_m[t].m3 = 0;
|
||||||
_m[t].m4 = 0 << 5 | 0 << 2;
|
_m[t].m4 = 0 << 5 | 0 << 2;
|
||||||
SetClearGroundDensity(t, g, density); // Sets m5
|
SetClearGroundDensity(t, g, density); // Sets m5
|
||||||
SB(_m[t].m6, 2, 4, 0); // Other bits are "tropic zone" and "bridge above"
|
_m[t].m6 = 0;
|
||||||
_me[t].m7 = 0;
|
_me[t].m7 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,14 +17,14 @@
|
||||||
* Look at docs/landscape.html for the exact meaning of the members.
|
* Look at docs/landscape.html for the exact meaning of the members.
|
||||||
*/
|
*/
|
||||||
struct Tile {
|
struct Tile {
|
||||||
byte type; ///< The type (bits 4..7)
|
byte type; ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
|
||||||
byte height; ///< The height of the northern corner.
|
byte height; ///< The height of the northern corner.
|
||||||
byte m1; ///< Primarily used for ownership information
|
byte m1; ///< Primarily used for ownership information
|
||||||
uint16 m2; ///< Primarily used for indices to towns, industries and stations
|
uint16 m2; ///< Primarily used for indices to towns, industries and stations
|
||||||
byte m3; ///< General purpose
|
byte m3; ///< General purpose
|
||||||
byte m4; ///< General purpose
|
byte m4; ///< General purpose
|
||||||
byte m5; ///< General purpose
|
byte m5; ///< General purpose
|
||||||
byte m6; ///< Primarily used for bridges and rainforest/desert
|
byte m6; ///< General purpose
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -576,6 +576,12 @@ bool AfterLoadGame()
|
||||||
_m[t].height = GB(_m[t].type, 0, 4);
|
_m[t].height = GB(_m[t].type, 0, 4);
|
||||||
SB(_m[t].type, 0, 2, GB(_m[t].m6, 0, 2));
|
SB(_m[t].type, 0, 2, GB(_m[t].m6, 0, 2));
|
||||||
SB(_m[t].m6, 0, 2, 0);
|
SB(_m[t].m6, 0, 2, 0);
|
||||||
|
if (MayHaveBridgeAbove(t)) {
|
||||||
|
SB(_m[t].type, 2, 2, GB(_m[t].m6, 6, 2));
|
||||||
|
SB(_m[t].m6, 6, 2, 0);
|
||||||
|
} else {
|
||||||
|
SB(_m[t].type, 2, 2, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue