| 379 | } |
| 380 | |
| 381 | void TriggerRoadStopAnimation(BaseStation *st, TileIndex trigger_tile, StationAnimationTrigger trigger, CargoType cargo_type) |
| 382 | { |
| 383 | assert(st != nullptr); |
| 384 | |
| 385 | /* Check the cached animation trigger bitmask to see if we need |
| 386 | * to bother with any further processing. */ |
| 387 | if (!st->cached_roadstop_anim_triggers.Test(trigger)) return; |
| 388 | |
| 389 | uint16_t random_bits = Random(); |
| 390 | auto process_tile = [&](TileIndex cur_tile) { |
| 391 | const RoadStopSpec *ss = GetRoadStopSpec(cur_tile); |
| 392 | if (ss != nullptr && ss->animation.triggers.Test(trigger)) { |
| 393 | uint8_t var18_extra = 0; |
| 394 | if (IsValidCargoType(cargo_type)) { |
| 395 | var18_extra |= ss->grf_prop.grffile->cargo_map[cargo_type] << 8; |
| 396 | } |
| 397 | RoadStopAnimationBase::ChangeAnimationFrame(CBID_STATION_ANIMATION_TRIGGER, ss, st, cur_tile, (random_bits << 16) | GB(Random(), 0, 16), to_underlying(trigger) | var18_extra); |
| 398 | } |
| 399 | }; |
| 400 | |
| 401 | if (trigger == StationAnimationTrigger::NewCargo || trigger == StationAnimationTrigger::CargoTaken || trigger == StationAnimationTrigger::AcceptanceTick) { |
| 402 | for (const RoadStopTileData &tile_data : st->custom_roadstop_tile_data) { |
| 403 | process_tile(tile_data.tile); |
| 404 | } |
| 405 | } else { |
| 406 | process_tile(trigger_tile); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | /** |
| 411 | * Trigger road stop randomisation |
no test coverage detected