# HG changeset patch # User smxx # Date 1270284361 0 # Node ID 9ca28cef559a4d4149baac3be740d0d40e2fde23 # Parent 2f3be13e114047b6cb5d51e9af1958af9b50f185 Engine: * Avoid GetRandom(0) causing an exception diff -r 2f3be13e1140 -r 9ca28cef559a hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Sat Apr 03 06:52:26 2010 +0000 +++ b/hedgewars/uRandom.pas Sat Apr 03 08:46:01 2010 +0000 @@ -36,7 +36,7 @@ implementation {$IFDEF DEBUGFILE} -uses uMisc; +uses uMisc, uConsole; {$ENDIF} var cirbuf: array[0..63] of Longword; n: byte; @@ -77,6 +77,12 @@ function GetRandom(m: LongWord): LongWord; begin +if m = 0 then + begin + WriteLnToConsole('Warning: GetRandom(0) not defined'); + GetRandom:= 0; + exit + end; GetNext; GetRandom:= GetNext mod m end;