Changeset - r12798:68ac0ef0475e
[Not reviewed]
master
0 1 0
rubidium - 15 years ago 2009-08-27 19:47:50
rubidium@openttd.org
(svn r17296) -Fix/feature [FS#3152]: allow rail wagons to be build when only el rail engines are available
1 file changed with 1 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/engine.cpp
Show inline comments
 
@@ -745,49 +745,49 @@ CommandCost CmdRenameEngine(TileIndex ti
 

	
 
/** Check if an engine is buildable.
 
 * @param engine  index of the engine to check.
 
 * @param type    the type the engine should be.
 
 * @param company index of the company.
 
 * @return True if an engine is valid, of the specified type, and buildable by
 
 *              the given company.
 
 */
 
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company)
 
{
 
	const Engine *e = Engine::GetIfValid(engine);
 

	
 
	/* check if it's an engine that is in the engine array */
 
	if (e == NULL) return false;
 

	
 
	/* check if it's an engine of specified type */
 
	if (e->type != type) return false;
 

	
 
	/* check if it's available */
 
	if (!HasBit(e->company_avail, company)) return false;
 

	
 
	if (type == VEH_TRAIN) {
 
		/* Check if the rail type is available to this company */
 
		const Company *c = Company::Get(company);
 
		if (!HasBit(c->avail_railtypes, RailVehInfo(engine)->railtype)) return false;
 
		if (((GetRailTypeInfo(RailVehInfo(engine)->railtype))->compatible_railtypes & c->avail_railtypes) == 0) return false;
 
	}
 

	
 
	return true;
 
}
 

	
 
/**
 
 * Check if an engine is refittable.
 
 * Note: Likely you want to use IsArticulatedVehicleRefittable().
 
 * @param engine index of the engine to check.
 
 * @return true if the engine is refittable.
 
 */
 
bool IsEngineRefittable(EngineID engine)
 
{
 
	const Engine *e = Engine::GetIfValid(engine);
 

	
 
	/* check if it's an engine that is in the engine array */
 
	if (e == NULL) return false;
 

	
 
	if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
 

	
 
	if (!e->CanCarryCargo()) return false;
 

	
 
	const EngineInfo *ei = &e->info;
 
	if (ei->refit_mask == 0) return false;
0 comments (0 inline, 0 general)