File diff r24596:eddf98238034 → r24597:afde5721a3b6
src/newgrf_engine.cpp
Show inline comments
 
@@ -919,50 +919,50 @@ static uint32 VehicleGetVariable(Vehicle
 
		*available = false;
 
		return UINT_MAX;
 
	}
 

	
 
	return VehicleGetVariable(const_cast<Vehicle*>(this->v), this, variable, parameter, available);
 
}
 

	
 

	
 
/* virtual */ const SpriteGroup *VehicleResolverObject::ResolveReal(const RealSpriteGroup *group) const
 
{
 
	const Vehicle *v = this->self_scope.v;
 

	
 
	if (v == nullptr) {
 
		if (group->num_loading > 0) return group->loading[0];
 
		if (group->num_loaded  > 0) return group->loaded[0];
 
		return nullptr;
 
	}
 

	
 
	bool in_motion = !v->First()->current_order.IsType(OT_LOADING);
 

	
 
	uint totalsets = in_motion ? group->num_loaded : group->num_loading;
 

	
 
	if (totalsets == 0) return nullptr;
 

	
 
	uint set = (v->cargo.StoredCount() * totalsets) / max((uint16)1, v->cargo_cap);
 
	set = min(set, totalsets - 1);
 
	uint set = (v->cargo.StoredCount() * totalsets) / std::max<uint16>(1u, v->cargo_cap);
 
	set = std::min(set, totalsets - 1);
 

	
 
	return in_motion ? group->loaded[set] : group->loading[set];
 
}
 

	
 
GrfSpecFeature VehicleResolverObject::GetFeature() const
 
{
 
	switch (Engine::Get(this->self_scope.self_type)->type) {
 
		case VEH_TRAIN: return GSF_TRAINS;
 
		case VEH_ROAD: return GSF_ROADVEHICLES;
 
		case VEH_SHIP: return GSF_SHIPS;
 
		case VEH_AIRCRAFT: return GSF_AIRCRAFT;
 
		default: return GSF_INVALID;
 
	}
 
}
 

	
 
uint32 VehicleResolverObject::GetDebugID() const
 
{
 
	return Engine::Get(this->self_scope.self_type)->grf_prop.local_id;
 
}
 

	
 
/**
 
 * Get the grf file associated with an engine type.
 
 * @param engine_type Engine to query.
 
 * @return grf file associated with the engine.