From 48fb6bb9e8ec77b1d5306e8d7e729d2c2d224d8f Mon Sep 17 00:00:00 2001 From: Evgeny Kurnevsky Date: Sat, 21 Apr 2018 16:27:07 +0300 Subject: [PATCH] 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; } }