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

@@ -2632,7 +2632,15 @@ public:
if (w->breakdown_type == BREAKDOWN_LOW_SPEED) {
SetDParam(1, min( w->First()->GetDisplayMaxSpeed(), w->breakdown_severity >> ((v->type == VEH_TRAIN) ? 0 : 1)));
} else if (w->breakdown_type == BREAKDOWN_LOW_POWER) {
SetDParam(1, w->breakdown_severity * 100 / 256);
int percent;
if (v->type == VEH_TRAIN) {
uint32 power, te;
Train::From(v)->CalculatePower(power, te, true);
percent = (100 * power) / Train::From(v)->gcache.cached_power;
} else {
percent = w->breakdown_severity * 100 / 256;
}
SetDParam(1, percent);
}
}
} else if (v->vehstatus & VS_STOPPED) {