Changeset - r2232:e57ed01defe1
[Not reviewed]
master
0 1 0
celestar - 19 years ago 2005-07-29 19:35:23
celestar@openttd.org
(svn r2752) -Doc: Added some doxygen stuff to rail.h. I'm gonna mess around with this file and wanted to get rid of this first
1 file changed with 11 insertions and 9 deletions:
rail.h
11
9
0 comments (0 inline, 0 general)
rail.h
Show inline comments
 
/* $Id$ */
 

	
 
/** @file rail.h */
 

	
 
#ifndef RAIL_H
 
#define RAIL_H
 

	
 
#include "tile.h"
 

	
 
/*
 
 * Some enums for accesing the map bytes for rail tiles
 
 */
 

	
 
/* These types are used in the map5 byte for rail tiles. Use GetRailTileType() to
 
/** These types are used in the map5 byte for rail tiles. Use GetRailTileType() to
 
 * get these values */
 
typedef enum RailTileTypes {
 
	RAIL_TYPE_NORMAL         = 0x0,
 
	RAIL_TYPE_SIGNALS        = 0x40,
 
	RAIL_TYPE_UNUSED         = 0x80, /* XXX: Maybe this could become waypoints? */
 
	RAIL_TYPE_DEPOT_WAYPOINT = 0xC0, /* Is really depots and waypoints... */
 
	RAIL_TILE_TYPE_MASK      = 0xC0,
 
} RailTileType;
 

	
 
enum { /* DEPRECATED TODO: Rewrite all uses of this */
 
	RAIL_TYPE_SPECIAL = 0x80, /* This used to say "If this bit is set, then it's
 
														 * not a regular track.", but currently, you
 
														 * should rather view map5[6..7] as one type,
 
														 * containing a value from RailTileTypes above.
 
														 * This value is only maintained for backwards
 
														 * compatibility */
 

	
 
	/* There used to be RAIL_BIT_* enums here, they moved to (for now) npf.c as
 
	 * TRACK_BIT_* */
 
};
 

	
 
/* These subtypes are used in the map5 byte when the main rail type is
 
/** These subtypes are used in the map5 byte when the main rail type is
 
 * RAIL_TYPE_DEPOT_WAYPOINT */
 
typedef enum RailTileSubtypes {
 
	RAIL_SUBTYPE_DEPOT    = 0x00,
 
	RAIL_SUBTYPE_WAYPOINT = 0x04,
 
	RAIL_SUBTYPE_MASK     = 0x3C,
 
} RailTileSubtype;
 

	
 
typedef enum SignalTypes {
 
	/* Stored in m4[0..1] for MP_RAILWAY */
 
  SIGTYPE_NORMAL  = 0,        // normal signal
 
  SIGTYPE_ENTRY   = 1,        // presignal block entry
 
  SIGTYPE_EXIT    = 2,        // presignal block exit
 
@@ -54,117 +56,117 @@ typedef enum RailTypes {
 
	RAILTYPE_RAIL   = 0,
 
	RAILTYPE_MONO   = 1,
 
	RAILTYPE_MAGLEV = 2,
 
	RAILTYPE_END,
 
	RAILTYPE_MASK   = 0x3,
 
	INVALID_RAILTYPE = 0xFF,
 
} RailType;
 

	
 
enum {
 
	SIG_SEMAPHORE_MASK = 1 << 3,
 
};
 

	
 
/* These are used to specify a single track. Can be translated to a trackbit
 
/** These are used to specify a single track. Can be translated to a trackbit
 
 * with TrackToTrackbit */
 
typedef enum Tracks {
 
  TRACK_DIAG1 = 0,
 
  TRACK_DIAG2 = 1,
 
  TRACK_UPPER = 2,
 
  TRACK_LOWER = 3,
 
  TRACK_LEFT  = 4,
 
  TRACK_RIGHT = 5,
 
  TRACK_END,
 
  INVALID_TRACK = 0xFF,
 
} Track;
 

	
 
/* These are the bitfield variants of the above */
 
/** These are the bitfield variants of the above */
 
typedef enum TrackBits {
 
  TRACK_BIT_DIAG1 = 1,  // 0
 
  TRACK_BIT_DIAG2 = 2,  // 1
 
  TRACK_BIT_UPPER = 4,  // 2
 
  TRACK_BIT_LOWER = 8,  // 3
 
  TRACK_BIT_LEFT  = 16, // 4
 
  TRACK_BIT_RIGHT = 32, // 5
 
	TRACK_BIT_MASK  = 0x3F,
 
} 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. */
 
typedef enum Trackdirs {
 
  TRACKDIR_DIAG1_NE = 0,
 
  TRACKDIR_DIAG2_SE = 1,
 
  TRACKDIR_UPPER_E  = 2,
 
  TRACKDIR_LOWER_E  = 3,
 
  TRACKDIR_LEFT_S   = 4,
 
  TRACKDIR_RIGHT_S  = 5,
 
	/* Note the two missing values here. This enables trackdir -> track
 
	 * conversion by doing (trackdir & 7) */
 
  TRACKDIR_DIAG1_SW = 8,
 
  TRACKDIR_DIAG2_NW = 9,
 
  TRACKDIR_UPPER_W  = 10,
 
  TRACKDIR_LOWER_W  = 11,
 
  TRACKDIR_LEFT_N   = 12,
 
  TRACKDIR_RIGHT_N  = 13,
 
  TRACKDIR_END,
 
  INVALID_TRACKDIR  = 0xFF,
 
} Trackdir;
 

	
 
/* 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. */
 
typedef enum TrackdirBits {
 
  TRACKDIR_BIT_DIAG1_NE = 0x1,
 
  TRACKDIR_BIT_DIAG2_SE = 0x2,
 
  TRACKDIR_BIT_UPPER_E  = 0x4,
 
  TRACKDIR_BIT_LOWER_E  = 0x8,
 
  TRACKDIR_BIT_LEFT_S   = 0x10,
 
  TRACKDIR_BIT_RIGHT_S  = 0x20,
 
	/* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
 
  TRACKDIR_BIT_DIAG1_SW = 0x0100,
 
  TRACKDIR_BIT_DIAG2_NW = 0x0200,
 
  TRACKDIR_BIT_UPPER_W  = 0x0400,
 
  TRACKDIR_BIT_LOWER_W  = 0x0800,
 
  TRACKDIR_BIT_LEFT_N   = 0x1000,
 
  TRACKDIR_BIT_RIGHT_N  = 0x2000,
 
	TRACKDIR_BIT_MASK			= 0x3F3F,
 
  INVALID_TRACKDIR_BIT  = 0xFFFF,
 
} TrackdirBits;
 

	
 
/* These are states in which a signal can be. Currently these are only two, so
 
/** These are states in which a signal can be. Currently these are only two, so
 
 * simple boolean logic will do. But do try to compare to this enum instead of
 
 * normal boolean evaluation, since that will make future additions easier.
 
 */
 
typedef enum SignalStates {
 
	SIGNAL_STATE_RED = 0,
 
	SIGNAL_STATE_GREEN = 1,
 
} SignalState;
 

	
 
// these are the maximums used for updating signal blocks, and checking if a depot is in a pbs block
 
enum {
 
	NUM_SSD_ENTRY = 256, // max amount of blocks
 
	NUM_SSD_STACK = 32 ,// max amount of blocks to check recursively
 
};
 

	
 
/**
 
 * Maps a Trackdir to the corresponding TrackdirBits value
 
 */
 
static inline TrackdirBits TrackdirToTrackdirBits(Trackdir trackdir) { return (TrackdirBits)(1 << trackdir); }
 

	
 
/*
 
/**
 
 * These functions check the validity of Tracks and Trackdirs. assert against
 
 * them when convenient.
 
 */
 
static inline bool IsValidTrack(Track track) { return track < TRACK_END; }
 
static inline bool IsValidTrackdir(Trackdir trackdir) { return (TrackdirToTrackdirBits(trackdir) & TRACKDIR_BIT_MASK) != 0; }
 

	
 
/*
 
/**
 
 * Functions to map tracks to the corresponding bits in the signal
 
 * presence/status bytes in the map. You should not use these directly, but
 
 * wrapper functions below instead. XXX: Which are these?
 
 */
 

	
 
/**
 
 * Maps a trackdir to the bit that stores its status in the map arrays, in the
 
 * direction along with the trackdir.
 
 */
 
extern const byte _signal_along_trackdir[TRACKDIR_END];
 
static inline byte SignalAlongTrackdir(Trackdir trackdir) {return _signal_along_trackdir[trackdir];}
 

	
0 comments (0 inline, 0 general)