Changeset - r5826:84618d25ce1d
[Not reviewed]
master
0 1 0
tron - 17 years ago 2007-01-24 17:58:07
tron@openttd.org
(svn r8392) -Fix

Use HASBIT() instead of implementing it manually
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/yapf/follow_track.hpp
Show inline comments
 
@@ -127,97 +127,97 @@ protected:
 
			if (exitdir != m_exitdir)
 
				return false;
 
		}
 

	
 
		// road depots can be also left in one direction only
 
		if (IsRoadTT() && IsTileDepotType(m_old_tile, TT())) {
 
			DiagDirection exitdir = GetRoadDepotDirection(m_old_tile);
 
			if (exitdir != m_exitdir)
 
				return false;
 
		}
 
		return true;
 
	}
 

	
 
	/** return true if we can enter m_new_tile from m_exitdir */
 
	FORCEINLINE bool CanEnterNewTile()
 
	{
 
		if (IsRoadTT() && IsRoadStopTile(m_new_tile)) {
 
			// road stop can be entered from one direction only
 
			DiagDirection exitdir = GetRoadStopDir(m_new_tile);
 
			if (ReverseDiagDir(exitdir) != m_exitdir)
 
				return false;
 
		}
 

	
 
		// road and rail depots can also be entered from one direction only
 
		if (IsRoadTT() && IsTileDepotType(m_new_tile, TT())) {
 
			DiagDirection exitdir = GetRoadDepotDirection(m_new_tile);
 
			if (ReverseDiagDir(exitdir) != m_exitdir)
 
				return false;
 
			// don't try to enter other player's depots
 
			if (GetTileOwner(m_new_tile) != m_veh->owner) {
 
				return false;
 
			}
 
		}
 
		if (IsRailTT() && IsTileDepotType(m_new_tile, TT())) {
 
			DiagDirection exitdir = GetRailDepotDirection(m_new_tile);
 
			if (ReverseDiagDir(exitdir) != m_exitdir)
 
				return false;
 
		}
 

	
 
		// rail transport is possible only on tiles with the same owner as vehicle
 
		if (IsRailTT() && GetTileOwner(m_new_tile) != m_veh->owner) {
 
			// different owner
 
			return false;
 
		}
 

	
 
		// rail transport is possible only on compatible rail types
 
		if (IsRailTT()) {
 
			RailType rail_type = GetTileRailType(m_new_tile, TrackdirToTrack(DiagdirToDiagTrackdir(m_exitdir)));
 
			if (((1 << rail_type) & m_veh->u.rail.compatible_railtypes) == 0) {
 
			if (!HASBIT(m_veh->u.rail.compatible_railtypes, rail_type)) {
 
				// incompatible rail type
 
				return false;
 
			}
 
		}
 

	
 
		// tunnel holes and bridge ramps can be entered only from proper direction
 
		if (!IsWaterTT() && IsTileType(m_new_tile, MP_TUNNELBRIDGE)) {
 
			if (IsTunnel(m_new_tile)) {
 
				if (!m_is_tunnel) {
 
					DiagDirection tunnel_enterdir = GetTunnelDirection(m_new_tile);
 
					if (tunnel_enterdir != m_exitdir) return false;
 
				}
 
			} else if (IsBridge(m_new_tile)) {
 
				if (!m_is_bridge) {
 
					DiagDirection ramp_enderdir = GetBridgeRampDirection(m_new_tile);
 
					if (ramp_enderdir != m_exitdir) return false;
 
				}
 
			}
 
		}
 

	
 
		// special handling for rail stations - get to the end of platform
 
		if (IsRailTT() && m_is_station) {
 
			// entered railway station
 
			// get platform length
 
			uint length = GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td));
 
			// how big step we must do to get to the last platform tile;
 
			m_tiles_skipped = length - 1;
 
			// move to the platform end
 
			TileIndexDiff diff = TileOffsByDiagDir(m_exitdir);
 
			diff *= m_tiles_skipped;
 
			m_new_tile = TILE_ADD(m_new_tile, diff);
 
			return true;
 
		}
 

	
 
		return true;
 
	}
 

	
 
	/** return true if we entered depot and reversed inside */
 
	FORCEINLINE bool EnteredDepot()
 
	{
 
		// rail and road depots cause reversing
 
		if (!IsWaterTT() && IsTileDepotType(m_old_tile, TT())) {
 
			DiagDirection exitdir = IsRailTT() ? GetRailDepotDirection(m_old_tile) : GetRoadDepotDirection(m_old_tile);
 
			if (exitdir != m_exitdir) {
 
				// reverse
 
				m_new_tile = m_old_tile;
 
				m_new_td_bits = TrackdirToTrackdirBits(ReverseTrackdir(m_old_td));
 
				m_exitdir = exitdir;
0 comments (0 inline, 0 general)