From ab66034ed17f045839f4fd16ac1fec4872e6afad Mon Sep 17 00:00:00 2001
From: rexelion <rexelion@users.noreply.github.com>
Date: Sat, 4 Nov 2017 02:15:56 +0000
Subject: [PATCH] use uniform_int_distribution instead of rand()

---
 apps/openmw/mwmechanics/character.cpp | 6 +++++-
 apps/openmw/mwmechanics/character.hpp | 1 -
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp
index deb9daa93c..ade9d635bb 100644
--- a/apps/openmw/mwmechanics/character.cpp
+++ b/apps/openmw/mwmechanics/character.cpp
@@ -20,6 +20,7 @@
 #include "character.hpp"
 
 #include <iostream>
+#include <random>
 
 #include <components/misc/rng.hpp>
 
@@ -254,8 +255,11 @@ void CharacterController::refreshHitRecoilAnims()
                 || mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0)
                 && mAnimation->hasAnimation("knockout"))
         {
+            std::random_device r;
+            std::mt19937 gen(r());
+            std::uniform_int_distribution<int> dist(1, 3);
             mTimeToWake = time(NULL);
-            mTimeToWake += (int)( (float)rand() / (float)RAND_MAX * 2) + 1; // Wake up after 1 to 3 seconds
+            mTimeToWake += dist(gen); // Wake up after 1 to 3 seconds
             if (isSwimming && mAnimation->hasAnimation("swimknockout"))
             {
                 mHitState = CharState_SwimKnockOut;
diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp
index af8415e352..12b4d6adcb 100644
--- a/apps/openmw/mwmechanics/character.hpp
+++ b/apps/openmw/mwmechanics/character.hpp
@@ -7,7 +7,6 @@
 
 #include "../mwworld/ptr.hpp"
 #include "../mwworld/containerstore.hpp"
-#include "../mwworld/timestamp.hpp"
 
 #include "../mwrender/animation.hpp"