Mercurial > hg > openttd
comparison src/vehicle.cpp @ 7544:0b69698895b6 draft
(svn r11064) -Fix [FS#553]: when autorenew is enabled and it cannot renew the vehicle anymore (because the player cannot build the engine), the aging warnings as if autorenew is not enabled are shown.
author | rubidium <rubidium@openttd.org> |
---|---|
date | Sat, 08 Sep 2007 22:53:10 +0000 |
parents | 69c1c81f234b |
children | a84d70ad7876 |
comparison
equal
deleted
inserted
replaced
7543:2e26b732a29b | 7544:0b69698895b6 |
---|---|
1468 | 1468 |
1469 static void ShowVehicleGettingOld(Vehicle *v, StringID msg) | 1469 static void ShowVehicleGettingOld(Vehicle *v, StringID msg) |
1470 { | 1470 { |
1471 if (v->owner != _local_player) return; | 1471 if (v->owner != _local_player) return; |
1472 | 1472 |
1473 /* Do not show getting-old message if autorenew is active */ | 1473 /* Do not show getting-old message if autorenew is active (and it can replace the vehicle) */ |
1474 if (GetPlayer(v->owner)->engine_renew) return; | 1474 if (GetPlayer(v->owner)->engine_renew && GetEngine(v->engine_type)->player_avail != 0) return; |
1475 | 1475 |
1476 SetDParam(0, _vehicle_type_names[v->type]); | 1476 SetDParam(0, _vehicle_type_names[v->type]); |
1477 SetDParam(1, v->unitnumber); | 1477 SetDParam(1, v->unitnumber); |
1478 AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); | 1478 AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0); |
1479 } | 1479 } |
1480 | 1480 |
1481 void AgeVehicle(Vehicle *v) | 1481 void AgeVehicle(Vehicle *v) |
1482 { | 1482 { |
1483 int age; | 1483 if (v->age < 65535) v->age++; |
1484 | 1484 |
1485 if (v->age < 65535) | 1485 int age = v->age - v->max_age; |
1486 v->age++; | 1486 if (age == 366*0 || age == 366*1 || age == 366*2 || age == 366*3 || age == 366*4) v->reliability_spd_dec <<= 1; |
1487 | |
1488 age = v->age - v->max_age; | |
1489 if (age == 366*0 || age == 366*1 || age == 366*2 || age == 366*3 || age == 366*4) | |
1490 v->reliability_spd_dec <<= 1; | |
1491 | 1487 |
1492 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); | 1488 InvalidateWindow(WC_VEHICLE_DETAILS, v->index); |
1493 | 1489 |
1494 if (age == -366) { | 1490 if (age == -366) { |
1495 ShowVehicleGettingOld(v, STR_01A0_IS_GETTING_OLD); | 1491 ShowVehicleGettingOld(v, STR_01A0_IS_GETTING_OLD); |
1496 } else if (age == 0) { | 1492 } else if (age == 0) { |
1497 ShowVehicleGettingOld(v, STR_01A1_IS_GETTING_VERY_OLD); | 1493 ShowVehicleGettingOld(v, STR_01A1_IS_GETTING_VERY_OLD); |
1498 } else if (age == 366*1 || age == 366*2 || age == 366*3 || age == 366*4 || age == 366*5) { | 1494 } else if ((age % 366) == 0) { |
1499 ShowVehicleGettingOld(v, STR_01A2_IS_GETTING_VERY_OLD_AND); | 1495 ShowVehicleGettingOld(v, STR_01A2_IS_GETTING_VERY_OLD_AND); |
1500 } | 1496 } |
1501 } | 1497 } |
1502 | 1498 |
1503 /** Starts or stops a lot of vehicles | 1499 /** Starts or stops a lot of vehicles |