diff options
author | rubidium <rubidium@openttd.org> | 2007-07-11 23:10:22 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-07-11 23:10:22 +0000 |
commit | 5f7f99e38167b83b7767ecc8b92df0df938c59cf (patch) | |
tree | 7c171c2dc2f8e4513a9017d8735c3ee621052493 /src | |
parent | 57268fa7e3c67ed1aec21bb935e271c56e430009 (diff) | |
download | openttd-5f7f99e38167b83b7767ecc8b92df0df938c59cf.tar.xz |
(svn r10515) -Codechange: allow getting some more data about the environment of an industry.
Diffstat (limited to 'src')
-rw-r--r-- | src/newgrf_industries.cpp | 23 | ||||
-rw-r--r-- | src/newgrf_industries.h | 2 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 5 |
3 files changed, 24 insertions, 6 deletions
diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index e66c5bc47..2c33259aa 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -165,8 +165,19 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par case 0x61: return 0; // Get random tile bits at offset param - case 0x62: // Land info of nearby tiles - case 0x63: break; // Animation stage of nerby tiles + /* Land info of nearby tiles */ + case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY); + + /* Animation stage of nearby tiles */ + case 0x63 : { + tile = GetNearbyTile(parameter, tile); + if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == industry) { + return GetIndustryAnimationState(tile); + } + return 0xFFFFFFFF; + } + + /* Distance of nearest industry of given type */ case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, indspec->grf_prop.grffile->grfid), industry); // Distance of nearest industry of given type /* Get town zone and Manhattan distance of closest town */ case 0x65: return GetTownRadiusGroup(industry->town, tile) << 16 | min(DistanceManhattan(tile, industry->town->xy), 0xFFFF); @@ -296,12 +307,16 @@ uint32 IndustryLocationGetVariable(const ResolverObject *object, byte variable, } switch (variable) { - case 0x62: break;// Land info of nearby tiles - case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, object->u.industry_location.spec->grf_prop.grffile->grfid), NULL); // Distance of nearest industry of given type + /* Land info of nearby tiles */ + case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY); + + /* Distance of nearest industry of given type */ + case 0x64: return GetClosestIndustry(tile, MapNewGRFIndustryType(parameter, object->u.industry_location.spec->grf_prop.grffile->grfid), NULL); /* Location where to build the industry */ case 0x80: return tile; case 0x81: return GB(tile, 8, 8); + /* Pointer to the town the industry is associated with */ case 0x82: return ClosestTownFromTile(tile, (uint)-1)->index; case 0x83: diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index a493c37e8..e2404f43e 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -22,4 +22,6 @@ uint32 IndustryTileGetRandomBits(const ResolverObject *object); uint32 IndustryTileGetTriggers(const ResolverObject *object); void IndustryTileSetTriggers(const ResolverObject *object, int triggers); +uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index); + #endif /* NEWGRF_INDUSTRIES_H */ diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index 028cbf54d..bfa1dbb88 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -30,7 +30,7 @@ * @param index of the industry been queried for * @return a construction of bits obeying the newgrf format */ -static uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index) +uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index) { byte tile_type; bool is_same_industry; @@ -87,7 +87,8 @@ static uint32 IndustryTileGetVariable(const ResolverObject *object, byte variabl /* Land info of nearby tiles */ case 0x60 : return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index); - case 0x61 : {/* Animation stage of nearby tiles */ + /* Animation stage of nearby tiles */ + case 0x61 : { tile = GetNearbyTile(parameter, tile); if (IsTileType(tile, MP_INDUSTRY) && GetIndustryByTile(tile) == inds) { return GetIndustryAnimationState(tile); |