diff options
author | frosch <frosch@openttd.org> | 2011-11-01 00:23:41 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2011-11-01 00:23:41 +0000 |
commit | acc3c75951c4db0873db794b657697774f0ff9e9 (patch) | |
tree | 2b7e5f953286b09c3c07688c9e8c49ee953c5adb /src/vehicle.cpp | |
parent | 72cd855978bf45fd444eae72551a12e13a35b0c8 (diff) | |
download | openttd-acc3c75951c4db0873db794b657697774f0ff9e9.tar.xz |
(svn r23075) -Codechange: Add GetGRF() and GetGRFID() methods to Engine and Vehicle to simplify code.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 5827b46da..7110cb46b 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -211,8 +211,7 @@ uint Vehicle::Crash(bool flooded) void ShowNewGrfVehicleError(EngineID engine, StringID part1, StringID part2, GRFBugs bug_type, bool critical) { const Engine *e = Engine::Get(engine); - uint32 grfid = e->grf_prop.grffile->grfid; - GRFConfig *grfconfig = GetGRFConfig(grfid); + GRFConfig *grfconfig = GetGRFConfig(e->GetGRFID()); if (!HasBit(grfconfig->grf_bugs, bug_type)) { SetBit(grfconfig->grf_bugs, bug_type); @@ -642,6 +641,26 @@ const Engine *Vehicle::GetEngine() const } /** + * Retrieve the NewGRF the vehicle is tied to. + * This is the GRF providing the Action 3 for the engine type. + * @return NewGRF associated to the vehicle. + */ +const GRFFile *Vehicle::GetGRF() const +{ + return this->GetEngine()->GetGRF(); +} + +/** + * Retrieve the GRF ID of the NewGRF the vehicle is tied to. + * This is the GRF providing the Action 3 for the engine type. + * @return GRF ID of the associated NewGRF. + */ +uint32 Vehicle::GetGRFID() const +{ + return this->GetEngine()->GetGRFID(); +} + +/** * Handle the pathfinding result, especially the lost status. * If the vehicle is now lost and wasn't previously fire an * event to the AIs and a news message to the user. If the |