diff options
Diffstat (limited to 'src/engine.cpp')
-rw-r--r-- | src/engine.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/engine.cpp b/src/engine.cpp index 048fcc82f..6f544edf8 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -29,6 +29,7 @@ #include "engine_func.h" #include "engine_base.h" #include "company_base.h" +#include "vehicle_func.h" #include "table/strings.h" #include "table/engines.h" @@ -430,6 +431,25 @@ EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uin } /** + * Tries to reset the engine mapping to match the current NewGRF configuration. + * This is only possible when there are currently no vehicles in the game. + * @return false if resetting failed due to present vehicles. + */ +bool EngineOverrideManager::ResetToCurrentNewGRFConfig() +{ + const Vehicle *v; + FOR_ALL_VEHICLES(v) { + if (IsCompanyBuildableVehicleType(v)) return false; + } + + /* Reset the engines, they will get new EngineIDs */ + _engine_mngr.ResetToDefaultMapping(); + ReloadNewGRFData(); + + return true; +} + +/** * Sets cached values in Company::num_vehicles and Group::num_vehicles */ void SetCachedEngineCounts() |