# track_type.h

Go to the documentation of this file.

    00001 /* $Id: track_type.h 19665 2010-04-17 22:27:49Z rubidium $ */
    00002
    00003 /*
    00004  * This file is part of OpenTTD.
    00005  * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
    00006  * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    00007  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
    00008  */
    00009
    00012 #ifndef TRACK_TYPE_H
    00013 #define TRACK_TYPE_H
    00014
    00015 #include "core/enum_type.hpp"
    00016
    00021 enum Track {
    00022   TRACK_BEGIN = 0,
    00023   TRACK_X     = 0,
    00024   TRACK_Y     = 1,
    00025   TRACK_UPPER = 2,
    00026   TRACK_LOWER = 3,
    00027   TRACK_LEFT  = 4,
    00028   TRACK_RIGHT = 5,
    00029   TRACK_END,
    00030   INVALID_TRACK = 0xFF
    00031 };
    00032
    00034 DECLARE_POSTFIX_INCREMENT(Track);
    00036 template <> struct EnumPropsT<Track> : MakeEnumPropsT<Track, byte, TRACK_BEGIN, TRACK_END, INVALID_TRACK, 3> {};
    00037 typedef TinyEnumT<Track> TrackByte;
    00038
    00039
    00041 enum TrackBits {
    00042   TRACK_BIT_NONE    = 0U,
    00043   TRACK_BIT_X       = 1U << TRACK_X,
    00044   TRACK_BIT_Y       = 1U << TRACK_Y,
    00045   TRACK_BIT_UPPER   = 1U << TRACK_UPPER,
    00046   TRACK_BIT_LOWER   = 1U << TRACK_LOWER,
    00047   TRACK_BIT_LEFT    = 1U << TRACK_LEFT,
    00048   TRACK_BIT_RIGHT   = 1U << TRACK_RIGHT,
    00049   TRACK_BIT_CROSS   = TRACK_BIT_X     | TRACK_BIT_Y,
    00050   TRACK_BIT_HORZ    = TRACK_BIT_UPPER | TRACK_BIT_LOWER,
    00051   TRACK_BIT_VERT    = TRACK_BIT_LEFT  | TRACK_BIT_RIGHT,
    00052   TRACK_BIT_3WAY_NE = TRACK_BIT_X     | TRACK_BIT_UPPER | TRACK_BIT_RIGHT,
    00053   TRACK_BIT_3WAY_SE = TRACK_BIT_Y     | TRACK_BIT_LOWER | TRACK_BIT_RIGHT,
    00054   TRACK_BIT_3WAY_SW = TRACK_BIT_X     | TRACK_BIT_LOWER | TRACK_BIT_LEFT,
    00055   TRACK_BIT_3WAY_NW = TRACK_BIT_Y     | TRACK_BIT_UPPER | TRACK_BIT_LEFT,
    00056   TRACK_BIT_ALL     = TRACK_BIT_CROSS | TRACK_BIT_HORZ  | TRACK_BIT_VERT,
    00057   TRACK_BIT_MASK    = 0x3FU,
    00058   TRACK_BIT_WORMHOLE = 0x40U,
    00059   TRACK_BIT_DEPOT   = 0x80U,
    00060   INVALID_TRACK_BIT = 0xFF
    00061 };
    00062 DECLARE_ENUM_AS_BIT_SET(TrackBits);
    00063 typedef SimpleTinyEnumT<TrackBits, byte> TrackBitsByte;
    00064
    00074 enum Trackdir {
    00075   TRACKDIR_BEGIN    =  0,
    00076   TRACKDIR_X_NE     =  0,
    00077   TRACKDIR_Y_SE     =  1,
    00078   TRACKDIR_UPPER_E  =  2,
    00079   TRACKDIR_LOWER_E  =  3,
    00080   TRACKDIR_LEFT_S   =  4,
    00081   TRACKDIR_RIGHT_S  =  5,
    00082   TRACKDIR_RVREV_NE =  6,
    00083   TRACKDIR_RVREV_SE =  7,
    00084   TRACKDIR_X_SW     =  8,
    00085   TRACKDIR_Y_NW     =  9,
    00086   TRACKDIR_UPPER_W  = 10,
    00087   TRACKDIR_LOWER_W  = 11,
    00088   TRACKDIR_LEFT_N   = 12,
    00089   TRACKDIR_RIGHT_N  = 13,
    00090   TRACKDIR_RVREV_SW = 14,
    00091   TRACKDIR_RVREV_NW = 15,
    00092   TRACKDIR_END,
    00093   INVALID_TRACKDIR  = 0xFF,
    00094 };
    00095
    00097 template <> struct EnumPropsT<Trackdir> : MakeEnumPropsT<Trackdir, byte, TRACKDIR_BEGIN, TRACKDIR_END, INVALID_TRACKDIR, 4> {};
    00098 typedef TinyEnumT<Trackdir> TrackdirByte;
    00099
    00106 enum TrackdirBits {
    00107   TRACKDIR_BIT_NONE     = 0x0000,
    00108   TRACKDIR_BIT_X_NE     = 0x0001,
    00109   TRACKDIR_BIT_Y_SE     = 0x0002,
    00110   TRACKDIR_BIT_UPPER_E  = 0x0004,
    00111   TRACKDIR_BIT_LOWER_E  = 0x0008,
    00112   TRACKDIR_BIT_LEFT_S   = 0x0010,
    00113   TRACKDIR_BIT_RIGHT_S  = 0x0020,
    00114   /* Again, note the two missing values here. This enables trackdir -> track conversion by doing (trackdir & 0xFF) */
    00115   TRACKDIR_BIT_X_SW     = 0x0100,
    00116   TRACKDIR_BIT_Y_NW     = 0x0200,
    00117   TRACKDIR_BIT_UPPER_W  = 0x0400,
    00118   TRACKDIR_BIT_LOWER_W  = 0x0800,
    00119   TRACKDIR_BIT_LEFT_N   = 0x1000,
    00120   TRACKDIR_BIT_RIGHT_N  = 0x2000,
    00121   TRACKDIR_BIT_MASK     = 0x3F3F,
    00122   INVALID_TRACKDIR_BIT  = 0xFFFF,
    00123 };
    00124 DECLARE_ENUM_AS_BIT_SET(TrackdirBits);
    00125 typedef SimpleTinyEnumT<TrackdirBits, uint16> TrackdirBitsShort;
    00126
    00127 typedef uint32 TrackStatus;
    00128
    00129 #endif /* TRACK_TYPE_H */