|
@@ -232,19 +232,12 @@ static uint32 GetRailContinuationInfo(Ti
|
|
|
/* virtual */ uint32 StationScopeResolver::GetTriggers() const
|
|
|
{
|
|
|
return this->st == NULL ? 0 : this->st->waiting_triggers;
|
|
|
}
|
|
|
|
|
|
|
|
|
/* 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
|
|
|
* several tiles that may be called multiple times per Resolve().
|
|
|
*/
|
|
|
static struct {
|
|
@@ -994,14 +987,15 @@ void TriggerStationRandomisation(Station
|
|
|
if (st->goods[i].cargo.TotalCount() == 0) {
|
|
|
SetBit(empty_mask, i);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* 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) {
|
|
|
if (st->TileBelongsToRailStation(tile)) {
|
|
|
const StationSpec *ss = GetStationSpec(tile);
|
|
|
if (ss == NULL) continue;
|
|
@@ -1011,17 +1005,19 @@ void TriggerStationRandomisation(Station
|
|
|
if (trigger == SRT_CARGO_TAKEN) {
|
|
|
if ((ss->cargo_triggers & ~empty_mask) != 0) continue;
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
reseed >>= 16;
|
|
|
|
|
|
/* Set individual tile random bits */
|
|
@@ -1034,12 +1030,13 @@ void TriggerStationRandomisation(Station
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* 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;
|
|
|
}
|
|
|
}
|
|
|
|