Changeset - r16774:e8f36b899894
[Not reviewed]
master
0 2 0
terkhen - 14 years ago 2010-12-14 21:27:30
terkhen@openttd.org
(svn r21517) -Codechange: Add IsGroundVehicle function to the Engine class.
2 files changed with 12 insertions and 3 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -108,7 +108,7 @@ CargoArray GetCapacityOfArticulatedParts
 
	uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
 
	if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
 

	
 
	if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return capacity;
 
	if (!e->IsGroundVehicle()) return capacity;
 

	
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return capacity;
 

	
 
@@ -133,7 +133,7 @@ bool IsArticulatedVehicleRefittable(Engi
 
	if (IsEngineRefittable(engine)) return true;
 

	
 
	const Engine *e = Engine::Get(engine);
 
	if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return false;
 
	if (!e->IsGroundVehicle()) return false;
 

	
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return false;
 

	
 
@@ -161,7 +161,7 @@ void GetArticulatedRefitMasks(EngineID e
 
	*union_mask = veh_cargos;
 
	*intersection_mask = (veh_cargos != 0) ? veh_cargos : UINT32_MAX;
 

	
 
	if (e->type != VEH_TRAIN && e->type != VEH_ROAD) return;
 
	if (!e->IsGroundVehicle()) return;
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
src/engine_base.h
Show inline comments
 
@@ -87,6 +87,15 @@ struct Engine : EnginePool::PoolItem<&_e
 
	uint GetDisplayWeight() const;
 
	uint GetDisplayMaxTractiveEffort() const;
 
	Date GetLifeLengthInDays() const;
 

	
 
	/**
 
	 * Check if the engine is a ground vehicle.
 
	 * @return True iff the engine is a train or a road vehicle.
 
	 */
 
	FORCEINLINE bool IsGroundVehicle() const
 
	{
 
		return this->type == VEH_TRAIN || this->type == VEH_ROAD;
 
	}
 
};
 

	
 
struct EngineIDMapping {
0 comments (0 inline, 0 general)