summaryrefslogtreecommitdiff
path: root/vehicle.c
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-08-12 17:49:16 +0000
committertruelight <truelight@openttd.org>2004-08-12 17:49:16 +0000
commit210ada1b514a173de5a2426f99cd25c95b23efaf (patch)
treeacb434304df44af2e1d0721b08cad09b677cf847 /vehicle.c
parent4b0d4dd3fe13e78e1766ac06ab891f9d39f1d0aa (diff)
downloadopenttd-210ada1b514a173de5a2426f99cd25c95b23efaf.tar.xz
(svn r27) -Fix: [1006715] Autorenew issues
-Add: PE_CURRENCY to patchmenu
Diffstat (limited to 'vehicle.c')
-rw-r--r--vehicle.c35
1 files changed, 29 insertions, 6 deletions
diff --git a/vehicle.c b/vehicle.c
index 667a336bc..7e37989c4 100644
--- a/vehicle.c
+++ b/vehicle.c
@@ -1302,6 +1302,9 @@ static void ShowVehicleGettingOld(Vehicle *v, StringID msg)
{
if (v->owner != _local_player)
return;
+ // Do not show getting-old message if autorenew is active
+ if (_patches.autorenew)
+ return;
SET_DPARAM16(0, _vehicle_type_names[v->type - 0x10]);
SET_DPARAM16(1, v->unitnumber);
@@ -1334,13 +1337,33 @@ void MaybeRenewVehicle(Vehicle *v, int32 build_cost)
{
Engine *e;
- // When automatically renewing a vehicle we want to prevent the
- // "getting old" messages so we renew it if it won't enter the
- // depot during the next service sooner than half a year before
- // the vehicle getting old (that's one year before it reaches
- // the max_age, see AgeVehicle).
- if (!(_patches.autorenew && v->max_age - v->age < 366 + 183 + v->service_interval))
+ // A vehicle is autorenewed when it it gets the amount of months
+ // give by _patches.autorenew_months away for his max age.
+ // Standard is -6, meaning 6 months before his max age
+ // It can be any value between -12 and 12.
+ if (!_patches.autorenew || v->age - v->max_age < (_patches.autorenew_months * 30))
+ return;
+
+ if (DEREF_PLAYER(v->owner)->money64 < _patches.autorenew_money + build_cost - v->value) {
+ if (v->owner == _local_player) {
+ int message;
+ SET_DPARAM16(0, v->unitnumber);
+ switch (v->type) {
+ case VEH_Train: message = STR_TRAIN_AUTORENEW_FAILED; break;
+ case VEH_Road: message = STR_ROADVEHICLE_AUTORENEW_FAILED; break;
+ case VEH_Ship: message = STR_SHIP_AUTORENEW_FAILED; break;
+ case VEH_Aircraft: message = STR_AIRCRAFT_AUTORENEW_FAILED; break;
+ // This should never happen
+ default: message = 0; break;
+ }
+
+ AddNewsItem(message, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_VEHICLE, NT_ADVICE, 0), v->index, 0);
+ }
return;
+ }
+
+ // Withdraw the money from the right player ;)
+ _current_player = v->owner;
e = &_engines[v->engine_type];
v->reliability = e->reliability;