summaryrefslogtreecommitdiff
path: root/src/vehicle.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-01-04 18:34:23 +0000
committersmatz <smatz@openttd.org>2009-01-04 18:34:23 +0000
commit67bf6a0998eb7e0be39449ca5b2563ace66b3a30 (patch)
tree24e7c278186d5ebd3bd6bce940783e6debc48253 /src/vehicle.cpp
parentf1cc20edc076a550615e1da3f1d453c47d6e55c2 (diff)
downloadopenttd-67bf6a0998eb7e0be39449ca5b2563ace66b3a30.tar.xz
(svn r14835) -Change: apply the 'warn if train's income is negative' setting to other vehicle types, too
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r--src/vehicle.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp
index 3769b1a7f..e88854bcc 100644
--- a/src/vehicle.cpp
+++ b/src/vehicle.cpp
@@ -2231,3 +2231,29 @@ void StopAllVehicles()
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
}
}
+
+void VehiclesYearlyLoop()
+{
+ Vehicle *v;
+ FOR_ALL_VEHICLES(v) {
+ if (v->IsPrimaryVehicle()) {
+ /* show warning if vehicle is not generating enough income last 2 years (corresponds to a red icon in the vehicle list) */
+ if (_settings_client.gui.vehicle_income_warn && v->owner == _local_company && v->age >= 730) {
+ Money profit = v->GetDisplayProfitThisYear();
+ if (profit < 0) {
+ SetDParam(0, v->index);
+ SetDParam(1, profit);
+ AddNewsItem(
+ STR_VEHICLE_IS_UNPROFITABLE,
+ NS_ADVICE,
+ v->index,
+ 0);
+ }
+ }
+
+ v->profit_last_year = v->profit_this_year;
+ v->profit_this_year = 0;
+ InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
+ }
+ }
+}