mirror of https://github.com/OpenTTD/OpenTTD
Change: [NewGRF] Provide shared random bits in multi-tile animation-triggers of airport tiles and objects, just like for other features. (#14090)
parent
8b927220c7
commit
f554d799d7
|
@ -300,20 +300,34 @@ void AnimateAirportTile(TileIndex tile)
|
|||
AirportTileAnimationBase::AnimateTile(ats, Station::GetByTile(tile), tile, HasBit(ats->animation_special_flags, 0));
|
||||
}
|
||||
|
||||
void TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type)
|
||||
static bool DoTriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, uint32_t random, uint32_t var18_extra = 0)
|
||||
{
|
||||
const AirportTileSpec *ats = AirportTileSpec::GetByTile(tile);
|
||||
if (!ats->animation.triggers.Test(trigger)) return;
|
||||
if (!ats->animation.triggers.Test(trigger)) return false;
|
||||
|
||||
AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIMATION_TRIGGER, ats, st, tile, Random(), to_underlying(trigger) | (cargo_type << 8));
|
||||
AirportTileAnimationBase::ChangeAnimationFrame(CBID_AIRPTILE_ANIMATION_TRIGGER, ats, st, tile, random, to_underlying(trigger) | var18_extra);
|
||||
return true;
|
||||
}
|
||||
|
||||
void TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type)
|
||||
bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type)
|
||||
{
|
||||
if (st->airport.tile == INVALID_TILE) return;
|
||||
|
||||
for (TileIndex tile : st->airport) {
|
||||
if (st->TileBelongsToAirport(tile)) TriggerAirportTileAnimation(st, tile, trigger, cargo_type);
|
||||
}
|
||||
return DoTriggerAirportTileAnimation(st, tile, trigger, Random(), cargo_type << 8);
|
||||
}
|
||||
|
||||
bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type)
|
||||
{
|
||||
if (st->airport.tile == INVALID_TILE) return false;
|
||||
|
||||
bool ret = true;
|
||||
uint32_t random = Random();
|
||||
for (TileIndex tile : st->airport) {
|
||||
if (!st->TileBelongsToAirport(tile)) continue;
|
||||
|
||||
if (DoTriggerAirportTileAnimation(st, tile, trigger, random, cargo_type << 8)) {
|
||||
SB(random, 0, 16, Random());
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -88,8 +88,8 @@ private:
|
|||
};
|
||||
|
||||
void AnimateAirportTile(TileIndex tile);
|
||||
void TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
void TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO);
|
||||
bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);
|
||||
|
||||
#endif /* NEWGRF_AIRPORTTILES_H */
|
||||
|
|
|
@ -276,23 +276,27 @@ void AnimateNewIndustryTile(TileIndex tile)
|
|||
IndustryAnimationBase::AnimateTile(itspec, Industry::GetByTile(tile), tile, itspec->special_flags.Test(IndustryTileSpecialFlag::NextFrameRandomBits));
|
||||
}
|
||||
|
||||
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random)
|
||||
static bool DoTriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random, uint32_t var18_extra = 0)
|
||||
{
|
||||
const IndustryTileSpec *itspec = GetIndustryTileSpec(GetIndustryGfx(tile));
|
||||
|
||||
if (!itspec->animation.triggers.Test(iat)) return false;
|
||||
|
||||
IndustryAnimationBase::ChangeAnimationFrame(CBID_INDTILE_ANIMATION_TRIGGER, itspec, Industry::GetByTile(tile), tile, random, to_underlying(iat));
|
||||
IndustryAnimationBase::ChangeAnimationFrame(CBID_INDTILE_ANIMATION_TRIGGER, itspec, Industry::GetByTile(tile), tile, random, to_underlying(iat) | var18_extra);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat)
|
||||
{
|
||||
return DoTriggerIndustryTileAnimation(tile, iat, Random());
|
||||
}
|
||||
|
||||
bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat)
|
||||
{
|
||||
bool ret = true;
|
||||
uint32_t random = Random();
|
||||
for (TileIndex tile : ind->location) {
|
||||
if (ind->TileBelongsToIndustry(tile)) {
|
||||
if (TriggerIndustryTileAnimation(tile, iat, random)) {
|
||||
if (DoTriggerIndustryTileAnimation(tile, iat, random)) {
|
||||
SB(random, 0, 16, Random());
|
||||
} else {
|
||||
ret = false;
|
||||
|
|
|
@ -62,7 +62,7 @@ uint16_t GetIndustryTileCallback(CallbackID callback, uint32_t param1, uint32_t
|
|||
CommandCost PerformIndustryTileSlopeCheck(TileIndex ind_base_tile, TileIndex ind_tile, const IndustryTileSpec *its, IndustryType type, IndustryGfx gfx, size_t layout_index, uint16_t initial_random_bits, Owner founder, IndustryAvailabilityCallType creation_type);
|
||||
|
||||
void AnimateNewIndustryTile(TileIndex tile);
|
||||
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat, uint32_t random = Random());
|
||||
bool TriggerIndustryTileAnimation(TileIndex tile, IndustryAnimationTrigger iat);
|
||||
bool TriggerIndustryAnimation(const Industry *ind, IndustryAnimationTrigger iat);
|
||||
|
||||
void TriggerIndustryTileRandomisation(TileIndex t, IndustryRandomTrigger trigger);
|
||||
|
|
|
@ -555,6 +555,14 @@ void AnimateNewObjectTile(TileIndex tile)
|
|||
ObjectAnimationBase::AnimateTile(spec, Object::GetByTile(tile), tile, spec->flags.Test(ObjectFlag::AnimRandomBits));
|
||||
}
|
||||
|
||||
static bool DoTriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec, uint32_t random, uint32_t var18_extra = 0)
|
||||
{
|
||||
if (!spec->animation.triggers.Test(trigger)) return false;
|
||||
|
||||
ObjectAnimationBase::ChangeAnimationFrame(CBID_OBJECT_ANIMATION_TRIGGER, spec, o, tile, random, to_underlying(trigger) | var18_extra);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the update of animation on a single tile.
|
||||
* @param o The object that got triggered.
|
||||
|
@ -562,11 +570,9 @@ void AnimateNewObjectTile(TileIndex tile)
|
|||
* @param trigger The trigger that is triggered.
|
||||
* @param spec The spec associated with the object.
|
||||
*/
|
||||
void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
|
||||
bool TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
|
||||
{
|
||||
if (!spec->animation.triggers.Test(trigger)) return;
|
||||
|
||||
ObjectAnimationBase::ChangeAnimationFrame(CBID_OBJECT_ANIMATION_TRIGGER, spec, o, tile, Random(), to_underlying(trigger));
|
||||
return DoTriggerObjectTileAnimation(o, tile, trigger, spec, Random());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -575,11 +581,19 @@ void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigge
|
|||
* @param trigger The trigger that is triggered.
|
||||
* @param spec The spec associated with the object.
|
||||
*/
|
||||
void TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
|
||||
bool TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec)
|
||||
{
|
||||
if (!spec->animation.triggers.Test(trigger)) return;
|
||||
if (!spec->animation.triggers.Test(trigger)) return false;
|
||||
|
||||
bool ret = true;
|
||||
uint32_t random = Random();
|
||||
for (TileIndex tile : o->location) {
|
||||
TriggerObjectTileAnimation(o, tile, trigger, spec);
|
||||
if (DoTriggerObjectTileAnimation(o, tile, trigger, spec, random)) {
|
||||
SB(random, 0, 16, Random());
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -174,7 +174,7 @@ uint16_t GetObjectCallback(CallbackID callback, uint32_t param1, uint32_t param2
|
|||
void DrawNewObjectTile(TileInfo *ti, const ObjectSpec *spec);
|
||||
void DrawNewObjectTileInGUI(int x, int y, const ObjectSpec *spec, uint8_t view);
|
||||
void AnimateNewObjectTile(TileIndex tile);
|
||||
void TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
||||
void TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
||||
bool TriggerObjectTileAnimation(Object *o, TileIndex tile, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
||||
bool TriggerObjectAnimation(Object *o, ObjectAnimationTrigger trigger, const ObjectSpec *spec);
|
||||
|
||||
#endif /* NEWGRF_OBJECT_H */
|
||||
|
|
Loading…
Reference in New Issue