TBTR: Preserve replacement flags when editing template

This commit is contained in:
Jonathan G Rennison
2020-09-19 12:06:35 +01:00
parent e9bf1bd71b
commit 9af2c258fa

View File

@@ -1148,8 +1148,19 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3
if (should_execute) { if (should_execute) {
VehicleID old_ID = INVALID_VEHICLE; VehicleID old_ID = INVALID_VEHICLE;
bool restore_flags = false;
bool reuse_depot_vehicles = true;
bool keep_remaining_vehicles = false;
bool refit_as_template = true;
bool replace_old_only = false;
if (template_vehicle != nullptr) { if (template_vehicle != nullptr) {
old_ID = template_vehicle->index; old_ID = template_vehicle->index;
restore_flags = true;
reuse_depot_vehicles = template_vehicle->reuse_depot_vehicles;
keep_remaining_vehicles = template_vehicle->keep_remaining_vehicles;
refit_as_template = template_vehicle->refit_as_template;
replace_old_only = template_vehicle->replace_old_only;
delete template_vehicle; delete template_vehicle;
template_vehicle = nullptr; template_vehicle = nullptr;
} }
@@ -1160,6 +1171,13 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3
return CMD_ERROR; return CMD_ERROR;
} }
if (restore_flags) {
template_vehicle->reuse_depot_vehicles = reuse_depot_vehicles;
template_vehicle->keep_remaining_vehicles = keep_remaining_vehicles;
template_vehicle->refit_as_template = refit_as_template;
template_vehicle->replace_old_only = replace_old_only;
}
// Make sure our replacements still point to the correct thing. // Make sure our replacements still point to the correct thing.
if (old_ID != template_vehicle->index) { if (old_ID != template_vehicle->index) {
bool reindex = false; bool reindex = false;