(svn r23075) -Codechange: Add GetGRF() and GetGRFID() methods to Engine and Vehicle to simplify code.
This commit is contained in:
@@ -155,6 +155,17 @@ bool Engine::IsEnabled() const
|
||||
return this->info.string_id != STR_NEWGRF_INVALID_ENGINE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user