Apply ATC speed restriction as advisory to prevent instant braking
Remove redundant function
This commit is contained in:
@@ -191,7 +191,6 @@ struct Train FINAL : public GroundVehicle<Train, VEH_TRAIN> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int GetAtcMaxSpeed() const;
|
|
||||||
MaxSpeedInfo GetCurrentMaxSpeedInfoInternal(bool update_state) const;
|
MaxSpeedInfo GetCurrentMaxSpeedInfoInternal(bool update_state) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@@ -993,18 +993,6 @@ static void AdvanceLookAheadPosition(Train *v)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Calculates the maximum speed based on any train in front of this train.
|
|
||||||
*/
|
|
||||||
int32 Train::GetAtcMaxSpeed() const
|
|
||||||
{
|
|
||||||
if (!(this->vehstatus & VS_CRASHED) && this->signal_speed_restriction != 0) {
|
|
||||||
return std::max<int32>(25, this->signal_speed_restriction);
|
|
||||||
}
|
|
||||||
|
|
||||||
return INT32_MAX;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calculates the maximum speed information of the vehicle under its current conditions.
|
* Calculates the maximum speed information of the vehicle under its current conditions.
|
||||||
* @return Maximum speed information of the vehicle.
|
* @return Maximum speed information of the vehicle.
|
||||||
@@ -1015,8 +1003,6 @@ Train::MaxSpeedInfo Train::GetCurrentMaxSpeedInfoInternal(bool update_state) con
|
|||||||
this->gcache.cached_max_track_speed :
|
this->gcache.cached_max_track_speed :
|
||||||
std::min<int>(this->tcache.cached_max_curve_speed, this->gcache.cached_max_track_speed);
|
std::min<int>(this->tcache.cached_max_curve_speed, this->gcache.cached_max_track_speed);
|
||||||
|
|
||||||
if (_settings_game.vehicle.train_speed_adaptation) max_speed = std::min<int>(max_speed, GetAtcMaxSpeed());
|
|
||||||
|
|
||||||
if (this->current_order.IsType(OT_LOADING_ADVANCE)) max_speed = std::min(max_speed, 15);
|
if (this->current_order.IsType(OT_LOADING_ADVANCE)) max_speed = std::min(max_speed, 15);
|
||||||
|
|
||||||
int advisory_max_speed = max_speed;
|
int advisory_max_speed = max_speed;
|
||||||
@@ -1080,6 +1066,9 @@ Train::MaxSpeedInfo Train::GetCurrentMaxSpeedInfoInternal(bool update_state) con
|
|||||||
if (this->speed_restriction != 0) {
|
if (this->speed_restriction != 0) {
|
||||||
advisory_max_speed = std::min<int>(advisory_max_speed, this->speed_restriction);
|
advisory_max_speed = std::min<int>(advisory_max_speed, this->speed_restriction);
|
||||||
}
|
}
|
||||||
|
if (this->signal_speed_restriction != 0 && _settings_game.vehicle.train_speed_adaptation) {
|
||||||
|
advisory_max_speed = std::min<int>(advisory_max_speed, this->signal_speed_restriction);
|
||||||
|
}
|
||||||
if (this->reverse_distance > 1) {
|
if (this->reverse_distance > 1) {
|
||||||
advisory_max_speed = std::min<int>(advisory_max_speed, ReversingDistanceTargetSpeed(this));
|
advisory_max_speed = std::min<int>(advisory_max_speed, ReversingDistanceTargetSpeed(this));
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user