/[LeafOK_CVS]/pvpgn-1.7.4/src/d2cs/d2cs_random.c
ViewVC logotype

Contents of /pvpgn-1.7.4/src/d2cs/d2cs_random.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Jun 10 16:18:57 2006 UTC (19 years, 9 months ago) by sysadm
Branch: MAIN
CVS Tags: pvpgn_1-7-4-0_MIL
Content type: text/x-csrc
Antibot

1 #include <time.h>
2 #include <stdlib.h>
3
4 static int d2cs_random_init(void)
5 {
6 struct timeval tv;
7
8 if(!gettimeofday(&tv,NULL)) {
9 const unsigned int seed=(unsigned int)tv.tv_sec^tv.tv_usec;
10 srandom(seed);
11 return 0;
12 }else{
13 return -1;
14 }
15
16 }
17
18 extern int d2cs_random_num(void)
19 {
20 if(d2cs_random_init())
21 return -1;
22 return (random()%10);
23 }
24
25 extern char d2cs_random_char(void)
26 {
27 if(d2cs_random_init())
28 return -1;
29 return (random()%7+97);
30 }

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1