Skip to content

Commit

Permalink
Fix #8093: Build+Refit changed game-state in command test run, and th…
Browse files Browse the repository at this point in the history
…us 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'.
  • Loading branch information
frosch123 committed May 3, 2020
1 parent 0f9dc88 commit 9f2e23d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vehicle_cmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit 9f2e23d

Please sign in to comment.