diff options
author | frosch <frosch@openttd.org> | 2017-10-25 15:38:14 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2017-10-25 15:38:14 +0000 |
commit | 82ae414e8d81718687b88db98346cee594fb2858 (patch) | |
tree | 1225534a7f9f17933b48c7426d77d2876adf8dd9 /src/newgrf_engine.cpp | |
parent | 146e4eddb631d597f1296162d3bf520e4fc524a1 (diff) | |
download | openttd-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_engine.cpp')
-rw-r--r-- | src/newgrf_engine.cpp | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/src/newgrf_engine.cpp b/src/newgrf_engine.cpp index 8dd8d545a..94c8df1d1 100644 --- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -347,21 +347,6 @@ static byte MapAircraftMovementAction(const Aircraft *v) return this->v == NULL ? 0 : this->v->waiting_triggers; } -/* virtual */ void VehicleScopeResolver::SetTriggers(int triggers) const -{ - /* Evil cast to get around const-ness. This used to be achieved by an - * innocent looking function pointer cast... Currently I cannot see a - * way of avoiding this without removing consts deep within gui code. - */ - Vehicle *v = const_cast<Vehicle *>(this->v); - - /* This function must only be called when processing triggers -- any - * other time is an error. */ - assert(this->ro.trigger != 0); - - if (v != NULL) v->waiting_triggers = triggers; -} - /* virtual */ ScopeResolver *VehicleResolverObject::GetScope(VarSpriteGroupScope scope, byte relative) { @@ -1140,13 +1125,18 @@ static void DoTriggerVehicle(Vehicle *v, VehicleTrigger trigger, byte base_rando assert(v != NULL); VehicleResolverObject object(v->engine_type, v, VehicleResolverObject::WO_CACHED, false, CBID_RANDOM_TRIGGER); - object.trigger = trigger; + object.waiting_triggers = v->waiting_triggers | trigger; + v->waiting_triggers = object.waiting_triggers; // store now for var 5F const SpriteGroup *group = object.Resolve(); if (group == NULL) return; + /* Store remaining triggers. */ + v->waiting_triggers = object.GetRemainingTriggers(); + + /* Rerandomise bits. Scopes other than SELF are invalid for rerandomisation. For bug-to-bug-compatibility with TTDP we ignore the scope. */ byte new_random_bits = Random(); - uint32 reseed = object.GetReseedSum(); // The scope only affects triggers, not the reseeding + uint32 reseed = object.GetReseedSum(); v->random_bits &= ~reseed; v->random_bits |= (first ? new_random_bits : base_random_bits) & reseed; |