Changeset - r21706:ae3a142677ea
[Not reviewed]
master
0 3 0
alberth - 10 years ago 2014-09-18 19:53:22
alberth@openttd.org
(svn r26849) -Fix[FS#6113]: Better display of refit information in articulated vehicles.
3 files changed with 42 insertions and 7 deletions:
0 comments (0 inline, 0 general)
src/articulated_vehicles.cpp
Show inline comments
 
@@ -163,6 +163,41 @@ CargoArray GetCapacityOfArticulatedParts
 
}
 

	
 
/**
 
 * Get the default cargoes and refits of an articulated vehicle.
 
 * The refits are linked to a cargo rather than an articulated part to prevent a long list of parts.
 
 * @param engine Model to investigate.
 
 * @param[out] cargoes Total amount of units that can be transported, summed by cargo.
 
 * @param[out] refits Whether a (possibly partial) refit for each cargo is possible.
 
 */
 
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits)
 
{
 
	cargoes->Clear();
 
	*refits = 0;
 

	
 
	const Engine *e = Engine::Get(engine);
 

	
 
	CargoID cargo_type;
 
	uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
 
	if (cargo_type < NUM_CARGO && cargo_capacity > 0) {
 
		(*cargoes)[cargo_type] += cargo_capacity;
 
		if (IsEngineRefittable(engine)) SetBit(*refits, cargo_type);
 
	}
 

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

	
 
	for (uint i = 1; i < MAX_ARTICULATED_PARTS; i++) {
 
		EngineID artic_engine = GetNextArticulatedPart(i, engine);
 
		if (artic_engine == INVALID_ENGINE) break;
 

	
 
		cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
 
		if (cargo_type < NUM_CARGO && cargo_capacity > 0) {
 
			(*cargoes)[cargo_type] += cargo_capacity;
 
			if (IsEngineRefittable(artic_engine)) SetBit(*refits, cargo_type);
 
		}
 
	}
 
}
 

	
 
/**
 
 * Checks whether any of the articulated parts is refittable
 
 * @param engine the first part
 
 * @return true if refittable
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -532,21 +532,20 @@ static GUIEngineList::FilterFunction * c
 
	&CargoFilter,
 
};
 

	
 
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine, bool refittable)
 
static int DrawCargoCapacityInfo(int left, int right, int y, EngineID engine)
 
{
 
	CargoArray cap = GetCapacityOfArticulatedParts(engine);
 
	CargoArray cap;
 
	uint32 refits;
 
	GetArticulatedVehicleCargoesAndRefits(engine, &cap, &refits);
 

	
 
	for (CargoID c = 0; c < NUM_CARGO; c++) {
 
		if (cap[c] == 0) continue;
 

	
 
		SetDParam(0, c);
 
		SetDParam(1, cap[c]);
 
		SetDParam(2, refittable ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
 
		SetDParam(2, HasBit(refits, c) ? STR_PURCHASE_INFO_REFITTABLE : STR_EMPTY);
 
		DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
 
		y += FONT_HEIGHT_NORMAL;
 

	
 
		/* Only show as refittable once */
 
		refittable = false;
 
	}
 

	
 
	return y;
 
@@ -831,7 +830,7 @@ int DrawVehiclePurchaseInfo(int left, in
 

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

	
 
		if (new_y == y) {
 
			SetDParam(0, CT_INVALID);
src/engine_func.h
Show inline comments
 
@@ -26,6 +26,7 @@ extern const uint8 _engine_offsets[4];
 

	
 
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
 
bool IsEngineRefittable(EngineID engine);
 
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits);
 
void SetYearEngineAgingStops();
 
void StartupOneEngine(Engine *e, Date aging_date);
 

	
0 comments (0 inline, 0 general)