File diff r6607:1410c388c54c → r6608:f2d13a751f0b
src/build_vehicle_gui.cpp
Show inline comments
 
@@ -377,25 +377,25 @@ static const StringID _sort_listing[][10
 

	
 
/* Draw rail wagon specific details */
 
static int DrawRailWagonPurchaseInfo(int x, int y, EngineID engine_number, const RailVehicleInfo *rvi)
 
{
 
	/* Purchase cost */
 
	SetDParam(0, (GetEngineProperty(engine_number, 0x17, rvi->base_cost) * _price.build_railwagon) >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_COST, 0);
 
	y += 10;
 

	
 
	/* Wagon weight - (including cargo) */
 
	uint weight = GetEngineProperty(engine_number, 0x16, rvi->weight);
 
	SetDParam(0, weight);
 
	SetDParam(1, (GetCargo(rvi->cargo_type)->weight * rvi->capacity >> 4) + weight);
 
	SetDParam(1, (GetCargo(rvi->cargo_type)->weight * GetEngineProperty(engine_number, 0x14, rvi->capacity) >> 4) + weight);
 
	DrawString(x, y, STR_PURCHASE_INFO_WEIGHT_CWEIGHT, 0);
 
	y += 10;
 

	
 
	/* Wagon speed limit, displayed if above zero */
 
	if (_patches.wagon_speed_limits) {
 
		uint max_speed = GetEngineProperty(engine_number, 0x09, rvi->max_speed);
 
		if (max_speed > 0) {
 
			SetDParam(0, max_speed * 10 / 16);
 
			DrawString(x, y, STR_PURCHASE_INFO_SPEED, 0);
 
			y += 10;
 
		}
 
	}
 
@@ -452,44 +452,44 @@ static int DrawRoadVehPurchaseInfo(int x
 
	SetDParam(0, GetEngineProperty(engine_number, 0x11, rvi->base_cost) * (_price.roadveh_base >> 3) >> 5);
 
	SetDParam(1, rvi->max_speed * 10 / 32);
 
	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
 
	y += 10;
 

	
 
	/* Running cost */
 
	SetDParam(0, rvi->running_cost * _price.roadveh_running >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 
	y += 10;
 

	
 
	/* Cargo type + capacity */
 
	SetDParam(0, rvi->cargo_type);
 
	SetDParam(1, rvi->capacity);
 
	SetDParam(1, GetEngineProperty(engine_number, 0x0F, rvi->capacity));
 
	SetDParam(2, refittable ? STR_9842_REFITTABLE : STR_EMPTY);
 
	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
	y += 10;
 

	
 
	return y;
 
}
 

	
 
/* Draw ship specific details */
 
static int DrawShipPurchaseInfo(int x, int y, EngineID engine_number, const ShipVehicleInfo *svi)
 
{
 
	/* Purchase cost - Max speed */
 
	SetDParam(0, GetEngineProperty(engine_number, 0x0A, svi->base_cost) * (_price.ship_base >> 3) >> 5);
 
	SetDParam(1, GetEngineProperty(engine_number, 0x0B, svi->max_speed) * 10 / 32);
 
	DrawString(x, y, STR_PURCHASE_INFO_COST_SPEED, 0);
 
	y += 10;
 

	
 
	/* Cargo type + capacity */
 
	SetDParam(0, svi->cargo_type);
 
	SetDParam(1, svi->capacity);
 
	SetDParam(1, GetEngineProperty(engine_number, 0x0D, svi->capacity));
 
	SetDParam(2, svi->refittable ? STR_9842_REFITTABLE : STR_EMPTY);
 
	DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
	y += 10;
 

	
 
	/* Running cost */
 
	SetDParam(0, GetEngineProperty(engine_number, 0x0F, svi->running_cost) * _price.ship_running >> 8);
 
	DrawString(x, y, STR_PURCHASE_INFO_RUNNINGCOST, 0);
 
	y += 10;
 

	
 
	return y;
 
}
 

	
 
@@ -536,42 +536,43 @@ static int DrawAircraftPurchaseInfo(int 
 
 * @return y after drawing all the text
 
 */
 
int DrawVehiclePurchaseInfo(int x, int y, uint w, EngineID engine_number)
 
{
 
	const Engine *e = GetEngine(engine_number);
 
	YearMonthDay ymd;
 
	ConvertDateToYMD(e->intro_date, &ymd);
 
	bool refitable = false;
 

	
 
	switch (e->type) {
 
		case VEH_TRAIN: {
 
			const RailVehicleInfo *rvi = RailVehInfo(engine_number);
 
			uint capacity = GetEngineProperty(engine_number, 0x14, rvi->capacity);
 

	
 
			refitable = (EngInfo(engine_number)->refit_mask != 0) && (rvi->capacity > 0);
 
			refitable = (EngInfo(engine_number)->refit_mask != 0) && (capacity > 0);
 

	
 
			if (rvi->railveh_type == RAILVEH_WAGON) {
 
				y = DrawRailWagonPurchaseInfo(x, y, engine_number, rvi);
 
			} else {
 
				y = DrawRailEnginePurchaseInfo(x, y, engine_number, rvi);
 
			}
 

	
 
			/* Cargo type + capacity, or N/A */
 
			if (rvi->capacity == 0) {
 
				SetDParam(0, CT_INVALID);
 
				SetDParam(2, STR_EMPTY);
 
			} else {
 
				int multihead = (rvi->railveh_type == RAILVEH_MULTIHEAD ? 1 : 0);
 

	
 
				SetDParam(0, rvi->cargo_type);
 
				SetDParam(1, (rvi->capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
 
				SetDParam(1, (capacity * (CountArticulatedParts(engine_number) + 1)) << multihead);
 
				SetDParam(2, refitable ? STR_9842_REFITTABLE : STR_EMPTY);
 
			}
 
			DrawString(x, y, STR_PURCHASE_INFO_CAPACITY, 0);
 
			y += 10;
 
		}
 
			break;
 
		case VEH_ROAD:
 
			y = DrawRoadVehPurchaseInfo(x, y, engine_number, RoadVehInfo(engine_number));
 
			refitable = true;
 
			break;
 
		case VEH_SHIP: {
 
			const ShipVehicleInfo *svi = ShipVehInfo(engine_number);