summaryrefslogtreecommitdiff
path: root/src/roadveh_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-11-08 13:02:05 +0000
committerfrosch <frosch@openttd.org>2009-11-08 13:02:05 +0000
commit6ca8f6e38025c9a7b484ffee669f27fad7ceb32d (patch)
tree9d745e0add388c8a8e058ec5399d66a4dc9d3d00 /src/roadveh_cmd.cpp
parentcc320dc4d0253fc349cffc2719f6d20bb7ced99d (diff)
downloadopenttd-6ca8f6e38025c9a7b484ffee669f27fad7ceb32d.tar.xz
(svn r18011) -Feature(ette): [NewGRF] CB 36 for roadvehicle property 09 'running cost factor'.
Diffstat (limited to 'src/roadveh_cmd.cpp')
-rw-r--r--src/roadveh_cmd.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/roadveh_cmd.cpp b/src/roadveh_cmd.cpp
index 8aebc4e4d..b5121095b 100644
--- a/src/roadveh_cmd.cpp
+++ b/src/roadveh_cmd.cpp
@@ -1821,6 +1821,17 @@ static bool RoadVehController(RoadVehicle *v)
return true;
}
+Money RoadVehicle::GetRunningCost() const
+{
+ const RoadVehicleInfo *rvi = RoadVehInfo(this->engine_type);
+ if (rvi->running_cost_class == INVALID_PRICE) return 0;
+
+ uint cost_factor = GetVehicleProperty(this, PROP_ROADVEH_RUNNING_COST_FACTOR, rvi->running_cost);
+ if (cost_factor == 0) return 0;
+
+ return cost_factor * GetPriceByIndex(rvi->running_cost_class);
+}
+
bool RoadVehicle::Tick()
{
if (this->IsRoadVehFront()) {