* Calculates future weather development. * RCT2 implements this as discrete probability distributions dependent on month and climate * for nextWeather. The other weather parameters are then looked up depending only on the * next weather. */
| 342 | * next weather. |
| 343 | */ |
| 344 | static void determineFutureWeather(uint32_t randomValue) |
| 345 | { |
| 346 | auto& objManager = GetContext()->GetObjectManager(); |
| 347 | auto* climateObj = objManager.GetLoadedObject<ClimateObject>(0); |
| 348 | if (climateObj == nullptr) |
| 349 | return; |
| 350 | |
| 351 | int32_t month = GetDate().GetMonth(); |
| 352 | const Pattern& pattern = climateObj->getPatternForMonth(month); |
| 353 | |
| 354 | // Generate a random index with values 0 up to randomBias-1 |
| 355 | // and choose weather from the distribution table accordingly |
| 356 | const auto randomIndex = ((randomValue % 256) * pattern.randomBias) / 256; |
| 357 | const auto nextWeather = pattern.distribution[randomIndex]; |
| 358 | |
| 359 | auto& gameState = getGameState(); |
| 360 | gameState.weatherNext.weatherType = nextWeather; |
| 361 | |
| 362 | const auto& nextWeatherTrait = kWeatherTraits[EnumValue(nextWeather)]; |
| 363 | gameState.weatherNext.temperature = pattern.baseTemperature + nextWeatherTrait.temperatureDelta; |
| 364 | gameState.weatherNext.weatherEffect = nextWeatherTrait.effectLevel; |
| 365 | gameState.weatherNext.weatherGloom = nextWeatherTrait.gloomLevel; |
| 366 | gameState.weatherNext.level = nextWeatherTrait.level; |
| 367 | |
| 368 | gameState.weatherUpdateTimer = 1920; |
| 369 | } |
| 370 | |
| 371 | static void updateWeatherSound() |
| 372 | { |
no test coverage detected