From 0442bc98f3e0a6fd52fdf9f7bd1a59cf3e87bddc Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 7 Sep 2015 22:31:11 +0200 Subject: [PATCH] Update sleep interruption formula according to wiki, thanks Hrnchamd --- apps/openmw/mwgui/waitdialog.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwgui/waitdialog.cpp b/apps/openmw/mwgui/waitdialog.cpp index 733fdd132..e8ac63bf6 100644 --- a/apps/openmw/mwgui/waitdialog.cpp +++ b/apps/openmw/mwgui/waitdialog.cpp @@ -158,11 +158,15 @@ namespace MWGui // figure out if player will be woken while sleeping int x = Misc::Rng::rollDice(hoursToWait); float fSleepRandMod = world->getStore().get().find("fSleepRandMod")->getFloat(); - if (x < static_cast(fSleepRandMod * hoursToWait)) + if (x < fSleepRandMod * hoursToWait) { float fSleepRestMod = world->getStore().get().find("fSleepRestMod")->getFloat(); - mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait); - mInterruptCreatureList = region->mSleepList; + int interruptAtHoursRemaining = int(fSleepRestMod * hoursToWait); + if (interruptAtHoursRemaining != 0) + { + mInterruptAt = hoursToWait - interruptAtHoursRemaining; + mInterruptCreatureList = region->mSleepList; + } } } }