* Test for vehicle build probability type. * @param v Vehicle whose build probability to test. * @param type Build probability type to test for. * @returns True or false depending on the probability result, or std::nullopt if the callback failed. */
| 1249 | * @returns True or false depending on the probability result, or std::nullopt if the callback failed. |
| 1250 | */ |
| 1251 | std::optional<bool> TestVehicleBuildProbability(Vehicle *v, EngineID engine, BuildProbabilityType type) |
| 1252 | { |
| 1253 | uint16_t p = GetVehicleCallback(CBID_VEHICLE_BUILD_PROBABILITY, to_underlying(type), 0, engine, v); |
| 1254 | if (p == CALLBACK_FAILED) return std::nullopt; |
| 1255 | |
| 1256 | const uint16_t PROBABILITY_RANGE = 100; |
| 1257 | return p + RandomRange(PROBABILITY_RANGE) >= PROBABILITY_RANGE; |
| 1258 | } |
| 1259 | |
| 1260 | static void DoTriggerVehicleRandomisation(Vehicle *v, VehicleRandomTrigger trigger, uint16_t base_random_bits, bool first) |
| 1261 | { |
no test coverage detected