equal
deleted
inserted
replaced
187 static void CalcEngineReliability(Engine *e) |
187 static void CalcEngineReliability(Engine *e) |
188 { |
188 { |
189 uint age = e->age; |
189 uint age = e->age; |
190 |
190 |
191 /* Check for early retirement */ |
191 /* Check for early retirement */ |
192 if (e->player_avail != 0 && !_settings.vehicle.never_expire_vehicles) { |
192 if (e->player_avail != 0 && !_settings_game.vehicle.never_expire_vehicles) { |
193 int retire_early = e->info.retire_early; |
193 int retire_early = e->info.retire_early; |
194 uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12); |
194 uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12); |
195 if (retire_early != 0 && age >= retire_early_max_age) { |
195 if (retire_early != 0 && age >= retire_early_max_age) { |
196 /* Early retirement is enabled and we're past the date... */ |
196 /* Early retirement is enabled and we're past the date... */ |
197 e->player_avail = 0; |
197 e->player_avail = 0; |
200 } |
200 } |
201 |
201 |
202 if (age < e->duration_phase_1) { |
202 if (age < e->duration_phase_1) { |
203 uint start = e->reliability_start; |
203 uint start = e->reliability_start; |
204 e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
204 e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
205 } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings.vehicle.never_expire_vehicles) { |
205 } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings_game.vehicle.never_expire_vehicles) { |
206 /* We are at the peak of this engines life. It will have max reliability. |
206 /* We are at the peak of this engines life. It will have max reliability. |
207 * This is also true if the engines never expire. They will not go bad over time */ |
207 * This is also true if the engines never expire. They will not go bad over time */ |
208 e->reliability = e->reliability_max; |
208 e->reliability = e->reliability_max; |
209 } else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
209 } else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
210 uint max = e->reliability_max; |
210 uint max = e->reliability_max; |
263 e->age = 0xFFFF; |
263 e->age = 0xFFFF; |
264 } else { |
264 } else { |
265 CalcEngineReliability(e); |
265 CalcEngineReliability(e); |
266 } |
266 } |
267 |
267 |
268 e->lifelength = ei->lifelength + _settings.vehicle.extend_vehicle_life; |
268 e->lifelength = ei->lifelength + _settings_game.vehicle.extend_vehicle_life; |
269 |
269 |
270 /* prevent certain engines from ever appearing. */ |
270 /* prevent certain engines from ever appearing. */ |
271 if (!HasBit(ei->climates, _settings.game_creation.landscape)) { |
271 if (!HasBit(ei->climates, _settings_game.game_creation.landscape)) { |
272 e->flags |= ENGINE_AVAILABLE; |
272 e->flags |= ENGINE_AVAILABLE; |
273 e->player_avail = 0; |
273 e->player_avail = 0; |
274 } |
274 } |
275 } |
275 } |
276 } |
276 } |