Changeset - r5827:8f1ee941816d
[Not reviewed]
master
0 1 0
tron - 17 years ago 2007-01-24 18:03:36
tron@openttd.org
(svn r8393) -Fix

-Codechange: CheckCompatibleRail() is only called for tiles which are known to contain a piece of rail. Simplify the function accordingly by eliminating unnecessary checks.
-Fix (?): Also fix an inconsistency in deciding what a compatible rail type is between level crossings and other rail tiles. It is unknown if this caused any problems.
1 file changed with 4 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/train_cmd.cpp
Show inline comments
 
@@ -2804,29 +2804,13 @@ static int GetDirectionToVehicle(const V
 
/* Check if the vehicle is compatible with the specified tile */
 
static bool CheckCompatibleRail(const Vehicle *v, TileIndex tile)
 
{
 
	switch (GetTileType(tile)) {
 
		case MP_TUNNELBRIDGE:
 
		case MP_RAILWAY:
 
		case MP_STATION:
 
			// normal tracks, jump to owner check
 
			break;
 

	
 
		case MP_STREET:
 
			// tracks over roads, do owner check of tracks
 
			return
 
				IsTileOwner(tile, v->owner) && (
 
					!IsFrontEngine(v) ||
 
					IsCompatibleRail(v->u.rail.railtype, GetRailTypeCrossing(tile))
 
				);
 

	
 
		default:
 
			return true;
 
	}
 

	
 
	return
 
		IsTileOwner(tile, v->owner) && (
 
			!IsFrontEngine(v) ||
 
			HASBIT(v->u.rail.compatible_railtypes, GetRailType(tile))
 
			HASBIT(
 
				v->u.rail.compatible_railtypes,
 
				IsTileType(tile, MP_STREET) ? GetRailTypeCrossing(tile) : GetRailType(tile)
 
			)
 
		);
 
}
 

	
0 comments (0 inline, 0 general)