# HG changeset patch # User rubidium # Date 1197846630 0 # Node ID d798735688985dfa8dc0118ee37c1c27ab809ab9 # Parent 6579b0a2ba0edd107b1d18664f297d994a763927 (svn r11651) -Codechange [FS#1555]: implement GRF parameter querying for industries and fix a 'bug' as side effect. diff -r 6579b0a2ba0e -r d79873568898 src/newgrf_industries.cpp --- a/src/newgrf_industries.cpp Sun Dec 16 22:21:34 2007 +0000 +++ b/src/newgrf_industries.cpp Sun Dec 16 23:10:30 2007 +0000 @@ -36,6 +36,15 @@ 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 @@ /* 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 -r 6579b0a2ba0e -r d79873568898 src/newgrf_industrytiles.cpp --- a/src/newgrf_industrytiles.cpp Sun Dec 16 22:21:34 2007 +0000 +++ b/src/newgrf_industrytiles.cpp Sun Dec 16 23:10:30 2007 +0000 @@ -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 @@ /* 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);