Changeset - r16279:c9054b28cdd6
[Not reviewed]
master
0 5 0
yexo - 14 years ago 2010-10-19 21:00:45
yexo@openttd.org
(svn r20996) -Change: [NewGRF] the X and Y offsets in the parameter for industry vars 60,61,62,63 are unsigned instead of signed
5 files changed with 12 insertions and 11 deletions:
0 comments (0 inline, 0 general)
src/newgrf_commons.cpp
Show inline comments
 
@@ -395,13 +395,13 @@ uint32 GetTerrainType(TileIndex tile, Ti
 
	}
 
}
 

	
 
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);
src/newgrf_commons.h
Show inline comments
 
@@ -144,7 +144,7 @@ extern AirportTileOverrideManager _airpo
 
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);
 

	
 
/**
src/newgrf_industries.cpp
Show inline comments
 
@@ -236,19 +236,19 @@ uint32 IndustryGetVariable(const Resolve
 
		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);
 
			}
src/newgrf_industries.h
Show inline comments
 
@@ -46,6 +46,6 @@ bool IndustryTemporarilyRefusesCargo(Ind
 
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 */
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -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;
0 comments (0 inline, 0 general)