tunnelbridge_cmd.c
changeset 4291 c0e769957f8b
parent 4290 2d6895dc84eb
child 4293 2c24234a7aec
equal deleted inserted replaced
4290:2d6895dc84eb 4291:c0e769957f8b
  1423 		}
  1423 		}
  1424 	}
  1424 	}
  1425 	return 0;
  1425 	return 0;
  1426 }
  1426 }
  1427 
  1427 
       
  1428 /** Retrieve the exit-tile of the vehicle from inside a tunnel
       
  1429  * Very similar to GetOtherTunnelEnd(), but we use the vehicle's
       
  1430  * direction for determining which end of the tunnel to find
       
  1431  * @param v the vehicle which is inside the tunnel and needs an exit
       
  1432  * @return the exit-tile of the tunnel based on the vehicle's direction */
       
  1433 TileIndex GetVehicleOutOfTunnelTile(const Vehicle *v)
       
  1434 {
       
  1435 	TileIndex tile = v->tile;
       
  1436 	DiagDirection dir = DirToDiagDir(v->direction);
       
  1437 	TileIndexDiff delta = TileOffsByDir(dir);
       
  1438 	byte z = v->z_pos;
       
  1439 
       
  1440 	dir = ReverseDiagDir(dir);
       
  1441 	while (
       
  1442 		!IsTunnelTile(tile) ||
       
  1443 		GetTunnelDirection(tile) != dir ||
       
  1444 		GetTileZ(tile) != z
       
  1445 	) {
       
  1446 		tile += delta;
       
  1447 	}
       
  1448 
       
  1449 	return tile;
       
  1450 }
  1428 
  1451 
  1429 const TileTypeProcs _tile_type_tunnelbridge_procs = {
  1452 const TileTypeProcs _tile_type_tunnelbridge_procs = {
  1430 	DrawTile_TunnelBridge,					/* draw_tile_proc */
  1453 	DrawTile_TunnelBridge,					/* draw_tile_proc */
  1431 	GetSlopeZ_TunnelBridge,					/* get_slope_z_proc */
  1454 	GetSlopeZ_TunnelBridge,					/* get_slope_z_proc */
  1432 	ClearTile_TunnelBridge,					/* clear_tile_proc */
  1455 	ClearTile_TunnelBridge,					/* clear_tile_proc */