summaryrefslogtreecommitdiff
path: root/src/newgrf_station.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_station.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_station.cpp')
-rw-r--r--src/newgrf_station.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp
index cd5dad7b4..091182185 100644
--- a/src/newgrf_station.cpp
+++ b/src/newgrf_station.cpp
@@ -235,13 +235,6 @@ static uint32 GetRailContinuationInfo(TileIndex tile)
}
-/* virtual */ void StationScopeResolver::SetTriggers(int triggers) const
-{
- BaseStation *st = const_cast<BaseStation *>(this->st);
- assert(st != NULL);
- st->waiting_triggers = triggers;
-}
-
/**
* Station variable cache
* This caches 'expensive' station variable lookups which iterate over
@@ -997,8 +990,9 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg
}
}
- /* Convert trigger to bit */
- uint8 trigger_bit = 1 << trigger;
+ /* Store triggers now for var 5F */
+ SetBit(st->waiting_triggers, trigger);
+ uint32 used_triggers = 0;
/* Check all tiles over the station to check if the specindex is still in use */
TILE_AREA_LOOP(tile, area) {
@@ -1014,11 +1008,13 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg
if (cargo_type == CT_INVALID || HasBit(ss->cargo_triggers, cargo_type)) {
StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
- object.trigger = trigger_bit;
+ object.waiting_triggers = st->waiting_triggers;
const SpriteGroup *group = object.Resolve();
if (group == NULL) continue;
+ used_triggers |= object.used_triggers;
+
uint32 reseed = object.GetReseedSum();
if (reseed != 0) {
whole_reseed |= reseed;
@@ -1037,6 +1033,7 @@ void TriggerStationRandomisation(Station *st, TileIndex tile, StationRandomTrigg
}
/* Update whole station random bits */
+ st->waiting_triggers &= ~used_triggers;
if ((whole_reseed & 0xFFFF) != 0) {
st->random_bits &= ~whole_reseed;
st->random_bits |= Random() & whole_reseed;