(svn r21975) -Add: console command to reset the engine pool. It removes the traces of engines which are no longer associated to a NewGRF, and can be used to e.g. 'fix' scenarios which were screwed up by the author. You can only use it when there are no vehicles in the game though.

This commit is contained in:
frosch
2011-02-05 16:07:23 +00:00
parent a4b08dddd1
commit 915e339d0f
5 changed files with 51 additions and 12 deletions

View File

@@ -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"
@@ -429,6 +430,25 @@ EngineID EngineOverrideManager::GetID(VehicleType type, uint16 grf_local_id, uin
return INVALID_ENGINE;
}
/**
* 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
*/