Avoid zero division

pull/578/head
Andrei Kortunov 5 years ago
parent 8c4acc69c4
commit 3ebbe14a62

@ -774,6 +774,9 @@ namespace MWMechanics
if (visitor.mRemainingTime > 0)
{
double timeScale = MWBase::Environment::get().getWorld()->getTimeScaleFactor();
if(timeScale == 0.0)
timeScale = 1;
restoreHours = std::max(0.0, hours - visitor.mRemainingTime * timeScale / 3600.f);
}
else if (visitor.mRemainingTime == -1)
@ -1935,7 +1938,11 @@ namespace MWMechanics
void Actors::rest(double hours, bool sleep)
{
float duration = hours * 3600.f / MWBase::Environment::get().getWorld()->getTimeScaleFactor();
float duration = hours * 3600.f;
float timeScale = MWBase::Environment::get().getWorld()->getTimeScaleFactor();
if (timeScale != 0.f)
duration /= timeScale;
const MWWorld::Ptr player = MWBase::Environment::get().getWorld()->getPlayerPtr();
const osg::Vec3f playerPos = player.getRefData().getPosition().asVec3();

Loading…
Cancel
Save