diff --git a/src/newgrf_airporttiles.cpp b/src/newgrf_airporttiles.cpp index 916b3f9f75..4e0253cd2d 100644 --- a/src/newgrf_airporttiles.cpp +++ b/src/newgrf_airporttiles.cpp @@ -309,9 +309,9 @@ static bool DoTriggerAirportTileAnimation(Station *st, TileIndex tile, AirportAn 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) @@ -323,7 +323,12 @@ bool TriggerAirportAnimation(Station *st, AirportAnimationTrigger trigger, Cargo for (TileIndex tile : st->airport) { 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()); } else { ret = false; diff --git a/src/newgrf_airporttiles.h b/src/newgrf_airporttiles.h index 89d72979d6..67db07743b 100644 --- a/src/newgrf_airporttiles.h +++ b/src/newgrf_airporttiles.h @@ -88,7 +88,7 @@ private: }; 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 DrawNewAirportTile(TileInfo *ti, Station *st, const AirportTileSpec *airts); diff --git a/src/newgrf_roadstop.cpp b/src/newgrf_roadstop.cpp index 4250b0b9cd..1d0dc82641 100644 --- a/src/newgrf_roadstop.cpp +++ b/src/newgrf_roadstop.cpp @@ -389,13 +389,11 @@ void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAn auto process_tile = [&](TileIndex cur_tile) { const RoadStopSpec *ss = GetRoadStopSpec(cur_tile); if (ss != nullptr && ss->animation.triggers.Test(trigger)) { - uint8_t local_cargo; - if (!IsValidCargoType(cargo_type)) { - local_cargo = UINT8_MAX; - } else { - local_cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; + uint8_t var18_extra = 0; + if (IsValidCargoType(cargo_type)) { + var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8; } - 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); } }; diff --git a/src/newgrf_station.cpp b/src/newgrf_station.cpp index f59f18daf3..3fda5fe9ce 100644 --- a/src/newgrf_station.cpp +++ b/src/newgrf_station.cpp @@ -923,13 +923,11 @@ void TriggerStationAnimation(BaseStation *st, TileIndex trigger_tile, StationAni if (st->TileBelongsToRailStation(tile)) { const StationSpec *ss = GetStationSpec(tile); if (ss != nullptr && ss->animation.triggers.Test(trigger)) { - uint8_t local_cargo; - if (!IsValidCargoType(cargo_type)) { - local_cargo = UINT8_MAX; - } else { - local_cargo = ss->grf_prop.grffile->cargo_map[cargo_type]; + uint8_t var18_extra = 0; + if (IsValidCargoType(cargo_type)) { + var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8; } - 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); } } }