summaryrefslogtreecommitdiff
path: root/road_map.h
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2006-04-03 13:35:19 +0000
committercelestar <celestar@openttd.org>2006-04-03 13:35:19 +0000
commit369ad5a573cfe7d4ccb130981517dd6ef3d3e9c7 (patch)
tree93c53a787280ccee680cbdae3070c9cf858a75dd /road_map.h
parentc6aac81a9d3c56884b66df36688b6823bf52ea76 (diff)
downloadopenttd-369ad5a573cfe7d4ccb130981517dd6ef3d3e9c7.tar.xz
(svn r4258) -Codechange: Add and make use of map accessors dealing with road ground types (including roadworks).
Diffstat (limited to 'road_map.h')
-rw-r--r--road_map.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/road_map.h b/road_map.h
index e06afcd5c..d7858cfc9 100644
--- a/road_map.h
+++ b/road_map.h
@@ -102,6 +102,72 @@ static inline bool IsCrossingBarred(TileIndex t)
return HASBIT(_m[t].m5, 2);
}
+#define IsOnDesert IsOnSnow
+static inline bool IsOnSnow(TileIndex t)
+{
+ return HASBIT(_m[t].m4, 7);
+}
+
+#define ToggleDesert ToggleSnow
+static inline void ToggleSnow(TileIndex t)
+{
+ TOGGLEBIT(_m[t].m4, 7);
+}
+
+typedef enum RoadGroundType {
+ RGT_BARREN,
+ RGT_GRASS,
+ RGT_PAVED,
+ RGT_LIGHT,
+ RGT_NOT_IN_USE, /* Has something to do with fund buildings */
+ RGT_ALLEY,
+ RGT_ROADWORK_GRASS,
+ RGT_ROADWORK_PAVED,
+
+ RGT_ROADWORK_OFFSET = RGT_ROADWORK_GRASS - RGT_GRASS
+} RoadGroundType;
+
+static inline RoadGroundType GetGroundType(TileIndex t)
+{
+ return (RoadGroundType)GB(_m[t].m4, 4, 3);
+}
+
+static inline void SetGroundType(TileIndex t, RoadGroundType rgt)
+{
+ SB(_m[t].m4, 4, 3, rgt);
+}
+
+static inline bool HasRoadWorks(TileIndex t)
+{
+ return GetGroundType(t) >= RGT_ROADWORK_GRASS;
+}
+
+static inline bool IncreaseRoadWorksCounter(TileIndex t)
+{
+ AB(_m[t].m4, 0, 4, 1);
+
+ return GB(_m[t].m4, 0, 4) == 15;
+}
+
+static inline void StartRoadWorks(TileIndex t)
+{
+ assert(!HasRoadWorks(t));
+ /* Remove any trees or lamps in case or roadwork */
+ SetGroundType(t, min(GetGroundType(t), RGT_PAVED) + RGT_ROADWORK_OFFSET);
+}
+
+static inline void TerminateRoadWorks(TileIndex t)
+{
+ assert(HasRoadWorks(t));
+ SetGroundType(t, GetGroundType(t) - RGT_ROADWORK_OFFSET);
+ /* Stop the counter */
+ SB(_m[t].m4, 0, 4, 0);
+}
+
+static inline bool HasPavement(TileIndex t)
+{
+ return GetGroundType(t) >= RGT_PAVED && GetGroundType(t) != RGT_ROADWORK_GRASS;
+}
static inline DiagDirection GetRoadDepotDirection(TileIndex t)
{