|
@@ -53,13 +53,13 @@ static const GRFFile *GetHouseSpecGrf(Ho
|
|
|
* @param not_yet_constructed House is still under construction.
|
|
|
* @param initial_random_bits Random bits during construction checks.
|
|
|
* @param watched_cargo_triggers Cargo types that triggered the watched cargo callback.
|
|
|
*/
|
|
|
HouseResolverObject::HouseResolverObject(HouseID house_id, TileIndex tile, Town *town,
|
|
|
CallbackID callback, uint32 param1, uint32 param2,
|
|
|
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
|
|
|
bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers)
|
|
|
: ResolverObject(GetHouseSpecGrf(house_id), callback, param1, param2),
|
|
|
house_scope(*this, house_id, tile, town, not_yet_constructed, initial_random_bits, watched_cargo_triggers),
|
|
|
town_scope(*this, town, not_yet_constructed) // Don't access StorePSA if house is not yet constructed.
|
|
|
{
|
|
|
this->root_spritegroup = HouseSpec::Get(house_id)->grf_prop.spritegroup[0];
|
|
|
}
|
|
@@ -406,13 +406,13 @@ static uint32 GetDistanceFromNearbyHouse
|
|
|
|
|
|
*available = false;
|
|
|
return UINT_MAX;
|
|
|
}
|
|
|
|
|
|
uint16 GetHouseCallback(CallbackID callback, uint32 param1, uint32 param2, HouseID house_id, Town *town, TileIndex tile,
|
|
|
bool not_yet_constructed, uint8 initial_random_bits, uint32 watched_cargo_triggers)
|
|
|
bool not_yet_constructed, uint8 initial_random_bits, CargoTypes watched_cargo_triggers)
|
|
|
{
|
|
|
assert(IsValidTile(tile) && (not_yet_constructed || IsTileType(tile, MP_HOUSE)));
|
|
|
|
|
|
HouseResolverObject object(house_id, tile, town, callback, param1, param2,
|
|
|
not_yet_constructed, initial_random_bits, watched_cargo_triggers);
|
|
|
return object.ResolveCallback();
|
|
@@ -469,19 +469,19 @@ void DrawNewHouseTile(TileInfo *ti, Hous
|
|
|
byte stage = GetHouseBuildingStage(ti->tile);
|
|
|
DrawTileLayout(ti, tlgroup, stage, house_id);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/* Simple wrapper for GetHouseCallback to keep the animation unified. */
|
|
|
uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, uint32 extra_data)
|
|
|
uint16 GetSimpleHouseCallback(CallbackID callback, uint32 param1, uint32 param2, const HouseSpec *spec, Town *town, TileIndex tile, CargoTypes extra_data)
|
|
|
{
|
|
|
return GetHouseCallback(callback, param1, param2, spec - HouseSpec::Get(0), town, tile, false, 0, extra_data);
|
|
|
}
|
|
|
|
|
|
/** Helper class for animation control. */
|
|
|
struct HouseAnimationBase : public AnimationBase<HouseAnimationBase, HouseSpec, Town, uint32, GetSimpleHouseCallback> {
|
|
|
struct HouseAnimationBase : public AnimationBase<HouseAnimationBase, HouseSpec, Town, CargoTypes, GetSimpleHouseCallback> {
|
|
|
static const CallbackID cb_animation_speed = CBID_HOUSE_ANIMATION_SPEED;
|
|
|
static const CallbackID cb_animation_next_frame = CBID_HOUSE_ANIMATION_NEXT_FRAME;
|
|
|
|
|
|
static const HouseCallbackMask cbm_animation_speed = CBM_HOUSE_ANIMATION_SPEED;
|
|
|
static const HouseCallbackMask cbm_animation_next_frame = CBM_HOUSE_ANIMATION_NEXT_FRAME;
|
|
|
};
|
|
@@ -630,26 +630,26 @@ void TriggerHouse(TileIndex t, HouseTrig
|
|
|
* Run the watched cargo accepted callback for a single house tile.
|
|
|
* @param tile The house tile.
|
|
|
* @param origin The triggering tile.
|
|
|
* @param trigger_cargoes Cargo types that triggered the callback.
|
|
|
* @param random Random bits.
|
|
|
*/
|
|
|
void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, uint32 trigger_cargoes, uint16 random)
|
|
|
void DoWatchedCargoCallback(TileIndex tile, TileIndex origin, CargoTypes trigger_cargoes, uint16 random)
|
|
|
{
|
|
|
TileIndexDiffC diff = TileIndexToTileIndexDiffC(origin, tile);
|
|
|
uint32 cb_info = random << 16 | (uint8)diff.y << 8 | (uint8)diff.x;
|
|
|
HouseAnimationBase::ChangeAnimationFrame(CBID_HOUSE_WATCHED_CARGO_ACCEPTED, HouseSpec::Get(GetHouseType(tile)), Town::GetByTile(tile), tile, 0, cb_info, trigger_cargoes);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Run watched cargo accepted callback for a house.
|
|
|
* @param tile House tile.
|
|
|
* @param trigger_cargoes Triggering cargo types.
|
|
|
* @pre IsTileType(t, MP_HOUSE)
|
|
|
*/
|
|
|
void WatchedCargoCallback(TileIndex tile, uint32 trigger_cargoes)
|
|
|
void WatchedCargoCallback(TileIndex tile, CargoTypes trigger_cargoes)
|
|
|
{
|
|
|
assert(IsTileType(tile, MP_HOUSE));
|
|
|
HouseID id = GetHouseType(tile);
|
|
|
const HouseSpec *hs = HouseSpec::Get(id);
|
|
|
|
|
|
trigger_cargoes &= hs->watched_cargoes;
|