mirror of https://github.com/OpenTTD/OpenTTD
Fix #7469: Desync when using build and refit feature.
parent
c99f731f89
commit
8114bad033
|
@ -31,6 +31,7 @@
|
||||||
#include "ship.h"
|
#include "ship.h"
|
||||||
#include "newgrf.h"
|
#include "newgrf.h"
|
||||||
#include "company_base.h"
|
#include "company_base.h"
|
||||||
|
#include "core/random_func.hpp"
|
||||||
|
|
||||||
#include "table/strings.h"
|
#include "table/strings.h"
|
||||||
|
|
||||||
|
@ -131,6 +132,11 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
DoCommandFlag subflags = flags;
|
DoCommandFlag subflags = flags;
|
||||||
if (refitting) subflags |= DC_EXEC;
|
if (refitting) subflags |= DC_EXEC;
|
||||||
|
|
||||||
|
/* Vehicle construction needs random bits, so we have to save the random
|
||||||
|
* seeds to prevent desyncs. */
|
||||||
|
SavedRandomSeeds saved_seeds;
|
||||||
|
if (flags != subflags) SaveRandomSeeds(&saved_seeds);
|
||||||
|
|
||||||
Vehicle *v = NULL;
|
Vehicle *v = NULL;
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break;
|
case VEH_TRAIN: value.AddCost(CmdBuildRailVehicle(tile, subflags, e, GB(p1, 24, 8), &v)); break;
|
||||||
|
@ -179,6 +185,8 @@ CommandCost CmdBuildVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (flags != subflags) RestoreRandomSeeds(saved_seeds);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue