From 495aa729df3944245ab0dbfcccb1a69aa909b632 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 25 Feb 2016 18:39:04 +0000 Subject: [PATCH 1/2] Fix VehicleCargoList::Truncate when not all cargo is MTA_KEEP. --- src/cargopacket.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cargopacket.cpp b/src/cargopacket.cpp index 9b96be62eb..22d0acd139 100644 --- a/src/cargopacket.cpp +++ b/src/cargopacket.cpp @@ -658,6 +658,7 @@ uint VehicleCargoList::Unload(uint max_move, StationCargoList *dest, CargoPaymen uint VehicleCargoList::Truncate(uint max_move) { max_move = min(this->count, max_move); + if (max_move > this->ActionCount(MTA_KEEP)) this->KeepAll(); this->PopCargo(CargoRemoval(this, max_move)); return max_move; } From 1818a83e6364b1bd2f33d6954c54c3a6e3e65648 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Thu, 25 Feb 2016 22:08:27 +0000 Subject: [PATCH 2/2] Add setting to control whether trains can crash with other companies'. --- src/lang/english.txt | 3 +++ src/settings_gui.cpp | 1 + src/settings_type.h | 1 + src/table/settings.ini | 9 +++++++++ src/train_cmd.cpp | 5 +++++ 5 files changed, 19 insertions(+) diff --git a/src/lang/english.txt b/src/lang/english.txt index be6c9a58ed..af09552caa 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -1254,6 +1254,9 @@ STR_CONFIG_SETTING_DYNAMIC_ENGINES_EXISTING_VEHICLES :{WHITE}Changing 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_NO_TRAIN_CRASH_OTHER_COMPANY :Trains from different companies may not crash into each other: {STRING2} +STR_CONFIG_SETTING_NO_TRAIN_CRASH_OTHER_COMPANY_HELPTEXT :This setting is primarily to prevent untrusted players deliberately causing crashes involving other companies' trains in multi-player rail infrastructure sharing games. + 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 bbeadd90f4..1c5e0539fb 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -1661,6 +1661,7 @@ static SettingsContainer &GetSettingsTree() disasters->Add(new SettingEntry("difficulty.economy")); disasters->Add(new SettingEntry("difficulty.vehicle_breakdowns")); disasters->Add(new SettingEntry("vehicle.plane_crashes")); + disasters->Add(new SettingEntry("vehicle.no_train_crash_other_company")); } SettingsPage *genworld = main->Add(new SettingsPage(STR_CONFIG_SETTING_GENWORLD)); diff --git a/src/settings_type.h b/src/settings_type.h index 864d26fee5..c1281d48d2 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 no_train_crash_other_company; ///< trains cannot crash with trains from other companies }; /** Settings related to the economy. */ diff --git a/src/table/settings.ini b/src/table/settings.ini index eaa9b8ccc2..a13ce3c669 100644 --- a/src/table/settings.ini +++ b/src/table/settings.ini @@ -1142,6 +1142,15 @@ strhelp = STR_CONFIG_SETTING_PLANE_CRASHES_HELPTEXT strval = STR_CONFIG_SETTING_PLANE_CRASHES_NONE cat = SC_BASIC +[SDT_BOOL] +base = GameSettings +var = vehicle.no_train_crash_other_company +def = false +str = STR_CONFIG_SETTING_NO_TRAIN_CRASH_OTHER_COMPANY +strhelp = STR_CONFIG_SETTING_NO_TRAIN_CRASH_OTHER_COMPANY_HELPTEXT +extver = SlXvFeatureTest(XSLFTO_AND, XSLFI_INFRA_SHARING) +patxname = ""infra_sharing.vehicle.no_train_crash_other_company"" + ; station.join_stations [SDT_NULL] length = 1 diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index d1448e60e6..f8e560cab8 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3011,6 +3011,11 @@ static Vehicle *FindTrainCollideEnum(Vehicle *v, void *data) /* not a train or in depot */ if (v->type != VEH_TRAIN || Train::From(v)->track == TRACK_BIT_DEPOT) return NULL; + if (_settings_game.vehicle.no_train_crash_other_company) { + /* do not crash into trains of another company. */ + if (v->owner != tcc->v->owner) return NULL; + } + /* get first vehicle now to make most usual checks faster */ Train *coll = Train::From(v)->First();