1
0
Fork 0

Fix: [NewGRF] For animation-triggers which do not supply a cargo-type in var18, the var18 bits should remain empty. (#14091)

pull/14092/head
frosch 2025-04-26 14:44:07 +02:00 committed by GitHub
parent 0d9074769d
commit d3ae6bc9a8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 17 additions and 16 deletions

View File

@ -309,9 +309,9 @@ static bool DoTriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAn
return true; return true;
} }
bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type) bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger)
{ {
return DoTriggerAirportTileAnimation(st, tile, trigger, Random(), cargo_type << 8); return DoTriggerAirportTileAnimation(st, tile, trigger, Random());
} }
bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type) bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, CargoType cargo_type)
@ -323,7 +323,12 @@ bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, Cargo
for (TileIndex tile : st->airport) { for (TileIndex tile : st->airport) {
if (!st->TileBelongsToAirport(tile)) continue; if (!st->TileBelongsToAirport(tile)) continue;
if (DoTriggerAirportTileAnimation(st, tile, trigger, random, cargo_type << 8)) { uint8_t var18_extra = 0;
if (IsValidCargoType(cargo_type)) {
var18_extra |= cargo_type << 8;
}
if (DoTriggerAirportTileAnimation(st, tile, trigger, random, var18_extra)) {
SB(random, 0, 16, Random()); SB(random, 0, 16, Random());
} else { } else {
ret = false; ret = false;

View File

@ -88,7 +88,7 @@ private:
}; };
void AnimateAirportTile(TileIndex tile); void AnimateAirportTile(TileIndex tile);
bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger, CargoType cargo_type = INVALID_CARGO); bool TriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAnimationTrigger trigger);
bool TriggerAirportAnimation(Station *st, 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); bool DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts);

View File

@ -389,13 +389,11 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn
auto process_tile = [&](TileIndex cur_tile) { auto process_tile = [&](TileIndex cur_tile) {
const RoadStopSpec *ss = GetRoadStopSpec(cur_tile); const RoadStopSpec *ss = GetRoadStopSpec(cur_tile);
if (ss != nullptr && ss->animation.triggers.Test(trigger)) { if (ss != nullptr && ss->animation.triggers.Test(trigger)) {
uint8_t local_cargo; uint8_t var18_extra = 0;
if (!IsValidCargoType(cargo_type)) { if (IsValidCargoType(cargo_type)) {
local_cargo = UINT8_MAX; var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8;
} else {
local_cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
} }
RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, cur_tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | (local_cargo << 8)); RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, cur_tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | var18_extra);
} }
}; };

View File

@ -923,13 +923,11 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni
if (st->TileBelongsToRailStation(tile)) { if (st->TileBelongsToRailStation(tile)) {
const StationSpec *ss = GetStationSpec(tile); const StationSpec *ss = GetStationSpec(tile);
if (ss != nullptr && ss->animation.triggers.Test(trigger)) { if (ss != nullptr && ss->animation.triggers.Test(trigger)) {
uint8_t local_cargo; uint8_t var18_extra = 0;
if (!IsValidCargoType(cargo_type)) { if (IsValidCargoType(cargo_type)) {
local_cargo = UINT8_MAX; var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8;
} else {
local_cargo = ss->grf_prop.grffile->cargo_map[cargo_type];
} }
StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | (local_cargo << 8)); StationAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | var18_extra);
} }
} }
} }