Engine:
authorsmxx
Sat, 03 Apr 2010 08:46:01 +0000
changeset 3282 9ca28cef559a
parent 3281 2f3be13e1140
child 3283 18ee933a5864
Engine: * Avoid GetRandom(0) causing an exception
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;