Changeset - r13211:4ba95564ba64
[Not reviewed]
master
0 9 0
frosch - 15 years ago 2009-10-06 19:52:38
frosch@openttd.org
(svn r17728) -Cleanup: Remove some more unneeded/unused parameters.
9 files changed with 48 insertions and 47 deletions:
0 comments (0 inline, 0 general)
src/ai/api/ai_engine.cpp
Show inline comments
 
@@ -75,7 +75,7 @@
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
			CargoArray capacities = GetCapacityOfArticulatedParts(engine_id, e->type);
 
			CargoArray capacities = GetCapacityOfArticulatedParts(engine_id);
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				if (capacities[c] == 0) continue;
 
				return capacities[c];
src/ai/api/ai_event_types.cpp
Show inline comments
 
@@ -41,7 +41,7 @@ int32 AIEventEnginePreview::GetCapacity(
 
	switch (e->type) {
 
		case VEH_ROAD:
 
		case VEH_TRAIN: {
 
			CargoArray capacities = GetCapacityOfArticulatedParts(this->engine, e->type);
 
			CargoArray capacities = GetCapacityOfArticulatedParts(this->engine);
 
			for (CargoID c = 0; c < NUM_CARGO; c++) {
 
				if (capacities[c] == 0) continue;
 
				return capacities[c];
src/articulated_vehicles.cpp
Show inline comments
 
@@ -81,23 +81,24 @@ static inline uint32 GetAvailableVehicle
 
	return cargos;
 
}
 

	
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine)
 
{
 
	CargoArray capacity;
 
	const Engine *e = Engine::Get(engine);
 

	
 
	CargoID cargo_type;
 
	uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
 
	if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
 

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

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

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
 
		if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
 

	
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
 

	
 
		cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
 
		if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
 
@@ -134,23 +135,23 @@ bool IsArticulatedVehicleRefittable(Engi
 
/**
 
 * Ors the refit_masks of all articulated parts.
 
 * @param engine the first part
 
 * @param type the vehicle type
 
 * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
 
 * @return bit mask of CargoIDs which are a refit option for at least one articulated part
 
 */
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint32 cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
 

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

	
 
	if (!HasBit(EngInfo(engine)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
 
		if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
 

	
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
 
		cargos |= GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
 
	}
 

	
 
@@ -160,26 +161,26 @@ uint32 GetUnionOfArticulatedRefitMasks(E
 
/**
 
 * Ands the refit_masks of all articulated parts.
 
 * @param engine the first part
 
 * @param type the vehicle type
 
 * @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
 
 * @return bit mask of CargoIDs which are a refit option for every articulated part (with default capacity > 0)
 
 */
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type)
 
{
 
	const Engine *e = Engine::Get(engine);
 
	uint32 cargos = UINT32_MAX;
 

	
 
	uint32 veh_cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
 
	if (veh_cargos != 0) cargos &= veh_cargos;
 

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

	
 
	if (!HasBit(EngInfo(engine)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
 
	if (!HasBit(e->info.callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return cargos;
 

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		uint16 callback = GetVehicleCallback(CBID_VEHICLE_ARTIC_ENGINE, i, 0, engine, NULL);
 
		if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
 

	
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
 
		EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), e->type, GB(callback, 0, 7));
 
		veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
 
		if (veh_cargos != 0) cargos &= veh_cargos;
 
	}
 
@@ -239,9 +240,9 @@ void CheckConsistencyOfArticulatedVehicl
 
{
 
	const Engine *engine = Engine::Get(v->engine_type);
 

	
 
	uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
	uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, v->type, true);
 
	CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type, v->type);
 
	uint32 purchase_refit_union = GetUnionOfArticulatedRefitMasks(v->engine_type, true);
 
	uint32 purchase_refit_intersection = GetIntersectionOfArticulatedRefitMasks(v->engine_type, true);
 
	CargoArray purchase_default_capacity = GetCapacityOfArticulatedParts(v->engine_type);
 

	
 
	uint32 real_refit_union = 0;
 
	uint32 real_refit_intersection = UINT_MAX;
src/articulated_vehicles.h
Show inline comments
 
@@ -16,10 +16,10 @@
 
#include "engine_type.h"
 

	
 
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
 
CargoArray GetCapacityOfArticulatedParts(EngineID engine);
 
void AddArticulatedParts(Vehicle *first);
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
 
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
 
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, bool include_initial_cargo_type);
 
bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type);
 
bool IsArticulatedVehicleRefittable(EngineID engine);
 
void CheckConsistencyOfArticulatedVehicle(const Vehicle *v);
src/autoreplace_cmd.cpp
Show inline comments
 
@@ -33,10 +33,10 @@ extern void ChangeVehicleViewWindow(Vehi
 
 * @param type the type of the engines
 
 * @return true if they can both carry the same type of cargo (or at least one of them got no capacity at all)
 
 */
 
static bool EnginesGotCargoInCommon(EngineID engine_a, EngineID engine_b, VehicleType type)
 
static bool EnginesHaveCargoInCommon(EngineID engine_a, EngineID engine_b)
 
{
 
	uint32 available_cargos_a = GetUnionOfArticulatedRefitMasks(engine_a, type, true);
 
	uint32 available_cargos_b = GetUnionOfArticulatedRefitMasks(engine_b, type, true);
 
	uint32 available_cargos_a = GetUnionOfArticulatedRefitMasks(engine_a, true);
 
	uint32 available_cargos_b = GetUnionOfArticulatedRefitMasks(engine_b, true);
 
	return (available_cargos_a == 0 || available_cargos_b == 0 || (available_cargos_a & available_cargos_b) != 0);
 
}
 

	
 
@@ -87,7 +87,7 @@ bool CheckAutoreplaceValidity(EngineID f
 
	}
 

	
 
	/* the engines needs to be able to carry the same cargo */
 
	return EnginesGotCargoInCommon(from, to, type);
 
	return EnginesHaveCargoInCommon(from, to);
 
}
 

	
 
/** Transfer cargo from a single (articulated )old vehicle to the new vehicle chain
 
@@ -138,8 +138,8 @@ static bool VerifyAutoreplaceRefitForOrd
 
	const Order *o;
 
	const Vehicle *u;
 

	
 
	uint32 union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, v->type, false);
 
	uint32 union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, v->type, false);
 
	uint32 union_refit_mask_a = GetUnionOfArticulatedRefitMasks(v->engine_type, false);
 
	uint32 union_refit_mask_b = GetUnionOfArticulatedRefitMasks(engine_type, false);
 

	
 
	if (v->type == VEH_TRAIN) {
 
		u = v->First();
 
@@ -171,11 +171,11 @@ static CargoID GetNewCargoTypeForReplace
 
{
 
	CargoID cargo_type;
 

	
 
	if (GetUnionOfArticulatedRefitMasks(engine_type, v->type, true) == 0) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
 
	if (GetUnionOfArticulatedRefitMasks(engine_type, true) == 0) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
 

	
 
	if (IsArticulatedVehicleCarryingDifferentCargos(v, &cargo_type)) return CT_INVALID; // We cannot refit to mixed cargos in an automated way
 

	
 
	uint32 available_cargo_types = GetIntersectionOfArticulatedRefitMasks(engine_type, v->type, true);
 
	uint32 available_cargo_types = GetIntersectionOfArticulatedRefitMasks(engine_type, true);
 

	
 
	if (cargo_type == CT_INVALID) {
 
		if (v->type != VEH_TRAIN) return CT_NO_REFIT; // If the vehicle does not carry anything at all, every replacement is fine.
 
@@ -190,7 +190,7 @@ static CargoID GetNewCargoTypeForReplace
 
			/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
 
			if (HasBit(available_cargo_types, v->cargo_type)) {
 
				/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
 
				CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
				CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type);
 
				for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
					if (cid != v->cargo_type && default_capacity[cid] > 0) return v->cargo_type;
 
				}
 
@@ -206,7 +206,7 @@ static CargoID GetNewCargoTypeForReplace
 
		if (part_of_chain && !VerifyAutoreplaceRefitForOrders(v, engine_type)) return CT_INVALID; // Some refit orders lose their effect
 

	
 
		/* Do we have to refit the vehicle, or is it already carrying the right cargo? */
 
		CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type, v->type);
 
		CargoArray default_capacity = GetCapacityOfArticulatedParts(engine_type);
 
		for (CargoID cid = 0; cid < NUM_CARGO; cid++) {
 
			if (cid != cargo_type && default_capacity[cid] > 0) return cargo_type;
 
		}
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -239,8 +239,8 @@ static int CDECL TrainEngineCapacitySort
 
	const RailVehicleInfo *rvi_a = RailVehInfo(*a);
 
	const RailVehicleInfo *rvi_b = RailVehInfo(*b);
 

	
 
	int va = GetTotalCapacityOfArticulatedParts(*a, VEH_TRAIN) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 
	int vb = GetTotalCapacityOfArticulatedParts(*b, VEH_TRAIN) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 
	int va = GetTotalCapacityOfArticulatedParts(*a) * (rvi_a->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 
	int vb = GetTotalCapacityOfArticulatedParts(*b) * (rvi_b->railveh_type == RAILVEH_MULTIHEAD ? 2 : 1);
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -262,8 +262,8 @@ static int CDECL TrainEnginesThenWagonsS
 
/* Road vehicle sorting functions */
 
static int CDECL RoadVehEngineCapacitySorter(const EngineID *a, const EngineID *b)
 
{
 
	int va = GetTotalCapacityOfArticulatedParts(*a, VEH_ROAD);
 
	int vb = GetTotalCapacityOfArticulatedParts(*b, VEH_ROAD);
 
	int va = GetTotalCapacityOfArticulatedParts(*a);
 
	int vb = GetTotalCapacityOfArticulatedParts(*b);
 
	int r = va - vb;
 

	
 
	/* Use EngineID to sort instead since we want consistent sorting */
 
@@ -406,7 +406,7 @@ static const StringID _sort_listing[][11
 
static bool CDECL CargoFilter(const EngineID *eid, const CargoID cid)
 
{
 
	if (cid == CF_ANY) return true;
 
	uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, Engine::Get(*eid)->type, true);
 
	uint32 refit_mask = GetUnionOfArticulatedRefitMasks(*eid, true);
 
	return (cid == CF_NONE ? refit_mask == 0 : HasBit(refit_mask, cid));
 
}
 

	
 
@@ -414,9 +414,9 @@ static GUIEngineList::FilterFunction * c
 
	&CargoFilter,
 
};
 

	
 
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, VehicleType type, bool refittable)
 
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, bool refittable)
 
{
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine);
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		if (cap[c] == 0) continue;
 
@@ -640,7 +640,7 @@ int DrawVehiclePurchaseInfo(int left, in
 
			}
 

	
 
			/* Cargo type + capacity, or N/A */
 
			int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, VEH_TRAIN, refittable);
 
			int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
 

	
 
			if (new_y == y) {
 
				SetDParam(0, CT_INVALID);
 
@@ -656,7 +656,7 @@ int DrawVehiclePurchaseInfo(int left, in
 
			y = DrawRoadVehPurchaseInfo(left, right, y, engine_number);
 

	
 
			/* Cargo type + capacity, or N/A */
 
			int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, VEH_ROAD, refittable);
 
			int new_y = DrawCargoCapacityInfo(left, right, y, engine_number, refittable);
 

	
 
			if (new_y == y) {
 
				SetDParam(0, CT_INVALID);
src/engine_func.h
Show inline comments
 
@@ -32,6 +32,6 @@ void SetCachedEngineCounts();
 
void SetYearEngineAgingStops();
 
void StartupOneEngine(Engine *e, Date aging_date);
 

	
 
uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type);
 
uint GetTotalCapacityOfArticulatedParts(EngineID engine);
 

	
 
#endif /* ENGINE_H */
src/engine_gui.cpp
Show inline comments
 
@@ -122,11 +122,11 @@ void ShowEnginePreviewWindow(EngineID en
 
	AllocateWindowDescFront<EnginePreviewWindow>(&_engine_preview_desc, engine);
 
}
 

	
 
uint GetTotalCapacityOfArticulatedParts(EngineID engine, VehicleType type)
 
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
 
{
 
	uint total = 0;
 

	
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine, type);
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine);
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		total += cap[c];
 
	}
 
@@ -143,7 +143,7 @@ static StringID GetTrainEngineInfoString
 

	
 
	SetDParam(4, e->GetRunningCost());
 

	
 
	uint capacity = GetTotalCapacityOfArticulatedParts(e->index, VEH_TRAIN);
 
	uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
 
	if (capacity != 0) {
 
		SetDParam(5, e->GetDefaultCargoType());
 
		SetDParam(6, capacity);
 
@@ -180,7 +180,7 @@ static StringID GetRoadVehEngineInfoStri
 
{
 
	SetDParam(0, e->GetCost());
 
	SetDParam(1, e->GetDisplayMaxSpeed());
 
	uint capacity = GetTotalCapacityOfArticulatedParts(e->index, VEH_ROAD);
 
	uint capacity = GetTotalCapacityOfArticulatedParts(e->index);
 
	if (capacity != 0) {
 
		SetDParam(2, e->GetDefaultCargoType());
 
		SetDParam(3, capacity);
src/vehicle_gui.cpp
Show inline comments
 
@@ -447,7 +447,7 @@ void ShowVehicleRefitWindow(const Vehicl
 
uint ShowRefitOptionsList(int left, int right, int y, EngineID engine)
 
{
 
	/* List of cargo types of this engine */
 
	uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, Engine::Get(engine)->type, false);
 
	uint32 cmask = GetUnionOfArticulatedRefitMasks(engine, false);
 
	/* List of cargo types available in this climate */
 
	uint32 lmask = _cargo_mask;
 
	char string[512];
0 comments (0 inline, 0 general)