summaryrefslogtreecommitdiff
path: root/engine.c
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2006-10-07 15:04:22 +0000
committerbjarni <bjarni@openttd.org>2006-10-07 15:04:22 +0000
commit2bb7f1da6c0d3425ef5ff0bba40b6f6cb80491c4 (patch)
tree0d1aa14c349735c9f986dfc2c7e51e447c827f81 /engine.c
parentbc1070654a4187273e38fcce5361e5606f33b1d9 (diff)
downloadopenttd-2bb7f1da6c0d3425ef5ff0bba40b6f6cb80491c4.tar.xz
(svn r6681) -Fix: when vehicles never expire they will stay at peak reliability instead of the lowest to make them useful even when old
-Fix: when retiring an engine design, invalidate the build windows and invalidate the build window data -Fix: mark build windows dirty when engine reliability changes
Diffstat (limited to 'engine.c')
-rw-r--r--engine.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/engine.c b/engine.c
index ddaa6391d..4862bd5fc 100644
--- a/engine.c
+++ b/engine.c
@@ -110,18 +110,21 @@ static void CalcEngineReliability(Engine *e)
if (age < e->duration_phase_1) {
uint start = e->reliability_start;
e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start;
- } else if ((age -= e->duration_phase_1) < e->duration_phase_2) {
+ } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _patches.never_expire_vehicles) {
+ /* We are at the peak of this engines life. It will have max reliability.
+ * This is also true if the engines never expire. They will not go bad over time */
e->reliability = e->reliability_max;
} else if ((age -= e->duration_phase_2) < e->duration_phase_3) {
uint max = e->reliability_max;
e->reliability = (int)age * (int)(e->reliability_final - max) / e->duration_phase_3 + max;
} else {
- // time's up for this engine
- // make it either available to all players (if never_expire_vehicles is enabled and if it was available earlier)
- // or disable this engine completely
- e->player_avail = (_patches.never_expire_vehicles && e->player_avail)? -1 : 0;
+ /* time's up for this engine.
+ * We will now completely retire this design */
+ e->player_avail = 0;
e->reliability = e->reliability_final;
+ InvalidateWindowClassesData(WC_BUILD_VEHICLE); // Kick this engine out of the lists
}
+ InvalidateWindowClasses(WC_BUILD_VEHICLE); // Update to show the new reliability
}
void AddTypeToEngines(void)