summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-12-16 23:10:30 +0000
committerrubidium <rubidium@openttd.org>2007-12-16 23:10:30 +0000
commit9ecda0a97a4b157f8434635d22a6cf48f45bfe02 (patch)
tree5bdffe121ca4c0e446b8a86379c19ac6ccb99951 /src
parent85b52f6a64cb5d1b36974e684aaacf136c768cc1 (diff)
downloadopenttd-9ecda0a97a4b157f8434635d22a6cf48f45bfe02.tar.xz
(svn r11651) -Codechange [FS#1555]: implement GRF parameter querying for industries and fix a 'bug' as side effect.
Diffstat (limited to 'src')
-rw-r--r--src/newgrf_industries.cpp12
-rw-r--r--src/newgrf_industrytiles.cpp12
2 files changed, 24 insertions, 0 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp
index 4cfec51f2..921544661 100644
--- a/src/newgrf_industries.cpp
+++ b/src/newgrf_industries.cpp
@@ -36,6 +36,15 @@ IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id)
return _industry_mngr.GetID(GB(grf_type, 0, 6), grf_id);
}
+static uint32 GetGRFParameter(IndustryType ind_id, byte parameter)
+{
+ const IndustrySpec *indspec = GetIndustrySpec(ind_id);
+ const GRFFile *file = indspec->grf_prop.grffile;
+
+ if (parameter >= file->param_end) return 0;
+ return file->param[parameter];
+}
+
/**
* Finds the distance for the closest tile with water/land given a tile
* @param tile the tile to find the distance too
@@ -269,6 +278,9 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par
/* Get a variable from the persistent storage */
case 0x7C: return industry->psa.Get(parameter);
+ /* Read GRF parameter */
+ case 0x7F: return GetGRFParameter(industry->type, parameter);
+
/* Industry structure access*/
case 0x80: return industry->xy;
case 0x81: return GB(industry->xy, 8, 8);
diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp
index f77f536b4..f414d1413 100644
--- a/src/newgrf_industrytiles.cpp
+++ b/src/newgrf_industrytiles.cpp
@@ -24,6 +24,15 @@
#include "sprite.h"
#include "transparency.h"
+static uint32 GetGRFParameter(IndustryGfx indtile_id, byte parameter)
+{
+ const IndustryTileSpec *indtspec = GetIndustryTileSpec(indtile_id);
+ const GRFFile *file = indtspec->grf_prop.grffile;
+
+ if (parameter >= file->param_end) return 0;
+ return file->param[parameter];
+}
+
/**
* Based on newhouses equivalent, but adapted for newindustries
* @param parameter from callback. It's in fact a pair of coordinates
@@ -101,6 +110,9 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl
/* Get industry tile ID at offset */
case 0x62 : return GetIndustryIDAtOffset(GetNearbyTile(parameter, tile), inds);
+
+ /* Read GRF parameter */
+ case 0x7F: return GetGRFParameter(GetIndustryGfx(tile), parameter);
}
DEBUG(grf, 1, "Unhandled industry tile property 0x%X", variable);