rail_map.h
author tron
Fri, 17 Mar 2006 06:26:37 +0000
changeset 3238 a100405fe221
parent 3237 985399d4099d
child 3239 45396b9950aa
permissions -rw-r--r--
(svn r3912) Move the signal type enum and GetSignalType() to rail_map.h; also add SetSignalType() and use the functions
3101
e2fdb8802c2f (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$ */
e2fdb8802c2f (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
e2fdb8802c2f (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
     3
#ifndef RAIL_MAP_H
e2fdb8802c2f (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
     4
#define RAIL_MAP_H
e2fdb8802c2f (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
e2fdb8802c2f (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
#include "rail.h"
e2fdb8802c2f (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
#include "tile.h"
e2fdb8802c2f (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
     8
#include "waypoint.h"
e2fdb8802c2f (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
     9
e2fdb8802c2f (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
    10
3185
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    11
static inline DiagDirection GetRailDepotDirection(TileIndex t)
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    12
{
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    13
	return (DiagDirection)GB(_m[t].m5, 0, 2);
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    14
}
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    15
c0ef161f700f (svn r3831) Add and use GetRailDepotDirection()
tron
parents: 3102
diff changeset
    16
3101
e2fdb8802c2f (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
    17
static inline TrackBits GetRailWaypointBits(TileIndex t)
e2fdb8802c2f (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
    18
{
3102
fde95020fc8e (svn r3697) Rename DIAG1/DIAG2 to X resp. Y as this conveys a bit better in which direction a pieces of rail goes
tron
parents: 3101
diff changeset
    19
	return _m[t].m5 & RAIL_WAYPOINT_TRACK_MASK ? TRACK_BIT_Y : TRACK_BIT_X;
3101
e2fdb8802c2f (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
    20
}
e2fdb8802c2f (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
    21
e2fdb8802c2f (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
    22
3238
a100405fe221 (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
    23
typedef enum SignalType {
a100405fe221 (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
    24
	SIGTYPE_NORMAL  = 0, // normal signal
a100405fe221 (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
    25
	SIGTYPE_ENTRY   = 1, // presignal block entry
a100405fe221 (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
    26
	SIGTYPE_EXIT    = 2, // presignal block exit
a100405fe221 (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
    27
	SIGTYPE_COMBO   = 3  // presignal inter-block
a100405fe221 (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
    28
} SignalType;
a100405fe221 (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
    29
a100405fe221 (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
    30
static inline SignalType GetSignalType(TileIndex t)
a100405fe221 (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
    31
{
a100405fe221 (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
    32
	assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
a100405fe221 (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
    33
	return (SignalType)GB(_m[t].m4, 0, 2);
a100405fe221 (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
    34
}
a100405fe221 (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
    35
a100405fe221 (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
    36
static inline void SetSignalType(TileIndex t, SignalType s)
a100405fe221 (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
    37
{
a100405fe221 (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
    38
	assert(GetRailTileType(t) == RAIL_TYPE_SIGNALS);
a100405fe221 (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
    39
	SB(_m[t].m4, 0, 2, s);
a100405fe221 (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
    40
}
a100405fe221 (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
    41
a100405fe221 (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
    42
3237
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    43
typedef enum SignalVariant {
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    44
	SIG_ELECTRIC  = 0,
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    45
	SIG_SEMAPHORE = 1
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    46
} SignalVariant;
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    47
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    48
static inline SignalVariant GetSignalVariant(TileIndex t)
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    49
{
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    50
	return (SignalVariant)GB(_m[t].m4, 2, 1);
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    51
}
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    52
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    53
static inline void SetSignalVariant(TileIndex t, SignalVariant v)
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    54
{
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    55
	SB(_m[t].m4, 2, 1, v);
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    56
}
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    57
985399d4099d (svn r3911) Add functions to retrieve/set the signal variant (electric/semaphore)
tron
parents: 3185
diff changeset
    58
3101
e2fdb8802c2f (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
    59
static inline void MakeRailNormal(TileIndex t, Owner o, TrackBits b, RailType r)
e2fdb8802c2f (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
    60
{
e2fdb8802c2f (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
    61
	SetTileType(t, MP_RAILWAY);
e2fdb8802c2f (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
    62
	SetTileOwner(t, o);
e2fdb8802c2f (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
    63
	_m[t].m2 = 0;
e2fdb8802c2f (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
    64
	_m[t].m3 = r;
e2fdb8802c2f (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
    65
	_m[t].m4 = 0;
e2fdb8802c2f (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
    66
	_m[t].m5 = RAIL_TYPE_NORMAL | b;
e2fdb8802c2f (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
    67
}
e2fdb8802c2f (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
    68
e2fdb8802c2f (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
    69
e2fdb8802c2f (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
    70
static inline void MakeRailDepot(TileIndex t, Owner o, DiagDirection d, RailType r)
e2fdb8802c2f (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
    71
{
e2fdb8802c2f (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
    72
	SetTileType(t, MP_RAILWAY);
e2fdb8802c2f (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
    73
	SetTileOwner(t, o);
e2fdb8802c2f (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
    74
	_m[t].m2 = 0;
e2fdb8802c2f (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
    75
	_m[t].m3 = r;
e2fdb8802c2f (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
    76
	_m[t].m4 = 0;
e2fdb8802c2f (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
    77
	_m[t].m5 = RAIL_TYPE_DEPOT_WAYPOINT | RAIL_SUBTYPE_DEPOT | d;
e2fdb8802c2f (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
    78
}
e2fdb8802c2f (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
    79
e2fdb8802c2f (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
    80
e2fdb8802c2f (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
    81
static inline void MakeRailWaypoint(TileIndex t, Owner o, Axis a, RailType r, uint index)
e2fdb8802c2f (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
    82
{
e2fdb8802c2f (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
    83
	SetTileType(t, MP_RAILWAY);
e2fdb8802c2f (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
    84
	SetTileOwner(t, o);
e2fdb8802c2f (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
    85
	_m[t].m2 = index;
e2fdb8802c2f (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
    86
	_m[t].m3 = r;
e2fdb8802c2f (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
    87
	_m[t].m4 = 0;
e2fdb8802c2f (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
    88
	_m[t].m5 = RAIL_TYPE_DEPOT_WAYPOINT | RAIL_SUBTYPE_WAYPOINT | a;
e2fdb8802c2f (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
    89
}
e2fdb8802c2f (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
    90
e2fdb8802c2f (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
    91
#endif