summaryrefslogtreecommitdiff
path: root/src/rail.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/rail.h')
-rw-r--r--src/rail.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/rail.h b/src/rail.h
index eec87bfb3..ac5805d09 100644
--- a/src/rail.h
+++ b/src/rail.h
@@ -21,6 +21,7 @@
#include "strings_type.h"
#include "date_type.h"
#include "signal_type.h"
+#include "settings_type.h"
/** Railtype flags. */
enum RailTypeFlags {
@@ -28,12 +29,16 @@ enum RailTypeFlags {
RTF_NO_LEVEL_CROSSING = 1, ///< Bit number for disallowing level crossings.
RTF_HIDDEN = 2, ///< Bit number for hiding from selection.
RTF_NO_SPRITE_COMBINE = 3, ///< Bit number for using non-combined junctions.
+ RTF_ALLOW_90DEG = 4, ///< Bit number for always allowed 90 degree turns, regardless of setting.
+ RTF_DISALLOW_90DEG = 5, ///< Bit number for never allowed 90 degree turns, regardless of setting.
RTFB_NONE = 0, ///< All flags cleared.
RTFB_CATENARY = 1 << RTF_CATENARY, ///< Value for drawing a catenary.
RTFB_NO_LEVEL_CROSSING = 1 << RTF_NO_LEVEL_CROSSING, ///< Value for disallowing level crossings.
RTFB_HIDDEN = 1 << RTF_HIDDEN, ///< Value for hiding from selection.
RTFB_NO_SPRITE_COMBINE = 1 << RTF_NO_SPRITE_COMBINE, ///< Value for using non-combined junctions.
+ RTFB_ALLOW_90DEG = 1 << RTF_ALLOW_90DEG, ///< Value for always allowed 90 degree turns, regardless of setting.
+ RTFB_DISALLOW_90DEG = 1 << RTF_DISALLOW_90DEG, ///< Value for never allowed 90 degree turns, regardless of setting.
};
DECLARE_ENUM_AS_BIT_SET(RailTypeFlags)
@@ -342,6 +347,26 @@ static inline bool RailNoLevelCrossings(RailType rt)
}
/**
+ * Test if 90 degree turns are disallowed between two railtypes.
+ * @param rt1 First railtype to test for.
+ * @param rt2 Second railtype to test for.
+ * @param def Default value to use if the rail type doesn't specify anything.
+ * @return True if 90 degree turns are disallowed between the two rail types.
+ */
+static inline bool Rail90DegTurnDisallowed(RailType rt1, RailType rt2, bool def = _settings_game.pf.forbid_90_deg)
+{
+ if (rt1 == INVALID_RAILTYPE || rt2 == INVALID_RAILTYPE) return def;
+
+ const RailtypeInfo *rti1 = GetRailTypeInfo(rt1);
+ const RailtypeInfo *rti2 = GetRailTypeInfo(rt2);
+
+ bool rt1_90deg = HasBit(rti1->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti1->flags, RTF_ALLOW_90DEG) && def);
+ bool rt2_90deg = HasBit(rti2->flags, RTF_DISALLOW_90DEG) || (!HasBit(rti2->flags, RTF_ALLOW_90DEG) && def);
+
+ return rt1_90deg || rt2_90deg;
+}
+
+/**
* Returns the cost of building the specified railtype.
* @param railtype The railtype being built.
* @return The cost multiplier.