From 2f9b1459a8217581c566561a3b09c0a4a01f8d02 Mon Sep 17 00:00:00 2001 From: Oliver Brakmann Date: Sat, 1 Feb 2014 00:04:24 +0100 Subject: [PATCH] Fix OpenRA.GetRandomInteger crashing under certain circumstances OpenRA.GetRandomInteger crashes when the supplied high value is less or equal to the low value. A situation where this might occur is when you try to get a random member of a dynamically generated array that happens to have only a single member. --- mods/common/lua/openra.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/mods/common/lua/openra.lua b/mods/common/lua/openra.lua index 9d20c03ff2..1b8b9d9bab 100644 --- a/mods/common/lua/openra.lua +++ b/mods/common/lua/openra.lua @@ -43,7 +43,11 @@ OpenRA.SetWinState = function(player, winState) end OpenRA.GetRandomInteger = function(low, high) - return Internal.GetRandomInteger(low, high) + if high <= low then + return low + else + return Internal.GetRandomInteger(low, high) + end end OpenRA.TakeOre = function(player, amount)