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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sat Jul 12 09:58:50 2008 UTC (17 years, 8 months ago) by sysadm
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Content type: text/x-csrc
Update

1 sysadm 1.2 #include <sys/time.h>
2 sysadm 1.1 #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