tunnel_map.h

Go to the documentation of this file.
00001 /* $Id$ */
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 TUNNEL_MAP_H
00013 #define TUNNEL_MAP_H
00014 
00015 #include "road_map.h"
00016 
00017 
00024 static inline bool IsTunnel(TileIndex t)
00025 {
00026   assert(IsTileType(t, MP_TUNNELBRIDGE));
00027   return !HasBit(_m[t].m5, 7);
00028 }
00029 
00035 static inline bool IsTunnelTile(TileIndex t)
00036 {
00037   return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
00038 }
00039 
00040 TileIndex GetOtherTunnelEnd(TileIndex);
00041 bool IsTunnelInWay(TileIndex, uint z);
00042 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
00043 bool IsTunnelBelow(TileIndex tile);
00044 
00052 static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
00053 {
00054   SetTileType(t, MP_TUNNELBRIDGE);
00055   SetTileOwner(t, o);
00056   _m[t].m2 = 0;
00057   _m[t].m3 = 0;
00058   _m[t].m4 = 0;
00059   _m[t].m5 = TRANSPORT_ROAD << 2 | d;
00060   SB(_m[t].m6, 2, 4, 0);
00061   _me[t].m7 = 0;
00062   SetRoadOwner(t, ROADTYPE_ROAD, o);
00063   if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
00064   SetRoadTypes(t, r);
00065 }
00066 
00074 static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
00075 {
00076   SetTileType(t, MP_TUNNELBRIDGE);
00077   SetTileOwner(t, o);
00078   _m[t].m2 = 0;
00079   _m[t].m3 = r;
00080   _m[t].m4 = 0;
00081   _m[t].m5 = TRANSPORT_RAIL << 2 | d;
00082   SB(_m[t].m6, 2, 4, 0);
00083   _me[t].m7 = 0;
00084 }
00085 
00086 #endif /* TUNNEL_MAP_H */