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 @@
Scripts (AI/GS) may not build this roadtype
NO_TOWN_MODIFY
Towns may not modify tiles of this roadtype in any way whatsoever
+
NO_TUNNELS
+
Disallow tunnels for this roadtype
@@ -202,6 +204,8 @@
Scripts (AI/GS) may not build this tramtype
NO_TOWN_MODIFY
Towns may not modify tiles of this tramtype in any way whatsoever
+
NO_TUNNELS
+
Disallow tunnels for this tramtype
diff --git a/docs/newgrf-additions.html b/docs/newgrf-additions.html index 2216d80fbf..5eb3d14c89 100644 --- a/docs/newgrf-additions.html +++ b/docs/newgrf-additions.html @@ -327,6 +327,8 @@ BitValueMeaning 01Scripts (AI/GS) may not build this road/tram type 12Towns may not modify tiles of this road/tram type in any way whatsoever + 24Disallow tunnels for this road/tram type
+ Support for this bit is indicated by the feature name: action0_roadtype_extra_flags, version 2.

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(WID_ROT_CONVERT_ROAD)->widget_data = rti->gui_sprites.convert_road; this->GetWidget(WID_ROT_BUILD_TUNNEL)->widget_data = rti->gui_sprites.build_tunnel; + if (HasBit(rti->extra_flags, RXTF_NO_TUNNELS)) this->DisableWidget(WID_ROT_BUILD_TUNNEL); } /** diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 72bac726f1..553e67df0e 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -1791,9 +1791,10 @@ class NIHRoadType : public NIHelper { HasBit(rti->flags, ROTF_HIDDEN) ? 'h' : '-', HasBit(rti->flags, ROTF_TOWN_BUILD) ? 'T' : '-'); output.print(buffer); - seprintf(buffer, lastof(buffer), " Extra Flags: %c%c", + seprintf(buffer, lastof(buffer), " Extra Flags: %c%c%c", HasBit(rti->extra_flags, RXTF_NOT_AVAILABLE_AI_GS) ? 's' : '-', - HasBit(rti->extra_flags, RXTF_NO_TOWN_MODIFICATION) ? 't' : '-'); + HasBit(rti->extra_flags, RXTF_NO_TOWN_MODIFICATION) ? 't' : '-', + HasBit(rti->extra_flags, RXTF_NO_TUNNELS) ? 'T' : '-'); output.print(buffer); seprintf(buffer, lastof(buffer), " Collision mode: %u", rti->collision_mode); output.print(buffer); diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index c7d65720ff..85d0d27adf 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -966,6 +966,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1, case TRANSPORT_ROAD: roadtype = Extract(p1); if (!ValParamRoadType(roadtype)) return CMD_ERROR; + if (RoadNoTunnels(roadtype)) return_cmd_error(STR_ERROR_TUNNEL_DISALLOWED_ROAD); break; default: return CMD_ERROR;