summaryrefslogtreecommitdiff
path: root/src/engine.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-11-01 00:23:41 +0000
committerfrosch <frosch@openttd.org>2011-11-01 00:23:41 +0000
commitacc3c75951c4db0873db794b657697774f0ff9e9 (patch)
tree2b7e5f953286b09c3c07688c9e8c49ee953c5adb /src/engine.cpp
parent72cd855978bf45fd444eae72551a12e13a35b0c8 (diff)
downloadopenttd-acc3c75951c4db0873db794b657697774f0ff9e9.tar.xz
(svn r23075) -Codechange: Add GetGRF() and GetGRFID() methods to Engine and Vehicle to simplify code.
Diffstat (limited to 'src/engine.cpp')
-rw-r--r--src/engine.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/engine.cpp b/src/engine.cpp
index f4474ea27..d59e2fb6f 100644
--- a/src/engine.cpp
+++ b/src/engine.cpp
@@ -156,6 +156,17 @@ bool Engine::IsEnabled() const
}
/**
+ * Retrieve the GRF ID of the NewGRF the engine is tied to.
+ * This is the GRF providing the Action 3.
+ * @return GRF ID of the associated NewGRF.
+ */
+uint32 Engine::GetGRFID() const
+{
+ const GRFFile *file = this->GetGRF();
+ return file == NULL ? 0 : file->grfid;
+}
+
+/**
* Determines whether an engine can carry something.
* A vehicle cannot carry anything if its capacity is zero, or none of the possible cargos is available in the climate.
* @return true if the vehicle can carry something.
@@ -265,7 +276,7 @@ Money Engine::GetRunningCost() const
default: NOT_REACHED();
}
- return GetPrice(base_price, cost_factor, this->grf_prop.grffile, -8);
+ return GetPrice(base_price, cost_factor, this->GetGRF(), -8);
}
/**
@@ -305,7 +316,7 @@ Money Engine::GetCost() const
default: NOT_REACHED();
}
- return GetPrice(base_price, cost_factor, this->grf_prop.grffile, -8);
+ return GetPrice(base_price, cost_factor, this->GetGRF(), -8);
}
/**