fix the weather not changing when sleeping/waiting

This commit is contained in:
scrawl 2012-09-25 21:28:25 +02:00
parent 359824d614
commit caef570c8a
3 changed files with 16 additions and 3 deletions

View file

@ -41,7 +41,8 @@ const float WeatherGlobals::mThunderSoundDelay = 0.25;
WeatherManager::WeatherManager(MWRender::RenderingManager* rendering) :
mHour(14), mCurrentWeather("clear"), mFirstUpdate(true), mWeatherUpdateTime(0),
mThunderFlash(0), mThunderChance(0), mThunderChanceNeeded(50), mThunderSoundDelay(0),
mRemainingTransitionTime(0), mMonth(0), mDay(0)
mRemainingTransitionTime(0), mMonth(0), mDay(0),
mTimePassed(0)
{
mRendering = rendering;
@ -487,7 +488,10 @@ WeatherResult WeatherManager::transition(float factor)
void WeatherManager::update(float duration)
{
mWeatherUpdateTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor();
float timePassed = mTimePassed;
mTimePassed = 0;
mWeatherUpdateTime -= timePassed;
bool exterior = (MWBase::Environment::get().getWorld()->isCellExterior() || MWBase::Environment::get().getWorld()->isCellQuasiExterior());
@ -558,7 +562,7 @@ void WeatherManager::update(float duration)
if (mNextWeather != "")
{
mRemainingTransitionTime -= duration * MWBase::Environment::get().getWorld()->getTimeScaleFactor();
mRemainingTransitionTime -= timePassed;
if (mRemainingTransitionTime < 0)
{
mCurrentWeather = mNextWeather;

View file

@ -231,6 +231,11 @@ namespace MWWorld
void setDate(const int day, const int month);
void advanceTime(double hours)
{
mTimePassed += hours*3600;
}
unsigned int getWeatherID() const;
private:
@ -261,6 +266,8 @@ namespace MWWorld
float mThunderChanceNeeded;
float mThunderSoundDelay;
double mTimePassed; // time passed since last update
WeatherResult transition(const float factor);
WeatherResult getResult(const Ogre::String& weather);

View file

@ -366,6 +366,8 @@ namespace MWWorld
void World::advanceTime (double hours)
{
mWeatherManager->advanceTime (hours);
hours += mGlobalVariables->getFloat ("gamehour");
setHour (hours);