mirror of https://github.com/OpenTTD/OpenTTD
Fix: [NewGRF] The result of Action123 evaluation affected rerandomisation in a weird corner case. (#14139)
Rerandomisation does not care about the Resolve result. But we skipped it, in case of 'invalid SpriteGroup reference'.pull/14121/head
parent
b281c5616e
commit
30b1eb6e5f
|
@ -1255,8 +1255,7 @@ static void DoTriggerVehicleRandomisation(Vehicle *v, VehicleRandomTrigger trigg
|
|||
v->waiting_random_triggers.Set(trigger); // store now for var 5F
|
||||
object.SetWaitingRandomTriggers(v->waiting_random_triggers);
|
||||
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
if (group == nullptr) return;
|
||||
object.ResolveRerandomisation();
|
||||
|
||||
/* Store remaining triggers. */
|
||||
v->waiting_random_triggers.Reset(object.GetUsedRandomTriggers());
|
||||
|
|
|
@ -675,8 +675,7 @@ static void DoTriggerHouseRandomisation(TileIndex tile, HouseRandomTrigger trigg
|
|||
SetHouseRandomTriggers(tile, waiting_random_triggers); // store now for var 5F
|
||||
object.SetWaitingRandomTriggers(waiting_random_triggers);
|
||||
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
if (group == nullptr) return;
|
||||
object.ResolveRerandomisation();
|
||||
|
||||
/* Store remaining triggers. */
|
||||
waiting_random_triggers.Reset(object.GetUsedRandomTriggers());
|
||||
|
|
|
@ -336,8 +336,7 @@ static void DoTriggerIndustryTileRandomisation(TileIndex tile, IndustryRandomTri
|
|||
SetIndustryRandomTriggers(tile, waiting_random_triggers); // store now for var 5F
|
||||
object.SetWaitingRandomTriggers(waiting_random_triggers);
|
||||
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
if (group == nullptr) return;
|
||||
object.ResolveRerandomisation();
|
||||
|
||||
/* Store remaining triggers. */
|
||||
waiting_random_triggers.Reset(object.GetUsedRandomTriggers());
|
||||
|
|
|
@ -451,8 +451,7 @@ void TriggerRoadStopRandomisation(BaseStation *st, TileIndex tile, StationRandom
|
|||
RoadStopResolverObject object(ss, st, cur_tile, INVALID_ROADTYPE, GetStationType(cur_tile), GetStationGfx(cur_tile));
|
||||
object.SetWaitingRandomTriggers(st->waiting_random_triggers);
|
||||
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
if (group == nullptr) return;
|
||||
object.ResolveRerandomisation();
|
||||
|
||||
used_random_triggers.Set(object.GetUsedRandomTriggers());
|
||||
|
||||
|
|
|
@ -336,13 +336,27 @@ public:
|
|||
return SpriteGroup::Resolve(this->root_spritegroup, *this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve bits to be rerandomised.
|
||||
* Access results via:
|
||||
* - reseed: Bits to rerandomise per scope, for features with proper PARENT rerandomisation. (only industry tiles)
|
||||
* - GetReseedSum: Bits to rerandomise for SELF scope, for features with broken-by-design PARENT randomisation. (all but industry tiles)
|
||||
* - GetUsedRandomTriggers: Consumed random triggers to be reset.
|
||||
*/
|
||||
void ResolveRerandomisation()
|
||||
{
|
||||
/* The Resolve result has no meaning.
|
||||
* It can be a SpriteSet, a callback result, or even an invalid SpriteGroup reference (nullptr). */
|
||||
this->Resolve();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve callback.
|
||||
* @return Callback result.
|
||||
*/
|
||||
uint16_t ResolveCallback()
|
||||
{
|
||||
const SpriteGroup *result = Resolve();
|
||||
const SpriteGroup *result = this->Resolve();
|
||||
return result != nullptr ? result->GetCallbackResult() : CALLBACK_FAILED;
|
||||
}
|
||||
|
||||
|
|
|
@ -996,8 +996,7 @@ void TriggerStationRandomisation(BaseStation *st, TileIndex trigger_tile, Statio
|
|||
StationResolverObject object(ss, st, tile, CBID_RANDOM_TRIGGER, 0);
|
||||
object.SetWaitingRandomTriggers(st->waiting_random_triggers);
|
||||
|
||||
const SpriteGroup *group = object.Resolve();
|
||||
if (group == nullptr) continue;
|
||||
object.ResolveRerandomisation();
|
||||
|
||||
used_random_triggers.Set(object.GetUsedRandomTriggers());
|
||||
|
||||
|
|
Loading…
Reference in New Issue