From 2fa312aab9f7bcad6689f9da9dc92b0b096b0247 Mon Sep 17 00:00:00 2001 From: frosch Date: Wed, 30 Sep 2009 20:25:59 +0000 Subject: (svn r17672) -Revert (r8081): 'last_value' and 'reseed' are shared between procedure and main chain. -Fix (r8075): 'scope' and 'count' are not. --- src/newgrf_spritegroup.cpp | 7 +++++-- src/newgrf_spritegroup.h | 14 ++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/newgrf_spritegroup.cpp b/src/newgrf_spritegroup.cpp index 2d0ca71bb..74cba113b 100644 --- a/src/newgrf_spritegroup.cpp +++ b/src/newgrf_spritegroup.cpp @@ -142,13 +142,16 @@ const SpriteGroup *DeterministicSpriteGroup::Resolve(ResolverObject *object) con /* Try to get the variable. We shall assume it is available, unless told otherwise. */ bool available = true; if (adjust->variable == 0x7E) { - ResolverObject subobject = *object; - const SpriteGroup *subgroup = SpriteGroup::Resolve(adjust->subroutine, &subobject); + const SpriteGroup *subgroup = SpriteGroup::Resolve(adjust->subroutine, object); if (subgroup == NULL) { value = CALLBACK_FAILED; } else { value = subgroup->GetCallbackResult(); } + + /* Reset values to current scope. + * Note: 'last_value' and 'reseed' are shared between the main chain and the procedure */ + object->scope = this->var_scope; } else { value = GetVariable(object, adjust->variable, adjust->parameter, &available); } diff --git a/src/newgrf_spritegroup.h b/src/newgrf_spritegroup.h index 0382de7c6..f10574bdd 100644 --- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -291,14 +291,16 @@ struct ResolverObject { uint32 callback_param2; byte trigger; - byte count; - uint32 last_value; - uint32 reseed; - VarSpriteGroupScope scope; - BaseStorageArray *psa; ///< The persistent storage array of this resolved object. + uint32 last_value; ///< Result of most recent DeterministicSpriteGroup (including procedure calls) + uint32 reseed; ///< Collects bits to rerandomise while triggering triggers. + + VarSpriteGroupScope scope; ///< Scope of currently resolved DeterministicSpriteGroup resp. RandomizedSpriteGroup + byte count; ///< Additional scope for RandomizedSpriteGroup + + BaseStorageArray *psa; ///< The persistent storage array of this resolved object. - const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to + const GRFFile *grffile; ///< GRFFile the resolved SpriteGroup belongs to union { struct { -- cgit v1.2.3-70-g09d2