Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/WeatherManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ WeatherManager::CurrentWeathers WeatherManager::GetCurrentWeathers()
}

result.currentWeather = sky->currentWeather;
result.lastWeather = sky->lastWeather;
result.lerpFactor = sky->currentWeatherPct;

// Update cache: store current lastWeather if it exists, otherwise keep the cached one
if (sky->lastWeather) {
cachedLastWeather = sky->lastWeather;
}

// Use cached last weather if sky->lastWeather is null
result.lastWeather = sky->lastWeather ? sky->lastWeather : cachedLastWeather;

return result;
}

Expand Down Expand Up @@ -260,5 +267,6 @@ void WeatherManager::ClearCache()
{
perWeatherSettingsCache.clear();
lastKnownWeather = CurrentWeathers();
cachedLastWeather = nullptr;
logger::info("Cleared WeatherManager cache");
}
3 changes: 3 additions & 0 deletions src/WeatherManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,7 @@ class WeatherManager

// Track last known weather state to detect changes
CurrentWeathers lastKnownWeather;

// Cached last weather - sky->lastWeather can be cleared before currentWeatherPct reaches 1.0
RE::TESWeather* cachedLastWeather = nullptr;
};