tron@3069: /* $Id$ */ tron@3069: tron@3518: #ifndef ROAD_H tron@3518: #define ROAD_H tron@3069: rubidium@5838: #include "helpers.hpp" rubidium@5838: rubidium@6574: enum RoadBits { rubidium@5838: ROAD_NONE = 0U, peter1138@3795: ROAD_NW = 1U, peter1138@3795: ROAD_SW = 2U, peter1138@3795: ROAD_SE = 4U, peter1138@3795: ROAD_NE = 8U, tron@3069: ROAD_X = ROAD_SW | ROAD_NE, tron@3069: ROAD_Y = ROAD_NW | ROAD_SE, tron@3069: ROAD_ALL = ROAD_X | ROAD_Y rubidium@6574: }; tron@3069: rubidium@5838: DECLARE_ENUM_AS_BIT_SET(RoadBits); rubidium@5838: tron@3103: static inline RoadBits ComplementRoadBits(RoadBits r) tron@3103: { KUDr@3900: return (RoadBits)(ROAD_ALL ^ r); tron@3103: } tron@3103: tron@3146: static inline RoadBits DiagDirToRoadBits(DiagDirection d) tron@3146: { KUDr@3900: return (RoadBits)(1U << (3 ^ d)); tron@3146: } tron@3146: rubidium@6335: /** Checks whether the trackdir means that we are reversing */ rubidium@6335: static inline bool IsReversingRoadTrackdir(Trackdir dir) rubidium@6335: { rubidium@6335: return (dir & 0x07) >= 6; rubidium@6335: } rubidium@6335: rubidium@6335: /** Checks whether the given trackdir is a straight road */ rubidium@6335: static inline bool IsStraightRoadTrackdir(Trackdir dir) rubidium@6335: { rubidium@6335: return (dir & 0x06) == 0; rubidium@6335: } rubidium@6335: rubidium@6442: /** rubidium@6442: * Is it allowed to remove the given road bits from the given tile? rubidium@6442: * @param tile the tile to remove the road from rubidium@6442: * @param remove the roadbits that are going to be removed rubidium@6442: * @param owner the actual owner of the roadbits of the tile rubidium@6442: * @param edge_road are the removed bits from a town? rubidium@6442: * @return true when it is allowed to remove the road bits rubidium@6442: */ rubidium@6442: bool CheckAllowRemoveRoad(TileIndex tile, RoadBits remove, Owner owner, bool *edge_road); rubidium@6442: peter1138@4666: #endif /* ROAD_H */