# tunnelbridge_map.h

Go to the documentation of this file.

    00001 /* $Id: tunnelbridge_map.h 17248 2009-08-21 20:21:05Z 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 TUNNELBRIDGE_MAP_H
    00013 #define TUNNELBRIDGE_MAP_H
    00014
    00015 #include "direction_func.h"
    00016 #include "core/bitmath_func.hpp"
    00017 #include "tile_map.h"
    00018 #include "bridge_map.h"
    00019 #include "tunnel_map.h"
    00020 #include "transport_type.h"
    00021 #include "track_func.h"
    00022
    00023
    00033 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
    00034 {
    00035   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00036   return (DiagDirection)GB(_m[t].m5, 0, 2);
    00037 }
    00038
    00046 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
    00047 {
    00048   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00049   return (TransportType)GB(_m[t].m5, 2, 2);
    00050 }
    00051
    00059 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
    00060 {
    00061   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00062   return HasBit(_me[t].m7, 5);
    00063 }
    00064
    00073 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
    00074 {
    00075   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00076   SB(_me[t].m7, 5, 1, snow_or_desert);
    00077 }
    00078
    00085 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
    00086 {
    00087   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00088   return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
    00089 }
    00090
    00091
    00098 static inline bool HasTunnelBridgeReservation(TileIndex t)
    00099 {
    00100   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00101   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
    00102   return HasBit(_m[t].m5, 4);
    00103 }
    00104
    00111 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
    00112 {
    00113   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00114   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
    00115   SB(_m[t].m5, 4, 1, b ? 1 : 0);
    00116 }
    00117
    00124 static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
    00125 {
    00126   return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
    00127 }
    00128
    00129 #endif /* TUNNELBRIDGE_MAP_H */