MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / determineFutureWeather

Function determineFutureWeather

src/openrct2/world/Weather.cpp:344–369  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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 {

Callers 3

resetFunction · 0.85
updateFunction · 0.85
forceWeatherFunction · 0.85

Calls 3

GetContextFunction · 0.85
EnumValueFunction · 0.85
GetMonthMethod · 0.80

Tested by

no test coverage detected