src/engine.cpp
changeset 10430 3125f2adebc5
parent 10427 cf023efb9a97
equal deleted inserted replaced
10429:b81d72d5b44a 10430:3125f2adebc5
   557 	}
   557 	}
   558 
   558 
   559 	return true;
   559 	return true;
   560 }
   560 }
   561 
   561 
       
   562 /**
       
   563  * Check if an engine is refittable.
       
   564  * @param engine index of the engine to check.
       
   565  * @return true if the engine is refittable.
       
   566  */
       
   567 bool IsEngineRefittable(EngineID engine)
       
   568 {
       
   569 	/* check if it's an engine that is in the engine array */
       
   570 	if (!IsEngineIndex(engine)) return false;
       
   571 
       
   572 	const Engine *e = GetEngine(engine);
       
   573 
       
   574 	if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
       
   575 
       
   576 	const EngineInfo *ei = &e->info;
       
   577 	if (ei->refit_mask == 0) return false;
       
   578 
       
   579 	/* Are there suffixes?
       
   580 	 * Note: This does not mean the suffixes are actually available for every consist at any time. */
       
   581 	if (HasBit(ei->callbackmask, CBM_VEHICLE_CARGO_SUFFIX)) return true;
       
   582 
       
   583 	/* Is there any cargo except the default cargo? */
       
   584 	CargoID default_cargo = GetEngineCargoType(engine);
       
   585 	return default_cargo != CT_INVALID && ei->refit_mask != 1U << default_cargo;
       
   586 }
       
   587 
   562 /** Get the default cargo type for a certain engine type
   588 /** Get the default cargo type for a certain engine type
   563  * @param engine The ID to get the cargo for
   589  * @param engine The ID to get the cargo for
   564  * @return The cargo type. CT_INVALID means no cargo capacity
   590  * @return The cargo type. CT_INVALID means no cargo capacity
   565  */
   591  */
   566 CargoID GetEngineCargoType(EngineID engine)
   592 CargoID GetEngineCargoType(EngineID engine)