hedgewars/uRandom.pas
changeset 3282 9ca28cef559a
parent 3236 4ab3917d7d44
child 3284 7ffd0e20ad08
equal deleted inserted replaced
3281:2f3be13e1140 3282:9ca28cef559a
    34 procedure DumpBuffer;
    34 procedure DumpBuffer;
    35 {$ENDIF}
    35 {$ENDIF}
    36 
    36 
    37 implementation
    37 implementation
    38 {$IFDEF DEBUGFILE}
    38 {$IFDEF DEBUGFILE}
    39 uses uMisc;
    39 uses uMisc, uConsole;
    40 {$ENDIF}
    40 {$ENDIF}
    41 var cirbuf: array[0..63] of Longword;
    41 var cirbuf: array[0..63] of Longword;
    42     n: byte;
    42     n: byte;
    43 
    43 
    44 function GetNext: Longword;
    44 function GetNext: Longword;
    75 GetRandom.QWordValue:= GetNext
    75 GetRandom.QWordValue:= GetNext
    76 end;
    76 end;
    77 
    77 
    78 function GetRandom(m: LongWord): LongWord;
    78 function GetRandom(m: LongWord): LongWord;
    79 begin
    79 begin
       
    80 if m = 0 then
       
    81     begin
       
    82     WriteLnToConsole('Warning: GetRandom(0) not defined');
       
    83     GetRandom:= 0;
       
    84     exit
       
    85     end;
    80 GetNext;
    86 GetNext;
    81 GetRandom:= GetNext mod m
    87 GetRandom:= GetNext mod m
    82 end;
    88 end;
    83 
    89 
    84 function rndSign(num: hwFloat): hwFloat;
    90 function rndSign(num: hwFloat): hwFloat;