diff options
author | Patric Stout <truebrain@openttd.org> | 2021-01-07 19:58:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 19:58:04 +0100 |
commit | 725d793be16636ef7f7c3d4a479f0d2523a5d83c (patch) | |
tree | a9268ed7aec110a291b0cd6f0df851fbeb9a44a2 | |
parent | 51e22515a8ee974aa309bf98a6b36013b2879fc5 (diff) | |
download | openttd-725d793be16636ef7f7c3d4a479f0d2523a5d83c.tar.xz |
Fix: don't allow cloning vehicles if cloning orders is failing (#8515)
Before this fix, any failing clone order was silently ignored
and you as user would never know till you checked the order list.
Evil.
-rw-r--r-- | src/vehicle_cmd.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index bb1574d4f..7e1d3a863 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -978,7 +978,12 @@ CommandCost CmdCloneVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint * the vehicle refitted before doing this, otherwise the moved * cargo types might not match (passenger vs non-passenger) */ - DoCommand(0, w_front->index | (p2 & 1 ? CO_SHARE : CO_COPY) << 30, v_front->index, flags, CMD_CLONE_ORDER); + CommandCost result = DoCommand(0, w_front->index | (p2 & 1 ? CO_SHARE : CO_COPY) << 30, v_front->index, flags, CMD_CLONE_ORDER); + if (result.Failed()) { + /* The vehicle has already been bought, so now it must be sold again. */ + DoCommand(w_front->tile, w_front->index | 1 << 20, 0, flags, GetCmdSellVeh(w_front)); + return result; + } /* Now clone the vehicle's name, if it has one. */ if (!v_front->name.empty()) CloneVehicleName(v_front, w_front); |