summaryrefslogtreecommitdiff
path: root/src/newgrf_industrytiles.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2017-10-25 15:38:14 +0000
committerfrosch <frosch@openttd.org>2017-10-25 15:38:14 +0000
commit82ae414e8d81718687b88db98346cee594fb2858 (patch)
tree1225534a7f9f17933b48c7426d77d2876adf8dd9 /src/newgrf_industrytiles.cpp
parent146e4eddb631d597f1296162d3bf520e4fc524a1 (diff)
downloadopenttd-82ae414e8d81718687b88db98346cee594fb2858.tar.xz
(svn r27928) -Fix: [NewGRF] While executing random triggers, var 5F should include the new triggers.
-Fix: [NewGRF] Reset used random triggers only after all A123 chains have been resolved, so that all RA2 in all chains can test the shard triggers. This also includes multiple RA2 in the same A123 chain. -Fix: [NewGRF] Industry random triggers are stored per tile, even when randomising the shared random bits of the parent industry.
Diffstat (limited to 'src/newgrf_industrytiles.cpp')
-rw-r--r--src/newgrf_industrytiles.cpp13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index 90a17550d..b4b8f77c4 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -117,12 +117,6 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
return GetIndustryTriggers(this->tile);
}
-/* virtual */ void IndustryTileScopeResolver::SetTriggers(int triggers) const
-{
- assert(this->industry != NULL && this->industry->index != INVALID_INDUSTRY && IsValidTile(this->tile) && IsTileType(this->tile, MP_INDUSTRY));
- SetIndustryTriggers(this->tile, triggers);
-}
-
/**
* Get the associated NewGRF file from the industry graphics.
* @param gfx Graphics to query.
@@ -326,11 +320,16 @@ static void DoTriggerIndustryTile(TileIndex tile, IndustryTileTrigger trigger, I
if (itspec->grf_prop.spritegroup[0] == NULL) return;
IndustryTileResolverObject object(gfx, tile, ind, CBID_RANDOM_TRIGGER);
- object.trigger = trigger;
+ object.waiting_triggers = GetIndustryTriggers(tile) | trigger;
+ SetIndustryTriggers(tile, object.waiting_triggers); // store now for var 5F
const SpriteGroup *group = object.Resolve();
if (group == NULL) return;
+ /* Store remaining triggers. */
+ SetIndustryTriggers(tile, object.GetRemainingTriggers());
+
+ /* Rerandomise tile bits */
byte new_random_bits = Random();
byte random_bits = GetIndustryRandomBits(tile);
random_bits &= ~object.reseed[VSG_SCOPE_SELF];