From b00b1125bec9c4171c9c9799ccd9577c640cf14d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Tue, 19 Jan 2016 22:37:23 +0000 Subject: [PATCH] Add a dedicated setting to enable ship collision avoidance. --- src/lang/english.txt | 2 ++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/ship_cmd.cpp | 2 +- src/table/settings.ini | 9 +++++++++ 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/lang/english.txt b/src/lang/english.txt index 0bd430bad0..34c266aa01 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1253,6 +1253,8 @@ STR_CONFIG_SETTING_STOP_ON_COMPETITOR_ROAD_HELPTEXT :Allow construct STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Changing this setting is not possible when there are vehicles STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE :Infrastructure maintenance: {STRING2} STR_CONFIG_SETTING_INFRASTRUCTURE_MAINTENANCE_HELPTEXT :When enabled, infrastructure causes maintenance costs. The cost grows over-proportional with the network size, thus affecting bigger companies more than smaller ones +STR_CONFIG_SETTING_SHIP_COLLISION_AVOIDANCE :Ships avoid collisions: {STRING2} +STR_CONFIG_SETTING_SHIP_COLLISION_AVOIDANCE_HELPTEXT :When enabled, ships try to avoid passing through each other. Requires 90° turns to be forbidden. STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS :Airports never expire: {STRING2} STR_CONFIG_SETTING_NEVER_EXPIRE_AIRPORTS_HELPTEXT :Enabling this setting makes each airport type stay available forever after its introduction diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 0652d1bd81..4de3ca7091 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1612,6 +1612,7 @@ static SettingsContainer &GetSettingsTree() physics->Add(new SettingEntry("vehicle.roadveh_slope_steepness")); physics->Add(new SettingEntry("vehicle.smoke_amount")); physics->Add(new SettingEntry("vehicle.plane_speed")); + physics->Add(new SettingEntry("vehicle.ship_collision_avoidance")); } SettingsPage *routing = vehicles->Add(new SettingsPage(STR_CONFIG_SETTING_VEHICLES_ROUTING)); diff --git a/src/settings_type.h b/src/settings_type.h index 41366a7719..31ab3ab46e 100644 --- a/src/settings_type.h +++ b/src/settings_type.h @@ -462,6 +462,7 @@ struct VehicleSettings { byte extend_vehicle_life; ///< extend vehicle life by this many years byte road_side; ///< the side of the road vehicles drive on uint8 plane_crashes; ///< number of plane crashes, 0 = none, 1 = reduced, 2 = normal + bool ship_collision_avoidance; ///< ships try to avoid colliding with each other }; /** Settings related to the economy. */ diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp index cd32f62634..f2085a996a 100644 --- a/src/ship_cmd.cpp +++ b/src/ship_cmd.cpp @@ -620,7 +620,7 @@ static void ShipController(Ship *v) if (track == INVALID_TRACK) goto reverse_direction; /* Try to avoid collision and keep distance between each other. */ - if (_settings_game.pf.forbid_90_deg && DistanceManhattan(v->dest_tile, gp.new_tile) > 3) { + if (_settings_game.pf.forbid_90_deg && _settings_game.vehicle.ship_collision_avoidance && DistanceManhattan(v->dest_tile, gp.new_tile) > 3) { if (HasVehicleOnPos(gp.new_tile, NULL, &FindShipOnTile) || HasVehicleOnPos(TileAddByDiagDir(gp.new_tile, _diagdir_to_next_tile[track][diagdir]), NULL, &FindShipOnTile)) { diff --git a/src/table/settings.ini b/src/table/settings.ini index 3a951f9b62..136e812fb3 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1138,6 +1138,15 @@ strhelp = STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT strval = STR_CONFIG_SETTING_PLANE_CRASHES_NONE cat = SC_BASIC +[SDT_BOOL] +base = GameSettings +var = vehicle.ship_collision_avoidance +def = true +str = STR_CONFIG_SETTING_SHIP_COLLISION_AVOIDANCE +strhelp = STR_CONFIG_SETTING_SHIP_COLLISION_AVOIDANCE_HELPTEXT +patxname = ""ship_collision_avoidance.vehicle.ship_collision_avoidance"" +cat = SC_BASIC + ; station.join_stations [SDT_NULL] length = 1