Cast Random result to float (bug #5175)

pull/2546/head
Capostrophic 5 years ago
parent 4efdc88f1a
commit bde4a38181

@ -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

@ -489,7 +489,7 @@ namespace Compiler
parseArguments ("l", scanner);
Generator::random (mCode);
mOperands.push_back ('l');
mOperands.push_back ('f');
mNextOperand = false;
return true;

@ -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<Type_Float>(Misc::Rng::rollDice(limit)); // [o, limit)
}
};

Loading…
Cancel
Save