Source:Hack 1.0/rnd.c

From NetHackWiki
Jump to: navigation, search

Below is the full text to rnd.c from the source code of Hack 1.0. To link to a particular line, write [[Hack 1.0/rnd.c#line123]], for example.

Warning! This is the source code from an old release. For the latest release, see Source code.

Screenshots and source code from Hack are used under the CWI license.

1.    #define RND(x)	((rand()>>3) % x)
2.    
3.    rn1(x,y)
4.    register x,y;
5.    {
6.    	return(RND(x)+y);
7.    }
8.    
9.    rn2(x)
10.   register x;
11.   {
12.   	return(RND(x));
13.   }
14.   
15.   rnd(x)
16.   register x;
17.   {
18.   	return(RND(x)+1);
19.   }
20.   
21.   d(n,x)
22.   register n,x;
23.   {
24.   	register tmp = n;
25.   
26.   	while(n--) tmp += RND(x);
27.   	return(tmp);
28.   }