(svn r20996) -Change: [NewGRF] the X and Y offsets in the parameter for industry vars 60,61,62,63 are unsigned instead of signed

This commit is contained in:
yexo 2010-10-19 21:00:45 +00:00
parent 3ab422b057
commit 9373ee71d9
5 changed files with 12 additions and 11 deletions

View File

@ -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);

View File

@ -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);
/**

View File

@ -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);
}

View File

@ -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 */

View File

@ -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;