summaryrefslogtreecommitdiff
path: root/src/newgrf_industries.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2014-03-03 20:02:31 +0000
committerfrosch <frosch@openttd.org>2014-03-03 20:02:31 +0000
commit6b61c4608fab00c7bfc78c296b3c85f611681f59 (patch)
tree9919983ecf008602a497445b2b3e05b5c32892b8 /src/newgrf_industries.cpp
parentb935cb84156f18b51196288ff6d12f8ca5b26630 (diff)
downloadopenttd-6b61c4608fab00c7bfc78c296b3c85f611681f59.tar.xz
(svn r26388) -Codechange: Move resolving of Action 3 into ResolverObject constructor.
Diffstat (limited to 'src/newgrf_industries.cpp')
-rw-r--r--src/newgrf_industries.cpp12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index dfc615b29..725373d10 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -432,6 +432,7 @@ IndustriesResolverObject::IndustriesResolverObject(TileIndex tile, Industry *ind
industries_scope(*this, tile, indus, type, random_bits),
town_scope(NULL)
{
+ this->root_spritegroup = GetIndustrySpec(type)->grf_prop.spritegroup[0];
}
IndustriesResolverObject::~IndustriesResolverObject()
@@ -490,10 +491,7 @@ IndustriesScopeResolver::IndustriesScopeResolver(ResolverObject &ro, TileIndex t
uint16 GetIndustryCallback(CallbackID callback, uint32 param1, uint32 param2, Industry *industry, IndustryType type, TileIndex tile)
{
IndustriesResolverObject object(tile, industry, type, 0, callback, param1, param2);
- const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
- if (group == NULL) return CALLBACK_FAILED;
-
- return group->GetCallbackResult();
+ return object.ResolveCallback();
}
/**
@@ -523,12 +521,10 @@ CommandCost CheckIfCallBackAllowsCreation(TileIndex tile, IndustryType type, uin
ind.psa = NULL;
IndustriesResolverObject object(tile, &ind, type, seed, CBID_INDUSTRY_LOCATION, 0, creation_type);
- const SpriteGroup *group = SpriteGroup::Resolve(GetIndustrySpec(type)->grf_prop.spritegroup[0], object);
+ uint16 result = object.ResolveCallback();
/* Unlike the "normal" cases, not having a valid result means we allow
* the building of the industry, as that's how it's done in TTDP. */
- if (group == NULL) return CommandCost();
- uint16 result = group->GetCallbackResult();
if (result == CALLBACK_FAILED) return CommandCost();
return GetErrorMessageFromLocationCallbackResult(result, indspec->grf_prop.grffile, STR_ERROR_SITE_UNSUITABLE);
@@ -596,7 +592,7 @@ void IndustryProductionCallback(Industry *ind, int reason)
}
SB(object.callback_param2, 8, 16, loop);
- const SpriteGroup *tgroup = SpriteGroup::Resolve(spec->grf_prop.spritegroup[0], object);
+ const SpriteGroup *tgroup = object.Resolve();
if (tgroup == NULL || tgroup->type != SGT_INDUSTRY_PRODUCTION) break;
const IndustryProductionSpriteGroup *group = (const IndustryProductionSpriteGroup *)tgroup;