Merge branch 'improved_breakdowns-sx' into jgrpp
# Conflicts: # src/saveload/extended_ver_sl.cpp # src/settings.cpp
This commit is contained in:
@@ -132,7 +132,7 @@ void CheckTrainsLengths()
|
||||
void CheckBreakdownFlags(Train *v)
|
||||
{
|
||||
assert(v->IsFrontEngine());
|
||||
/* clear the flags we're gonna check first, we'll set them again later (if applicable ) */
|
||||
/* clear the flags we're gonna check first, we'll set them again later (if applicable) */
|
||||
CLRBITS(v->flags, (1 << VRF_BREAKDOWN_BRAKING) | VRF_IS_BROKEN);
|
||||
|
||||
for (const Train *w = v; w != NULL; w = w->Next()) {
|
||||
@@ -151,6 +151,17 @@ void CheckBreakdownFlags(Train *v)
|
||||
}
|
||||
}
|
||||
|
||||
uint16 GetTrainVehicleMaxSpeed(const Train *u, const RailVehicleInfo *rvi_u, const Train *front)
|
||||
{
|
||||
uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed);
|
||||
if (HasBit(u->flags, VRF_NEED_REPAIR) && front->IsFrontEngine()) {
|
||||
for (uint i = 0; i < u->critical_breakdown_count; i++) {
|
||||
speed = min(speed - (speed / (front->tcache.cached_num_engines + 2)) + 1, speed);
|
||||
}
|
||||
}
|
||||
return speed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recalculates the cached stuff of a train. Should be called each time a vehicle is added
|
||||
* to/removed from the chain, and when the game is loaded.
|
||||
@@ -241,12 +252,7 @@ void Train::ConsistChanged(ConsistChangeFlags allowed_changes)
|
||||
|
||||
/* max speed is the minimum of the speed limits of all vehicles in the consist */
|
||||
if ((rvi_u->railveh_type != RAILVEH_WAGON || _settings_game.vehicle.wagon_speed_limits) && !UsesWagonOverride(u)) {
|
||||
uint16 speed = GetVehicleProperty(u, PROP_TRAIN_SPEED, rvi_u->max_speed);
|
||||
if (HasBit(u->flags, VRF_NEED_REPAIR) && this->IsFrontEngine()) {
|
||||
for (uint i = 0; i < u->critical_breakdown_count; i++) {
|
||||
speed = min(speed - (speed / (this->tcache.cached_num_engines + 2)) + 1, speed);
|
||||
}
|
||||
}
|
||||
uint16 speed = GetTrainVehicleMaxSpeed(u, rvi_u, this);
|
||||
if (speed != 0) max_speed = min(speed, max_speed);
|
||||
}
|
||||
}
|
||||
@@ -495,10 +501,8 @@ void Train::UpdateAcceleration()
|
||||
|
||||
if (_settings_game.vehicle.improved_breakdowns) {
|
||||
if (_settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) {
|
||||
this->breakdown_chance = max(128 * 3 / (this->tcache.cached_num_engines + 2), 5);
|
||||
this->breakdown_chance_factor = max(128 * 3 / (this->tcache.cached_num_engines + 2), 5);
|
||||
}
|
||||
} else {
|
||||
this->breakdown_chance = 128;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4440,7 +4444,6 @@ void Train::OnNewDay()
|
||||
if ((++this->day_counter & 7) == 0) DecreaseVehicleValue(this);
|
||||
|
||||
if (this->IsFrontEngine()) {
|
||||
|
||||
CheckIfTrainNeedsService(this);
|
||||
|
||||
CheckOrders(this);
|
||||
@@ -4467,7 +4470,7 @@ void Train::OnNewDay()
|
||||
SetWindowClassesDirty(WC_TRAINS_LIST);
|
||||
}
|
||||
}
|
||||
if(IsEngine() || IsMultiheaded()) {
|
||||
if (IsEngine() || IsMultiheaded()) {
|
||||
CheckVehicleBreakdown(this);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user