Changeset - r18308:05de10e00a85
[Not reviewed]
master
0 9 0
frosch - 13 years ago 2011-11-08 17:29:01
frosch@openttd.org
(svn r23154) -Change: [NewGRF v8] Use heightlevel units in nearby tile info variables. (rubidium)
9 files changed with 31 insertions and 19 deletions:
0 comments (0 inline, 0 general)
src/newgrf_airporttiles.cpp
Show inline comments
 
@@ -112,14 +112,15 @@ static const SpriteGroup *AirportTileRes
 
 * @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 grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
 * @return a construction of bits obeying the newgrf format
 
 */
 
uint32 GetNearbyAirportTileInformation(byte parameter, TileIndex tile, StationID index)
 
static uint32 GetNearbyAirportTileInformation(byte parameter, TileIndex tile, StationID index, bool grf_version8)
 
{
 
	if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 
	bool is_same_airport = (IsTileType(tile, MP_STATION) && IsAirport(tile) && GetStationIndex(tile) == index);
 

	
 
	return GetNearbyTileInformation(tile) | (is_same_airport ? 1 : 0) << 8;
 
	return GetNearbyTileInformation(tile, grf_version8) | (is_same_airport ? 1 : 0) << 8;
 
}
 

	
 

	
 
@@ -194,7 +195,7 @@ static uint32 AirportTileGetVariable(con
 
		case 0x44: return GetAnimationFrame(tile);
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index);
 
		case 0x60: return GetNearbyAirportTileInformation(parameter, tile, st->index, object->grffile);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x61:
src/newgrf_commons.cpp
Show inline comments
 
@@ -442,9 +442,10 @@ TileIndex GetNearbyTile(byte parameter, 
 
 * Common part of station var 0x67, house var 0x62, indtile var 0x60, industry var 0x62.
 
 *
 
 * @param tile the tile of interest.
 
 * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
 * @return 0czzbbss: c = TileType; zz = TileZ; bb: 7-3 zero, 4-2 TerrainType, 1 water/shore, 0 zero; ss = TileSlope
 
 */
 
uint32 GetNearbyTileInformation(TileIndex tile)
 
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8)
 
{
 
	TileType tile_type = GetTileType(tile);
 

	
 
@@ -455,7 +456,8 @@ uint32 GetNearbyTileInformation(TileInde
 
	Slope tileh = GetTilePixelSlope(tile, &z);
 
	/* Return 0 if the tile is a land tile */
 
	byte terrain_type = (HasTileWaterClass(tile) ? (GetWaterClass(tile) + 1) & 3 : 0) << 5 | GetTerrainType(tile) << 2 | (tile_type == MP_WATER ? 1 : 0) << 1;
 
	return tile_type << 24 | z << 16 | terrain_type << 8 | tileh;
 
	if (grf_version8) z /= TILE_HEIGHT;
 
	return tile_type << 24 | Clamp(z, 0, 0xFF) << 16 | terrain_type << 8 | tileh;
 
}
 

	
 
/**
src/newgrf_commons.h
Show inline comments
 
@@ -296,7 +296,7 @@ extern ObjectOverrideManager _object_mng
 

	
 
uint32 GetTerrainType(TileIndex tile, TileContext context = TCX_NORMAL);
 
TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets = true, Axis axis = INVALID_AXIS);
 
uint32 GetNearbyTileInformation(TileIndex tile);
 
uint32 GetNearbyTileInformation(TileIndex tile, bool grf_version8);
 
uint32 GetCompanyInfo(CompanyID owner, const struct Livery *l = NULL);
 
CommandCost GetErrorMessageFromLocationCallbackResult(uint16 cb_res, uint32 grfid, StringID default_error);
 

	
src/newgrf_house.cpp
Show inline comments
 
@@ -132,10 +132,17 @@ static uint32 GetNumHouses(HouseID house
 
	return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
 
}
 

	
 
uint32 GetNearbyTileInformation(byte parameter, TileIndex tile)
 
/**
 
 * Get information about a nearby tile.
 
 * @param parameter from callback. It's in fact a pair of coordinates
 
 * @param tile TileIndex from which the callback was initiated
 
 * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
 * @return a construction of bits obeying the newgrf format
 
 */
 
static uint32 GetNearbyTileInformation(byte parameter, TileIndex tile, bool grf_version8)
 
{
 
	tile = GetNearbyTile(parameter, tile);
 
	return GetNearbyTileInformation(tile);
 
	return GetNearbyTileInformation(tile, grf_version8);
 
}
 

	
 
/** Structure with user-data for SearchNearbyHouseXXX - functions */
 
@@ -302,7 +309,7 @@ static uint32 HouseGetVariable(const Res
 
		}
 

	
 
		/* Land info for nearby tiles. */
 
		case 0x62: return GetNearbyTileInformation(parameter, tile);
 
		case 0x62: return GetNearbyTileInformation(parameter, tile, object->grffile->grf_version >= 8);
 

	
 
		/* Current animation frame of nearby house tiles */
 
		case 0x63: {
src/newgrf_industries.cpp
Show inline comments
 
@@ -251,7 +251,7 @@ uint32 IndustryGetVariable(const Resolve
 
			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, false);
 
		case 0x62: return GetNearbyIndustryTileInformation(parameter, tile, INVALID_INDUSTRY, false, object->grffile->grf_version >= 8);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x63:
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, bool signed_offsets = true);
 
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8);
 

	
 
#endif /* NEWGRF_INDUSTRIES_H */
src/newgrf_industrytiles.cpp
Show inline comments
 
@@ -32,14 +32,15 @@
 
 * @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?
 
 * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
 * @return a construction of bits obeying the newgrf format
 
 */
 
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets)
 
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8)
 
{
 
	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;
 
	return GetNearbyTileInformation(tile, grf_version8) | (is_same_industry ? 1 : 0) << 8;
 
}
 

	
 
/**
 
@@ -87,7 +88,7 @@ static uint32 IndustryTileGetVariable(co
 
		case 0x44: return (IsTileType(tile, MP_INDUSTRY)) ? GetAnimationFrame(tile) : 0;
 

	
 
		/* Land info of nearby tiles */
 
		case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index);
 
		case 0x60: return GetNearbyIndustryTileInformation(parameter, tile, inds == NULL ? (IndustryID)INVALID_INDUSTRY : inds->index, true, object->grffile->grf_version >= 8);
 

	
 
		/* Animation stage of nearby tiles */
 
		case 0x61:
src/newgrf_object.cpp
Show inline comments
 
@@ -157,14 +157,15 @@ static uint32 GetObjectIDAtOffset(TileIn
 
 * @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 object been queried for
 
 * @param grf_version8 True, if we are dealing with a new NewGRF which uses GRF version >= 8.
 
 * @return a construction of bits obeying the newgrf format
 
 */
 
static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index)
 
static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index, bool grf_version8)
 
{
 
	if (parameter != 0) tile = GetNearbyTile(parameter, tile); // only perform if it is required
 
	bool is_same_object = (IsTileType(tile, MP_OBJECT) && GetObjectIndex(tile) == index);
 

	
 
	return GetNearbyTileInformation(tile) | (is_same_object ? 1 : 0) << 8;
 
	return GetNearbyTileInformation(tile, grf_version8) | (is_same_object ? 1 : 0) << 8;
 
}
 

	
 
/**
 
@@ -321,7 +322,7 @@ static uint32 ObjectGetVariable(const Re
 
			return (IsTileType(tile, MP_OBJECT) && Object::GetByTile(tile) == o) ? GetObjectRandomBits(tile) : 0;
 

	
 
		/* Land info of nearby tiles */
 
		case 0x62: return GetNearbyObjectTileInformation(parameter, tile, o == NULL ? INVALID_OBJECT : o->index);
 
		case 0x62: return GetNearbyObjectTileInformation(parameter, tile, o == NULL ? INVALID_OBJECT : o->index, object->grffile->grf_version >= 8);
 

	
 
		/* Animation counter of nearby tile */
 
		case 0x63:
src/newgrf_station.cpp
Show inline comments
 
@@ -296,7 +296,7 @@ static uint32 StationGetVariable(const R
 
					Slope tileh = GetTileSlope(tile);
 
					bool swap = (object->u.station.axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
					return GetNearbyTileInformation(tile) ^ (swap ? SLOPE_EW : 0);
 
					return GetNearbyTileInformation(tile, object->grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
 
				}
 
				break;
 

	
 
@@ -353,7 +353,7 @@ static uint32 StationGetVariable(const R
 
			Slope tileh = GetTileSlope(tile);
 
			bool swap = (axis == AXIS_Y && HasBit(tileh, CORNER_W) != HasBit(tileh, CORNER_E));
 

	
 
			return GetNearbyTileInformation(tile) ^ (swap ? SLOPE_EW : 0);
 
			return GetNearbyTileInformation(tile, object->grffile->grf_version >= 8) ^ (swap ? SLOPE_EW : 0);
 
		}
 

	
 
		case 0x68: { // Station info of nearby tiles
0 comments (0 inline, 0 general)