WeatherManager: fix for cells that have no region.

This commit is contained in:
scrawl 2012-05-17 18:21:05 +02:00
parent 0afda15ce9
commit 375c198ebd

View file

@ -499,51 +499,54 @@ void WeatherManager::update(float duration)
mCurrentRegion = regionstr; mCurrentRegion = regionstr;
mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600; mWeatherUpdateTime = WeatherGlobals::mWeatherUpdateTime*3600;
std::string weather; std::string weather = "clear";
if (mRegionOverrides.find(regionstr) != mRegionOverrides.end()) if (mRegionOverrides.find(regionstr) != mRegionOverrides.end())
weather = mRegionOverrides[regionstr]; weather = mRegionOverrides[regionstr];
else else
{ {
// get weather probabilities for the current region // get weather probabilities for the current region
const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.find (regionstr); const ESM::Region *region = MWBase::Environment::get().getWorld()->getStore().regions.search (regionstr);
float clear = region->data.clear/255.f; if (region != 0)
float cloudy = region->data.cloudy/255.f; {
float foggy = region->data.foggy/255.f; float clear = region->data.clear/255.f;
float overcast = region->data.overcast/255.f; float cloudy = region->data.cloudy/255.f;
float rain = region->data.rain/255.f; float foggy = region->data.foggy/255.f;
float thunder = region->data.thunder/255.f; float overcast = region->data.overcast/255.f;
float ash = region->data.ash/255.f; float rain = region->data.rain/255.f;
float blight = region->data.blight/255.f; float thunder = region->data.thunder/255.f;
//float snow = region->data.a/255.f; float ash = region->data.ash/255.f;
//float blizzard = region->data.b/255.f; float blight = region->data.blight/255.f;
//float snow = region->data.a/255.f;
//float blizzard = region->data.b/255.f;
// re-scale to 100 percent // re-scale to 100 percent
const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard; const float total = clear+cloudy+foggy+overcast+rain+thunder+ash+blight;//+snow+blizzard;
float random = ((rand()%100)/100.f) * total; float random = ((rand()%100)/100.f) * total;
//if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear) //if (random >= snow+blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
// weather = "blizzard"; // weather = "blizzard";
//else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear) //else if (random >= blight+ash+thunder+rain+overcast+foggy+cloudy+clear)
// weather = "snow"; // weather = "snow";
/*else*/ if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear) /*else*/ if (random >= ash+thunder+rain+overcast+foggy+cloudy+clear)
weather = "blight"; weather = "blight";
else if (random >= thunder+rain+overcast+foggy+cloudy+clear) else if (random >= thunder+rain+overcast+foggy+cloudy+clear)
weather = "ashstorm"; weather = "ashstorm";
else if (random >= rain+overcast+foggy+cloudy+clear) else if (random >= rain+overcast+foggy+cloudy+clear)
weather = "thunderstorm"; weather = "thunderstorm";
else if (random >= overcast+foggy+cloudy+clear) else if (random >= overcast+foggy+cloudy+clear)
weather = "rain"; weather = "rain";
else if (random >= foggy+cloudy+clear) else if (random >= foggy+cloudy+clear)
weather = "overcast"; weather = "overcast";
else if (random >= cloudy+clear) else if (random >= cloudy+clear)
weather = "foggy"; weather = "foggy";
else if (random >= clear) else if (random >= clear)
weather = "cloudy"; weather = "cloudy";
else else
weather = "clear"; weather = "clear";
}
} }
setWeather(weather, false); setWeather(weather, false);