mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-11 13:10:45 +00:00
(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:
parent
3ab422b057
commit
9373ee71d9
@ -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 x = GB(parameter, 0, 4);
|
||||||
int8 y = GB(parameter, 4, 4);
|
int8 y = GB(parameter, 4, 4);
|
||||||
|
|
||||||
if (x >= 8) x -= 16;
|
if (signed_offsets && x >= 8) x -= 16;
|
||||||
if (y >= 8) y -= 16;
|
if (signed_offsets && y >= 8) y -= 16;
|
||||||
|
|
||||||
/* Swap width and height depending on axis for railway stations */
|
/* Swap width and height depending on axis for railway stations */
|
||||||
if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
|
if (HasStationTileRail(tile) && GetRailStationAxis(tile) == AXIS_Y) Swap(x, y);
|
||||||
|
@ -144,7 +144,7 @@ extern AirportTileOverrideManager _airporttile_mngr;
|
|||||||
extern ObjectOverrideManager _object_mngr;
|
extern ObjectOverrideManager _object_mngr;
|
||||||
|
|
||||||
uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
|
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);
|
uint32 GetNearbyTileInformation(TileIndex tile);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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)
|
case 0x46: return industry->construction_date; // Date when built - long format - (in days)
|
||||||
|
|
||||||
/* Get industry ID at offset param */
|
/* 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 */
|
/* Get random tile bits at offset param */
|
||||||
case 0x61:
|
case 0x61:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
|
return (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) ? GetIndustryRandomBits(tile) : 0;
|
||||||
|
|
||||||
/* Land info of nearby tiles */
|
/* 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 */
|
/* Animation stage of nearby tiles */
|
||||||
case 0x63:
|
case 0x63:
|
||||||
tile = GetNearbyTile(parameter, tile);
|
tile = GetNearbyTile(parameter, tile, false);
|
||||||
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
if (IsTileType(tile, MP_INDUSTRY) && Industry::GetByTile(tile) == industry) {
|
||||||
return GetAnimationFrame(tile);
|
return GetAnimationFrame(tile);
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,6 @@ bool IndustryTemporarilyRefusesCargo(Industry *ind, CargoID cargo_type);
|
|||||||
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
|
IndustryType MapNewGRFIndustryType(IndustryType grf_type, uint32 grf_id);
|
||||||
|
|
||||||
/* in newgrf_industrytiles.cpp*/
|
/* 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 */
|
#endif /* NEWGRF_INDUSTRIES_H */
|
||||||
|
@ -32,11 +32,12 @@
|
|||||||
* @param parameter from callback. It's in fact a pair of coordinates
|
* @param parameter from callback. It's in fact a pair of coordinates
|
||||||
* @param tile TileIndex from which the callback was initiated
|
* @param tile TileIndex from which the callback was initiated
|
||||||
* @param index of the industry been queried for
|
* @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
|
* @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);
|
bool is_same_industry = (IsTileType(tile, MP_INDUSTRY) && GetIndustryIndex(tile) == index);
|
||||||
|
|
||||||
return GetNearbyTileInformation(tile) | (is_same_industry ? 1 : 0) << 8;
|
return GetNearbyTileInformation(tile) | (is_same_industry ? 1 : 0) << 8;
|
||||||
|
Loading…
Reference in New Issue
Block a user