tunnel_map.h

Go to the documentation of this file.
00001 /* $Id: tunnel_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 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 
00051 static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
00052 {
00053   SetTileType(t, MP_TUNNELBRIDGE);
00054   SetTileOwner(t, o);
00055   _m[t].m2 = 0;
00056   _m[t].m3 = 0;
00057   _m[t].m4 = 0;
00058   _m[t].m5 = TRANSPORT_ROAD << 2 | d;
00059   SB(_m[t].m6, 2, 4, 0);
00060   _me[t].m7 = 0;
00061   SetRoadOwner(t, ROADTYPE_ROAD, o);
00062   if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
00063   SetRoadTypes(t, r);
00064 }
00065 
00073 static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
00074 {
00075   SetTileType(t, MP_TUNNELBRIDGE);
00076   SetTileOwner(t, o);
00077   _m[t].m2 = 0;
00078   _m[t].m3 = r;
00079   _m[t].m4 = 0;
00080   _m[t].m5 = TRANSPORT_RAIL << 2 | d;
00081   SB(_m[t].m6, 2, 4, 0);
00082   _me[t].m7 = 0;
00083 }
00084 
00085 #endif /* TUNNEL_MAP_H */

Generated on Thu Feb 4 17:20:30 2010 for OpenTTD by  doxygen 1.5.6