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'.
This commit is contained in:
frosch 2020-05-03 22:06:56 +02:00 committed by frosch
parent 0f9dc88834
commit 9f2e23d8ba
1 changed files with 2 additions and 2 deletions

View File

@ -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);
}
}