tunnelbridge_map.h

Go to the documentation of this file.
00001 /* $Id: tunnelbridge_map.h 18809 2010-01-15 16:41:15Z 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 "bridge_map.h"
00016 #include "tunnel_map.h"
00017 
00018 
00028 static inline DiagDirection GetTunnelBridgeDirection(TileIndex t)
00029 {
00030   assert(IsTileType(t, MP_TUNNELBRIDGE));
00031   return (DiagDirection)GB(_m[t].m5, 0, 2);
00032 }
00033 
00041 static inline TransportType GetTunnelBridgeTransportType(TileIndex t)
00042 {
00043   assert(IsTileType(t, MP_TUNNELBRIDGE));
00044   return (TransportType)GB(_m[t].m5, 2, 2);
00045 }
00046 
00054 static inline bool HasTunnelBridgeSnowOrDesert(TileIndex t)
00055 {
00056   assert(IsTileType(t, MP_TUNNELBRIDGE));
00057   return HasBit(_me[t].m7, 5);
00058 }
00059 
00068 static inline void SetTunnelBridgeSnowOrDesert(TileIndex t, bool snow_or_desert)
00069 {
00070   assert(IsTileType(t, MP_TUNNELBRIDGE));
00071   SB(_me[t].m7, 5, 1, snow_or_desert);
00072 }
00073 
00080 static inline TileIndex GetOtherTunnelBridgeEnd(TileIndex t)
00081 {
00082   assert(IsTileType(t, MP_TUNNELBRIDGE));
00083   return IsTunnel(t) ? GetOtherTunnelEnd(t) : GetOtherBridgeEnd(t);
00084 }
00085 
00086 
00093 static inline bool HasTunnelBridgeReservation(TileIndex t)
00094 {
00095   assert(IsTileType(t, MP_TUNNELBRIDGE));
00096   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00097   return HasBit(_m[t].m5, 4);
00098 }
00099 
00106 static inline void SetTunnelBridgeReservation(TileIndex t, bool b)
00107 {
00108   assert(IsTileType(t, MP_TUNNELBRIDGE));
00109   assert(GetTunnelBridgeTransportType(t) == TRANSPORT_RAIL);
00110   SB(_m[t].m5, 4, 1, b ? 1 : 0);
00111 }
00112 
00119 static inline TrackBits GetTunnelBridgeReservationTrackBits(TileIndex t)
00120 {
00121   return HasTunnelBridgeReservation(t) ? DiagDirToDiagTrackBits(GetTunnelBridgeDirection(t)) : TRACK_BIT_NONE;
00122 }
00123 
00124 #endif /* TUNNELBRIDGE_MAP_H */

Generated on Sat Nov 20 20:59:11 2010 for OpenTTD by  doxygen 1.6.1