1
0
Fork 0

Codechange: Integrate ResolverObject::ResetState() into DoResolve(), no need to call it manually.

pull/14224/head
frosch 2025-05-06 16:49:29 +02:00 committed by frosch
parent f8c928ed98
commit 22fedca77e
3 changed files with 4 additions and 17 deletions

View File

@ -1099,7 +1099,6 @@ static void GetCustomEngineSprite(EngineID engine, const Vehicle *v, Direction d
bool sprite_stack = EngInfo(engine)->misc_flags.Test(EngineMiscFlag::SpriteStack);
uint max_stack = sprite_stack ? static_cast<uint>(std::size(result->seq)) : 1;
for (uint stack = 0; stack < max_stack; ++stack) {
object.ResetState();
object.callback_param1 = image_type | (stack << 8);
const auto *group = object.Resolve<ResultSpriteGroup>();
int32_t reg100 = sprite_stack ? object.GetRegister(0x100) : 0;
@ -1142,7 +1141,6 @@ static void GetRotorOverrideSprite(EngineID engine, const struct Aircraft *v, En
bool sprite_stack = e->info.misc_flags.Test(EngineMiscFlag::SpriteStack);
uint max_stack = sprite_stack ? static_cast<uint>(std::size(result->seq)) : 1;
for (uint stack = 0; stack < max_stack; ++stack) {
object.ResetState();
object.callback_param1 = image_type | (stack << 8);
const auto *group = object.Resolve<ResultSpriteGroup>();
int32_t reg100 = sprite_stack ? object.GetRegister(0x100) : 0;

View File

@ -307,13 +307,16 @@ public:
ResolverObject(const GRFFile *grffile, CallbackID callback = CBID_NO_CALLBACK, uint32_t callback_param1 = 0, uint32_t callback_param2 = 0)
: default_scope(*this), callback(callback), callback_param1(callback_param1), callback_param2(callback_param2), grffile(grffile), root_spritegroup(nullptr)
{
this->ResetState();
}
virtual ~ResolverObject() = default;
ResolverResult DoResolve()
{
temp_store.ClearChanges();
this->last_value = 0;
this->used_random_triggers = 0;
this->reseed.fill(0);
return SpriteGroup::Resolve(this->root_spritegroup, *this);
}
@ -434,19 +437,6 @@ public:
return sum;
}
/**
* Resets the dynamic state of the resolver object.
* To be called before resolving an Action-1-2-3 chain.
*/
void ResetState()
{
temp_store.ClearChanges();
this->last_value = 0;
this->waiting_random_triggers = 0;
this->used_random_triggers = 0;
this->reseed.fill(0);
}
/**
* Get the feature number being resolved for.
* This function is mainly intended for the callback profiling feature.

View File

@ -631,7 +631,6 @@ void GetCustomStationRelocation(SpriteLayoutProcessor &processor, const StationS
{
StationResolverObject object(statspec, st, tile, CBID_NO_CALLBACK);
for (uint8_t var10 : processor.Var10Values()) {
object.ResetState();
object.callback_param1 = var10;
const auto *group = object.Resolve<ResultSpriteGroup>();
if (group == nullptr || group->num_sprites == 0) continue;