diff options
author | yexo <yexo@openttd.org> | 2010-10-19 21:00:45 +0000 |
---|---|---|
committer | yexo <yexo@openttd.org> | 2010-10-19 21:00:45 +0000 |
commit | 9373ee71d999a08c51938f6214fc0360c477992a (patch) | |
tree | 00e8ee0c86f194913c08f2bb0876a1ae08b00537 | |
parent | 3ab422b05715591be52334ce8cd522e506ddfdee (diff) | |
download | openttd-9373ee71d999a08c51938f6214fc0360c477992a.tar.xz |
(svn r20996) -Change: [NewGRF] the X and Y offsets in the parameter for industry vars 60,61,62,63 are unsigned instead of signed
-rw-r--r-- | src/newgrf_commons.cpp | 6 | ||||
-rw-r--r-- | src/newgrf_commons.h | 2 | ||||
-rw-r--r-- | src/newgrf_industries.cpp | 8 | ||||
-rw-r--r-- | src/newgrf_industries.h | 2 | ||||
-rw-r--r-- | src/newgrf_industrytiles.cpp | 5 |
5 files changed, 12 insertions, 11 deletions
diff --git a/src/newgrf_commons.cpp b/src/newgrf_commons.cpp index 6521a39f7..4bf5b6e9f 100644 --- a/src/newgrf_commons.cpp +++ b/src/newgrf_commons.cpp @@ -395,13 +395,13 @@ uint32 GetTerrainType(TileIndex tile, TileContext context) } } -TileIndex GetNearbyTile(byte parameter, TileIndex tile) +TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets) { int8 x = GB(parameter, 0, 4); int8 y = GB(parameter, 4, 4); - if (x >= 8) x -= 16; - if (y >= 8) y -= 16; + if (signed_offsets && x >= 8) x -= 16; + if (signed_offsets && y >= 8) y -= 16; /* Swap width and height depending on axis for railway stations */ if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y); diff --git a/src/newgrf_commons.h b/src/newgrf_commons.h index 172641743..171ccf759 100644 --- a/src/newgrf_commons.h +++ b/src/newgrf_commons.h @@ -144,7 +144,7 @@ extern AirportTileOverrideManager _airporttile_mngr; extern ObjectOverrideManager _object_mngr; uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL); -TileIndex GetNearbyTile(byte parameter, TileIndex tile); +TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true); uint32 GetNearbyTileInformation(TileIndex tile); /** diff --git a/src/newgrf_industries.cpp b/src/newgrf_industries.cpp index a88a2d0a0..76b6af876 100644 --- a/src/newgrf_industries.cpp +++ b/src/newgrf_industries.cpp @@ -236,19 +236,19 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, byte par case 0x46: return industry->construction_date; // Date when built - long format - (in days) /* Get industry ID at offset param */ - case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->location.tile), industry, object->grffile->grfid); + case 0x60: return GetIndustryIDAtOffset(GetNearbyTile(parameter, industry->location.tile, false), industry, object->grffile->grfid); /* Get random tile bits at offset param */ case 0x61: - tile = GetNearbyTile(parameter, tile); + tile = GetNearbyTile(parameter, tile, false); return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0; /* Land info of nearby tiles */ - case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY); + case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY, false); /* Animation stage of nearby tiles */ case 0x63: - tile = GetNearbyTile(parameter, tile); + tile = GetNearbyTile(parameter, tile, false); if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) { return GetAnimationFrame(tile); } diff --git a/src/newgrf_industries.h b/src/newgrf_industries.h index c05cd1246..af12a390e 100644 --- a/src/newgrf_industries.h +++ b/src/newgrf_industries.h @@ -46,6 +46,6 @@ bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type); IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id); /* in newgrf_industrytiles.cpp*/ -uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index); +uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets = true); #endif /* NEWGRF_INDUSTRIES_H */ diff --git a/src/newgrf_industrytiles.cpp b/src/newgrf_industrytiles.cpp index fa1606b39..db6378702 100644 --- a/src/newgrf_industrytiles.cpp +++ b/src/newgrf_industrytiles.cpp @@ -32,11 +32,12 @@ * @param parameter from callback. It's in fact a pair of coordinates * @param tile TileIndex from which the callback was initiated * @param index of the industry been queried for + * @param signed_offsets Are the x and y offset encoded in parameter signed? * @return a construction of bits obeying the newgrf format */ -uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index) +uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets) { - if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required + if (parameter != 0) tile = GetNearbyTile(parameter, tile, signed_offsets); // only perform if it is required bool is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index); return GetNearbyTileInformation(tile) | (is_same_industry ? 1 : 0) << 8; |