Changeset - r17236:40bfbfc512f0
[Not reviewed]
master
0 3 0
frosch - 13 years ago 2011-02-05 20:37:00
frosch@openttd.org
(svn r21986) -Codechange: Add helper function to test whether an engine is still associated to a GRF.
3 files changed with 12 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -145,6 +145,15 @@ Engine::~Engine()
 
}
 

	
 
/**
 
 * Checks whether the engine spec is properly initialised.
 
 * @return true if enabled
 
 */
 
bool Engine::IsEnabled() const
 
{
 
	return this->info.string_id != STR_NEWGRF_INVALID_ENGINE;
 
}
 

	
 
/**
 
 * 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.
 
 * @return true if the vehicle can carry something.
 
@@ -935,7 +944,7 @@ bool IsEngineBuildable(EngineID engine, 
 
	/* check if it's available */
 
	if (!HasBit(e->company_avail, company)) return false;
 

	
 
	if (e->info.string_id == STR_NEWGRF_INVALID_ENGINE) return false;
 
	if (!e->IsEnabled()) return false;
 

	
 
	if (type == VEH_TRAIN) {
 
		/* Check if the rail type is available to this company */
src/engine_base.h
Show inline comments
 
@@ -61,6 +61,7 @@ struct Engine : EnginePool::PoolItem<&_e
 
	Engine();
 
	Engine(VehicleType type, EngineID base);
 
	~Engine();
 
	bool IsEnabled() const;
 

	
 
	/**
 
	 * Determines the default cargo type of an engine.
src/strings.cpp
Show inline comments
 
@@ -1110,7 +1110,7 @@ static char *FormatString(char *buff, co
 

	
 
				assert(e != NULL);
 

	
 
				if (e->name != NULL && e->info.string_id != STR_NEWGRF_INVALID_ENGINE) {
 
				if (e->name != NULL && e->IsEnabled()) {
 
					buff = strecpy(buff, e->name, last);
 
				} else {
 
					buff = GetStringWithArgs(buff, e->info.string_id, NULL, NULL, last);
0 comments (0 inline, 0 general)