(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.
This commit is contained in:
frosch
2017-10-25 15:38:14 +00:00
parent 146e4eddb6
commit 82ae414e8d
12 changed files with 43 additions and 72 deletions

View File

@@ -109,12 +109,6 @@ ScopeResolver::~ScopeResolver() {}
return 0;
}
/**
* Set the triggers. Base class implementation does nothing.
* @param triggers Triggers to set.
*/
/* virtual */ void ScopeResolver::SetTriggers(int triggers) const {}
/**
* Get a variable value. Default implementation has no available variables.
* @param variable Variable to read
@@ -304,21 +298,15 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject &object) con
const SpriteGroup *RandomizedSpriteGroup::Resolve(ResolverObject &object) const
{
ScopeResolver *scope = object.GetScope(this->var_scope, this->count);
if (object.trigger != 0) {
if (object.callback == CBID_RANDOM_TRIGGER) {
/* Handle triggers */
/* Magic code that may or may not do the right things... */
byte waiting_triggers = scope->GetTriggers();
byte match = this->triggers & (waiting_triggers | object.trigger);
byte match = this->triggers & object.waiting_triggers;
bool res = (this->cmp_mode == RSG_CMP_ANY) ? (match != 0) : (match == this->triggers);
if (res) {
waiting_triggers &= ~match;
object.used_triggers |= match;
object.reseed[this->var_scope] |= (this->num_groups - 1) << this->lowest_randbit;
} else {
waiting_triggers |= object.trigger;
}
scope->SetTriggers(waiting_triggers);
}
uint32 mask = (this->num_groups - 1) << this->lowest_randbit;