2006-02-23 08:20:28 +00:00
|
|
|
/* $Id$ */
|
|
|
|
|
2009-08-21 20:21:05 +00:00
|
|
|
/*
|
|
|
|
* This file is part of OpenTTD.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2008-05-06 15:11:33 +00:00
|
|
|
/** @file road_map.h Map accessors for roads. */
|
2007-03-28 20:41:35 +00:00
|
|
|
|
2006-03-05 11:18:34 +00:00
|
|
|
#ifndef ROAD_MAP_H
|
|
|
|
#define ROAD_MAP_H
|
2006-02-23 08:20:28 +00:00
|
|
|
|
2007-12-18 20:10:21 +00:00
|
|
|
#include "track_func.h"
|
2009-09-10 14:33:07 +00:00
|
|
|
#include "depot_type.h"
|
2007-12-18 20:10:21 +00:00
|
|
|
#include "rail_type.h"
|
2008-01-07 14:02:26 +00:00
|
|
|
#include "town_type.h"
|
2007-12-18 20:38:16 +00:00
|
|
|
#include "road_func.h"
|
2007-12-19 23:26:02 +00:00
|
|
|
#include "tile_map.h"
|
2006-02-23 08:20:28 +00:00
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
enum RoadTileType {
|
2006-05-09 08:25:31 +00:00
|
|
|
ROAD_TILE_NORMAL,
|
|
|
|
ROAD_TILE_CROSSING,
|
|
|
|
ROAD_TILE_DEPOT
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-03-30 09:29:01 +00:00
|
|
|
|
2006-05-09 08:25:31 +00:00
|
|
|
static inline RoadTileType GetRoadTileType(TileIndex t)
|
2008-02-10 18:31:33 +00:00
|
|
|
{
|
2007-07-29 23:42:59 +00:00
|
|
|
assert(IsTileType(t, MP_ROAD));
|
2007-05-20 19:14:08 +00:00
|
|
|
return (RoadTileType)GB(_m[t].m5, 6, 2);
|
2006-03-30 09:29:01 +00:00
|
|
|
}
|
|
|
|
|
2008-02-14 15:59:16 +00:00
|
|
|
static inline bool IsNormalRoad(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetRoadTileType(t) == ROAD_TILE_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsNormalRoadTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_ROAD) && IsNormalRoad(t);
|
|
|
|
}
|
|
|
|
|
2006-04-10 20:38:59 +00:00
|
|
|
static inline bool IsLevelCrossing(TileIndex t)
|
|
|
|
{
|
2006-05-09 08:25:31 +00:00
|
|
|
return GetRoadTileType(t) == ROAD_TILE_CROSSING;
|
2006-04-10 20:38:59 +00:00
|
|
|
}
|
|
|
|
|
2006-04-15 20:07:42 +00:00
|
|
|
static inline bool IsLevelCrossingTile(TileIndex t)
|
|
|
|
{
|
2007-07-29 23:42:59 +00:00
|
|
|
return IsTileType(t, MP_ROAD) && IsLevelCrossing(t);
|
2006-04-15 20:07:42 +00:00
|
|
|
}
|
2006-03-30 09:29:01 +00:00
|
|
|
|
2008-02-14 15:59:16 +00:00
|
|
|
static inline bool IsRoadDepot(TileIndex t)
|
|
|
|
{
|
|
|
|
return GetRoadTileType(t) == ROAD_TILE_DEPOT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IsRoadDepotTile(TileIndex t)
|
|
|
|
{
|
|
|
|
return IsTileType(t, MP_ROAD) && IsRoadDepot(t);
|
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline RoadBits GetRoadBits(TileIndex t, RoadType rt)
|
2006-02-23 08:20:28 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsNormalRoad(t));
|
2007-05-20 19:14:08 +00:00
|
|
|
switch (rt) {
|
|
|
|
default: NOT_REACHED();
|
2009-03-02 22:57:47 +00:00
|
|
|
case ROADTYPE_ROAD: return (RoadBits)GB(_m[t].m5, 0, 4);
|
|
|
|
case ROADTYPE_TRAM: return (RoadBits)GB(_m[t].m3, 0, 4);
|
2007-05-20 19:14:08 +00:00
|
|
|
}
|
2006-02-23 08:20:28 +00:00
|
|
|
}
|
|
|
|
|
2008-03-27 14:26:31 +00:00
|
|
|
/**
|
|
|
|
* Get all RoadBits set on a tile except from the given RoadType
|
|
|
|
*
|
|
|
|
* @param t The tile from which we want to get the RoadBits
|
|
|
|
* @param rt The RoadType which we exclude from the querry
|
|
|
|
* @return all set RoadBits of the tile which are not from the given RoadType
|
|
|
|
*/
|
|
|
|
static inline RoadBits GetOtherRoadBits(TileIndex t, RoadType rt)
|
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
return GetRoadBits(t, rt == ROADTYPE_ROAD ? ROADTYPE_TRAM : ROADTYPE_ROAD);
|
2008-03-27 14:26:31 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 18:59:25 +00:00
|
|
|
/**
|
|
|
|
* Get all set RoadBits on the given tile
|
|
|
|
*
|
|
|
|
* @param tile The tile from which we want to get the RoadBits
|
|
|
|
* @return all set RoadBits of the tile
|
|
|
|
*/
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline RoadBits GetAllRoadBits(TileIndex tile)
|
2006-03-06 13:11:08 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
return GetRoadBits(tile, ROADTYPE_ROAD) | GetRoadBits(tile, ROADTYPE_TRAM);
|
2006-03-06 13:11:08 +00:00
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline void SetRoadBits(TileIndex t, RoadBits r, RoadType rt)
|
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsNormalRoad(t)); // XXX incomplete
|
2007-05-20 19:14:08 +00:00
|
|
|
switch (rt) {
|
|
|
|
default: NOT_REACHED();
|
2009-03-02 22:57:47 +00:00
|
|
|
case ROADTYPE_ROAD: SB(_m[t].m5, 0, 4, r); break;
|
|
|
|
case ROADTYPE_TRAM: SB(_m[t].m3, 0, 4, r); break;
|
2007-05-20 19:14:08 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-06 13:11:08 +00:00
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline RoadTypes GetRoadTypes(TileIndex t)
|
2006-03-19 17:15:33 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
return (RoadTypes)GB(_me[t].m7, 6, 2);
|
2006-03-19 17:15:33 +00:00
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline void SetRoadTypes(TileIndex t, RoadTypes rt)
|
2006-02-23 11:53:48 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
assert(IsTileType(t, MP_ROAD) || IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));
|
|
|
|
SB(_me[t].m7, 6, 2, rt);
|
2006-02-23 11:53:48 +00:00
|
|
|
}
|
|
|
|
|
2008-02-14 15:59:16 +00:00
|
|
|
static inline bool HasTileRoadType(TileIndex t, RoadType rt)
|
|
|
|
{
|
|
|
|
return HasBit(GetRoadTypes(t), rt);
|
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline Owner GetRoadOwner(TileIndex t, RoadType rt)
|
2006-03-01 12:31:39 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
switch (rt) {
|
2007-05-20 19:14:08 +00:00
|
|
|
default: NOT_REACHED();
|
2009-03-02 22:57:47 +00:00
|
|
|
case ROADTYPE_ROAD: return (Owner)GB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5);
|
|
|
|
case ROADTYPE_TRAM: {
|
|
|
|
/* Trams don't need OWNER_TOWN, and remapping OWNER_NONE
|
2009-03-14 18:16:29 +00:00
|
|
|
* to OWNER_TOWN makes it use one bit less */
|
2009-03-02 22:57:47 +00:00
|
|
|
Owner o = (Owner)GB(_m[t].m3, 4, 4);
|
|
|
|
return o == OWNER_TOWN ? OWNER_NONE : o;
|
|
|
|
}
|
2007-05-20 19:14:08 +00:00
|
|
|
}
|
2006-03-01 12:31:39 +00:00
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline void SetRoadOwner(TileIndex t, RoadType rt, Owner o)
|
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
switch (rt) {
|
2007-05-20 19:14:08 +00:00
|
|
|
default: NOT_REACHED();
|
2009-03-02 22:57:47 +00:00
|
|
|
case ROADTYPE_ROAD: SB(IsNormalRoadTile(t) ? _m[t].m1 : _me[t].m7, 0, 5, o); break;
|
|
|
|
case ROADTYPE_TRAM: SB(_m[t].m3, 4, 4, o == OWNER_NONE ? OWNER_TOWN : o); break;
|
2007-05-20 19:14:08 +00:00
|
|
|
}
|
|
|
|
}
|
2006-03-01 12:31:39 +00:00
|
|
|
|
2008-05-24 19:36:20 +00:00
|
|
|
static inline bool IsRoadOwner(TileIndex t, RoadType rt, Owner o)
|
|
|
|
{
|
2008-11-18 22:43:59 +00:00
|
|
|
assert(HasTileRoadType(t, rt));
|
2008-05-24 19:36:20 +00:00
|
|
|
return (GetRoadOwner(t, rt) == o);
|
|
|
|
}
|
|
|
|
|
2008-11-18 22:43:59 +00:00
|
|
|
/** Checks if given tile has town owned road
|
|
|
|
* @param t tile to check
|
|
|
|
* @return true iff tile has road and the road is owned by a town
|
|
|
|
* @pre IsTileType(t, MP_ROAD)
|
|
|
|
*/
|
|
|
|
static inline bool HasTownOwnedRoad(TileIndex t)
|
|
|
|
{
|
|
|
|
return HasTileRoadType(t, ROADTYPE_ROAD) && IsRoadOwner(t, ROADTYPE_ROAD, OWNER_TOWN);
|
|
|
|
}
|
|
|
|
|
2007-05-31 15:15:00 +00:00
|
|
|
/** Which directions are disallowed ? */
|
|
|
|
enum DisallowedRoadDirections {
|
|
|
|
DRD_NONE, ///< None of the directions are disallowed
|
|
|
|
DRD_SOUTHBOUND, ///< All southbound traffic is disallowed
|
|
|
|
DRD_NORTHBOUND, ///< All northbound traffic is disallowed
|
|
|
|
DRD_BOTH, ///< All directions are disallowed
|
|
|
|
DRD_END
|
|
|
|
};
|
|
|
|
DECLARE_ENUM_AS_BIT_SET(DisallowedRoadDirections);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the disallowed directions
|
|
|
|
* @param t the tile to get the directions from
|
|
|
|
* @return the disallowed directions
|
|
|
|
*/
|
|
|
|
static inline DisallowedRoadDirections GetDisallowedRoadDirections(TileIndex t)
|
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsNormalRoad(t));
|
2007-05-31 15:15:00 +00:00
|
|
|
return (DisallowedRoadDirections)GB(_m[t].m5, 4, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the disallowed directions
|
|
|
|
* @param t the tile to set the directions for
|
|
|
|
* @param drd the disallowed directions
|
|
|
|
*/
|
|
|
|
static inline void SetDisallowedRoadDirections(TileIndex t, DisallowedRoadDirections drd)
|
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsNormalRoad(t));
|
2007-05-31 15:15:00 +00:00
|
|
|
assert(drd < DRD_END);
|
|
|
|
SB(_m[t].m5, 4, 2, drd);
|
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline Axis GetCrossingRoadAxis(TileIndex t)
|
2006-03-19 19:33:19 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsLevelCrossing(t));
|
2009-03-02 22:57:47 +00:00
|
|
|
return (Axis)GB(_m[t].m5, 0, 1);
|
2006-03-19 19:33:19 +00:00
|
|
|
}
|
|
|
|
|
2008-02-18 18:35:36 +00:00
|
|
|
static inline Axis GetCrossingRailAxis(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(IsLevelCrossing(t));
|
|
|
|
return OtherAxis((Axis)GetCrossingRoadAxis(t));
|
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline RoadBits GetCrossingRoadBits(TileIndex tile)
|
2006-03-19 19:33:19 +00:00
|
|
|
{
|
2007-05-20 19:14:08 +00:00
|
|
|
return GetCrossingRoadAxis(tile) == AXIS_X ? ROAD_X : ROAD_Y;
|
|
|
|
}
|
|
|
|
|
2008-02-18 18:35:36 +00:00
|
|
|
static inline Track GetCrossingRailTrack(TileIndex tile)
|
|
|
|
{
|
|
|
|
return AxisToTrack(GetCrossingRailAxis(tile));
|
|
|
|
}
|
|
|
|
|
2007-05-20 19:14:08 +00:00
|
|
|
static inline TrackBits GetCrossingRailBits(TileIndex tile)
|
|
|
|
{
|
2008-02-18 18:35:36 +00:00
|
|
|
return AxisToTrackBits(GetCrossingRailAxis(tile));
|
2006-03-19 19:33:19 +00:00
|
|
|
}
|
|
|
|
|
2008-08-02 22:47:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the reservation state of the rail crossing
|
|
|
|
* @pre IsLevelCrossingTile(t)
|
|
|
|
* @param t the crossing tile
|
|
|
|
* @return reservation state
|
|
|
|
*/
|
2009-07-21 22:37:10 +00:00
|
|
|
static inline bool HasCrossingReservation(TileIndex t)
|
2008-08-02 22:47:20 +00:00
|
|
|
{
|
|
|
|
assert(IsLevelCrossingTile(t));
|
|
|
|
return HasBit(_m[t].m5, 4);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set the reservation state of the rail crossing
|
|
|
|
* @note Works for both waypoints and rail depots
|
|
|
|
* @pre IsLevelCrossingTile(t)
|
|
|
|
* @param t the crossing tile
|
|
|
|
* @param b the reservation state
|
|
|
|
*/
|
|
|
|
static inline void SetCrossingReservation(TileIndex t, bool b)
|
|
|
|
{
|
|
|
|
assert(IsLevelCrossingTile(t));
|
|
|
|
SB(_m[t].m5, 4, 1, b ? 1 : 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the reserved track bits for a rail crossing
|
|
|
|
* @pre IsLevelCrossingTile(t)
|
|
|
|
* @param t the tile
|
|
|
|
* @return reserved track bits
|
|
|
|
*/
|
2009-07-21 22:37:10 +00:00
|
|
|
static inline TrackBits GetCrossingReservationTrackBits(TileIndex t)
|
2008-08-02 22:47:20 +00:00
|
|
|
{
|
2009-07-21 22:37:10 +00:00
|
|
|
return HasCrossingReservation(t) ? GetCrossingRailBits(t) : TRACK_BIT_NONE;
|
2008-08-02 22:47:20 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 20:41:33 +00:00
|
|
|
static inline bool IsCrossingBarred(TileIndex t)
|
2006-03-24 15:24:16 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsLevelCrossing(t));
|
2009-03-02 22:57:47 +00:00
|
|
|
return HasBit(_m[t].m5, 5);
|
2006-03-24 15:24:16 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 20:41:33 +00:00
|
|
|
static inline void SetCrossingBarred(TileIndex t, bool barred)
|
2006-03-24 15:24:16 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsLevelCrossing(t));
|
2009-03-02 22:57:47 +00:00
|
|
|
SB(_m[t].m5, 5, 1, barred ? 1 : 0);
|
2006-03-24 15:24:16 +00:00
|
|
|
}
|
|
|
|
|
2008-01-17 20:41:33 +00:00
|
|
|
static inline void UnbarCrossing(TileIndex t)
|
2006-03-24 15:24:16 +00:00
|
|
|
{
|
2008-01-17 20:41:33 +00:00
|
|
|
SetCrossingBarred(t, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void BarCrossing(TileIndex t)
|
|
|
|
{
|
|
|
|
SetCrossingBarred(t, true);
|
2006-03-24 15:24:16 +00:00
|
|
|
}
|
2006-03-19 19:33:19 +00:00
|
|
|
|
2006-04-03 13:35:19 +00:00
|
|
|
#define IsOnDesert IsOnSnow
|
|
|
|
static inline bool IsOnSnow(TileIndex t)
|
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
return HasBit(_me[t].m7, 5);
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#define ToggleDesert ToggleSnow
|
|
|
|
static inline void ToggleSnow(TileIndex t)
|
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
ToggleBit(_me[t].m7, 5);
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-03-07 12:11:48 +00:00
|
|
|
enum Roadside {
|
2006-06-19 20:13:50 +00:00
|
|
|
ROADSIDE_BARREN = 0,
|
|
|
|
ROADSIDE_GRASS = 1,
|
|
|
|
ROADSIDE_PAVED = 2,
|
|
|
|
ROADSIDE_STREET_LIGHTS = 3,
|
|
|
|
ROADSIDE_TREES = 5,
|
|
|
|
ROADSIDE_GRASS_ROAD_WORKS = 6,
|
|
|
|
ROADSIDE_PAVED_ROAD_WORKS = 7
|
2007-03-07 12:11:48 +00:00
|
|
|
};
|
2006-04-03 13:35:19 +00:00
|
|
|
|
2006-06-19 20:13:50 +00:00
|
|
|
static inline Roadside GetRoadside(TileIndex tile)
|
2006-04-03 13:35:19 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
return (Roadside)GB(_m[tile].m6, 3, 3);
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
2006-06-19 20:13:50 +00:00
|
|
|
static inline void SetRoadside(TileIndex tile, Roadside s)
|
2006-04-03 13:35:19 +00:00
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
SB(_m[tile].m6, 3, 3, s);
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool HasRoadWorks(TileIndex t)
|
|
|
|
{
|
2006-06-19 20:13:50 +00:00
|
|
|
return GetRoadside(t) >= ROADSIDE_GRASS_ROAD_WORKS;
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline bool IncreaseRoadWorksCounter(TileIndex t)
|
|
|
|
{
|
2009-03-02 22:57:47 +00:00
|
|
|
AB(_me[t].m7, 0, 4, 1);
|
2006-04-03 13:35:19 +00:00
|
|
|
|
2009-03-02 22:57:47 +00:00
|
|
|
return GB(_me[t].m7, 0, 4) == 15;
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void StartRoadWorks(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(!HasRoadWorks(t));
|
|
|
|
/* Remove any trees or lamps in case or roadwork */
|
2006-06-19 20:13:50 +00:00
|
|
|
switch (GetRoadside(t)) {
|
|
|
|
case ROADSIDE_BARREN:
|
|
|
|
case ROADSIDE_GRASS: SetRoadside(t, ROADSIDE_GRASS_ROAD_WORKS); break;
|
|
|
|
default: SetRoadside(t, ROADSIDE_PAVED_ROAD_WORKS); break;
|
2006-06-19 09:40:08 +00:00
|
|
|
}
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static inline void TerminateRoadWorks(TileIndex t)
|
|
|
|
{
|
|
|
|
assert(HasRoadWorks(t));
|
2006-06-19 20:13:50 +00:00
|
|
|
SetRoadside(t, (Roadside)(GetRoadside(t) - ROADSIDE_GRASS_ROAD_WORKS + ROADSIDE_GRASS));
|
2006-04-03 13:35:19 +00:00
|
|
|
/* Stop the counter */
|
2009-03-02 22:57:47 +00:00
|
|
|
SB(_me[t].m7, 0, 4, 0);
|
2006-04-03 13:35:19 +00:00
|
|
|
}
|
|
|
|
|
2006-02-28 21:19:50 +00:00
|
|
|
|
2006-03-30 09:29:01 +00:00
|
|
|
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
|
2006-03-08 15:29:23 +00:00
|
|
|
{
|
2008-02-14 15:59:16 +00:00
|
|
|
assert(IsRoadDepot(t));
|
2006-03-30 09:29:01 +00:00
|
|
|
return (DiagDirection)GB(_m[t].m5, 0, 2);
|
2006-03-08 15:29:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-03-05 12:22:20 +00:00
|
|
|
/**
|
|
|
|
* Returns the RoadBits on an arbitrary tile
|
2007-03-28 20:06:28 +00:00
|
|
|
* Special behaviour:
|
2006-03-05 12:22:20 +00:00
|
|
|
* - road depots: entrance is treated as road piece
|
|
|
|
* - road tunnels: entrance is treated as road piece
|
2006-03-14 12:00:11 +00:00
|
|
|
* - bridge ramps: start of the ramp is treated as road piece
|
2006-03-05 12:22:20 +00:00
|
|
|
* - bridge middle parts: bridge itself is ignored
|
2008-03-22 10:56:08 +00:00
|
|
|
*
|
|
|
|
* If straight_tunnel_bridge_entrance is set a ROAD_X or ROAD_Y
|
|
|
|
* for bridge ramps and tunnel entrances is returned depending
|
|
|
|
* on the orientation of the tunnel or bridge.
|
2007-04-03 21:51:40 +00:00
|
|
|
* @param tile the tile to get the road bits for
|
2007-05-20 19:14:08 +00:00
|
|
|
* @param rt the road type to get the road bits form
|
2009-09-19 09:51:14 +00:00
|
|
|
* @param straight_tunnel_bridge_entrance whether to return straight road bits for tunnels/bridges.
|
2007-04-03 21:51:40 +00:00
|
|
|
* @return the road bits of the given tile
|
2006-03-05 12:22:20 +00:00
|
|
|
*/
|
2008-03-22 10:56:08 +00:00
|
|
|
RoadBits GetAnyRoadBits(TileIndex tile, RoadType rt, bool straight_tunnel_bridge_entrance = false);
|
2006-03-05 12:22:20 +00:00
|
|
|
|
2007-12-18 20:38:16 +00:00
|
|
|
/**
|
|
|
|
* Return if the tile is a valid tile for a crossing.
|
|
|
|
*
|
|
|
|
* @note function is overloaded
|
|
|
|
* @param tile the curent tile
|
|
|
|
* @param ax the axis of the road over the rail
|
|
|
|
* @return true if it is a valid tile
|
|
|
|
*/
|
|
|
|
bool IsPossibleCrossing(const TileIndex tile, Axis ax);
|
|
|
|
|
2006-03-06 13:11:08 +00:00
|
|
|
|
2009-03-02 22:57:47 +00:00
|
|
|
static inline void MakeRoadNormal(TileIndex t, RoadBits bits, RoadTypes rot, TownID town, Owner road, Owner tram)
|
2006-02-28 21:19:50 +00:00
|
|
|
{
|
2007-07-29 23:42:59 +00:00
|
|
|
SetTileType(t, MP_ROAD);
|
2007-05-20 19:14:08 +00:00
|
|
|
SetTileOwner(t, road);
|
2006-02-28 21:19:50 +00:00
|
|
|
_m[t].m2 = town;
|
2009-03-02 22:57:47 +00:00
|
|
|
_m[t].m3 = (HasBit(rot, ROADTYPE_TRAM) ? bits : 0);
|
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = (HasBit(rot, ROADTYPE_ROAD) ? bits : 0) | ROAD_TILE_NORMAL << 6;
|
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
|
|
|
_me[t].m7 = rot << 6;
|
2007-06-01 17:58:43 +00:00
|
|
|
SetRoadOwner(t, ROADTYPE_TRAM, tram);
|
2006-02-28 21:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-03-02 22:57:47 +00:00
|
|
|
static inline void MakeRoadCrossing(TileIndex t, Owner road, Owner tram, Owner rail, Axis roaddir, RailType rat, RoadTypes rot, uint town)
|
2006-02-28 21:19:50 +00:00
|
|
|
{
|
2007-07-29 23:42:59 +00:00
|
|
|
SetTileType(t, MP_ROAD);
|
2006-02-28 21:19:50 +00:00
|
|
|
SetTileOwner(t, rail);
|
|
|
|
_m[t].m2 = town;
|
2007-05-20 19:14:08 +00:00
|
|
|
_m[t].m3 = rat;
|
2009-03-02 22:57:47 +00:00
|
|
|
_m[t].m4 = 0;
|
|
|
|
_m[t].m5 = ROAD_TILE_CROSSING << 6 | roaddir;
|
2007-05-20 19:14:08 +00:00
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
2009-03-02 22:57:47 +00:00
|
|
|
_me[t].m7 = rot << 6 | road;
|
|
|
|
SetRoadOwner(t, ROADTYPE_TRAM, tram);
|
2006-02-28 21:19:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-09-10 14:33:07 +00:00
|
|
|
static inline void MakeRoadDepot(TileIndex t, Owner owner, DepotID did, DiagDirection dir, RoadType rt)
|
2006-02-28 21:19:50 +00:00
|
|
|
{
|
2007-07-29 23:42:59 +00:00
|
|
|
SetTileType(t, MP_ROAD);
|
2006-02-28 21:19:50 +00:00
|
|
|
SetTileOwner(t, owner);
|
2009-09-10 14:33:07 +00:00
|
|
|
_m[t].m2 = did;
|
2006-02-28 21:19:50 +00:00
|
|
|
_m[t].m3 = 0;
|
|
|
|
_m[t].m4 = 0;
|
2007-05-20 19:14:08 +00:00
|
|
|
_m[t].m5 = ROAD_TILE_DEPOT << 6 | dir;
|
|
|
|
SB(_m[t].m6, 2, 4, 0);
|
2009-03-02 22:57:47 +00:00
|
|
|
_me[t].m7 = RoadTypeToRoadTypes(rt) << 6 | owner;
|
|
|
|
SetRoadOwner(t, ROADTYPE_TRAM, owner);
|
2006-02-28 21:19:50 +00:00
|
|
|
}
|
|
|
|
|
2006-09-28 18:42:35 +00:00
|
|
|
#endif /* ROAD_MAP_H */
|