From 0b84b3c2cf3253b0cf6c514485fd4601677859a4 Mon Sep 17 00:00:00 2001 From: scrawl Date: Thu, 14 Jan 2016 17:41:39 +0100 Subject: [PATCH] Don't crash when region weather chances don't add to 100 The invalid weather ID was resulting in out-of-bounds vector access later in the code. --- apps/openmw/mwworld/weather.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 5ce3d5c2f..321637194 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -321,10 +321,14 @@ void RegionWeather::chooseNewWeather() { sum += mChances[i]; if(chance <= sum) - break; + { + mWeather = i; + return; + } } - mWeather = i; + // if we hit this path then the chances don't add to 100, choose a default weather instead + mWeather = 0; } MoonModel::MoonModel(const std::string& name, const MWWorld::Fallback& fallback)