From 48fb6bb9e8ec77b1d5306e8d7e729d2c2d224d8f Mon Sep 17 00:00:00 2001 From: Evgeny Kurnevsky Date: Sat, 21 Apr 2018 16:27:07 +0300 Subject: [PATCH 1/2] Fix crash when rollDice is called with 0. --- components/misc/rng.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/misc/rng.cpp b/components/misc/rng.cpp index dfe0eff40..e402f0b79 100644 --- a/components/misc/rng.cpp +++ b/components/misc/rng.cpp @@ -25,7 +25,7 @@ namespace Misc int Rng::rollDice(int max) { - return std::uniform_int_distribution(0, max - 1)(generator); + return max > 0 ? std::uniform_int_distribution(0, max - 1)(generator) : 0; } } From c025b8f8f3ceab7998c53778cecfdb11f0a2c5ca Mon Sep 17 00:00:00 2001 From: Evgeny Kurnevsky Date: Sat, 21 Apr 2018 16:42:28 +0300 Subject: [PATCH 2/2] Remove useless comparison. --- apps/openmw/mwmechanics/character.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 06e0a42d7..2ef5e07d7 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -286,7 +286,7 @@ void CharacterController::refreshHitRecoilAnims() } else if (recovery) { - std::string anim = isSwimming ? chooseRandomGroup("swimhit") : chooseRandomGroup("hit"); + std::string anim = chooseRandomGroup("swimhit"); if (isSwimming && mAnimation->hasAnimation(anim)) { mHitState = CharState_SwimHit;