Source:Hack 1.0/rnd.c

From NetHackWiki
Revision as of 02:18, 30 August 2006 by Ray Chason (talk | contribs) (This file is reconstructed from later versions)
Jump to navigation Jump to 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.

The Usenet post in which this file was originally distributed is not archived at Google Groups. No copy is known to be publicly available. This file is reconstructed from later versions and may not match the original distribution exactly.

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 int x,y;
5.    {
6.    	return(RND(x)+y);
7.    }
8.    
9.    rn2(x)
10.   register int x;
11.   {
12.   	return(RND(x));
13.   }
14.   
15.   rnd(x)
16.   register int x;
17.   {
18.   	return(RND(x)+1);
19.   }
20.   
21.   d(n,x)
22.   register int n,x;
23.   {
24.   	register int tmp = n;
25.   
26.   	while(n--) tmp += RND(x);
27.   	return(tmp);
28.   }