summaryrefslogtreecommitdiff
path: root/src/station.cpp
diff options
context:
space:
mode:
authormichi_cc <michi_cc@openttd.org>2011-12-03 23:40:46 +0000
committermichi_cc <michi_cc@openttd.org>2011-12-03 23:40:46 +0000
commitd3b7b89493e025654d218fb77da095649b4f6ba2 (patch)
tree6667e4164c5c8bda4c1b7092376872b315c65610 /src/station.cpp
parentf98312eb77e12cfa45de40a1b4e8359160b0d9ff (diff)
downloadopenttd-d3b7b89493e025654d218fb77da095649b4f6ba2.tar.xz
(svn r23415) -Feature: Infrastructure maintenance costs.
Diffstat (limited to 'src/station.cpp')
-rw-r--r--src/station.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/station.cpp b/src/station.cpp
index a3df6fe74..5fc2bbdf5 100644
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -523,3 +523,22 @@ StationRect& StationRect::operator = (const Rect &src)
this->bottom = src.bottom;
return *this;
}
+
+/**
+ * Calculates the maintenance cost of all airports of a company.
+ * @param owner Company.
+ * @return Total cost.
+ */
+Money AirportMaintenanceCost(Owner owner)
+{
+ Money total_cost = 0;
+
+ const Station *st;
+ FOR_ALL_STATIONS(st) {
+ if (st->owner == owner && (st->facilities & FACIL_AIRPORT)) {
+ total_cost += _price[PR_INFRASTRUCTURE_AIRPORT] * st->airport.GetSpec()->maintenance_cost;
+ }
+ }
+ /* 3 bits fraction for the maintenance cost factor. */
+ return total_cost >> 3;
+}