GRF: Use access mask when evaluating get nearby tile information variable

This commit is contained in:
Jonathan G Rennison
2022-05-31 01:32:18 +01:00
parent 7207c9330c
commit 8eb86fa6c7
10 changed files with 57 additions and 36 deletions

View File

@@ -170,12 +170,14 @@ static uint32 GetObjectIDAtOffset(TileIndex tile, uint32 cur_grfid)
* @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, bool grf_version8)
static uint32 GetNearbyObjectTileInformation(byte parameter, TileIndex tile, ObjectID index, bool grf_version8, uint32 mask)
{
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, grf_version8) | (is_same_object ? 1 : 0) << 8;
uint32 result = (is_same_object ? 1 : 0) << 8;
if (mask & ~0x100) result |= GetNearbyTileInformation(tile, grf_version8, mask);
return result;
}
/**
@@ -330,7 +332,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
}
/* Land info of nearby tiles */
case 0x62: return GetNearbyObjectTileInformation(parameter, this->tile, this->obj == nullptr ? INVALID_OBJECT : this->obj->index, this->ro.grffile->grf_version >= 8);
case 0x62: return GetNearbyObjectTileInformation(parameter, this->tile, this->obj == nullptr ? INVALID_OBJECT : this->obj->index, this->ro.grffile->grf_version >= 8, extra->mask);
/* Animation counter of nearby tile */
case 0x63: {