diff --git a/docs/newgrf-additions-nml.html b/docs/newgrf-additions-nml.html index dd70450c73..e0ce15ac6a 100644 --- a/docs/newgrf-additions-nml.html +++ b/docs/newgrf-additions-nml.html @@ -175,6 +175,8 @@
This is indicated by the feature name: action0_roadtype_extra_flags, version 1
diff --git a/src/lang/extra/english.txt b/src/lang/extra/english.txt index 3b3b272b5d..850d711c7c 100644 --- a/src/lang/extra/english.txt +++ b/src/lang/extra/english.txt @@ -2026,3 +2026,5 @@ STR_SHIFT_KEY_NAME :{BLACK}Shift STR_CTRL_KEY_NAME :{BLACK}Ctrl STR_MODIFIER_TOGGLE_SHIFT_TOOLTIP :{BLACK}Click to invert state of Shift key STR_MODIFIER_TOGGLE_CTRL_TOOLTIP :{BLACK}Click to invert state of Ctrl key + +STR_ERROR_TUNNEL_DISALLOWED_ROAD :{WHITE}Tunnels not allowed for this road type diff --git a/src/newgrf_extension.cpp b/src/newgrf_extension.cpp index 92803c7c31..477c9da188 100644 --- a/src/newgrf_extension.cpp +++ b/src/newgrf_extension.cpp @@ -38,7 +38,7 @@ extern const GRFFeatureInfo _grf_feature_list[] = { GRFFeatureInfo("action0_railtype_disable_realistic_braking", 1), GRFFeatureInfo("action0_railtype_recolour", 1), GRFFeatureInfo("action0_railtype_extra_aspects", 1), - GRFFeatureInfo("action0_roadtype_extra_flags", 1), + GRFFeatureInfo("action0_roadtype_extra_flags", 2), GRFFeatureInfo("action0_roadtype_collision_mode", 1), GRFFeatureInfo("varaction2_railtype_signal_context", 1), GRFFeatureInfo("action0_global_extra_station_names", 2), diff --git a/src/road.h b/src/road.h index 81b7438072..6abe4d2c4f 100644 --- a/src/road.h +++ b/src/road.h @@ -55,10 +55,9 @@ DECLARE_ENUM_AS_BIT_SET(RoadTypeFlags) enum RoadTypeExtraFlags { RXTF_NOT_AVAILABLE_AI_GS = 0, ///< Bit number for unavailable for AI/GS RXTF_NO_TOWN_MODIFICATION, ///< Bit number for no town modification + RXTF_NO_TUNNELS, ///< Bit number for no tunnels RXTFB_NONE = 0, ///< All flags cleared. - RXTFB_NOT_AVAILABLE_AI_GS = 1 << RXTF_NOT_AVAILABLE_AI_GS, ///< Value for unavailable for AI/GS - RXTFB_NO_TOWN_MODIFICATION = 1 << RXTF_NO_TOWN_MODIFICATION, ///< Value for no town modification }; DECLARE_ENUM_AS_BIT_SET(RoadTypeExtraFlags) @@ -325,6 +324,17 @@ static inline bool RoadNoLevelCrossing(RoadType roadtype) return HasBit(GetRoadTypeInfo(roadtype)->flags, ROTF_NO_LEVEL_CROSSING); } +/** + * Test if road disallows tunnels + * @param roadtype The roadtype we are testing + * @return True iff the roadtype disallows tunnels + */ +static inline bool RoadNoTunnels(RoadType roadtype) +{ + assert(roadtype < ROADTYPE_END); + return HasBit(GetRoadTypeInfo(roadtype)->extra_flags, RXTF_NO_TUNNELS); +} + RoadType GetRoadTypeByLabel(RoadTypeLabel label, bool allow_alternate_labels = true); void ResetRoadTypes(); diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index dc30d09011..0b5515f276 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1330,6 +1330,8 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 /* Only allow building the outer roadbit, so building long roads stops at existing bridges */ if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) goto do_clear; if (HasTileRoadType(tile, rtt)) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if (RoadNoTunnels(rt)) return_cmd_error(STR_ERROR_TUNNEL_DISALLOWED_ROAD); + /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ CommandCost ret = TunnelBridgeIsFree(tile, other_end); if (ret.Failed()) return ret; @@ -3054,6 +3056,10 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 break; case MP_TUNNELBRIDGE: if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) continue; + if (IsTunnel(tile) && RoadNoTunnels(to_type)) { + error.MakeError(STR_ERROR_TUNNEL_DISALLOWED_ROAD); + continue; + } break; default: continue; } diff --git a/src/road_gui.cpp b/src/road_gui.cpp index a2bb493a71..d7cd63183e 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -443,6 +443,7 @@ struct BuildRoadToolbarWindow : Window { } this->GetWidget