|
@@ -131,55 +131,54 @@ void DecreaseBuildingCount(Town *t, Hous
|
|
|
if (_building_counts.id_count[house_id] > 0) _building_counts.id_count[house_id]--;
|
|
|
|
|
|
if (class_id == HOUSE_NO_CLASS) return;
|
|
|
|
|
|
if (t->cache.building_counts.class_count[class_id] > 0) t->cache.building_counts.class_count[class_id]--;
|
|
|
if (_building_counts.class_count[class_id] > 0) _building_counts.class_count[class_id]--;
|
|
|
}
|
|
|
|
|
|
/* virtual */ uint32 HouseScopeResolver::GetRandomBits() const
|
|
|
{
|
|
|
/* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
|
|
|
assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)));
|
|
|
return this->not_yet_constructed ? this->initial_random_bits : GetHouseRandomBits(this->tile);
|
|
|
}
|
|
|
|
|
|
/* virtual */ uint32 HouseScopeResolver::GetTriggers() const
|
|
|
{
|
|
|
/* Note: Towns build houses over houses. So during construction checks 'tile' may be a valid but unrelated house. */
|
|
|
assert(IsValidTile(this->tile) && (this->not_yet_constructed || IsTileType(this->tile, MP_HOUSE)));
|
|
|
return this->not_yet_constructed ? 0 : GetHouseTriggers(this->tile);
|
|
|
}
|
|
|
|
|
|
static uint32 GetNumHouses(HouseID house_id, const Town *town)
|
|
|
{
|
|
|
uint8 map_id_count, town_id_count, map_class_count, town_class_count;
|
|
|
HouseClassID class_id = HouseSpec::Get(house_id)->class_id;
|
|
|
|
|
|
map_id_count = ClampU(_building_counts.id_count[house_id], 0, 255);
|
|
|
map_class_count = ClampU(_building_counts.class_count[class_id], 0, 255);
|
|
|
town_id_count = ClampU(town->cache.building_counts.id_count[house_id], 0, 255);
|
|
|
town_class_count = ClampU(town->cache.building_counts.class_count[class_id], 0, 255);
|
|
|
uint8_t map_id_count = ClampTo<uint8_t>(_building_counts.id_count[house_id]);
|
|
|
uint8_t map_class_count = ClampTo<uint8_t>(_building_counts.class_count[class_id]);
|
|
|
uint8_t town_id_count = ClampTo<uint8_t>(town->cache.building_counts.id_count[house_id]);
|
|
|
uint8_t town_class_count = ClampTo<uint8_t>(town->cache.building_counts.class_count[class_id]);
|
|
|
|
|
|
return map_class_count << 24 | town_class_count << 16 | map_id_count << 8 | town_id_count;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 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, grf_version8);
|
|
|
}
|
|
|
|
|
|
/** Structure with user-data for SearchNearbyHouseXXX - functions */
|
|
|
struct SearchNearbyHouseData {
|
|
|
const HouseSpec *hs; ///< Specs of the house that started the search.
|
|
|
TileIndex north_tile; ///< Northern tile of the house.
|
|
|
};
|
|
|
|
|
|
/**
|