From 814c91843acbd3c42eb85939e68efc56ee1f065d Mon Sep 17 00:00:00 2001 From: frosch Date: Tue, 29 Jul 2008 19:51:30 +0000 Subject: [PATCH] (svn r13868) -Fix: Parent scope of industry variables. --- src/newgrf_industries.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index 68739f9caa..16a36dc6a4 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -210,6 +210,23 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par IndustryType type = object->u.industry.type; const IndustrySpec *indspec = GetIndustrySpec(type); + /* Shall the variable get resolved in parent scope and are we not yet in parent scope? */ + if (object->u.industry.gfx == INVALID_INDUSTRYTILE && object->scope == VSG_SCOPE_PARENT) { + /* Pass the request on to the town of the industry */ + const Town *t; + + if (industry != NULL) { + t = industry->town; + } else if (tile != INVALID_TILE) { + t = ClosestTownFromTile(tile, UINT_MAX); + } else { + *available = false; + return UINT_MAX; + } + + return TownGetVariable(variable, parameter, available, t); + } + if (industry == NULL) { /* industry does not exist, only use those variables that are "safe" */ switch (variable) {