Changeset - r8597:282d922c27d7
[Not reviewed]
master
0 1 0
smatz - 16 years ago 2008-02-18 16:35:38
smatz@openttd.org
(svn r12178) -Codechange: use the 'side' parameter in TrainController and TrainCheckIfLineEnds to simplify the code
1 file changed with 4 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -3037,13 +3037,13 @@ static void TrainController(Vehicle *v, 
 
				Direction dir = GetNewVehicleDirectionByTile(gp.new_tile, gp.old_tile);
 
				enterdir = DirToDiagDir(dir);
 
				assert(IsValidDiagDirection(enterdir));
 

	
 
				/* Get the status of the tracks in the new tile and mask
 
				 * away the bits that aren't reachable. */
 
				uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0) & _reachable_tracks[enterdir];
 
				uint32 ts = GetTileTrackStatus(gp.new_tile, TRANSPORT_RAIL, 0, ReverseDiagDir(enterdir)) & _reachable_tracks[enterdir];
 

	
 
				/* Combine the from & to directions.
 
				 * Now, the lower byte contains the track status, and the byte at bit 16 contains
 
				 * the signal status. */
 
				uint32 tracks = ts | (ts >> 8);
 
				TrackBits bits = (TrackBits)(tracks & TRACK_BIT_MASK);
 
@@ -3472,27 +3472,24 @@ static bool TrainCheckIfLineEnds(Vehicle
 
	/* Determine the non-diagonal direction in which we will exit this tile */
 
	DiagDirection dir = TrainExitDir(v->direction, v->u.rail.track);
 
	/* Calculate next tile */
 
	TileIndex tile = v->tile + TileOffsByDiagDir(dir);
 

	
 
	/* Determine the track status on the next tile */
 
	uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & _reachable_tracks[dir];
 
	uint32 ts = GetTileTrackStatus(tile, TRANSPORT_RAIL, 0, ReverseDiagDir(dir)) & _reachable_tracks[dir];
 

	
 
	/* We are sure the train is not entering a depot, it is detected above */
 

	
 
	/* mask unreachable track bits if we are forbidden to do 90deg turns */
 
	TrackBits bits = (TrackBits)((ts | (ts >> 8)) & TRACK_BIT_MASK);
 
	if (_patches.pathfinder_for_trains != VPF_NTP && _patches.forbid_90_deg) {
 
		bits &= ~TrackCrossesTracks(FindFirstTrack(v->u.rail.track));
 
	}
 

	
 
	/* no suitable trackbits at all || wrong railtype || not our track ||
 
	 *   tunnel/bridge from opposite side || depot from opposite side */
 
	if (bits == TRACK_BIT_NONE || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner ||
 
			(IsTileType(tile, MP_TUNNELBRIDGE) && GetTunnelBridgeDirection(tile) != dir) ||
 
			(IsTileDepotType(tile, TRANSPORT_RAIL) && GetRailDepotDirection(tile) == dir) ) {
 
	/* no suitable trackbits at all || wrong railtype || not our track */
 
	if (bits == TRACK_BIT_NONE || !CheckCompatibleRail(v, tile) || GetTileOwner(tile) != v->owner) {
 
		return TrainApproachingLineEnd(v, false);
 
	}
 

	
 
	/* approaching red signal */
 
	if ((ts & (ts >> 16)) != 0) return TrainApproachingLineEnd(v, true);
 

	
0 comments (0 inline, 0 general)