summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index c6b776667..d1475602d 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -91,8 +91,9 @@ static void CalcEngineReliability(Engine *e)
/* Check for early retirement */
if (e->player_avail != 0 && !_patches.never_expire_vehicles) {
- uint retire_early = EngInfo(e - _engines)->retire_early;
- if (retire_early > 0 && age >= e->duration_phase_1 + e->duration_phase_2 - retire_early * 12) {
+ int retire_early = EngInfo(e - _engines)->retire_early;
+ uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12);
+ if (retire_early != 0 && age >= retire_early_max_age) {
/* Early retirement is enabled and we're past the date... */
e->player_avail = 0;
AddRemoveEngineFromAutoreplaceAndBuildWindows(e->type);