Difference between revisions of "Talk:GetRandomPercent"
Jump to navigation
Jump to search
Algorithm
imported>JOG m |
imported>Haama (Algorithm) |
||
Line 97: | Line 97: | ||
:Hehe, don't betray all the secrets of the "cryptic" coders :)--[[User:JOG|JOG]] 14:02, 31 August 2006 (EDT) | :Hehe, don't betray all the secrets of the "cryptic" coders :)--[[User:JOG|JOG]] 14:02, 31 August 2006 (EDT) | ||
== Algorithm == | |||
Here's the hex of the function | |||
<pre>call sub_47DDA0; returns system time? calls GetSystemTimeAsFileTime | |||
mov edi, eax | |||
mov eax, 0AE147AE1h; or some other constant | |||
imul edi | |||
sar edx, 5 | |||
mov eax, edx | |||
shr eax, 1Fh | |||
add eax, edx | |||
imul eax, 64h | |||
add edi, eax</pre> | |||
From Ian Patt "That function is a wrapper around MS' stdlib rand that calls srand(time(NULL)) if it hasn't been seeded yet. It only uses the system timer once. The rest of the code is just some modular arithmetic done in fixed point."--[[User:Haama|Haama]] 13:42, 25 May 2008 (EDT) |