MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TriggerRoadStopAnimation

Function TriggerRoadStopAnimation

src/newgrf_roadstop.cpp:381–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

379}
380
381void 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

Callers 7

LeaveStationMethod · 0.85
CmdBuildRoadStopFunction · 0.85
TileLoop_StationFunction · 0.85
OnTick_StationFunction · 0.85
UpdateStationWaitingFunction · 0.85
LoadUnloadVehicleFunction · 0.85

Calls 6

GetRoadStopSpecFunction · 0.85
IsValidCargoTypeFunction · 0.85
GBFunction · 0.85
to_underlyingFunction · 0.85
TestMethod · 0.80
RandomFunction · 0.50

Tested by

no test coverage detected