TBTR: Add option to replace only old vehicles
This commit is contained in:
@@ -899,6 +899,35 @@ CommandCost CmdToggleRefitAsTemplate(TileIndex tile, DoCommandFlag flags, uint32
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles replace old only on a template vehicle.
|
||||
* @param tile unused
|
||||
* @param flags type of operation
|
||||
* @param p1 the template vehicle's index
|
||||
* @param p2 unused
|
||||
* @param text unused
|
||||
* @return the cost of this operation or an error
|
||||
*/
|
||||
CommandCost CmdToggleTemplateReplaceOldOnly(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
|
||||
{
|
||||
// Identify template to toggle
|
||||
TemplateVehicle *template_vehicle = TemplateVehicle::GetIfValid(p1);
|
||||
|
||||
if (template_vehicle == NULL) {
|
||||
return CMD_ERROR;
|
||||
}
|
||||
|
||||
bool should_execute = (flags & DC_EXEC) != 0;
|
||||
|
||||
if (should_execute) {
|
||||
template_vehicle->ToggleReplaceOldOnly();
|
||||
|
||||
InvalidateWindowClassesData(WC_TEMPLATEGUI_MAIN, 0);
|
||||
}
|
||||
|
||||
return CommandCost();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a virtual train from a template vehicle.
|
||||
* @param tile unused
|
||||
|
Reference in New Issue
Block a user