src/rail_map.h
author translators
Fri, 28 Nov 2008 18:47:49 +0000
changeset 10389 05465e8a465c
parent 10322 1a2a97853c0c
permissions -rw-r--r--
(svn r14640) -Update: WebTranslator2 update to 2008-11-28 18:47:35
bulgarian - 1 fixed by Ar4i (1)
catalan - 1 fixed by arnaullv (1)
croatian - 43 fixed by knovak (43)
esperanto - 3 fixed by Athaba (3)
estonian - 8 fixed by t2t2 (8)
german - 1 fixed by Athaba (1)
latvian - 315 fixed, 112 changed by Reinis (414), yopzer (7), niko (6)
polish - 1 fixed by xaxa (1)
romanian - 6 fixed, 1 changed by kkmic (7)
ukrainian - 2 fixed by mad (2)
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     1
/* $Id$ */
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     2
6393
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6248
diff changeset
     3
/** @file rail_map.h Hides the direct accesses to the map array with map accessors */
e1e4939d19b5 (svn r9523) -Cleanup: doxygen changes. Time to take care of "R"
belugas
parents: 6248
diff changeset
     4
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     5
#ifndef RAIL_MAP_H
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     6
#define RAIL_MAP_H
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
     7
8138
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8108
diff changeset
     8
#include "rail_type.h"
dbfdc08fa6b9 (svn r11700) -Codechange: reduce the amount of unnecessary includes.
rubidium
parents: 8108
diff changeset
     9
#include "signal_func.h"
8100
6bc08f98ec16 (svn r11661) -Codechange: some header reworks in order to try to reduce the compile time of OpenTTD by reduce the amount of circular-ish dependencies.
rubidium
parents: 7928
diff changeset
    10
#include "direction_func.h"
8101
d5357bde8cab (svn r11662) -Codechange: move some rail types/related functions around.
rubidium
parents: 8100
diff changeset
    11
#include "track_func.h"
8108
b42a0e5c67ef (svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents: 8101
diff changeset
    12
#include "tile_map.h"
8761
40d9db82a895 (svn r12457) -Codechange: Move signal enums on their own header.
belugas
parents: 8632
diff changeset
    13
#include "signal_type.h"
8775
fd5e36ec9f6c (svn r12474) -Codechange: split type related stuff from waypoints from waypoint.h (and openttd.h) to waypoint_type.h.
rubidium
parents: 8761
diff changeset
    14
#include "waypoint_type.h"
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    15
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    16
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    17
/** Different types of Rail-related tiles */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
    18
enum RailTileType {
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    19
	RAIL_TILE_NORMAL   = 0, ///< Normal rail tile without signals
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    20
	RAIL_TILE_SIGNALS  = 1, ///< Normal rail tile with signals
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    21
	RAIL_TILE_WAYPOINT = 2, ///< Waypoint (X or Y direction)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    22
	RAIL_TILE_DEPOT    = 3, ///< Depot (one entrance)
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
    23
};
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    24
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    25
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    26
 * Returns the RailTileType (normal with or without signals,
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    27
 * waypoint or depot).
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    28
 * @param t the tile to get the information from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    29
 * @pre IsTileType(t, MP_RAILWAY)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    30
 * @return the RailTileType
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    31
 */
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    32
static inline RailTileType GetRailTileType(TileIndex t)
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    33
{
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    34
	assert(IsTileType(t, MP_RAILWAY));
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
    35
	return (RailTileType)GB(_m[t].m5, 6, 2);
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    36
}
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
    37
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    38
/**
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    39
 * Returns whether this is plain rails, with or without signals. Iow, if this
3792
67c865c9315c (svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents: 3772
diff changeset
    40
 * tiles RailTileType is RAIL_TILE_NORMAL or RAIL_TILE_SIGNALS.
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    41
 * @param t the tile to get the information from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    42
 * @pre IsTileType(t, MP_RAILWAY)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    43
 * @return true if and only if the tile is normal rail (with or without signals)
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    44
 */
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    45
static inline bool IsPlainRailTile(TileIndex t)
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    46
{
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    47
	RailTileType rtt = GetRailTileType(t);
3792
67c865c9315c (svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents: 3772
diff changeset
    48
	return rtt == RAIL_TILE_NORMAL || rtt == RAIL_TILE_SIGNALS;
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    49
}
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    50
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    51
/**
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    52
 * Checks if a rail tile has signals.
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    53
 * @param t the tile to get the information from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    54
 * @pre IsTileType(t, MP_RAILWAY)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    55
 * @return true if and only if the tile has signals
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    56
 */
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    57
static inline bool HasSignals(TileIndex t)
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    58
{
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    59
	return GetRailTileType(t) == RAIL_TILE_SIGNALS;
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    60
}
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    61
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    62
/**
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
    63
 * Add/remove the 'has signal' bit from the RailTileType
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    64
 * @param tile the tile to add/remove the signals to/from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    65
 * @param signals whether the rail tile should have signals or not
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    66
 * @pre IsPlainRailTile(tile)
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    67
 */
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
    68
static inline void SetHasSignals(TileIndex tile, bool signals)
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    69
{
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
    70
	assert(IsPlainRailTile(tile));
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
    71
	SB(_m[tile].m5, 6, 1, signals);
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    72
}
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
    73
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    74
/**
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    75
 * Is this rail tile a rail waypoint?
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    76
 * @param t the tile to get the information from
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    77
 * @pre IsTileType(t, MP_RAILWAY)
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    78
 * @return true if and only if the tile is a rail waypoint
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    79
 */
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    80
static inline bool IsRailWaypoint(TileIndex t)
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    81
{
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    82
	return GetRailTileType(t) == RAIL_TILE_WAYPOINT;
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    83
}
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    84
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    85
/**
10099
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    86
 * Is this tile rail tile and a rail waypoint?
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    87
 * @param t the tile to get the information from
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    88
 * @return true if and only if the tile is a rail waypoint
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    89
 */
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    90
static inline bool IsRailWaypointTile(TileIndex t)
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    91
{
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    92
	return IsTileType(t, MP_RAILWAY) && IsRailWaypoint(t);
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    93
}
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    94
a42cafcba550 (svn r14280) -Codechange: use IsRailWaypointTile() instead of IsTileType() and IsRailWaypoint() checks at several places
smatz
parents: 9798
diff changeset
    95
/**
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
    96
 * Is this rail tile a rail depot?
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    97
 * @param t the tile to get the information from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    98
 * @pre IsTileType(t, MP_RAILWAY)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
    99
 * @return true if and only if the tile is a rail depot
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   100
 */
4182
48dba107ff43 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4158
diff changeset
   101
static inline bool IsRailDepot(TileIndex t)
48dba107ff43 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4158
diff changeset
   102
{
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   103
	return GetRailTileType(t) == RAIL_TILE_DEPOT;
4182
48dba107ff43 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4158
diff changeset
   104
}
48dba107ff43 (svn r5624) Use {IsPlainRailTile,IsRailDepot,IsRailWaypoint,HasSignals}() instead of GetRailTile{T,Subt}ype() - this is more concise and a bit more flexible if/when the rail tile encoding changes
tron
parents: 4158
diff changeset
   105
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   106
/**
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
   107
 * Is this tile rail tile and a rail depot?
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   108
 * @param t the tile to get the information from
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
   109
 * @return true if and only if the tile is a rail depot
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   110
 */
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
   111
static inline bool IsRailDepotTile(TileIndex t)
4044
8db2992cb412 (svn r5313) Move IsRailWaypoint() to rail_map.h and remove unused enum
tron
parents: 4041
diff changeset
   112
{
8954
3993bae3bfb8 (svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents: 8775
diff changeset
   113
	return IsTileType(t, MP_RAILWAY) && IsRailDepot(t);
4044
8db2992cb412 (svn r5313) Move IsRailWaypoint() to rail_map.h and remove unused enum
tron
parents: 4041
diff changeset
   114
}
8db2992cb412 (svn r5313) Move IsRailWaypoint() to rail_map.h and remove unused enum
tron
parents: 4041
diff changeset
   115
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   116
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   117
 * Gets the rail type of the given tile
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   118
 * @param t the tile to get the rail type from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   119
 * @return the rail type of the tile
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   120
 */
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   121
static inline RailType GetRailType(TileIndex t)
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   122
{
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   123
	return (RailType)GB(_m[t].m3, 0, 4);
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   124
}
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   125
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   126
/**
8632
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   127
 * Sets the rail type of the given tile
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   128
 * @param t the tile to set the rail type of
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   129
 * @param r the new rail type for the tile
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   130
 */
3242
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
   131
static inline void SetRailType(TileIndex t, RailType r)
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
   132
{
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
   133
	SB(_m[t].m3, 0, 4, r);
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
   134
}
4c32bf21153b (svn r3916) Get/Set the rail type by [GS]etRailType{Crossing,OnBridge,}()
tron
parents: 3239
diff changeset
   135
3239
9b1030ac7d83 (svn r3913) Move declarations to rail_map.h so rail.h is dependent on rail_map.h and not the other way round
tron
parents: 3238
diff changeset
   136
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   137
/**
8632
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   138
 * Gets the track bits of the given tile
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   139
 * @param t the tile to get the track bits from
2b48de850547 (svn r12239) -Fix [FS#1800] (r9729): inverted comments for SetRailType() and GetTrackBits() (michi_cc)
glx
parents: 8523
diff changeset
   140
 * @return the track bits of the tile
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   141
 */
3267
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   142
static inline TrackBits GetTrackBits(TileIndex tile)
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   143
{
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   144
	return (TrackBits)GB(_m[tile].m5, 0, 6);
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   145
}
feff95208a9f (svn r3979) Move GetRailFoundation() to rail_map.h and use it and friends to get information about rail tiles
tron
parents: 3258
diff changeset
   146
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   147
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   148
 * Sets the track bits of the given tile
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   149
 * @param t the tile to set the track bits of
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   150
 * @param b the new track bits for the tile
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   151
 */
3273
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   152
static inline void SetTrackBits(TileIndex t, TrackBits b)
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   153
{
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   154
	SB(_m[t].m5, 0, 6, b);
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   155
}
3089ecca8e21 (svn r3985) Make CmdBuildSingleRail() a bit more comprehensible
tron
parents: 3267
diff changeset
   156
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   157
/**
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   158
 * Returns whether the given track is present on the given tile.
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   159
 * @param tile  the tile to check the track presence of
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   160
 * @param track the track to search for on the tile
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   161
 * @pre IsPlainRailTile(tile)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   162
 * @return true if and only if the given track exists on the tile
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   163
 */
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   164
static inline bool HasTrack(TileIndex tile, Track track)
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   165
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7771
diff changeset
   166
	return HasBit(GetTrackBits(tile), track);
3772
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   167
}
f2cf079d7afe (svn r4764) Move some functions from rail.h to rail_map.h
tron
parents: 3575
diff changeset
   168
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   169
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   170
 * Returns the direction the depot is facing to
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   171
 * @param t the tile to get the depot facing from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   172
 * @pre IsRailDepotTile(t)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   173
 * @return the direction the depot is facing
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   174
 */
3185
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   175
static inline DiagDirection GetRailDepotDirection(TileIndex t)
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   176
{
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   177
	return (DiagDirection)GB(_m[t].m5, 0, 2);
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   178
}
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   179
9224
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   180
/**
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   181
 * Returns the track of a depot, ignoring direction
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   182
 * @pre IsRailDepotTile(t)
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   183
 * @param t the tile to get the depot track from
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   184
 * @return the track of the depot
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   185
 */
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   186
static inline Track GetRailDepotTrack(TileIndex t)
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   187
{
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   188
	return DiagDirToDiagTrack(GetRailDepotDirection(t));
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   189
}
93528d9cb96d (svn r13090) -Codechange: add functions for direct conversion from DiagDirection to Track and Trackbits
smatz
parents: 8954
diff changeset
   190
4158
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   191
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   192
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   193
 * Returns the axis of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   194
 * @param t the tile to get the waypoint axis from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   195
 * @pre IsRailWaypointTile(t)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   196
 * @return the axis of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   197
 */
4158
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   198
static inline Axis GetWaypointAxis(TileIndex t)
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   199
{
4474
973c48d699bd (svn r6259) Extract the axis directly, don't use a trinary operator
tron
parents: 4466
diff changeset
   200
	return (Axis)GB(_m[t].m5, 0, 1);
4158
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   201
}
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   202
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   203
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   204
 * Returns the track of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   205
 * @param t the tile to get the waypoint track from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   206
 * @pre IsRailWaypointTile(t)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   207
 * @return the track of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   208
 */
3453
956365eb1f8a (svn r4286) -Fix: Typo in 4280
celestar
parents: 3448
diff changeset
   209
static inline Track GetRailWaypointTrack(TileIndex t)
3448
bc96e486627d (svn r4280) -Codechange: Add and make use of map accessors concerning railway waypoints
celestar
parents: 3355
diff changeset
   210
{
4158
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   211
	return AxisToTrack(GetWaypointAxis(t));
3448
bc96e486627d (svn r4280) -Codechange: Add and make use of map accessors concerning railway waypoints
celestar
parents: 3355
diff changeset
   212
}
3185
a9d0cdff7b84 (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
   213
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   214
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   215
 * Returns the track bits of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   216
 * @param t the tile to get the waypoint track bits from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   217
 * @pre IsRailWaypointTile(t)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   218
 * @return the track bits of the waypoint
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   219
 */
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   220
static inline TrackBits GetRailWaypointBits(TileIndex t)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   221
{
4158
91ff9bb84ced (svn r5582) Add and use AxisToTrack{Bits,}()
tron
parents: 4077
diff changeset
   222
	return TrackToTrackBits(GetRailWaypointTrack(t));
3528
42e939a5e21a (svn r4384) -Codechange: rail drawing code
celestar
parents: 3523
diff changeset
   223
}
42e939a5e21a (svn r4384) -Codechange: rail drawing code
celestar
parents: 3523
diff changeset
   224
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   225
/**
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   226
 * Returns waypoint index (for the waypoint pool)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   227
 * @param t the tile to get the waypoint index from
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   228
 * @pre IsRailWaypointTile(t)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   229
 * @return the waypoint index
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   230
 */
6182
7337aca829f1 (svn r8954) -Codechange: remove direct map accesses from non-map-accessor headers.
rubidium
parents: 6172
diff changeset
   231
static inline WaypointID GetWaypointIndex(TileIndex t)
7337aca829f1 (svn r8954) -Codechange: remove direct map accesses from non-map-accessor headers.
rubidium
parents: 6172
diff changeset
   232
{
7337aca829f1 (svn r8954) -Codechange: remove direct map accesses from non-map-accessor headers.
rubidium
parents: 6172
diff changeset
   233
	return (WaypointID)_m[t].m2;
7337aca829f1 (svn r8954) -Codechange: remove direct map accesses from non-map-accessor headers.
rubidium
parents: 6172
diff changeset
   234
}
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   235
9784
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   236
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   237
/**
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   238
 * Returns the reserved track bits of the tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   239
 * @pre IsPlainRailTile(t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   240
 * @param t the tile to query
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   241
 * @return the track bits
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   242
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   243
static inline TrackBits GetTrackReservation(TileIndex t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   244
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   245
	assert(IsPlainRailTile(t));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   246
	byte track_b = GB(_m[t].m2, 8, 3);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   247
	Track track = (Track)(track_b - 1);    // map array saves Track+1
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   248
	if (track_b == 0) return TRACK_BIT_NONE;
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   249
	return (TrackBits)(TrackToTrackBits(track) | (HasBit(_m[t].m2, 11) ? TrackToTrackBits(TrackToOppositeTrack(track)) : 0));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   250
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   251
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   252
/**
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   253
 * Sets the reserved track bits of the tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   254
 * @pre IsPlainRailTile(t) && !TracksOverlap(b)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   255
 * @param t the tile to change
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   256
 * @param b the track bits
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   257
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   258
static inline void SetTrackReservation(TileIndex t, TrackBits b)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   259
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   260
	assert(IsPlainRailTile(t));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   261
	assert(b != INVALID_TRACK_BIT);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   262
	assert(!TracksOverlap(b));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   263
	Track track = RemoveFirstTrack(&b);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   264
	SB(_m[t].m2, 8, 3, track == INVALID_TRACK ? 0 : track+1);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   265
	SB(_m[t].m2, 11, 1, (byte)(b != TRACK_BIT_NONE));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   266
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   267
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   268
/**
9787
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   269
 * 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: 9784
diff changeset
   270
 * @pre IsPlainRailTile(t) && HasTrack(tile, t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   271
 * @param tile the tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   272
 * @param t the rack to reserve
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   273
 * @return true if successful
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   274
 */
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   275
static inline bool TryReserveTrack(TileIndex tile, Track t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   276
{
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   277
	assert(HasTrack(tile, t));
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   278
	TrackBits bits = TrackToTrackBits(t);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   279
	TrackBits res = GetTrackReservation(tile);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   280
	if ((res & bits) != TRACK_BIT_NONE) return false;  // already reserved
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   281
	res |= bits;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   282
	if (TracksOverlap(res)) return false;  // crossing reservation present
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   283
	SetTrackReservation(tile, res);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   284
	return true;
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   285
}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   286
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   287
/**
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   288
 * 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: 9784
diff changeset
   289
 * @pre IsPlainRailTile(t) && HasTrack(tile, t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   290
 * @param tile the tile
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   291
 * @param t the track to free
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   292
 */
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   293
static inline void UnreserveTrack(TileIndex tile, Track t)
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   294
{
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   295
	assert(HasTrack(tile, t));
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   296
	TrackBits res = GetTrackReservation(tile);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   297
	res &= ~TrackToTrackBits(t);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   298
	SetTrackReservation(tile, res);
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   299
}
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   300
cedb26977f52 (svn r13929) -Codechange [YAPP]: Reserving and unreserving of single tracks is now possible. (michi_cc)
rubidium
parents: 9784
diff changeset
   301
/**
9784
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   302
 * Get the reservation state of the waypoint or depot
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   303
 * @note Works for both waypoints and rail depots
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   304
 * @pre IsRailWaypoint(t) || IsRailDepot(t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   305
 * @param t the waypoint/depot tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   306
 * @return reservation state
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   307
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   308
static inline bool GetDepotWaypointReservation(TileIndex t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   309
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   310
	assert(IsRailWaypoint(t) || IsRailDepot(t));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   311
	return HasBit(_m[t].m5, 4);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   312
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   313
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   314
/**
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   315
 * Set the reservation state of the waypoint or depot
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   316
 * @note Works for both waypoints and rail depots
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   317
 * @pre IsRailWaypoint(t) || IsRailDepot(t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   318
 * @param t the waypoint/depot tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   319
 * @param b the reservation state
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   320
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   321
static inline void SetDepotWaypointReservation(TileIndex t, bool b)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   322
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   323
	assert(IsRailWaypoint(t) || IsRailDepot(t));
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   324
	SB(_m[t].m5, 4, 1, (byte)b);
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   325
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   326
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   327
/**
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   328
 * Get the reserved track bits for a waypoint
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   329
 * @pre IsRailWaypoint(t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   330
 * @param t the tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   331
 * @return reserved track bits
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   332
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   333
static inline TrackBits GetRailWaypointReservation(TileIndex t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   334
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   335
	return GetDepotWaypointReservation(t) ? GetRailWaypointBits(t) : TRACK_BIT_NONE;
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   336
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   337
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   338
/**
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   339
 * Get the reserved track bits for a depot
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   340
 * @pre IsRailDepot(t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   341
 * @param t the tile
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   342
 * @return reserved track bits
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   343
 */
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   344
static inline TrackBits GetRailDepotReservation(TileIndex t)
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   345
{
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   346
	return GetDepotWaypointReservation(t) ? TrackToTrackBits(GetRailDepotTrack(t)) : TRACK_BIT_NONE;
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   347
}
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   348
a9cc0dff1667 (svn r13926) -Add [YAPP]: Add map accessors for path reservations. (michi_cc)
rubidium
parents: 9224
diff changeset
   349
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   350
static inline bool IsPbsSignal(SignalType s)
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   351
{
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   352
	return s == SIGTYPE_PBS || s == SIGTYPE_PBS_ONEWAY;
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   353
}
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   354
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   355
static inline SignalType GetSignalType(TileIndex t, Track track)
3238
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   356
{
3792
67c865c9315c (svn r4788) - Codechange: RAILTYPE_{NORMAL,ELECTRIC,...} and RAIL_TYPE_{NORMAL,SIGNAL,...} have nearly the same name, rename RAIL_TYPE_* to RAIL_TILE_* of extra clarity
rubidium
parents: 3772
diff changeset
   357
	assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   358
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   359
	return (SignalType)GB(_m[t].m2, pos, 3);
3238
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   360
}
9ebec0a611ee (svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
tron
parents: 3237
diff changeset
   361
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   362
static inline void SetSignalType(TileIndex t, Track track, SignalType s)
3521
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   363
{
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   364
	assert(GetRailTileType(t) == RAIL_TILE_SIGNALS);
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   365
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 0;
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   366
	SB(_m[t].m2, pos, 3, s);
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   367
	if (track == INVALID_TRACK) SB(_m[t].m2, 4, 3, s);
3521
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   368
}
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   369
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   370
static inline bool IsPresignalEntry(TileIndex t, Track track)
3521
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   371
{
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   372
	return GetSignalType(t, track) == SIGTYPE_ENTRY || GetSignalType(t, track) == SIGTYPE_COMBO;
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   373
}
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   374
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   375
static inline bool IsPresignalExit(TileIndex t, Track track)
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   376
{
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   377
	return GetSignalType(t, track) == SIGTYPE_EXIT || GetSignalType(t, track) == SIGTYPE_COMBO;
3521
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   378
}
addbba7b20ff (svn r4377) -Add and make use of a function that finds out whether a signal is an entry or and exit signal to a presignal block (as combos act as both)
celestar
parents: 3453
diff changeset
   379
9791
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   380
/** One-way signals can't be passed the 'wrong' way. */
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   381
static inline bool IsOnewaySignal(TileIndex t, Track track)
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   382
{
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   383
	return GetSignalType(t, track) != SIGTYPE_PBS;
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   384
}
7bcdf05e5e5b (svn r13933) -Codechange [YAPP]: Handle through and PBS signals correctly in the signal code. (michi_cc)
rubidium
parents: 9790
diff changeset
   385
3522
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   386
static inline void CycleSignalSide(TileIndex t, Track track)
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   387
{
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   388
	byte sig;
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   389
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 4 : 6;
3522
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   390
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   391
	sig = GB(_m[t].m3, pos, 2);
9795
55c38728362c (svn r13937) -Codechange [YAPP]: Don't cycle through two-sided PBS signals during build. (michi_cc)
rubidium
parents: 9791
diff changeset
   392
	if (--sig == 0) sig = IsPbsSignal(GetSignalType(t, track)) ? 2 : 3;
3522
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   393
	SB(_m[t].m3, pos, 2, sig);
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   394
}
888ac5081c6e (svn r4378) -Add and make use of an accessor function two-way => one-way => one-way => two-way signal cycling
celestar
parents: 3521
diff changeset
   395
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   396
static inline SignalVariant GetSignalVariant(TileIndex t, Track track)
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   397
{
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   398
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   399
	return (SignalVariant)GB(_m[t].m2, pos, 1);
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   400
}
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   401
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   402
static inline void SetSignalVariant(TileIndex t, Track track, SignalVariant v)
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   403
{
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   404
	byte pos = (track == TRACK_LOWER || track == TRACK_RIGHT) ? 7 : 3;
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   405
	SB(_m[t].m2, pos, 1, v);
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   406
	if (track == INVALID_TRACK) SB(_m[t].m2, 7, 1, v);
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   407
}
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   408
3575
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   409
/** These are states in which a signal can be. Currently these are only two, so
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   410
 * simple boolean logic will do. But do try to compare to this enum instead of
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   411
 * normal boolean evaluation, since that will make future additions easier.
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   412
 */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
   413
enum SignalState {
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   414
	SIGNAL_STATE_RED   = 0, ///< The signal is red
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   415
	SIGNAL_STATE_GREEN = 1, ///< The signal is green
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
   416
};
3575
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   417
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   418
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   419
 * Set the states of the signals (Along/AgainstTrackDir)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   420
 * @param tile  the tile to set the states for
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   421
 * @param state the new state
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   422
 */
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   423
static inline void SetSignalStates(TileIndex tile, uint state)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   424
{
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   425
	SB(_m[tile].m4, 4, 4, state);
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   426
}
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   427
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   428
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   429
 * Set the states of the signals (Along/AgainstTrackDir)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   430
 * @param tile  the tile to set the states for
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   431
 * @param state the new state
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   432
 */
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   433
static inline uint GetSignalStates(TileIndex tile)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   434
{
6770
408585d467f9 (svn r10006) -Fix (FS#362): allow different signal types on one tile
glx
parents: 6753
diff changeset
   435
	return GB(_m[tile].m4, 4, 4);
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   436
}
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   437
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   438
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   439
 * Get the state of a single signal
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   440
 * @param t         the tile to get the signal state for
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   441
 * @param signalbit the signal
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   442
 * @return the state of the signal
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   443
 */
3575
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   444
static inline SignalState GetSingleSignalState(TileIndex t, byte signalbit)
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   445
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7771
diff changeset
   446
	return (SignalState)HasBit(GetSignalStates(t), signalbit);
3575
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   447
}
f5b56bd958c0 (svn r4461) -Codechange: Add and make use of map accessor functions for signal drawing. Includes some basic cleanup of the drawing functions
celestar
parents: 3530
diff changeset
   448
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   449
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   450
 * Set whether the given signals are present (Along/AgainstTrackDir)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   451
 * @param tile    the tile to set the present signals for
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   452
 * @param signals the signals that have to be present
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   453
 */
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   454
static inline void SetPresentSignals(TileIndex tile, uint signals)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   455
{
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   456
	SB(_m[tile].m3, 4, 4, signals);
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   457
}
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   458
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   459
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   460
 * Get whether the given signals are present (Along/AgainstTrackDir)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   461
 * @param tile the tile to get the present signals for
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   462
 * @return the signals that are present
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   463
 */
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   464
static inline uint GetPresentSignals(TileIndex tile)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   465
{
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   466
	return GB(_m[tile].m3, 4, 4);
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   467
}
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   468
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   469
/**
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   470
 * Checks whether the given signals is present
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   471
 * @param t         the tile to check on
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   472
 * @param signalbit the signal
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   473
 * @return true if and only if the signal is present
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   474
 */
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   475
static inline bool IsSignalPresent(TileIndex t, byte signalbit)
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   476
{
7928
63e18de69e50 (svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents: 7771
diff changeset
   477
	return HasBit(GetPresentSignals(t), signalbit);
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   478
}
3237
2cf19f9603b2 (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
   479
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   480
/**
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   481
 * Checks for the presence of signals (either way) on the given track on the
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   482
 * given rail tile.
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   483
 */
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   484
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   485
{
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   486
	assert(IsValidTrack(track));
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   487
	return
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   488
		GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   489
		(GetPresentSignals(tile) & SignalOnTrack(track)) != 0;
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   490
}
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   491
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   492
/**
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   493
 * Checks for the presence of signals along the given trackdir on the given
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   494
 * rail tile.
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   495
 *
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   496
 * Along meaning if you are currently driving on the given trackdir, this is
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   497
 * the signal that is facing us (for which we stop when it's red).
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   498
 */
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   499
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   500
{
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   501
	assert (IsValidTrackdir(trackdir));
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   502
	return
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   503
		GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   504
		GetPresentSignals(tile) & SignalAlongTrackdir(trackdir);
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   505
}
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   506
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   507
/**
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   508
 * Gets the state of the signal along the given trackdir.
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   509
 *
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   510
 * Along meaning if you are currently driving on the given trackdir, this is
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   511
 * the signal that is facing us (for which we stop when it's red).
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   512
 */
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   513
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   514
{
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   515
	assert(IsValidTrackdir(trackdir));
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   516
	assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
6753
c1013c837417 (svn r9988) -Codechange: remove the last direct map accesses, except the ones needed for the savegame saving/loading mechanisms.
rubidium
parents: 6540
diff changeset
   517
	return GetSignalStates(tile) & SignalAlongTrackdir(trackdir) ?
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   518
		SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   519
}
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   520
8238
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   521
/**
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   522
 * Sets the state of the signal along the given trackdir.
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   523
 */
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   524
static inline void SetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir, SignalState state)
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   525
{
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   526
	if (state == SIGNAL_STATE_GREEN) { // set 1
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   527
		SetSignalStates(tile, GetSignalStates(tile) | SignalAlongTrackdir(trackdir));
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   528
	} else {
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   529
		SetSignalStates(tile, GetSignalStates(tile) & ~SignalAlongTrackdir(trackdir));
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   530
	}
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   531
}
d47a86c79603 (svn r11802) -Fix [FS#716]: do not crash trains when leaving depot to a very long track
smatz
parents: 8138
diff changeset
   532
9790
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   533
/**
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   534
 * Is a pbs signal present along the trackdir?
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   535
 * @param tile the tile to check
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   536
 * @param td the trackdir to check
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   537
 */
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   538
static inline bool HasPbsSignalOnTrackdir(TileIndex tile, Trackdir td)
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   539
{
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   540
	return
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   541
		IsTileType(tile, MP_RAILWAY) &&
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   542
		HasSignalOnTrackdir(tile, td) &&
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   543
		IsPbsSignal(GetSignalType(tile, TrackdirToTrack(td)));
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   544
}
5d5c70e0334e (svn r13932) -Add [YAPP]: PBS signals added to the map array. The signals are drawn using the old Patch-like PBS sprites. (michi_cc)
rubidium
parents: 9787
diff changeset
   545
9798
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   546
/**
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   547
 * Is a one-way signal blocking the trackdir? A one-way signal on the
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   548
 * trackdir against will block, but signals on both trackdirs won't.
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   549
 * @param tile the tile to check
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   550
 * @param td the trackdir to check
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   551
 */
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   552
static inline bool HasOnewaySignalBlockingTrackdir(TileIndex tile, Trackdir td)
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   553
{
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   554
	return
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   555
		IsTileType(tile, MP_RAILWAY) &&
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   556
		HasSignalOnTrackdir(tile, ReverseTrackdir(td)) &&
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   557
		!HasSignalOnTrackdir(tile, td) &&
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   558
		IsOnewaySignal(tile, TrackdirToTrack(td));
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   559
}
4b8cdc1adf4b (svn r13940) -Add [YAPP]: YAPF is now able to reserve the found path. (michi_cc)
rubidium
parents: 9795
diff changeset
   560
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   561
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   562
/**
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   563
 * Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   564
 */
6154
8f4c65bdf930 (svn r8899) -Fix
tron
parents: 5587
diff changeset
   565
RailType GetTileRailType(TileIndex tile);
4041
72276cd8ee2b (svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
tron
parents: 3977
diff changeset
   566
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   567
/** The ground 'under' the rail */
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
   568
enum RailGroundType {
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   569
	RAIL_GROUND_BARREN       =  0, ///< Nothing (dirt)
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   570
	RAIL_GROUND_GRASS        =  1, ///< Grassy
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   571
	RAIL_GROUND_FENCE_NW     =  2, ///< Grass with a fence at the NW edge
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   572
	RAIL_GROUND_FENCE_SE     =  3, ///< Grass with a fence at the SE edge
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   573
	RAIL_GROUND_FENCE_SENW   =  4, ///< Grass with a fence at the NW and SE edges
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   574
	RAIL_GROUND_FENCE_NE     =  5, ///< Grass with a fence at the NE edge
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   575
	RAIL_GROUND_FENCE_SW     =  6, ///< Grass with a fence at the SW edge
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   576
	RAIL_GROUND_FENCE_NESW   =  7, ///< Grass with a fence at the NE and SW edges
7307
9f8922176b67 (svn r10659) -Codechange: updated documentation around RAIL_GROUND_FENCE_VERT[12] (frosch)
truelight
parents: 6770
diff changeset
   577
	RAIL_GROUND_FENCE_VERT1  =  8, ///< Grass with a fence at the eastern side
9f8922176b67 (svn r10659) -Codechange: updated documentation around RAIL_GROUND_FENCE_VERT[12] (frosch)
truelight
parents: 6770
diff changeset
   578
	RAIL_GROUND_FENCE_VERT2  =  9, ///< Grass with a fence at the western side
6540
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   579
	RAIL_GROUND_FENCE_HORIZ1 = 10, ///< Grass with a fence at the southern side
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   580
	RAIL_GROUND_FENCE_HORIZ2 = 11, ///< Grass with a fence at the northern side
d30795308feb (svn r9729) -Documentation: add some documentation in various places
rubidium
parents: 6393
diff changeset
   581
	RAIL_GROUND_ICE_DESERT   = 12, ///< Icy or sandy
8414
488721240c47 (svn r11984) -Fix: Also draw corner shores under rail tracks.
frosch
parents: 8238
diff changeset
   582
	RAIL_GROUND_WATER        = 13, ///< Grass with a fence and shore or water on the free halftile
8523
2ded162394a9 (svn r12098) -Fix: make snow appear on rail tiles dependant on track height, not on height of the lowest part of the tile
smatz
parents: 8414
diff changeset
   583
	RAIL_GROUND_HALF_SNOW    = 14, ///< Snow only on higher part of slope (steep or one corner raised)
6248
e4a2ed7e5613 (svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents: 6182
diff changeset
   584
};
3523
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   585
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   586
static inline void SetRailGroundType(TileIndex t, RailGroundType rgt)
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   587
{
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   588
	SB(_m[t].m4, 0, 4, rgt);
3523
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   589
}
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   590
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   591
static inline RailGroundType GetRailGroundType(TileIndex t)
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   592
{
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   593
	return (RailGroundType)GB(_m[t].m4, 0, 4);
3523
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   594
}
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   595
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   596
static inline bool IsSnowRailGround(TileIndex t)
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   597
{
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   598
	return GetRailGroundType(t) == RAIL_GROUND_ICE_DESERT;
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   599
}
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   600
549603ffba5d (svn r4379) -Codechange: Add and make use of map accessor functions concerning rail ground types
celestar
parents: 3522
diff changeset
   601
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   602
static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   603
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   604
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   605
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   606
	_m[t].m2 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   607
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   608
	_m[t].m4 = 0;
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   609
	_m[t].m5 = RAIL_TILE_NORMAL << 6 | b;
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   610
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   611
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   612
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   613
static inline void MakeRailDepot(TileIndex t, Owner o, DiagDirection d, RailType r)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   614
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   615
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   616
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   617
	_m[t].m2 = 0;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   618
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   619
	_m[t].m4 = 0;
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   620
	_m[t].m5 = RAIL_TILE_DEPOT << 6 | d;
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   621
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   622
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   623
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   624
static inline void MakeRailWaypoint(TileIndex t, Owner o, Axis a, RailType r, uint index)
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   625
{
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   626
	SetTileType(t, MP_RAILWAY);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   627
	SetTileOwner(t, o);
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   628
	_m[t].m2 = index;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   629
	_m[t].m3 = r;
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   630
	_m[t].m4 = 0;
6172
e6d7a5b3d63f (svn r8935) -Codechange: unification of track type between road and rail tiles, unification of ground type between normal rail tiles and depots/waypoints and removing the need for RailTileSubType.
rubidium
parents: 6154
diff changeset
   631
	_m[t].m5 = RAIL_TILE_WAYPOINT << 6 | a;
3101
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   632
}
a44fdf9faef1 (svn r3696) Add functions to turn a tile into a normal rail tile/depot/waypoint. This is just a tiny step, the rail code needs way more love and caring
tron
parents:
diff changeset
   633
4666
172a0cdf28a6 (svn r6560) - Codechange: Minor fix; add missing #include guards and comments, and correct svn properties on bmp.[ch]
peter1138
parents: 4474
diff changeset
   634
#endif /* RAIL_MAP_H */