TBTR: Fix template replacement refits having 0 cost
This commit is contained in:
@@ -346,18 +346,21 @@ int NumTrainsNeedTemplateReplacement(GroupID g_id, const TemplateVehicle *tv)
|
||||
return count;
|
||||
}
|
||||
// refit each vehicle in t as is in tv, assume t and tv contain the same types of vehicles
|
||||
void CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags)
|
||||
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag flags)
|
||||
{
|
||||
CommandCost cost(t->GetExpenseType(false));
|
||||
|
||||
while (t && tv) {
|
||||
// refit t as tv
|
||||
uint32 cb = GetCmdRefitVeh(t);
|
||||
|
||||
DoCommand(t->tile, t->index, tv->cargo_type | tv->cargo_subtype << 8 | (1 << 16) | (1 << 31), flags, cb);
|
||||
cost.AddCost(DoCommand(t->tile, t->index, tv->cargo_type | tv->cargo_subtype << 8 | (1 << 16) | (1 << 31), flags, cb));
|
||||
|
||||
// next
|
||||
t = t->GetNextUnit();
|
||||
tv = tv->GetNextUnit();
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
/** using cmdtemplatereplacevehicle as test-function (i.e. with flag DC_NONE) is not a good idea as that function relies on
|
||||
|
@@ -46,7 +46,7 @@ int NumTrainsNeedTemplateReplacement(GroupID, const TemplateVehicle*);
|
||||
|
||||
CommandCost TestBuyAllTemplateVehiclesInChain(TemplateVehicle *tv, TileIndex tile);
|
||||
|
||||
void CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag);
|
||||
CommandCost CmdRefitTrainFromTemplate(Train *t, TemplateVehicle *tv, DoCommandFlag);
|
||||
void BreakUpRemainders(Train *t);
|
||||
|
||||
bool TemplateVehicleContainsEngineOfRailtype(const TemplateVehicle*, RailType);
|
||||
|
@@ -5659,7 +5659,7 @@ CommandCost CmdTemplateReplaceVehicle(TileIndex tile, DoCommandFlag flags, uint3
|
||||
|
||||
// refit, only if the template option is set so
|
||||
if (use_refit && (need_refit || need_replacement)) {
|
||||
CmdRefitTrainFromTemplate(new_chain, tv, flags);
|
||||
buy.AddCost(CmdRefitTrainFromTemplate(new_chain, tv, flags));
|
||||
}
|
||||
|
||||
if (new_chain && remainder_chain) {
|
||||
|
Reference in New Issue
Block a user