From bde4a3818141fe55f24d5a52d40d00362844bec1 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Thu, 3 Oct 2019 23:15:25 +0300 Subject: [PATCH] Cast Random result to float (bug #5175) --- CHANGELOG.md | 1 + components/compiler/exprparser.cpp | 2 +- components/interpreter/miscopcodes.hpp | 4 +--- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 07c7d5b36..47e5bb485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -153,6 +153,7 @@ Bug #5167: Player can select and cast spells before magic menu is enabled Bug #5168: Force1stPerson and Force3rdPerson commands are not really force view change Bug #5169: Nested levelled items/creatures have significantly higher chance not to spawn + Bug #5175: Random script function returns an integer value Feature #1774: Handle AvoidNode Feature #2229: Improve pathfinding AI Feature #3025: Analogue gamepad movement controls diff --git a/components/compiler/exprparser.cpp b/components/compiler/exprparser.cpp index e3a306b8f..017e36373 100644 --- a/components/compiler/exprparser.cpp +++ b/components/compiler/exprparser.cpp @@ -489,7 +489,7 @@ namespace Compiler parseArguments ("l", scanner); Generator::random (mCode); - mOperands.push_back ('l'); + mOperands.push_back ('f'); mNextOperand = false; return true; diff --git a/components/interpreter/miscopcodes.hpp b/components/interpreter/miscopcodes.hpp index 29d1c063b..a77e0d7d8 100644 --- a/components/interpreter/miscopcodes.hpp +++ b/components/interpreter/miscopcodes.hpp @@ -190,9 +190,7 @@ namespace Interpreter throw std::runtime_error ( "random: argument out of range (Don't be so negative!)"); - Type_Integer value = Misc::Rng::rollDice(limit); // [o, limit) - - runtime[0].mInteger = value; + runtime[0].mFloat = static_cast(Misc::Rng::rollDice(limit)); // [o, limit) } };