Changeset - r19149:5ee950f53f03
[Not reviewed]
master
0 3 0
yexo - 12 years ago 2012-03-14 20:49:54
yexo@openttd.org
(svn r24029) -Change: [NoAI] make AIEngine::IsArticulated return true if the articulated callback flag is set, don't try to run the callback.
3 files changed with 12 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -52,12 +52,22 @@ static EngineID GetNextArticulatedPart(u
 
	}
 

	
 
	return GetNewEngineID(front_engine->GetGRF(), front_engine->type, callback);
 
}
 

	
 
/**
 
 * Does a NewGRF report that this should be an articulated vehicle?
 
 * @param engine_type The engine to check.
 
 * @return True iff the articulated engine callback flag is set.
 
 */
 
bool IsArticulatedEngine(EngineID engine_type)
 
{
 
	return HasBit(EngInfo(engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE);
 
}
 

	
 
/**
 
 * Count the number of articulated parts of an engine.
 
 * @param engine_type The engine to get the number of parts of.
 
 * @param purchase_window Whether we are in the scope of the purchase window or not, i.e. whether we cannot allocate vehicles.
 
 * @return The nmumber of parts.
 
 */
 
uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
src/articulated_vehicles.h
Show inline comments
 
@@ -20,10 +20,11 @@ CargoArray GetCapacityOfArticulatedParts
 
void AddArticulatedParts(Vehicle *first);
 
void GetArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type, uint32 *union_mask, uint32 *intersection_mask);
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
 
bool IsArticulatedVehicleCarryingDifferentCargoes(const Vehicle *v, CargoID *cargo_type);
 
bool IsArticulatedVehicleRefittable(EngineID engine);
 
bool IsArticulatedEngine(EngineID engine_type);
 
void CheckConsistencyOfArticulatedVehicle(const Vehicle *v);
 

	
 

	
 
#endif /* ARTICULATED_VEHICLES_H */
src/script/api/script_engine.cpp
Show inline comments
 
@@ -230,13 +230,13 @@
 

	
 
/* static */ bool ScriptEngine::IsArticulated(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return false;
 
	if (GetVehicleType(engine_id) != ScriptVehicle::VT_ROAD && GetVehicleType(engine_id) != ScriptVehicle::VT_RAIL) return false;
 

	
 
	return CountArticulatedParts(engine_id, true) != 0;
 
	return IsArticulatedEngine(engine_id);
 
}
 

	
 
/* static */ ScriptAirport::PlaneType ScriptEngine::GetPlaneType(EngineID engine_id)
 
{
 
	if (!IsValidEngine(engine_id)) return ScriptAirport::PT_INVALID;
 
	if (GetVehicleType(engine_id) != ScriptVehicle::VT_AIR) return ScriptAirport::PT_INVALID;
0 comments (0 inline, 0 general)