TBTR: Check that refit command virtual flag can't be used on non-virtual vehicles

This commit is contained in:
Jonathan G Rennison
2019-12-17 17:12:50 +00:00
parent a9c4b80d26
commit abfb141afd

View File

@@ -493,6 +493,8 @@ CommandCost CmdRefitVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
bool is_virtual_train = HasBit(p2, 31); bool is_virtual_train = HasBit(p2, 31);
bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew bool free_wagon = v->type == VEH_TRAIN && Train::From(front)->IsFreeWagon(); // used by autoreplace/renew
if (is_virtual_train && !(v->type == VEH_TRAIN && Train::From(front)->IsVirtual())) return CMD_ERROR;
if (is_virtual_train || (v->type == VEH_TRAIN && Train::From(front)->IsVirtual())) { if (is_virtual_train || (v->type == VEH_TRAIN && Train::From(front)->IsVirtual())) {
CommandCost ret = CheckOwnership(front->owner); CommandCost ret = CheckOwnership(front->owner);
if (ret.Failed()) return ret; if (ret.Failed()) return ret;