mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 22:28:56 +00:00
(svn r5309) Partially fix the rail header dependency fiasco: rail_map.h now depends on rail.h and not the other way round anymore
This commit is contained in:
parent
60e65953fc
commit
1ad425e802
@ -3,6 +3,7 @@
|
|||||||
#include "stdafx.h"
|
#include "stdafx.h"
|
||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "clear_map.h"
|
#include "clear_map.h"
|
||||||
|
#include "rail_map.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
103
rail.h
103
rail.h
@ -6,9 +6,55 @@
|
|||||||
#define RAIL_H
|
#define RAIL_H
|
||||||
|
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
#include "rail_map.h"
|
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
|
||||||
|
typedef enum RailTypes {
|
||||||
|
RAILTYPE_RAIL = 0,
|
||||||
|
RAILTYPE_ELECTRIC = 1,
|
||||||
|
RAILTYPE_MONO = 2,
|
||||||
|
RAILTYPE_MAGLEV = 3,
|
||||||
|
RAILTYPE_END,
|
||||||
|
INVALID_RAILTYPE = 0xFF
|
||||||
|
} RailType;
|
||||||
|
|
||||||
|
typedef byte RailTypeMask;
|
||||||
|
|
||||||
|
|
||||||
|
/** These are used to specify a single track.
|
||||||
|
* Can be translated to a trackbit with TrackToTrackbit */
|
||||||
|
typedef enum Track {
|
||||||
|
TRACK_X = 0,
|
||||||
|
TRACK_Y = 1,
|
||||||
|
TRACK_UPPER = 2,
|
||||||
|
TRACK_LOWER = 3,
|
||||||
|
TRACK_LEFT = 4,
|
||||||
|
TRACK_RIGHT = 5,
|
||||||
|
TRACK_END,
|
||||||
|
INVALID_TRACK = 0xFF
|
||||||
|
} Track;
|
||||||
|
|
||||||
|
|
||||||
|
/** Bitfield corresponding to Track */
|
||||||
|
typedef enum TrackBits {
|
||||||
|
TRACK_BIT_NONE = 0U,
|
||||||
|
TRACK_BIT_X = 1U << TRACK_X,
|
||||||
|
TRACK_BIT_Y = 1U << TRACK_Y,
|
||||||
|
TRACK_BIT_UPPER = 1U << TRACK_UPPER,
|
||||||
|
TRACK_BIT_LOWER = 1U << TRACK_LOWER,
|
||||||
|
TRACK_BIT_LEFT = 1U << TRACK_LEFT,
|
||||||
|
TRACK_BIT_RIGHT = 1U << TRACK_RIGHT,
|
||||||
|
TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y,
|
||||||
|
TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
|
||||||
|
TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT,
|
||||||
|
TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
|
||||||
|
TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
|
||||||
|
TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
|
||||||
|
TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
|
||||||
|
TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT,
|
||||||
|
TRACK_BIT_MASK = 0x3FU
|
||||||
|
} TrackBits;
|
||||||
|
|
||||||
|
|
||||||
/** These are a combination of tracks and directions. Values are 0-5 in one
|
/** These are a combination of tracks and directions. Values are 0-5 in one
|
||||||
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
direction (corresponding to the Track enum) and 8-13 in the other direction. */
|
||||||
typedef enum Trackdirs {
|
typedef enum Trackdirs {
|
||||||
@ -326,61 +372,6 @@ static inline bool IsDiagonalTrack(Track track) { return (track == TRACK_X) || (
|
|||||||
/* Checks if a given Trackdir is diagonal. */
|
/* Checks if a given Trackdir is diagonal. */
|
||||||
static inline bool IsDiagonalTrackdir(Trackdir trackdir) { return IsDiagonalTrack(TrackdirToTrack(trackdir)); }
|
static inline bool IsDiagonalTrackdir(Trackdir trackdir) { return IsDiagonalTrack(TrackdirToTrack(trackdir)); }
|
||||||
|
|
||||||
/*
|
|
||||||
* Functions quering signals on tiles.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for the presence of signals (either way) on the given track on the
|
|
||||||
* given rail tile.
|
|
||||||
*/
|
|
||||||
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
|
|
||||||
{
|
|
||||||
assert(IsValidTrack(track));
|
|
||||||
return
|
|
||||||
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
|
|
||||||
(_m[tile].m3 & SignalOnTrack(track)) != 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks for the presence of signals along the given trackdir on the given
|
|
||||||
* rail tile.
|
|
||||||
*
|
|
||||||
* Along meaning if you are currently driving on the given trackdir, this is
|
|
||||||
* the signal that is facing us (for which we stop when it's red).
|
|
||||||
*/
|
|
||||||
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
|
|
||||||
{
|
|
||||||
assert (IsValidTrackdir(trackdir));
|
|
||||||
return
|
|
||||||
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
|
|
||||||
_m[tile].m3 & SignalAlongTrackdir(trackdir);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the state of the signal along the given trackdir.
|
|
||||||
*
|
|
||||||
* Along meaning if you are currently driving on the given trackdir, this is
|
|
||||||
* the signal that is facing us (for which we stop when it's red).
|
|
||||||
*/
|
|
||||||
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
|
|
||||||
{
|
|
||||||
assert(IsValidTrackdir(trackdir));
|
|
||||||
assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
|
|
||||||
return _m[tile].m2 & SignalAlongTrackdir(trackdir) ?
|
|
||||||
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
|
|
||||||
* Note that there is no check if the given trackdir is actually present on
|
|
||||||
* the tile!
|
|
||||||
* The given trackdir is used when there are (could be) multiple rail types on
|
|
||||||
* one tile.
|
|
||||||
*/
|
|
||||||
RailType GetTileRailType(TileIndex tile, Trackdir trackdir);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a pointer to the Railtype information for a given railtype
|
* Returns a pointer to the Railtype information for a given railtype
|
||||||
|
98
rail_map.h
98
rail_map.h
@ -4,6 +4,7 @@
|
|||||||
#define RAIL_MAP_H
|
#define RAIL_MAP_H
|
||||||
|
|
||||||
#include "direction.h"
|
#include "direction.h"
|
||||||
|
#include "rail.h"
|
||||||
#include "tile.h"
|
#include "tile.h"
|
||||||
|
|
||||||
|
|
||||||
@ -59,17 +60,6 @@ static inline RailTileSubtype GetRailTileSubtype(TileIndex tile)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
typedef enum RailTypes {
|
|
||||||
RAILTYPE_RAIL = 0,
|
|
||||||
RAILTYPE_ELECTRIC = 1,
|
|
||||||
RAILTYPE_MONO = 2,
|
|
||||||
RAILTYPE_MAGLEV = 3,
|
|
||||||
RAILTYPE_END,
|
|
||||||
INVALID_RAILTYPE = 0xFF
|
|
||||||
} RailType;
|
|
||||||
|
|
||||||
typedef byte RailTypeMask;
|
|
||||||
|
|
||||||
static inline RailType GetRailType(TileIndex t)
|
static inline RailType GetRailType(TileIndex t)
|
||||||
{
|
{
|
||||||
return (RailType)GB(_m[t].m3, 0, 4);
|
return (RailType)GB(_m[t].m3, 0, 4);
|
||||||
@ -103,40 +93,6 @@ static inline void SetRailTypeOnBridge(TileIndex t, RailType r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** These are used to specify a single track.
|
|
||||||
* Can be translated to a trackbit with TrackToTrackbit */
|
|
||||||
typedef enum Track {
|
|
||||||
TRACK_X = 0,
|
|
||||||
TRACK_Y = 1,
|
|
||||||
TRACK_UPPER = 2,
|
|
||||||
TRACK_LOWER = 3,
|
|
||||||
TRACK_LEFT = 4,
|
|
||||||
TRACK_RIGHT = 5,
|
|
||||||
TRACK_END,
|
|
||||||
INVALID_TRACK = 0xFF
|
|
||||||
} Track;
|
|
||||||
|
|
||||||
|
|
||||||
/** Bitfield corresponding to Track */
|
|
||||||
typedef enum TrackBits {
|
|
||||||
TRACK_BIT_NONE = 0U,
|
|
||||||
TRACK_BIT_X = 1U << TRACK_X,
|
|
||||||
TRACK_BIT_Y = 1U << TRACK_Y,
|
|
||||||
TRACK_BIT_UPPER = 1U << TRACK_UPPER,
|
|
||||||
TRACK_BIT_LOWER = 1U << TRACK_LOWER,
|
|
||||||
TRACK_BIT_LEFT = 1U << TRACK_LEFT,
|
|
||||||
TRACK_BIT_RIGHT = 1U << TRACK_RIGHT,
|
|
||||||
TRACK_BIT_CROSS = TRACK_BIT_X | TRACK_BIT_Y,
|
|
||||||
TRACK_BIT_HORZ = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
|
|
||||||
TRACK_BIT_VERT = TRACK_BIT_LEFT | TRACK_BIT_RIGHT,
|
|
||||||
TRACK_BIT_3WAY_NE = TRACK_BIT_X | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
|
|
||||||
TRACK_BIT_3WAY_SE = TRACK_BIT_Y | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
|
|
||||||
TRACK_BIT_3WAY_SW = TRACK_BIT_X | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
|
|
||||||
TRACK_BIT_3WAY_NW = TRACK_BIT_Y | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
|
|
||||||
TRACK_BIT_ALL = TRACK_BIT_CROSS | TRACK_BIT_HORZ | TRACK_BIT_VERT,
|
|
||||||
TRACK_BIT_MASK = 0x3FU
|
|
||||||
} TrackBits;
|
|
||||||
|
|
||||||
static inline TrackBits GetTrackBits(TileIndex tile)
|
static inline TrackBits GetTrackBits(TileIndex tile)
|
||||||
{
|
{
|
||||||
return (TrackBits)GB(_m[tile].m5, 0, 6);
|
return (TrackBits)GB(_m[tile].m5, 0, 6);
|
||||||
@ -269,6 +225,58 @@ static inline SignalState GetSingleSignalState(TileIndex t, byte signalbit)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for the presence of signals (either way) on the given track on the
|
||||||
|
* given rail tile.
|
||||||
|
*/
|
||||||
|
static inline bool HasSignalOnTrack(TileIndex tile, Track track)
|
||||||
|
{
|
||||||
|
assert(IsValidTrack(track));
|
||||||
|
return
|
||||||
|
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
|
||||||
|
(_m[tile].m3 & SignalOnTrack(track)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks for the presence of signals along the given trackdir on the given
|
||||||
|
* rail tile.
|
||||||
|
*
|
||||||
|
* Along meaning if you are currently driving on the given trackdir, this is
|
||||||
|
* the signal that is facing us (for which we stop when it's red).
|
||||||
|
*/
|
||||||
|
static inline bool HasSignalOnTrackdir(TileIndex tile, Trackdir trackdir)
|
||||||
|
{
|
||||||
|
assert (IsValidTrackdir(trackdir));
|
||||||
|
return
|
||||||
|
GetRailTileType(tile) == RAIL_TILE_SIGNALS &&
|
||||||
|
_m[tile].m3 & SignalAlongTrackdir(trackdir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the state of the signal along the given trackdir.
|
||||||
|
*
|
||||||
|
* Along meaning if you are currently driving on the given trackdir, this is
|
||||||
|
* the signal that is facing us (for which we stop when it's red).
|
||||||
|
*/
|
||||||
|
static inline SignalState GetSignalStateByTrackdir(TileIndex tile, Trackdir trackdir)
|
||||||
|
{
|
||||||
|
assert(IsValidTrackdir(trackdir));
|
||||||
|
assert(HasSignalOnTrack(tile, TrackdirToTrack(trackdir)));
|
||||||
|
return _m[tile].m2 & SignalAlongTrackdir(trackdir) ?
|
||||||
|
SIGNAL_STATE_GREEN : SIGNAL_STATE_RED;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return the rail type of tile, or INVALID_RAILTYPE if this is no rail tile.
|
||||||
|
* Note that there is no check if the given trackdir is actually present on
|
||||||
|
* the tile!
|
||||||
|
* The given trackdir is used when there are (could be) multiple rail types on
|
||||||
|
* one tile.
|
||||||
|
*/
|
||||||
|
RailType GetTileRailType(TileIndex tile, Trackdir trackdir);
|
||||||
|
|
||||||
|
|
||||||
typedef enum RailGroundType {
|
typedef enum RailGroundType {
|
||||||
RAIL_MAP2LO_GROUND_MASK = 0xF,
|
RAIL_MAP2LO_GROUND_MASK = 0xF,
|
||||||
RAIL_GROUND_BARREN = 0,
|
RAIL_GROUND_BARREN = 0,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
#ifndef STATION_MAP_H
|
#ifndef STATION_MAP_H
|
||||||
#define STATION_MAP_H
|
#define STATION_MAP_H
|
||||||
|
|
||||||
|
#include "rail_map.h"
|
||||||
#include "station.h"
|
#include "station.h"
|
||||||
|
|
||||||
typedef byte StationGfx;
|
typedef byte StationGfx;
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "openttd.h"
|
#include "openttd.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "functions.h"
|
#include "functions.h"
|
||||||
|
#include "rail_map.h"
|
||||||
#include "table/sprites.h"
|
#include "table/sprites.h"
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
#include "map.h"
|
#include "map.h"
|
||||||
|
Loading…
Reference in New Issue
Block a user