TBTR: Fix template ownership and replacement checks in CmdReplaceTemplateVehicle
This commit is contained in:
@@ -1249,6 +1249,10 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3
|
||||
}
|
||||
CommandCost ret = CheckOwnership(vehicle->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
if (template_vehicle != nullptr) {
|
||||
ret = CheckOwnership(template_vehicle->owner);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
vehicle = vehicle->First();
|
||||
|
||||
@@ -1295,7 +1299,7 @@ CommandCost CmdReplaceTemplateVehicle(TileIndex tile, DoCommandFlag flags, uint3
|
||||
}
|
||||
|
||||
// Make sure our replacements still point to the correct thing.
|
||||
if (old_ID != template_vehicle->index) {
|
||||
if (old_ID != INVALID_VEHICLE && old_ID != template_vehicle->index) {
|
||||
bool reindex = false;
|
||||
for (TemplateReplacement *tr : TemplateReplacement::Iterate()) {
|
||||
if (tr->GetTemplateVehicleID() == old_ID) {
|
||||
|
Reference in New Issue
Block a user