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.
coverity_scan
scrawl 9 years ago
parent 091ca9743e
commit 0b84b3c2cf

@ -321,10 +321,14 @@ void RegionWeather::chooseNewWeather()
{ {
sum += mChances[i]; sum += mChances[i];
if(chance <= sum) 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) MoonModel::MoonModel(const std::string& name, const MWWorld::Fallback& fallback)

Loading…
Cancel
Save