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

Function FloodVehicle

src/water_cmd.cpp:1028–1037  ·  view source on GitHub ↗

* Handle the flooding of a vehicle. This sets the vehicle state to crashed, * creates a newsitem and dirties the necessary windows. * @param v The vehicle to flood. */

Source from the content-addressed store, hash-verified

1026 * @param v The vehicle to flood.
1027 */
1028static void FloodVehicle(Vehicle *v)
1029{
1030 uint victims = v->Crash(true);
1031
1032 AI::NewEvent(v->owner, new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims, v->owner));
1033 Game::NewEvent(new ScriptEventVehicleCrashed(v->index, v->tile, ScriptEventVehicleCrashed::CRASH_FLOODED, victims, v->owner));
1034 AddTileNewsItem(GetEncodedString(STR_NEWS_DISASTER_FLOOD_VEHICLE, victims), NewsType::Accident, v->tile);
1035 CreateEffectVehicleRel(v, 4, 4, 8, EV_EXPLOSION_LARGE);
1036 if (_settings_client.sound.disaster) SndPlayVehicleFx(SND_12_EXPLOSION, v);
1037}
1038
1039/**
1040 * Flood a vehicle if we are allowed to flood it, i.e. when it is on the ground.

Callers 1

FloodVehicleProcFunction · 0.85

Calls 5

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

Tested by

no test coverage detected