mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-24 09:39:51 +00:00
Avoid zero division
This commit is contained in:
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…
x
Reference in New Issue
Block a user