diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 6c95700b3..32ff20ba7 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -128,7 +128,10 @@ void OMW::Engine::frame(float frametime) } if (!guiActive) - mEnvironment.getWorld()->advanceTimeByFrame(frametime); + { + double hours = (frametime * mEnvironment.getWorld()->getTimeScaleFactor()) / 3600.0; + mEnvironment.getWorld()->advanceTime(hours, true); + } } osg::Timer_t afterScriptTick = osg::Timer::instance()->tick(); diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 636370342..a3d293d95 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -185,12 +185,9 @@ namespace MWBase virtual void disable (const MWWorld::Ptr& ptr) = 0; - virtual void advanceTime (double hours) = 0; + virtual void advanceTime (double hours, bool incremental = false) = 0; ///< Advance in-game time. - virtual void advanceTimeByFrame (double frametime) = 0; - ///< Advance in-game time by the duration of a frame. - virtual void setHour (double hour) = 0; ///< Set in-game time hour. diff --git a/apps/openmw/mwworld/weather.cpp b/apps/openmw/mwworld/weather.cpp index 5c2a81c09..52609f21a 100644 --- a/apps/openmw/mwworld/weather.cpp +++ b/apps/openmw/mwworld/weather.cpp @@ -670,19 +670,12 @@ osg::Vec3f WeatherManager::getStormDirection() const return mStormDirection; } -void WeatherManager::advanceTime(double hours) +void WeatherManager::advanceTime(double hours, bool incremental) { - // This is called when the player sleeps/waits, serves jail time, travels, or trains. - // In Morrowind, when any of those events occur, all weather transitions are immediately applied, regardless of - // whatever transition time might have been remaining. - mTimePassed += hours; - mFastForward = true; -} - -void WeatherManager::advanceTimeByFrame(double hours) -{ - // Called when time is advanced by an incremental update for each frame. + // In Morrowind, when the player sleeps/waits, serves jail time, travels, or trains, all weather transitions are + // immediately applied, regardless of whatever transition time might have been remaining. mTimePassed += hours; + mFastForward = (!mFastForward && !incremental) ? true : mFastForward; } unsigned int WeatherManager::getWeatherID() const diff --git a/apps/openmw/mwworld/weather.hpp b/apps/openmw/mwworld/weather.hpp index cdbe14dfa..c808b029b 100644 --- a/apps/openmw/mwworld/weather.hpp +++ b/apps/openmw/mwworld/weather.hpp @@ -206,8 +206,7 @@ namespace MWWorld osg::Vec3f getStormDirection() const; - void advanceTime(double hours); - void advanceTimeByFrame(double hours); + void advanceTime(double hours, bool incremental); unsigned int getWeatherID() const; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 56c7415a2..5f9c8f8d3 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -787,30 +787,11 @@ namespace MWWorld } } - void World::advanceTime (double hours) + void World::advanceTime (double hours, bool incremental) { MWBase::Environment::get().getMechanicsManager()->advanceTime(static_cast(hours * 3600)); - mWeatherManager->advanceTime (hours); - - hours += mGlobalVariables["gamehour"].getFloat(); - - setHour (hours); - - int days = static_cast(hours / 24); - - if (days>0) - mGlobalVariables["dayspassed"].setInteger ( - days + mGlobalVariables["dayspassed"].getInteger()); - } - - void World::advanceTimeByFrame (double frametime) - { - double hours = (frametime * getTimeScaleFactor()) / 3600.0; - - MWBase::Environment::get().getMechanicsManager()->advanceTime(static_cast(hours * 3600)); - - mWeatherManager->advanceTimeByFrame (hours); + mWeatherManager->advanceTime (hours, incremental); hours += mGlobalVariables["gamehour"].getFloat(); diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 80fe6d850..241dacc8a 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -274,12 +274,9 @@ namespace MWWorld virtual void disable (const Ptr& ptr); - virtual void advanceTime (double hours); + virtual void advanceTime (double hours, bool incremental = false); ///< Advance in-game time. - virtual void advanceTimeByFrame (double frametime); - ///< Advance in-game time by the duration of a frame. - virtual void setHour (double hour); ///< Set in-game time hour.