From 9f2e23d8bac33effe68c911335e8a1d6ff6211fb Mon Sep 17 00:00:00 2001 From: frosch Date: Sun, 3 May 2020 22:06:56 +0200 Subject: Fix #8093: Build+Refit changed game-state in command test run, and thus caused desyncs. Use DC_AUTOREPLACE for actions that shall be reversibe, in this case: - Do not rearrange free wagons in test-run. - Do not discard OrderBackups. The latter was not triggered by actual auto-replace, since it does not set a 'user'. --- src/vehicle_cmd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vehicle_cmd.cpp b/src/vehicle_cmd.cpp index 7383e1d4a..2f0a49ca2 100644 --- a/src/vehicle_cmd.cpp +++ b/src/vehicle_cmd.cpp @@ -128,7 +128,7 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint /* If we are refitting we need to temporarily purchase the vehicle to be able to * test it. */ DoCommandFlag subflags = flags; - if (refitting) subflags |= DC_EXEC; + if (refitting && !(flags & DC_EXEC)) subflags |= DC_EXEC | DC_AUTOREPLACE; /* Vehicle construction needs random bits, so we have to save the random * seeds to prevent desyncs. */ @@ -173,7 +173,7 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint if (v->IsPrimaryVehicle()) { GroupStatistics::CountVehicle(v, 1); - OrderBackup::Restore(v, p2); + if (!(subflags & DC_AUTOREPLACE)) OrderBackup::Restore(v, p2); } } -- cgit v1.2.3-70-g09d2