Changeset - r21733:9e3a5387d8a6
[Not reviewed]
master
0 4 0
rubidium - 10 years ago 2014-09-21 11:20:11
rubidium@openttd.org
(svn r26876) -Codechange: move 'has bride above' data from m6 to type
4 files changed with 13 insertions and 18 deletions:
0 comments (0 inline, 0 general)
src/bridge_map.h
Show inline comments
 
@@ -49,19 +49,17 @@ static inline bool MayHaveBridgeAbove(Ti
 
			IsTileType(t, MP_WATER) || IsTileType(t, MP_TUNNELBRIDGE) || IsTileType(t, MP_OBJECT);
 
}
 

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

	
 
/**
 
 * Determines the type of bridge on a tile
 
 * @param t The tile to analyze
 
 * @pre IsBridgeTile(t)
 
@@ -79,13 +77,13 @@ static inline BridgeType GetBridgeType(T
 
 * @pre IsBridgeAbove(t)
 
 * @return the above mentioned axis
 
 */
 
static inline Axis GetBridgeAxis(TileIndex 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 GetSouthernBridgeEnd(TileIndex t);
 
TileIndex GetOtherBridgeEnd(TileIndex t);
 

	
 
@@ -101,41 +99,36 @@ static inline int GetBridgePixelHeight(T
 
}
 

	
 
/**
 
 * 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
 
 * @pre MayHaveBridgeAbove(t)
 
 */
 
static inline void ClearSingleBridgeMiddle(TileIndex t, Axis a)
 
{
 
	assert(MayHaveBridgeAbove(t));
 
	ClrBit(_m[t].m6, 6 + a);
 
	ClrBit(_m[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
 
 * @pre MayHaveBridgeAbove(t)
 
 */
 
static inline void ClearBridgeMiddle(TileIndex 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
 
 * @pre MayHaveBridgeAbove(t)
 
 */
 
static inline void SetBridgeMiddle(TileIndex t, Axis a)
 
{
 
	assert(MayHaveBridgeAbove(t));
 
	SetBit(_m[t].m6, 6 + a);
 
	SetBit(_m[t].type, 2 + a);
 
}
 

	
 
/**
 
 * Generic part to make a bridge ramp for both roads and rails.
 
 * @param t          the tile to make a bridge ramp
 
 * @param o          the new owner of the bridge ramp
src/clear_map.h
Show inline comments
 
@@ -257,24 +257,20 @@ static inline void SetFence(TileIndex t,
 
 * @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(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);
 
	_m[t].m1 = 0;
 
	SetTileOwner(t, OWNER_NONE);
 
	_m[t].m2 = 0;
 
	_m[t].m3 = 0;
 
	_m[t].m4 = 0 << 5 | 0 << 2;
 
	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;
 
}
 

	
 

	
 
/**
 
 * Make a (farm) field tile.
src/map_type.h
Show inline comments
 
@@ -14,20 +14,20 @@
 

	
 
/**
 
 * Data that is stored per tile. Also used TileExtended for this.
 
 * Look at docs/landscape.html for the exact meaning of the members.
 
 */
 
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   m1;          ///< Primarily used for ownership information
 
	uint16 m2;          ///< Primarily used for indices to towns, industries and stations
 
	byte   m3;          ///< General purpose
 
	byte   m4;          ///< General purpose
 
	byte   m5;          ///< General purpose
 
	byte   m6;          ///< Primarily used for bridges and rainforest/desert
 
	byte   m6;          ///< General purpose
 
};
 

	
 
/**
 
 * Data that is stored per tile. Also used Tile for this.
 
 * Look at docs/landscape.html for the exact meaning of the members.
 
 */
src/saveload/afterload.cpp
Show inline comments
 
@@ -573,12 +573,18 @@ bool AfterLoadGame()
 
	if (IsSavegameVersionBefore(194)) {
 
		/* In old savegame versions, the heightlevel was coded in bits 0..3 of the type field */
 
		for (TileIndex t = 0; t < map_size; t++) {
 
			_m[t].height = GB(_m[t].type, 0, 4);
 
			SB(_m[t].type, 0, 2, GB(_m[t].m6, 0, 2));
 
			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);
 
			}
 
		}
 
	}
 

	
 
	/* in version 2.1 of the savegame, town owner was unified. */
 
	if (IsSavegameVersionBefore(2, 1)) ConvertTownOwner();
 

	
0 comments (0 inline, 0 general)