Improved breakdowns: Various changes and fixes.

* Revert breakdown_chance to (mostly) its original behaviour.
* Create a new breakdown_chance_factor to hold breakdown_chance
  from improved breakdowns logic.
* Revert airport crash probabilities back to original behaviour, with
  modified behaviour only during emergency landings.
* Low power breakdowns now only reduce the power of the engine which
  has broken down.
* Low power breakdowns no longer reduce speed directly.
* Add callback function to run whenever improved breakdowns setting
  is changed. Reset breakdown_chance_factor where required.
* More whitespace/formatting...
This commit is contained in:
Jonathan G Rennison
2016-01-31 22:55:25 +00:00
parent 9742300a1e
commit 5eed9865d6
14 changed files with 89 additions and 43 deletions

View File

@@ -370,22 +370,23 @@ protected:
uint spd = this->subspeed + accel;
this->subspeed = (byte)spd;
int tempmax = max_speed;
/* When we are going faster than the maximum speed, reduce the speed
* somewhat gradually. But never lower than the maximum speed. */
int tempmax = ((this->breakdown_ctr == 1) ? this->cur_speed : max_speed);
if (this->breakdown_ctr == 1) {
if (this->breakdown_type == BREAKDOWN_LOW_POWER) {
if ((this->tick_counter & 0x7) == 0) {
if ((this->tick_counter & 0x7) == 0 && _settings_game.vehicle.train_acceleration_model == AM_ORIGINAL) {
if (this->cur_speed > (this->breakdown_severity * max_speed) >> 8) {
tempmax = this->cur_speed - (this->cur_speed / 10) - 1;
} else {
tempmax = (this->breakdown_severity * max_speed) >> 8;
}
}
}
if (this->breakdown_type == BREAKDOWN_LOW_SPEED) {
} else if (this->breakdown_type == BREAKDOWN_LOW_SPEED) {
tempmax = min(max_speed, this->breakdown_severity);
} else {
tempmax = this->cur_speed;
}
}