From 37a58fd11dcd49d85a02cdb5a7d9639258bd6137 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sun, 20 Nov 2016 01:49:10 +0000 Subject: [PATCH] Add setting to increase station catchment radius. Update acceptance and refresh screen when catchment settings change. --- src/airport_gui.cpp | 4 ++-- src/dock_gui.cpp | 1 + src/lang/english.txt | 2 ++ src/rail_gui.cpp | 1 + src/road_gui.cpp | 1 + src/saveload/extended_ver_sl.cpp | 1 + src/saveload/extended_ver_sl.h | 1 + src/script/api/script_airport.cpp | 2 +- src/script/api/script_station.cpp | 14 ++++++++------ src/script/api/script_tile.cpp | 4 ++-- src/script/api/script_tilelist.cpp | 4 ++-- src/settings.cpp | 3 +++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/station.cpp | 2 ++ src/station_cmd.cpp | 1 + src/table/settings.ini | 14 ++++++++++++++ src/zoning_cmd.cpp | 4 ++-- 18 files changed, 46 insertions(+), 15 deletions(-) diff --git a/src/airport_gui.cpp b/src/airport_gui.cpp index 434cc228fa..2bdd4a2176 100644 --- a/src/airport_gui.cpp +++ b/src/airport_gui.cpp @@ -406,7 +406,7 @@ public: if (_selected_airport_index != -1) { const AirportSpec *as = AirportClass::Get(_selected_airport_class)->GetSpec(_selected_airport_index); - int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED; + int rad = (_settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED) + _settings_game.station.catchment_increase; /* only show the station (airport) noise, if the noise option is activated */ if (_settings_game.economy.station_noise_level) { @@ -457,7 +457,7 @@ public: this->SetWidgetDisabledState(WID_AP_LAYOUT_DECREASE, _selected_airport_layout == 0); this->SetWidgetDisabledState(WID_AP_LAYOUT_INCREASE, _selected_airport_layout + 1 >= as->num_table); - int rad = _settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED; + int rad = (_settings_game.station.modified_catchment ? as->catchment : (uint)CA_UNMODIFIED) + _settings_game.station.catchment_increase; if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); } } diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp index b532380ac5..62dae8d3e4 100644 --- a/src/dock_gui.cpp +++ b/src/dock_gui.cpp @@ -415,6 +415,7 @@ public: virtual void OnPaint() { int rad = (_settings_game.station.modified_catchment) ? CA_DOCK : CA_UNMODIFIED; + rad += _settings_game.station.catchment_increase; this->DrawWidgets(); diff --git a/src/lang/english.txt b/src/lang/english.txt index e98c2695c1..971eb8b557 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1177,6 +1177,8 @@ STR_CONFIG_SETTING_AUTOSLOPE :Allow landscapi STR_CONFIG_SETTING_AUTOSLOPE_HELPTEXT :Allow landscaping under buildings and tracks without removing them STR_CONFIG_SETTING_CATCHMENT :Allow more realistically sized catchment areas: {STRING2} STR_CONFIG_SETTING_CATCHMENT_HELPTEXT :Have differently sized catchment areas for different types of stations and airports +STR_CONFIG_SETTING_CATCHMENT_INCREASE :Increase station catchment radius: {STRING2} +STR_CONFIG_SETTING_CATCHMENT_INCREASE_HELPTEXT :Increase radius of station catchment areas by this many tiles STR_CONFIG_SETTING_EXTRADYNAMITE :Allow removal of more town-owned roads, bridges and tunnels: {STRING2} STR_CONFIG_SETTING_EXTRADYNAMITE_HELPTEXT :Make it easier to remove town-owned infrastructure and buildings STR_CONFIG_SETTING_TRAIN_LENGTH :Maximum length of trains: {STRING2} diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp index 39965c4fb7..38c35d47e8 100644 --- a/src/rail_gui.cpp +++ b/src/rail_gui.cpp @@ -1129,6 +1129,7 @@ public: } int rad = (_settings_game.station.modified_catchment) ? CA_TRAIN : CA_UNMODIFIED; + rad += _settings_game.station.catchment_increase; if (_settings_client.gui.station_show_coverage) SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); diff --git a/src/road_gui.cpp b/src/road_gui.cpp index d530b9d21a..c10cabcc04 100644 --- a/src/road_gui.cpp +++ b/src/road_gui.cpp @@ -984,6 +984,7 @@ struct BuildRoadStationWindow : public PickerWindowBase { this->DrawWidgets(); int rad = _settings_game.station.modified_catchment ? ((this->window_class == WC_BUS_STATION) ? CA_BUS : CA_TRUCK) : CA_UNMODIFIED; + rad += _settings_game.station.catchment_increase; if (_settings_client.gui.station_show_coverage) { SetTileSelectBigSize(-rad, -rad, 2 * rad, 2 * rad); } else { diff --git a/src/saveload/extended_ver_sl.cpp b/src/saveload/extended_ver_sl.cpp index 3a9ddca21d..7685eb10e6 100644 --- a/src/saveload/extended_ver_sl.cpp +++ b/src/saveload/extended_ver_sl.cpp @@ -72,6 +72,7 @@ const SlxiSubChunkInfo _sl_xv_sub_chunk_infos[] = { { XSLFI_MORE_RAIL_TYPES, XSCF_NULL, 1, 1, "more_rail_types", NULL, NULL, NULL }, { XSLFI_CARGO_TYPE_ORDERS, XSCF_NULL, 2, 2, "cargo_type_orders", NULL, NULL, "ORDX,VEOX" }, { XSLFI_EXTENDED_GAMELOG, XSCF_NULL, 1, 1, "extended_gamelog", NULL, NULL, NULL }, + { XSLFI_STATION_CATCHMENT_INC, XSCF_NULL, 1, 1, "station_catchment_inc", NULL, NULL, NULL }, { XSLFI_NULL, XSCF_NULL, 0, 0, NULL, NULL, NULL, NULL },// This is the end marker }; diff --git a/src/saveload/extended_ver_sl.h b/src/saveload/extended_ver_sl.h index 88ec923f37..938672918b 100644 --- a/src/saveload/extended_ver_sl.h +++ b/src/saveload/extended_ver_sl.h @@ -46,6 +46,7 @@ enum SlXvFeatureIndex { XSLFI_MORE_RAIL_TYPES, ///< Increased number of rail types XSLFI_CARGO_TYPE_ORDERS, ///< Cargo-specific load/unload order flags XSLFI_EXTENDED_GAMELOG, ///< Extended gamelog + XSLFI_STATION_CATCHMENT_INC, ///< Station catchment radius increase XSLFI_RIFF_HEADER_60_BIT, ///< Size field in RIFF chunk header is 60 bit XSLFI_HEIGHT_8_BIT, ///< Map tile height is 8 bit instead of 4 bit, but savegame version may be before this became true in trunk diff --git a/src/script/api/script_airport.cpp b/src/script/api/script_airport.cpp index edb912609e..f478513ac5 100644 --- a/src/script/api/script_airport.cpp +++ b/src/script/api/script_airport.cpp @@ -67,7 +67,7 @@ { if (!IsAirportInformationAvailable(type)) return -1; - return _settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED; + return (_settings_game.station.modified_catchment ? ::AirportSpec::Get(type)->catchment : (uint)CA_UNMODIFIED) + _settings_game.station.catchment_increase; } /* static */ bool ScriptAirport::BuildAirport(TileIndex tile, AirportType type, StationID station_id) diff --git a/src/script/api/script_station.cpp b/src/script/api/script_station.cpp index 5ed43e0a67..0c9836450a 100644 --- a/src/script/api/script_station.cpp +++ b/src/script/api/script_station.cpp @@ -159,14 +159,16 @@ template if (station_type == STATION_AIRPORT) return -1; if (!HasExactlyOneBit(station_type)) return -1; - if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED; + const int32 inc = _settings_game.station.catchment_increase; + + if (!_settings_game.station.modified_catchment) return CA_UNMODIFIED + inc; switch (station_type) { - case STATION_TRAIN: return CA_TRAIN; - case STATION_TRUCK_STOP: return CA_TRUCK; - case STATION_BUS_STOP: return CA_BUS; - case STATION_DOCK: return CA_DOCK; - default: return CA_NONE; + case STATION_TRAIN: return CA_TRAIN + inc; + case STATION_TRUCK_STOP: return CA_TRUCK + inc; + case STATION_BUS_STOP: return CA_BUS + inc; + case STATION_DOCK: return CA_DOCK + inc; + default: return CA_NONE + inc; } } diff --git a/src/script/api/script_tile.cpp b/src/script/api/script_tile.cpp index db9220acd6..3a5f3ea40d 100644 --- a/src/script/api/script_tile.cpp +++ b/src/script/api/script_tile.cpp @@ -208,7 +208,7 @@ { if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1; - CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); + CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED + _settings_game.station.catchment_increase); return acceptance[cargo_type]; } @@ -216,7 +216,7 @@ { if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !ScriptCargo::IsValidCargo(cargo_type)) return -1; - CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED); + CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED + _settings_game.station.catchment_increase); return produced[cargo_type]; } diff --git a/src/script/api/script_tilelist.cpp b/src/script/api/script_tilelist.cpp index 933a92c4cb..6c4e7abec9 100644 --- a/src/script/api/script_tilelist.cpp +++ b/src/script/api/script_tilelist.cpp @@ -64,7 +64,7 @@ ScriptTileList_IndustryAccepting::ScriptTileList_IndustryAccepting(IndustryID in if (!cargo_accepts) return; } - if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED; + if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED + _settings_game.station.catchment_increase; TileArea ta(i->location.tile - ::TileDiffXY(radius, radius), i->location.w + radius * 2, i->location.h + radius * 2); TILE_AREA_LOOP(cur_tile, ta) { @@ -100,7 +100,7 @@ ScriptTileList_IndustryProducing::ScriptTileList_IndustryProducing(IndustryID in } if (!cargo_produces) return; - if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED; + if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED + _settings_game.station.catchment_increase; TileArea ta(i->location.tile - ::TileDiffXY(radius, radius), i->location.w + radius * 2, i->location.h + radius * 2); TILE_AREA_LOOP(cur_tile, ta) { diff --git a/src/settings.cpp b/src/settings.cpp index 03af43b952..d7be94a9f0 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -1317,6 +1317,9 @@ static bool ChangeMaxHeightLevel(int32 p1) static bool StationCatchmentChanged(int32 p1) { Station::RecomputeIndustriesNearForAll(); + Station *st; + FOR_ALL_STATIONS(st) UpdateStationAcceptance(st, true); + MarkWholeScreenDirty(); return true; } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a536d94bee..56e0495424 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1801,6 +1801,7 @@ static SettingsContainer &GetSettingsTree() } environment->Add(new SettingEntry("station.modified_catchment")); + environment->Add(new SettingEntry("station.catchment_increase")); } SettingsPage *ai = main->Add(new SettingsPage(STR_CONFIG_SETTING_AI)); diff --git a/src/settings_type.h b/src/settings_type.h index e827b1a311..97c2256a4b 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -578,6 +578,7 @@ struct StationSettings { bool distant_join_stations; ///< allow to join non-adjacent stations bool never_expire_airports; ///< never expire airports byte station_spread; ///< amount a station may spread + byte catchment_increase; ///< amount by which station catchment is increased }; /** Default settings for vehicles. */ diff --git a/src/station.cpp b/src/station.cpp index c8f587bed4..f0124f1f99 100644 --- a/src/station.cpp +++ b/src/station.cpp @@ -288,6 +288,8 @@ uint Station::GetCatchmentRadius() const } } + if (ret != CA_NONE) ret += _settings_game.station.catchment_increase; + return ret; } diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp index 1d878d2ee8..97ba4f14fa 100644 --- a/src/station_cmd.cpp +++ b/src/station_cmd.cpp @@ -3866,6 +3866,7 @@ void FindStationsAroundTiles(const TileArea &location, StationList *stations) { /* area to search = producer plus station catchment radius */ uint max_rad = (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED); + max_rad += _settings_game.station.catchment_increase; uint x = TileX(location.tile); uint y = TileY(location.tile); diff --git a/src/table/settings.ini b/src/table/settings.ini index f43c53237c..71807996a1 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1358,6 +1358,20 @@ strhelp = STR_CONFIG_SETTING_CATCHMENT_HELPTEXT proc = StationCatchmentChanged cat = SC_EXPERT +[SDT_VAR] +base = GameSettings +var = station.catchment_increase +type = SLE_UINT8 +def = 0 +min = 0 +max = 5 +str = STR_CONFIG_SETTING_CATCHMENT_INCREASE +strhelp = STR_CONFIG_SETTING_CATCHMENT_INCREASE_HELPTEXT +strval = STR_JUST_COMMA +proc = StationCatchmentChanged +extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_STATION_CATCHMENT_INC) +patxname = ""station_catchment_inc.station.catchment_increase"" + [SDT_BOOL] base = GameSettings var = order.gradual_loading diff --git a/src/zoning_cmd.cpp b/src/zoning_cmd.cpp index d347ad5474..37d80fd461 100644 --- a/src/zoning_cmd.cpp +++ b/src/zoning_cmd.cpp @@ -60,7 +60,7 @@ void DrawZoningSprites(SpriteID image, SpriteID colour, const TileInfo *ti) */ bool IsAreaWithinAcceptanceZoneOfStation(TileArea area, Owner owner, StationFacility facility_mask) { - int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED); + int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED) + _settings_game.station.catchment_increase; StationFinder morestations(TileArea(TileXY(TileX(area.tile) - (catchment / 2), TileY(area.tile) - (catchment / 2)), TileX(area.tile) + area.w + catchment, TileY(area.tile) + area.h + catchment)); @@ -90,7 +90,7 @@ bool IsAreaWithinAcceptanceZoneOfStation(TileArea area, Owner owner, StationFaci */ bool IsTileWithinAcceptanceZoneOfStation(TileIndex tile, Owner owner, StationFacility facility_mask, bool open_window_only) { - int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED); + int catchment = _settings_game.station.station_spread + (_settings_game.station.modified_catchment ? MAX_CATCHMENT : CA_UNMODIFIED) + _settings_game.station.catchment_increase; StationFinder morestations(TileArea(TileXY(TileX(tile) - (catchment / 2), TileY(tile) - (catchment / 2)), catchment, catchment));