src/pbs.cpp
author bjarni
Sat, 09 Aug 2008 17:56:31 +0000
changeset 9884 e33430df09e6
parent 9831 b233da1b1723
child 9952 e003ab3361ad
permissions -rw-r--r--
(svn r14032) -Fix (r13584): [OSX] changed the condition for selecting 8 or 32 bpp blitter by default
Now we will pick 32 bpp if no 8 bpp fullscreen resolutions are available on the main display (the one with the dock)
9786
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     1
/* $Id$ */
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     2
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     3
/** @file pbs.cpp */
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     4
#include "stdafx.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     5
#include "openttd.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     6
#include "pbs.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     7
#include "rail_map.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     8
#include "road_map.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
     9
#include "station_map.h"
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    10
#include "tunnelbridge_map.h"
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    11
#include "functions.h"
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    12
#include "debug.h"
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    13
#include "direction_func.h"
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    14
#include "settings_type.h"
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
    15
#include "road_func.h"
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
    16
#include "vehicle_base.h"
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
    17
#include "vehicle_func.h"
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
    18
#include "yapf/follow_track.hpp"
9786
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    19
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    20
/**
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    21
 * Get the reserved trackbits for any tile, regardless of type.
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    22
 * @param t the tile
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    23
 * @return the reserved trackbits. TRACK_BIT_NONE on nothing reserved or
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    24
 *     a tile without rail.
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    25
 */
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    26
TrackBits GetReservedTrackbits(TileIndex t)
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    27
{
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    28
	switch (GetTileType(t)) {
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    29
		case MP_RAILWAY:
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    30
			if (IsRailWaypoint(t) || IsRailDepot(t)) return GetRailWaypointReservation(t);
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    31
			if (IsPlainRailTile(t)) return GetTrackReservation(t);
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    32
			break;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    33
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    34
		case MP_ROAD:
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    35
			if (IsLevelCrossing(t)) return GetRailCrossingReservation(t);
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    36
			break;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    37
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    38
		case MP_STATION:
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    39
			if (IsRailwayStation(t)) return GetRailStationReservation(t);
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    40
			break;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    41
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    42
		case MP_TUNNELBRIDGE:
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    43
			if (GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL) return GetRailTunnelBridgeReservation(t);
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    44
			break;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    45
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    46
		default:
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    47
			break;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    48
	}
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    49
	return TRACK_BIT_NONE;
0169b327f3d2 (svn r13928) -Add [YAPP]: Function for getting the path reservation state of any tile. (michi_cc)
rubidium
parents:
diff changeset
    50
}
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    51
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    52
/**
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    53
 * Set the reservation for a complete station platform.
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    54
 * @pre IsRailwayStationTile(start)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    55
 * @param start starting tile of the platform
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    56
 * @param dir the direction in which to follow the platform
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    57
 * @param b the state the reservation should be set to
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    58
 */
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    59
void SetRailwayStationPlatformReservation(TileIndex start, DiagDirection dir, bool b)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    60
{
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    61
	TileIndex     tile = start;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    62
	TileIndexDiff diff = TileOffsByDiagDir(dir);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    63
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    64
	assert(IsRailwayStationTile(start));
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    65
	assert(GetRailStationAxis(start) == DiagDirToAxis(dir));
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    66
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    67
	do {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    68
		SetRailwayStationReservation(tile, b);
9823
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
    69
		MarkTileDirtyByTile(tile);
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    70
		tile = TILE_ADD(tile, diff);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    71
	} while (IsCompatibleTrainStationTile(tile, start));
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    72
}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    73
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    74
/**
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    75
 * Try to reserve a specific track on a tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    76
 * @param tile the tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    77
 * @param t the track
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    78
 * @return true if reservation was successfull, i.e. the track was
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    79
 *     free and didn't cross any other reserved tracks.
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    80
 */
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    81
bool TryReserveRailTrack(TileIndex tile, Track t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    82
{
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    83
	assert((GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & TrackToTrackBits(t)) != 0);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    84
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    85
	if (_settings_client.gui.show_track_reservation) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    86
		MarkTileDirtyByTile(tile);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    87
	}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    88
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    89
	switch (GetTileType(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    90
		case MP_RAILWAY:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    91
			if (IsPlainRailTile(tile)) return TryReserveTrack(tile, t);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    92
			if (IsRailWaypoint(tile) || IsRailDepot(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    93
				if (!GetDepotWaypointReservation(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    94
					SetDepotWaypointReservation(tile, true);
9823
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
    95
					MarkTileDirtyByTile(tile);
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    96
					return true;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    97
				}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    98
			}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
    99
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   100
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   101
		case MP_ROAD:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   102
			if (IsLevelCrossing(tile) && !GetCrossingReservation(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   103
				SetCrossingReservation(tile, true);
9824
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   104
				BarCrossing(tile);
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   105
				MarkTileDirtyByTile(tile);
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   106
				return true;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   107
			}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   108
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   109
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   110
		case MP_STATION:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   111
			if (IsRailwayStation(tile) && !GetRailwayStationReservation(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   112
				SetRailwayStationReservation(tile, true);
9823
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   113
				MarkTileDirtyByTile(tile);
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   114
				return true;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   115
			}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   116
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   117
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   118
		case MP_TUNNELBRIDGE:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   119
			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL && !GetRailTunnelBridgeReservation(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   120
				SetTunnelBridgeReservation(tile, true);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   121
				return true;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   122
			}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   123
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   124
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   125
		default:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   126
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   127
	}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   128
	return false;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   129
}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   130
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   131
/**
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   132
 * Lift the reservation of a specific track on a tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   133
 * @param tile the tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   134
 * @param t the track
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   135
 */
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   136
 void UnreserveRailTrack(TileIndex tile, Track t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   137
{
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   138
	assert((GetTileTrackStatus(tile, TRANSPORT_RAIL, 0) & TrackToTrackBits(t)) != 0);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   139
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   140
	if (_settings_client.gui.show_track_reservation) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   141
		MarkTileDirtyByTile(tile);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   142
	}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   143
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   144
	switch (GetTileType(tile)) {
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   145
		case MP_RAILWAY:
9823
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   146
			if (IsRailWaypoint(tile) || IsRailDepot(tile)) {
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   147
				SetDepotWaypointReservation(tile, false);
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   148
				MarkTileDirtyByTile(tile);
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   149
			}
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   150
			if (IsPlainRailTile(tile)) UnreserveTrack(tile, t);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   151
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   152
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   153
		case MP_ROAD:
9824
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   154
			if (IsLevelCrossing(tile)) {
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   155
				SetCrossingReservation(tile, false);
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   156
				UpdateLevelCrossing(tile);
4db1a1b0ab09 (svn r13966) -Codechange [YAPP]: Bar level crossings upon path reservation. (michi_cc)
rubidium
parents: 9823
diff changeset
   157
			}
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   158
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   159
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   160
		case MP_STATION:
9823
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   161
			if (IsRailwayStation(tile)) {
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   162
				SetRailwayStationReservation(tile, false);
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   163
				MarkTileDirtyByTile(tile);
352b11cff200 (svn r13965) -Add [YAPP]: Implement newgrf var 0x44 for stations (PBS reservation state). (michi_cc)
rubidium
parents: 9814
diff changeset
   164
			}
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   165
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   166
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   167
		case MP_TUNNELBRIDGE:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   168
			if (GetTunnelBridgeTransportType(tile) == TRANSPORT_RAIL) SetTunnelBridgeReservation(tile, false);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   169
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   170
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   171
		default:
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   172
			break;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   173
	}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9786
diff changeset
   174
}
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   175
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   176
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   177
/** Follow a reservation starting from a specific tile to the end. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   178
static PBSTileInfo FollowReservation(Owner o, RailTypes rts, TileIndex tile, Trackdir trackdir, bool ignore_oneway = false)
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   179
{
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   180
	/* Do not disallow 90 deg turns as the setting might have changed between reserving and now. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   181
	CFollowTrackRail ft(o, rts);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   182
	while (ft.Follow(tile, trackdir)) {
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   183
		TrackdirBits reserved = (TrackdirBits)(ft.m_new_td_bits & (GetReservedTrackbits(ft.m_new_tile) * 0x101));
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   184
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   185
		/* No reservation --> path end found */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   186
		if (reserved == TRACKDIR_BIT_NONE) break;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   187
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   188
		/* Can't have more than one reserved trackdir */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   189
		Trackdir new_trackdir = FindFirstTrackdir(reserved);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   190
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   191
		/* One-way signal against us. The reservation can't be ours as it is not
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   192
		 * a safe position from our direction and we can never pass the signal. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   193
		if (!ignore_oneway && HasOnewaySignalBlockingTrackdir(ft.m_new_tile, new_trackdir)) break;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   194
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   195
		tile = ft.m_new_tile;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   196
		trackdir = new_trackdir;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   197
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   198
		/* Depot tile? Can't continue. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   199
		if (IsRailDepotTile(tile)) break;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   200
		/* Non-pbs signal? Reservation can't continue. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   201
		if (IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, TrackdirToTrack(trackdir)))) break;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   202
	}
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   203
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   204
	return PBSTileInfo(tile, trackdir, false);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   205
}
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   206
9831
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   207
/** Callback for VehicleFromPos to find a train on a specific track. */
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   208
static Vehicle *FindTrainOnTrackEnum(Vehicle *v, void *data)
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   209
{
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   210
	PBSTileInfo info = *(PBSTileInfo *)data;
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   211
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   212
	if (v->type == VEH_TRAIN && !(v->vehstatus & VS_CRASHED) && HasBit((TrackBits)v->u.rail.track, TrackdirToTrack(info.trackdir))) return v;
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   213
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   214
	return NULL;
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   215
}
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   216
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   217
/**
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   218
 * Follow a train reservation to the last tile.
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   219
 *
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   220
 * @param v the vehicle
9831
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   221
 * @param train_on_res Is set to a train we might encounter
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   222
 * @returns The last tile of the reservation or the current train tile if no reservation present.
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   223
 */
9831
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   224
PBSTileInfo FollowTrainReservation(const Vehicle *v, Vehicle **train_on_res)
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   225
{
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   226
	assert(v->type == VEH_TRAIN);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   227
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   228
	TileIndex tile = v->tile;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   229
	Trackdir  trackdir = GetVehicleTrackdir(v);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   230
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   231
	if (IsRailDepotTile(tile) && !GetRailDepotReservation(tile)) return PBSTileInfo(tile, trackdir, false);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   232
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   233
	PBSTileInfo res = FollowReservation(v->owner, GetRailTypeInfo(v->u.rail.railtype)->compatible_railtypes, tile, trackdir);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   234
	res.okay = IsSafeWaitingPosition(v, res.tile, res.trackdir, true, _settings_game.pf.forbid_90_deg);
9831
b233da1b1723 (svn r13974) -Fix [YAPP]: A train crash could lead to stale reservations. (michi_cc)
frosch
parents: 9824
diff changeset
   235
	if (train_on_res != NULL) *train_on_res = VehicleFromPos(res.tile, &res, FindTrainOnTrackEnum);
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   236
	return res;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   237
}
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   238
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   239
/**
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   240
 * Find the train which has reserved a specific path.
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   241
 *
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   242
 * @param tile A tile on the path.
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   243
 * @param track A reserved track on the tile.
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   244
 * @return The vehicle holding the reservation or NULL if the path is stray.
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   245
 */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   246
Vehicle *GetTrainForReservation(TileIndex tile, Track track)
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   247
{
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   248
	assert(HasReservedTracks(tile, TrackToTrackBits(track)));
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   249
	Trackdir  trackdir = TrackToTrackdir(track);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   250
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   251
	RailTypes rts = GetRailTypeInfo(GetTileRailType(tile))->compatible_railtypes;
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   252
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   253
	/* Follow the path from tile to both ends, one of the end tiles should
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   254
	 * have a train on it. We need FollowReservation to ignore one-way signals
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   255
	 * here, as one of the two search directions will be the "wrong" way. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   256
	for (int i = 0; i < 2; ++i, trackdir = ReverseTrackdir(trackdir)) {
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   257
		PBSTileInfo dest = FollowReservation(GetTileOwner(tile), rts, tile, trackdir, true);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   258
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   259
		Vehicle *v = VehicleFromPos(dest.tile, &dest, FindTrainOnTrackEnum);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   260
		if (v != NULL) return v->First();
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   261
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   262
		/* Special case for stations: check the whole platform for a vehicle. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   263
		if (IsRailwayStationTile(dest.tile)) {
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   264
			TileIndexDiff diff = TileOffsByDiagDir(TrackdirToExitdir(ReverseTrackdir(dest.trackdir)));
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   265
			for (TileIndex st_tile = dest.tile + diff; IsCompatibleTrainStationTile(st_tile, dest.tile); st_tile += diff) {
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   266
				v = VehicleFromPos(st_tile, &dest, FindTrainOnTrackEnum);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   267
				if (v != NULL) return v->First();
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   268
			}
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   269
		}
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   270
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   271
		/* Special case for bridges/tunnels: check the other end as well. */
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   272
		if (IsTileType(dest.tile, MP_TUNNELBRIDGE)) {
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   273
			v = VehicleFromPos(GetOtherTunnelBridgeEnd(dest.tile), &dest, FindTrainOnTrackEnum);
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   274
			if (v != NULL) return v->First();
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   275
		}
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   276
	}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   277
9814
19720a320565 (svn r13956) -Add [YAPP]: Function for getting the train holding a reserved path. (michi_cc)
rubidium
parents: 9798
diff changeset
   278
	return NULL;
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   279
}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   280
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   281
/**
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   282
 * Determine whether a certain track on a tile is a safe position to end a path.
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   283
 *
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   284
 * @param v the vehicle to test for
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   285
 * @param tile The tile
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   286
 * @param trackdir The trackdir to test
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   287
 * @param include_line_end Should end-of-line tiles be considered safe?
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   288
 * @param forbid_90def Don't allow trains to make 90 degree turns
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   289
 * @return True if it is a safe position
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   290
 */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   291
bool IsSafeWaitingPosition(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool include_line_end, bool forbid_90deg)
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   292
{
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   293
	if (IsRailDepotTile(tile)) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   294
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   295
	if (IsTileType(tile, MP_RAILWAY)) {
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   296
		/* For non-pbs signals, stop on the signal tile. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   297
		if (HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, TrackdirToTrack(trackdir)))) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   298
	}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   299
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   300
	/* Check next tile. For perfomance reasons, we check for 90 degree turns ourself. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   301
	CFollowTrackRail ft(v, GetRailTypeInfo(v->u.rail.railtype)->compatible_railtypes);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   302
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   303
	/* End of track? */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   304
	if (!ft.Follow(tile, trackdir)) {
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   305
		/* Last tile of a terminus station is a safe position. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   306
		if (include_line_end) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   307
	}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   308
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   309
	/* Check for reachable tracks. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   310
	ft.m_new_td_bits &= DiagdirReachesTrackdirs(ft.m_exitdir);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   311
	if (ft.m_new_td_bits == TRACKDIR_BIT_NONE) return include_line_end;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   312
	if (forbid_90deg) ft.m_new_td_bits &= ~TrackdirCrossesTrackdirs(trackdir);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   313
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   314
	if (ft.m_new_td_bits != TRACKDIR_BIT_NONE && KillFirstBit(ft.m_new_td_bits) == TRACKDIR_BIT_NONE) {
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   315
		/* PBS signal on next trackdir? Safe position. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   316
		if (HasPbsSignalOnTrackdir(ft.m_new_tile, FindFirstTrackdir(ft.m_new_td_bits))) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   317
	}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   318
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   319
	return false;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   320
}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   321
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   322
/**
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   323
 * Check if a safe position is free.
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   324
 *
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   325
 * @param v the vehicle to test for
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   326
 * @param tile The tile
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   327
 * @param trackdir The trackdir to test
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   328
 * @param forbid_90def Don't allow trains to make 90 degree turns
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   329
 * @return True if the position is free
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   330
 */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   331
bool IsWaitingPositionFree(const Vehicle *v, TileIndex tile, Trackdir trackdir, bool forbid_90deg)
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   332
{
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   333
	Track     track = TrackdirToTrack(trackdir);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   334
	TrackBits reserved = GetReservedTrackbits(tile);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   335
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   336
	/* Tile reserved? Can never be a free waiting position. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   337
	if (TrackOverlapsTracks(reserved, track)) return false;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   338
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   339
	/* Not reserved and depot or not a pbs signal -> free. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   340
	if (IsRailDepotTile(tile)) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   341
	if (IsTileType(tile, MP_RAILWAY) && HasSignalOnTrackdir(tile, trackdir) && !IsPbsSignal(GetSignalType(tile, track))) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   342
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   343
	/* Check the next tile, if it's a PBS signal, it has to be free as well. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   344
	CFollowTrackRail ft(v, GetRailTypeInfo(v->u.rail.railtype)->compatible_railtypes);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   345
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   346
	if (!ft.Follow(tile, trackdir)) return true;
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   347
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   348
	/* Check for reachable tracks. */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   349
	ft.m_new_td_bits &= DiagdirReachesTrackdirs(ft.m_exitdir);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   350
	if (forbid_90deg) ft.m_new_td_bits &= ~TrackdirCrossesTrackdirs(trackdir);
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   351
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   352
	return !HasReservedTracks(ft.m_new_tile, TrackdirBitsToTrackBits(ft.m_new_td_bits));
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9787
diff changeset
   353
}