mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-08 01:10:28 +00:00
(svn r23154) -Change: [NewGRF v8] Use heightlevel units in nearby tile info variables. (rubidium)
This commit is contained in:
parent
8bfc1ebf9f
commit
e29221a31e
@ -112,14 +112,15 @@ static const SpriteGroup *AirportTileResolveReal(const ResolverObject *object, c
|
||||
* @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(const ResolverObject *object, byte variable
|
||||
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:
|
||||
|
@ -442,9 +442,10 @@ TileIndex GetNearbyTile(byte parameter, TileIndex tile, bool signed_offsets, Axi
|
||||
* 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(TileIndex tile)
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -296,7 +296,7 @@ extern ObjectOverrideManager _object_mngr;
|
||||
|
||||
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);
|
||||
|
||||
|
@ -132,10 +132,17 @@ static uint32 GetNumHouses(HouseID house_id, const Town *town)
|
||||
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 ResolverObject *object, byte variable, uint
|
||||
}
|
||||
|
||||
/* 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: {
|
||||
|
@ -251,7 +251,7 @@ uint32 IndustryGetVariable(const ResolverObject *object, byte variable, uint32 p
|
||||
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:
|
||||
|
@ -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, bool signed_offsets = true);
|
||||
uint32 GetNearbyIndustryTileInformation(byte parameter, TileIndex tile, IndustryID index, bool signed_offsets, bool grf_version8);
|
||||
|
||||
#endif /* NEWGRF_INDUSTRIES_H */
|
||||
|
@ -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(const ResolverObject *object, byte variabl
|
||||
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:
|
||||
|
@ -157,14 +157,15 @@ static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid)
|
||||
* @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 ResolverObject *object, byte variable, uin
|
||||
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:
|
||||
|
@ -296,7 +296,7 @@ static uint32 StationGetVariable(const ResolverObject *object, byte variable, ui
|
||||
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 ResolverObject *object, byte variable, ui
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user