Add setting to control whether trains can crash with other companies'.

pull/6/merge
Jonathan G Rennison 8 years ago
parent 66bac3808e
commit 1818a83e63

@ -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

@ -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));

@ -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. */

@ -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

@ -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();

Loading…
Cancel
Save