diff -r 7de85783b823 -r 4a4f21070479 hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Sun Nov 11 16:53:16 2012 +0100 +++ b/hedgewars/uRandom.pas Sun Nov 11 17:15:19 2012 +0100 @@ -31,7 +31,7 @@ uses uFloat; procedure SetRandomSeed(Seed: shortstring); // Sets the seed that should be used for generating pseudo-random values. -function GetRandomf: hwFloat; overload; // Returns a pseudo-random hwFloat. +function GetRandomf: hwFloat; // Returns a pseudo-random hwFloat. function GetRandom(m: LongWord): LongWord; overload; inline; // Returns a positive pseudo-random integer smaller than m. procedure AddRandomness(r: LongWord); inline; function rndSign(num: hwFloat): hwFloat; // Returns num with a random chance of having a inverted sign. @@ -45,10 +45,11 @@ procedure AddRandomness(r: LongWord); inline; begin n:= (n + 1) and $3F; -cirbuf[n]:= cirbuf[n] xor r + cirbuf[n]:= cirbuf[n] xor r; end; function GetNext: Longword; inline; +var s : string; begin n:= (n + 1) and $3F; cirbuf[n]:= @@ -56,7 +57,8 @@ cirbuf[(n + 9) and $3F]) {n - 55 mod 64} and $7FFFFFFF; {mod 2^31} -GetNext:= cirbuf[n] + GetNext:= cirbuf[n]; + str(GetNext, s); end; procedure SetRandomSeed(Seed: shortstring); @@ -74,7 +76,7 @@ cirbuf[i]:= $A98765 + 68; // odd number for i:= 0 to 1023 do - GetNext + GetNext; end; function GetRandomf: hwFloat; @@ -84,7 +86,7 @@ GetRandomf.QWordValue:= GetNext end; -function GetRandom(m: LongWord): LongWord; inline; +function GetRandom(m: LongWord): LongWord; overload; inline; begin GetNext; GetRandom:= GetNext mod m