# 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 "direction_func.h"
    00016 #include "rail_type.h"
    00017 #include "road_type.h"
    00018 #include "transport_type.h"
    00019 #include "road_map.h"
    00020
    00021
    00028 static inline bool IsTunnel(TileIndex t)
    00029 {
    00030   assert(IsTileType(t, MP_TUNNELBRIDGE));
    00031   return !HasBit(_m[t].m5, 7);
    00032 }
    00033
    00039 static inline bool IsTunnelTile(TileIndex t)
    00040 {
    00041   return IsTileType(t, MP_TUNNELBRIDGE) && IsTunnel(t);
    00042 }
    00043
    00044 TileIndex GetOtherTunnelEnd(TileIndex);
    00045 bool IsTunnelInWay(TileIndex, uint z);
    00046 bool IsTunnelInWayDir(TileIndex tile, uint z, DiagDirection dir);
    00047
    00055 static inline void MakeRoadTunnel(TileIndex t, Owner o, DiagDirection d, RoadTypes r)
    00056 {
    00057   SetTileType(t, MP_TUNNELBRIDGE);
    00058   SetTileOwner(t, o);
    00059   _m[t].m2 = 0;
    00060   _m[t].m3 = 0;
    00061   _m[t].m4 = 0;
    00062   _m[t].m5 = TRANSPORT_ROAD << 2 | d;
    00063   SB(_m[t].m6, 2, 4, 0);
    00064   _me[t].m7 = 0;
    00065   SetRoadOwner(t, ROADTYPE_ROAD, o);
    00066   if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o);
    00067   SetRoadTypes(t, r);
    00068 }
    00069
    00077 static inline void MakeRailTunnel(TileIndex t, Owner o, DiagDirection d, RailType r)
    00078 {
    00079   SetTileType(t, MP_TUNNELBRIDGE);
    00080   SetTileOwner(t, o);
    00081   _m[t].m2 = 0;
    00082   _m[t].m3 = r;
    00083   _m[t].m4 = 0;
    00084   _m[t].m5 = TRANSPORT_RAIL << 2 | d;
    00085   SB(_m[t].m6, 2, 4, 0);
    00086   _me[t].m7 = 0;
    00087 }
    00088
    00089 #endif /* TUNNEL_MAP_H */