Mercurial > hg > openttd
changeset 17843:2d62fee43556 draft
(svn r22634) -Codechange: Deduplicate some code. Note that zeroing 'count' is intentionally removed, it is only used together with 'scope'.
author | frosch <frosch@openttd.org> |
---|---|
date | Mon, 04 Jul 2011 20:31:57 +0000 |
parents | 10f4aab26eba |
children | 91d7b400b453 |
files | src/newgrf_airport.cpp src/newgrf_airporttiles.cpp src/newgrf_canal.cpp src/newgrf_cargo.cpp src/newgrf_engine.cpp src/newgrf_generic.cpp src/newgrf_house.cpp src/newgrf_industries.cpp src/newgrf_industrytiles.cpp src/newgrf_object.cpp src/newgrf_railtype.cpp src/newgrf_spritegroup.h src/newgrf_station.cpp |
diffstat | 13 files changed, 27 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/src/newgrf_airport.cpp +++ b/src/newgrf_airport.cpp @@ -224,10 +224,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); const AirportSpec *as = AirportSpec::Get(airport_id); res->grffile = as->grf_prop.grffile;
--- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -238,10 +238,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); res->grffile = ats->grf_prop.grffile; }
--- a/src/newgrf_canal.cpp +++ b/src/newgrf_canal.cpp @@ -89,10 +89,8 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); + res->grffile = grffile; }
--- a/src/newgrf_cargo.cpp +++ b/src/newgrf_cargo.cpp @@ -66,10 +66,8 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); + res->grffile = cs->grffile; }
--- a/src/newgrf_engine.cpp +++ b/src/newgrf_engine.cpp @@ -878,10 +878,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); const Engine *e = Engine::Get(engine_type); res->grffile = (e != NULL ? e->grf_prop.grffile : NULL);
--- a/src/newgrf_generic.cpp +++ b/src/newgrf_generic.cpp @@ -126,10 +126,8 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); + res->grffile = grffile; }
--- a/src/newgrf_house.cpp +++ b/src/newgrf_house.cpp @@ -397,10 +397,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); const HouseSpec *hs = HouseSpec::Get(house_id); res->grffile = (hs != NULL ? hs->grf_prop.grffile : NULL);
--- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -424,10 +424,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); const IndustrySpec *indspec = GetIndustrySpec(type); res->grffile = (indspec != NULL ? indspec->grf_prop.grffile : NULL);
--- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -190,10 +190,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); const IndustryTileSpec *its = GetIndustryTileSpec(gfx); res->grffile = (its != NULL ? its->grf_prop.grffile : NULL);
--- a/src/newgrf_object.cpp +++ b/src/newgrf_object.cpp @@ -393,10 +393,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); res->grffile = spec->grf_prop.grffile; }
--- a/src/newgrf_railtype.cpp +++ b/src/newgrf_railtype.cpp @@ -81,10 +81,7 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); res->grffile = grffile; }
--- a/src/newgrf_spritegroup.h +++ b/src/newgrf_spritegroup.h @@ -381,6 +381,17 @@ uint32 (*GetVariable)(const struct ResolverObject*, byte, byte, bool*); const SpriteGroup *(*ResolveReal)(const struct ResolverObject*, const RealSpriteGroup*); void (*StorePSA)(struct ResolverObject*, uint, int32); + + /** + * Resets the dynamic state of the resolver object. + * To be called before resolving an Action-1-2-3 chain. + */ + void ResetState() + { + this->last_value = 0; + this->trigger = 0; + this->reseed = 0; + } }; #endif /* NEWGRF_SPRITEGROUP_H */
--- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -548,10 +548,8 @@ res->callback = CBID_NO_CALLBACK; res->callback_param1 = 0; res->callback_param2 = 0; - res->last_value = 0; - res->trigger = 0; - res->reseed = 0; - res->count = 0; + res->ResetState(); + res->grffile = (statspec != NULL ? statspec->grf_prop.grffile : NULL); /* Invalidate all cached vars */