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

Function RoadVehCrash

src/roadveh_cmd.cpp:555–571  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553}
554
555static void RoadVehCrash(RoadVehicle *v)
556{
557 uint victims = v->Crash();
558
559 AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, victims, v->owner));
560 Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_RV_LEVEL_CROSSING, victims, v->owner));
561
562 EncodedString headline = (victims == 1)
563 ? GetEncodedString(STR_NEWS_ROAD_VEHICLE_CRASH_DRIVER)
564 : GetEncodedString(STR_NEWS_ROAD_VEHICLE_CRASH, victims);
565 NewsType newstype = v->owner == _local_company ? NewsType::Accident : NewsType::AccidentOther;
566
567 AddTileNewsItem(std::move(headline), newstype, v->tile);
568
569 ModifyStationRatingAround(v->tile, v->owner, -160, 22);
570 if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
571}
572
573static bool RoadVehCheckTrainCrash(RoadVehicle *v)
574{

Callers 1

RoadVehCheckTrainCrashFunction · 0.85

Calls 5

AddTileNewsItemFunction · 0.85
SndPlayVehicleFxFunction · 0.85
GetEncodedStringFunction · 0.70
CrashMethod · 0.45

Tested by

no test coverage detected