equal
deleted
inserted
replaced
70 |
70 |
71 /* Check if this base engine is within the original engine data range */ |
71 /* Check if this base engine is within the original engine data range */ |
72 if (base >= _engine_counts[type]) { |
72 if (base >= _engine_counts[type]) { |
73 /* Mark engine as valid anyway */ |
73 /* Mark engine as valid anyway */ |
74 this->info.climates = 0x80; |
74 this->info.climates = 0x80; |
|
75 /* Set model life to maximum to make wagons available */ |
|
76 this->info.base_life = 0xFF; |
75 return; |
77 return; |
76 } |
78 } |
77 |
79 |
78 /* Copy the original engine info for this slot */ |
80 /* Copy the original engine info for this slot */ |
79 this->info = _orig_engine_info[_engine_offsets[type] + base]; |
81 this->info = _orig_engine_info[_engine_offsets[type] + base]; |
84 |
86 |
85 case VEH_TRAIN: |
87 case VEH_TRAIN: |
86 this->u.rail = _orig_rail_vehicle_info[base]; |
88 this->u.rail = _orig_rail_vehicle_info[base]; |
87 this->image_index = this->u.rail.image_index; |
89 this->image_index = this->u.rail.image_index; |
88 this->info.string_id = STR_8000_KIRBY_PAUL_TANK_STEAM + base; |
90 this->info.string_id = STR_8000_KIRBY_PAUL_TANK_STEAM + base; |
|
91 |
|
92 /* Set the default model life of original wagons to "infinite" */ |
|
93 if (this->u.rail.railveh_type == RAILVEH_WAGON) this->info.base_life = 0xFF; |
|
94 |
89 break; |
95 break; |
90 |
96 |
91 case VEH_ROAD: |
97 case VEH_ROAD: |
92 this->u.road = _orig_road_vehicle_info[base]; |
98 this->u.road = _orig_road_vehicle_info[base]; |
93 this->image_index = this->u.road.image_index; |
99 this->image_index = this->u.road.image_index; |
193 static void CalcEngineReliability(Engine *e) |
199 static void CalcEngineReliability(Engine *e) |
194 { |
200 { |
195 uint age = e->age; |
201 uint age = e->age; |
196 |
202 |
197 /* Check for early retirement */ |
203 /* Check for early retirement */ |
198 if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles) { |
204 if (e->company_avail != 0 && !_settings_game.vehicle.never_expire_vehicles && e->info.base_life != 0xFF) { |
199 int retire_early = e->info.retire_early; |
205 int retire_early = e->info.retire_early; |
200 uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12); |
206 uint retire_early_max_age = max(0, e->duration_phase_1 + e->duration_phase_2 - retire_early * 12); |
201 if (retire_early != 0 && age >= retire_early_max_age) { |
207 if (retire_early != 0 && age >= retire_early_max_age) { |
202 /* Early retirement is enabled and we're past the date... */ |
208 /* Early retirement is enabled and we're past the date... */ |
203 e->company_avail = 0; |
209 e->company_avail = 0; |
206 } |
212 } |
207 |
213 |
208 if (age < e->duration_phase_1) { |
214 if (age < e->duration_phase_1) { |
209 uint start = e->reliability_start; |
215 uint start = e->reliability_start; |
210 e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
216 e->reliability = age * (e->reliability_max - start) / e->duration_phase_1 + start; |
211 } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings_game.vehicle.never_expire_vehicles) { |
217 } else if ((age -= e->duration_phase_1) < e->duration_phase_2 || _settings_game.vehicle.never_expire_vehicles || e->info.base_life == 0xFF) { |
212 /* We are at the peak of this engines life. It will have max reliability. |
218 /* We are at the peak of this engines life. It will have max reliability. |
213 * This is also true if the engines never expire. They will not go bad over time */ |
219 * This is also true if the engines never expire. They will not go bad over time */ |
214 e->reliability = e->reliability_max; |
220 e->reliability = e->reliability_max; |
215 } else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
221 } else if ((age -= e->duration_phase_2) < e->duration_phase_3) { |
216 uint max = e->reliability_max; |
222 uint max = e->reliability_max; |
262 e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; |
268 e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; |
263 e->duration_phase_3 = GB(r, 9, 7) + 120; |
269 e->duration_phase_3 = GB(r, 9, 7) + 120; |
264 |
270 |
265 e->reliability_spd_dec = ei->decay_speed << 2; |
271 e->reliability_spd_dec = ei->decay_speed << 2; |
266 |
272 |
267 if (IsWagon(e->index)) { |
273 CalcEngineReliability(e); |
268 e->age = 0xFFFF; |
|
269 } else { |
|
270 CalcEngineReliability(e); |
|
271 } |
|
272 |
274 |
273 e->lifelength = ei->lifelength + _settings_game.vehicle.extend_vehicle_life; |
275 e->lifelength = ei->lifelength + _settings_game.vehicle.extend_vehicle_life; |
274 |
276 |
275 /* prevent certain engines from ever appearing. */ |
277 /* prevent certain engines from ever appearing. */ |
276 if (!HasBit(ei->climates, _settings_game.game_creation.landscape)) { |
278 if (!HasBit(ei->climates, _settings_game.game_creation.landscape)) { |