(svn r23075) -Codechange: Add GetGRF() and GetGRFID() methods to Engine and Vehicle to simplify code.

This commit is contained in:
frosch
2011-11-01 00:23:41 +00:00
parent e57ba5d0ae
commit ad38f27242
17 changed files with 84 additions and 64 deletions

View File

@@ -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);
}
/**