Fix virtual train consist change callbacks being run before cargotype set
When instantiating virtual train from non-buildable template train See: #402 Also fixes instantiating virtual train from train not refitting leading vehicle.
This commit is contained in:
@@ -1452,7 +1452,7 @@ struct BuildVehicleWindow : BuildVehicleWindowBase {
|
||||
SavedRandomSeeds saved_seeds;
|
||||
SaveRandomSeeds(&saved_seeds);
|
||||
StringID err;
|
||||
Train *t = CmdBuildVirtualRailVehicle(this->sel_engine, err, 0);
|
||||
Train *t = BuildVirtualRailVehicle(this->sel_engine, err, 0, false);
|
||||
if (t != nullptr) {
|
||||
const CommandCost ret = CmdRefitVehicle(0, DC_QUERY_COST, t->index, cargo | (1 << 16), nullptr);
|
||||
this->te.cost = ret.GetCost();
|
||||
@@ -2234,7 +2234,7 @@ struct BuildVehicleWindowTrainAdvanced final : BuildVehicleWindowBase {
|
||||
SavedRandomSeeds saved_seeds;
|
||||
SaveRandomSeeds(&saved_seeds);
|
||||
StringID err;
|
||||
Train *t = CmdBuildVirtualRailVehicle(state.sel_engine, err, 0);
|
||||
Train *t = BuildVirtualRailVehicle(state.sel_engine, err, 0, false);
|
||||
if (t != nullptr) {
|
||||
const CommandCost ret = CmdRefitVehicle(0, DC_QUERY_COST, t->index, cargo | (1 << 16), nullptr);
|
||||
state.te.cost = ret.GetCost();
|
||||
|
Reference in New Issue
Block a user