diff options
author | rubidium <rubidium@openttd.org> | 2008-01-29 00:36:55 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2008-01-29 00:36:55 +0000 |
commit | 1629699094b6dd708c7c379f3bb03000fad549e3 (patch) | |
tree | aa58f2dfe5d8cb2b9ca934a66092611d90ca1f05 /src/newgrf_industries.cpp | |
parent | c9a9103566e7be441d79255fedf9752a53ab5ee9 (diff) | |
download | openttd-1629699094b6dd708c7c379f3bb03000fad549e3.tar.xz |
(svn r12006) -Fix: implement FS#1697 without the nasty side effects as specified in FS#1712.
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r-- | src/newgrf_industries.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index dd995263f..8eb6eb951 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -25,6 +25,8 @@ #include "table/strings.h" +static Randomizer _industry_creation_randomizer; + /* Since the industry IDs defined by the GRF file don't necessarily correlate * to those used by the game, the IDs used for overriding old industries must be * translated when the idustry spec is set. */ @@ -466,15 +468,15 @@ uint32 IndustryLocationGetVariable(const ResolverObject *object, byte variable, /* Square of Euclidian distance from town */ case 0x8D: return min(DistanceSquare(industry->town->xy, tile), 65535); - /* 32 random bits TODO! Wait for a better scheme that will not cause problems, MP desyncs and asserts */ - // case 0x8F: return Random(); + /* 32 random bits */ + case 0x8F: return _industry_creation_randomizer.Next(); } /* None of the special ones, so try the general ones */ return IndustryGetVariable(object, variable, parameter, available); } -bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index) +bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspec_index, uint32 seed) { const IndustrySpec *indspec = GetIndustrySpec(type); @@ -492,6 +494,7 @@ bool CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uint itspe NewIndustryResolver(&object, tile, &ind, type); object.GetVariable = IndustryLocationGetVariable; object.callback = CBID_INDUSTRY_LOCATION; + _industry_creation_randomizer.SetSeed(seed); group = Resolve(GetIndustrySpec(type)->grf_prop.spritegroup, &object); |