|
@@ -2059,63 +2059,61 @@ CommandCost CmdRefitRailVehicle(TileInde
|
|
|
}
|
|
|
|
|
|
if (amount == CALLBACK_FAILED) { // callback failed or not used, use default
|
|
|
const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
|
|
|
CargoID old_cid = rvi->cargo_type;
|
|
|
/* normally, the capacity depends on the cargo type, a rail vehicle can
|
|
|
* carry twice as much mail/goods as normal cargo, and four times as
|
|
|
* many passengers
|
|
|
*/
|
|
|
amount = rvi->capacity;
|
|
|
switch (old_cid) {
|
|
|
case CT_PASSENGERS: break;
|
|
|
case CT_MAIL:
|
|
|
case CT_GOODS: amount *= 2; break;
|
|
|
default: amount *= 4; break;
|
|
|
}
|
|
|
switch (new_cid) {
|
|
|
case CT_PASSENGERS: break;
|
|
|
case CT_MAIL:
|
|
|
case CT_GOODS: amount /= 2; break;
|
|
|
default: amount /= 4; break;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (amount != 0) {
|
|
|
if (new_cid != v->cargo_type) {
|
|
|
cost.AddCost(GetRefitCost(v->engine_type));
|
|
|
}
|
|
|
|
|
|
num += amount;
|
|
|
if (flags & DC_EXEC) {
|
|
|
v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0);
|
|
|
v->cargo_type = new_cid;
|
|
|
v->cargo_cap = amount;
|
|
|
v->cargo_subtype = new_subtype;
|
|
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
|
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
|
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
|
|
}
|
|
|
if (new_cid != v->cargo_type) {
|
|
|
cost.AddCost(GetRefitCost(v->engine_type));
|
|
|
}
|
|
|
|
|
|
num += amount;
|
|
|
if (flags & DC_EXEC) {
|
|
|
v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0);
|
|
|
v->cargo_type = new_cid;
|
|
|
v->cargo_cap = amount;
|
|
|
v->cargo_subtype = new_subtype;
|
|
|
InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
|
|
|
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
|
|
|
InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
|
|
|
}
|
|
|
}
|
|
|
} while ((v = v->Next()) != NULL && !only_this);
|
|
|
|
|
|
_returned_refit_capacity = num;
|
|
|
|
|
|
/* Update the train's cached variables */
|
|
|
if (flags & DC_EXEC) TrainConsistChanged(GetVehicle(p1)->First(), false);
|
|
|
|
|
|
return cost;
|
|
|
}
|
|
|
|
|
|
struct TrainFindDepotData {
|
|
|
uint best_length;
|
|
|
TileIndex tile;
|
|
|
Owner owner;
|
|
|
/**
|
|
|
* true if reversing is necessary for the train to get to this depot
|
|
|
* This value is unused when new depot finding and NPF are both disabled
|
|
|
*/
|
|
|
bool reverse;
|
|
|
};
|
|
|
|
|
|
static bool NtpCallbFindDepot(TileIndex tile, TrainFindDepotData *tfdd, int track, uint length)
|