* Decide whether aircraft \a v should crash. * @param v Aircraft to test. */
| 1382 | * @param v Aircraft to test. |
| 1383 | */ |
| 1384 | static void MaybeCrashAirplane(Aircraft *v) |
| 1385 | { |
| 1386 | |
| 1387 | Station *st = Station::Get(v->targetairport); |
| 1388 | |
| 1389 | uint32_t prob; |
| 1390 | if (st->airport.GetFTA()->flags.Test(AirportFTAClass::Flag::ShortStrip) && |
| 1391 | (AircraftVehInfo(v->engine_type)->subtype & AIR_FAST) && |
| 1392 | !_cheats.no_jetcrash.value) { |
| 1393 | prob = 3276; |
| 1394 | } else { |
| 1395 | if (_settings_game.vehicle.plane_crashes == 0) return; |
| 1396 | prob = (0x4000 << _settings_game.vehicle.plane_crashes) / 1500; |
| 1397 | } |
| 1398 | |
| 1399 | if (GB(Random(), 0, 22) > prob) return; |
| 1400 | |
| 1401 | /* Crash the airplane. Remove all goods stored at the station. */ |
| 1402 | for (GoodsEntry &ge : st->goods) { |
| 1403 | ge.rating = 1; |
| 1404 | if (ge.HasData()) ge.GetData().cargo.Truncate(); |
| 1405 | } |
| 1406 | |
| 1407 | CrashAirplane(v); |
| 1408 | } |
| 1409 | |
| 1410 | /** |
| 1411 | * Aircraft arrives at a terminal. If it is the first aircraft, throw a party. |
no test coverage detected