mirror of https://github.com/OpenTTD/OpenTTD
(svn r26972) [1.4] -Backport from trunk:
- Fix: Compilation of strgen on various platforms like Solaris (r26850) - Fix: Better display of refit information for articulated vehicles [FS#6113] (r26849, r26848) - Fix: Do not assign a next hop when returning cargo [FS#6110] (r26847) - Fix: The ok-button in the OSK for the signs list should just close the OSK [FS#6116] (r26827)release/1.4
parent
cac97612ac
commit
628b52921f
|
@ -1441,6 +1441,7 @@ make_cflags_and_ldflags() {
|
||||||
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
|
make_compiler_cflags "$cc_host" "CFLAGS" "CXXFLAGS" "LDFLAGS" "FEATURES"
|
||||||
|
|
||||||
CFLAGS="$CFLAGS -D$os"
|
CFLAGS="$CFLAGS -D$os"
|
||||||
|
CFLAGS_BUILD="$CFLAGS_BUILD -D$os"
|
||||||
|
|
||||||
if [ "$enable_debug" = "0" ]; then
|
if [ "$enable_debug" = "0" ]; then
|
||||||
# No debug, add default stuff
|
# No debug, add default stuff
|
||||||
|
|
|
@ -160,6 +160,41 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine)
|
||||||
return capacity;
|
return capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
* Checks whether any of the articulated parts is refittable
|
||||||
* @param engine the first part
|
* @param engine the first part
|
||||||
|
|
|
@ -526,21 +526,20 @@ static GUIEngineList::FilterFunction * const _filter_funcs[] = {
|
||||||
&CargoFilter,
|
&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++) {
|
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
||||||
if (cap[c] == 0) continue;
|
if (cap[c] == 0) continue;
|
||||||
|
|
||||||
SetDParam(0, c);
|
SetDParam(0, c);
|
||||||
SetDParam(1, cap[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);
|
DrawString(left, right, y, STR_PURCHASE_INFO_CAPACITY);
|
||||||
y += FONT_HEIGHT_NORMAL;
|
y += FONT_HEIGHT_NORMAL;
|
||||||
|
|
||||||
/* Only show as refittable once */
|
|
||||||
refittable = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return y;
|
return y;
|
||||||
|
@ -825,7 +824,7 @@ int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number)
|
||||||
|
|
||||||
if (articulated_cargo) {
|
if (articulated_cargo) {
|
||||||
/* Cargo type + capacity, or N/A */
|
/* 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) {
|
if (new_y == y) {
|
||||||
SetDParam(0, CT_INVALID);
|
SetDParam(0, CT_INVALID);
|
||||||
|
|
|
@ -1514,7 +1514,11 @@ static void HandleStationRefit(Vehicle *v, CargoArray &consist_capleft, Station
|
||||||
|
|
||||||
/* Refit if given a valid cargo. */
|
/* Refit if given a valid cargo. */
|
||||||
if (new_cid < NUM_CARGO && new_cid != v_start->cargo_type) {
|
if (new_cid < NUM_CARGO && new_cid != v_start->cargo_type) {
|
||||||
IterateVehicleParts(v_start, ReturnCargoAction(st, StationIDStack(next_station).Pop()));
|
/* INVALID_STATION because in the DT_MANUAL case that's correct and in the DT_(A)SYMMETRIC
|
||||||
|
* cases the next hop of the vehicle doesn't really tell us anything if the cargo had been
|
||||||
|
* "via any station" before reserving. We rather produce some more "any station" cargo than
|
||||||
|
* misrouting it. */
|
||||||
|
IterateVehicleParts(v_start, ReturnCargoAction(st, INVALID_STATION));
|
||||||
CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
CommandCost cost = DoCommand(v_start->tile, v_start->index, new_cid | 1U << 6 | 0xFF << 8 | 1U << 16, DC_EXEC, GetCmdRefitVeh(v_start)); // Auto-refit and only this vehicle including artic parts.
|
||||||
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
|
if (cost.Succeeded()) v->First()->profit_this_year -= cost.GetCost() << 8;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ extern const uint8 _engine_offsets[4];
|
||||||
|
|
||||||
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
|
bool IsEngineBuildable(EngineID engine, VehicleType type, CompanyID company);
|
||||||
bool IsEngineRefittable(EngineID engine);
|
bool IsEngineRefittable(EngineID engine);
|
||||||
|
void GetArticulatedVehicleCargoesAndRefits(EngineID engine, CargoArray *cargoes, uint32 *refits);
|
||||||
void SetYearEngineAgingStops();
|
void SetYearEngineAgingStops();
|
||||||
void StartupOneEngine(Engine *e, Date aging_date);
|
void StartupOneEngine(Engine *e, Date aging_date);
|
||||||
|
|
||||||
|
|
|
@ -140,14 +140,8 @@ void ShowEnginePreviewWindow(EngineID engine)
|
||||||
*/
|
*/
|
||||||
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
|
uint GetTotalCapacityOfArticulatedParts(EngineID engine)
|
||||||
{
|
{
|
||||||
uint total = 0;
|
|
||||||
|
|
||||||
CargoArray cap = GetCapacityOfArticulatedParts(engine);
|
CargoArray cap = GetCapacityOfArticulatedParts(engine);
|
||||||
for (CargoID c = 0; c < NUM_CARGO; c++) {
|
return cap.GetSum<uint>();
|
||||||
total += cap[c];
|
|
||||||
}
|
|
||||||
|
|
||||||
return total;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static StringID GetTrainEngineInfoString(const Engine *e)
|
static StringID GetTrainEngineInfoString(const Engine *e)
|
||||||
|
|
|
@ -158,7 +158,6 @@ struct SignListWindow : Window, SignList {
|
||||||
|
|
||||||
/* Initialize the text edit widget */
|
/* Initialize the text edit widget */
|
||||||
this->querystrings[WID_SIL_FILTER_TEXT] = &this->filter_editbox;
|
this->querystrings[WID_SIL_FILTER_TEXT] = &this->filter_editbox;
|
||||||
this->filter_editbox.ok_button = WID_SIL_FILTER_ENTER_BTN;
|
|
||||||
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
this->filter_editbox.cancel_button = QueryString::ACTION_CLEAR;
|
||||||
|
|
||||||
/* Initialize the filtering variables */
|
/* Initialize the filtering variables */
|
||||||
|
|
Loading…
Reference in New Issue