summaryrefslogtreecommitdiff
path: root/src/train_cmd.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2009-11-24 13:12:34 +0000
committerfrosch <frosch@openttd.org>2009-11-24 13:12:34 +0000
commit912bce0b8cdeca9849dd257ca95566b009719d53 (patch)
treea2abd63725a9c6baffb22a8b3c39dc6b2f535dfb /src/train_cmd.cpp
parentb6b551533532d64f47e883d770b9633027ca7628 (diff)
downloadopenttd-912bce0b8cdeca9849dd257ca95566b009719d53.tar.xz
(svn r18266) -Codechange: Add a function to compute prices from price base and cost factor and use it consistently for vehicle purchase, running cost, and refit cost.
Diffstat (limited to 'src/train_cmd.cpp')
-rw-r--r--src/train_cmd.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index bd5205b6c..3022045d4 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -4443,16 +4443,16 @@ Money Train::GetRunningCost() const
const Train *v = this;
do {
- const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
- if (rvi->running_cost_class == INVALID_PRICE) continue;
+ const Engine *e = Engine::Get(v->engine_type);
+ if (e->u.rail.running_cost_class == INVALID_PRICE) continue;
- uint cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, rvi->running_cost);
+ uint cost_factor = GetVehicleProperty(v, PROP_TRAIN_RUNNING_COST_FACTOR, e->u.rail.running_cost);
if (cost_factor == 0) continue;
/* Halve running cost for multiheaded parts */
if (v->IsMultiheaded()) cost_factor /= 2;
- cost += cost_factor * GetPriceByIndex(rvi->running_cost_class);
+ cost += GetPrice(e->u.rail.running_cost_class, cost_factor);
} while ((v = v->GetNextVehicle()) != NULL);
return cost;