diff --git a/src/genworld.cpp b/src/genworld.cpp index 531c51e1a8..97c6bab0ac 100644 --- a/src/genworld.cpp +++ b/src/genworld.cpp @@ -46,7 +46,7 @@ void GenerateClearTile(); void GenerateIndustries(); void GenerateObjects(); void GenerateTrees(); -void GeneratePublicRoads(); +extern void GeneratePublicRoads(PublicRoadsConstruction build_mode); void StartupEconomy(); void StartupCompanies(); @@ -157,7 +157,7 @@ static void _GenerateWorld() GenerateIndustries(); GenerateObjects(); GenerateTrees(); - GeneratePublicRoads(); + GeneratePublicRoads(_settings_game.game_creation.build_public_roads); } } diff --git a/src/road.cpp b/src/road.cpp index 46ace8cc4b..b4c27367cb 100644 --- a/src/road.cpp +++ b/src/road.cpp @@ -309,6 +309,7 @@ CommandCost CmdBuildRoad(TileIndex tile, DoCommandFlag flags, uint32_t p1, uint3 static RoadType _public_road_type; static const uint _public_road_hash_size = 8U; ///< The number of bits the hash for river finding should have. +static PublicRoadsConstruction _public_road_mode = PRC_NONE; /** Helper function to check if a slope along a certain direction is going up an inclined slope. */ static bool IsUpwardsSlope(const Slope slope, DiagDirection road_direction) @@ -893,7 +894,7 @@ static int32_t PublicRoad_CalculateG(AyStar *, AyStarNode *current, OpenListNode } } - if (_settings_game.game_creation.build_public_roads == PRC_AVOID_CURVES && + if (_public_road_mode == PRC_AVOID_CURVES && parent->path.parent != nullptr && DiagdirBetweenTiles(parent->path.parent->node.tile, parent->path.node.tile) != DiagdirBetweenTiles(parent->path.node.tile, current->tile)) { cost += 1; @@ -977,9 +978,11 @@ void PostProcessNetworks(AyStar &finder, const std::vector towns; towns.clear(); diff --git a/src/settings.cpp b/src/settings.cpp index f7f5f5fdd5..c5ff2dcddb 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1775,10 +1775,6 @@ static void ChangeTrackTypeSortMode(int32_t new_value) { MarkWholeScreenDirty(); } -static void PublicRoadsSettingChange(int32_t new_value) { - InvalidateWindowClassesData(WC_SCEN_LAND_GEN); -} - static void TrainSpeedAdaptationChanged(int32_t new_value) { extern void ClearAllSignalSpeedRestrictions(); ClearAllSignalSpeedRestrictions(); diff --git a/src/table/settings/world_settings.ini b/src/table/settings/world_settings.ini index 9be7067d0f..a5db7ee9cc 100644 --- a/src/table/settings/world_settings.ini +++ b/src/table/settings/world_settings.ini @@ -16,7 +16,6 @@ static void UpdateFreeformEdges(int32_t new_value); static bool CheckMapEdgeMode(int32_t &new_value); static void MapEdgeModeChanged(int32_t new_value); static void ClimateThresholdModeChanged(int32_t new_value); -static void PublicRoadsSettingChange(int32_t new_value); static void MarkAllViewportsDirty(int32_t new_value); static bool AllowRoadStopsUnderBridgesSettingGUI(SettingOnGuiCtrlData &data); @@ -500,7 +499,6 @@ max = PRC_END - 1 str = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS strhelp = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_HELPTEXT strval = STR_CONFIG_SETTING_BUILD_PUBLIC_ROADS_NONE -post_cb = PublicRoadsSettingChange patxname = ""public_roads.game_creation.build_public_roads"" [SDT_VAR] diff --git a/src/terraform_gui.cpp b/src/terraform_gui.cpp index 64966ca6ef..fe8846d400 100644 --- a/src/terraform_gui.cpp +++ b/src/terraform_gui.cpp @@ -563,10 +563,8 @@ static constexpr NWidgetPart _nested_scen_edit_land_gen_widgets[] = { SetFill(1, 0), SetDataTip(STR_TERRAFORM_SE_NEW_WORLD, STR_TERRAFORM_TOOLTIP_GENERATE_RANDOM_LAND), SetPadding(0, 2, 0, 2), NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_RESET_LANDSCAPE), SetMinimalSize(160, 12), SetFill(1, 0), SetDataTip(STR_TERRAFORM_RESET_LANDSCAPE, STR_TERRAFORM_RESET_LANDSCAPE_TOOLTIP), SetPadding(1, 2, 0, 2), - NWidget(NWID_SELECTION, INVALID_COLOUR, WID_ETT_SHOW_PUBLIC_ROADS), - NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_PUBLIC_ROADS), SetMinimalSize(160, 12), - SetFill(1, 0), SetDataTip(STR_TERRAFORM_PUBLIC_ROADS, STR_TERRAFORM_PUBLIC_ROADS_TOOLTIP), SetPadding(1, 2, 0, 2), - EndContainer(), + NWidget(WWT_TEXTBTN, COLOUR_GREY, WID_ETT_PUBLIC_ROADS), SetMinimalSize(160, 12), + SetFill(1, 0), SetDataTip(STR_TERRAFORM_PUBLIC_ROADS, STR_TERRAFORM_PUBLIC_ROADS_TOOLTIP), SetPadding(1, 2, 0, 2), NWidget(NWID_SPACER), SetMinimalSize(0, 2), EndContainer(), }; @@ -713,8 +711,10 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { break; case WID_ETT_PUBLIC_ROADS: { // Build public roads - extern void GeneratePublicRoads(); - GeneratePublicRoads(); + extern void GeneratePublicRoads(PublicRoadsConstruction build_mode); + PublicRoadsConstruction build_mode = _settings_game.game_creation.build_public_roads; + if (build_mode == PRC_NONE) build_mode = PRC_WITH_CURVES; + GeneratePublicRoads(build_mode); break; } @@ -807,8 +807,6 @@ struct ScenarioEditorLandscapeGenerationWindow : Window { { NWidgetStacked *show_desert = this->GetWidget(WID_ETT_SHOW_PLACE_DESERT); show_desert->SetDisplayedPlane(_settings_game.game_creation.landscape == LT_TROPIC ? 0 : SZSP_NONE); - NWidgetStacked *show_public_roads = this->GetWidget(WID_ETT_SHOW_PUBLIC_ROADS); - show_public_roads->SetDisplayedPlane(_settings_game.game_creation.build_public_roads != 0 ? 0 : SZSP_NONE); } static HotkeyList hotkeys; diff --git a/src/widgets/terraform_widget.h b/src/widgets/terraform_widget.h index 9c47c3db6b..06acc86c3a 100644 --- a/src/widgets/terraform_widget.h +++ b/src/widgets/terraform_widget.h @@ -30,7 +30,6 @@ enum TerraformToolbarWidgets : WidgetID { /** Widgets of the #ScenarioEditorLandscapeGenerationWindow class. */ enum EditorTerraformToolbarWidgets : WidgetID { WID_ETT_SHOW_PLACE_DESERT, ///< Should the place desert button be shown? - WID_ETT_SHOW_PUBLIC_ROADS, ///< Should the public roads button be shown? WID_ETT_START, ///< Used for iterations. WID_ETT_DOTS = WID_ETT_START, ///< Invisible widget for rendering the terraform size on. WID_ETT_BUTTONS_START, ///< Start of pushable buttons.