From: hackbard Date: Fri, 4 Apr 2003 14:09:48 +0000 (+0000) Subject: fixed new read random condition. changed function variable names. X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=4763687aeb58d8a251e697a9c48d458477783238;p=physik%2Fmorpheus.git fixed new read random condition. changed function variable names. --- diff --git a/random.c b/random.c index 5657eed..b2e11fd 100644 --- a/random.c +++ b/random.c @@ -17,12 +17,12 @@ extern u32 *rand_buf,*rand_current; /* return random integer between 0 - max-1 */ u32 rand_get(u32 max) { - if(rand_current==rand_buf+RAND_BUF_SIZE) + if(rand_current>=rand_buf+(RAND_BUF_SIZE/sizeof(u32))) { printfd("debug: reading new random bytes\n"); if(read(random_fd,rand_buf,RAND_BUF_SIZE)!=RAND_BUF_SIZE) { - puts("failed reading viel bytes of random data"); + puts("failed reading 1 mega bytes of random data"); return -23; } rand_current=rand_buf; @@ -32,14 +32,15 @@ u32 rand_get(u32 max) } /* get z value (linear growth of probability with depths) */ -u32 rand_get_lgp(int slope_nel,int start_nel,u32 z_max) +u32 rand_get_lgp(int slope,int start,u32 z_max) { int z; u32 i,weighted_sum_z; - weighted_sum_z=z_max*start_nel+slope_nel*gr; + weighted_sum_z=z_max*start+slope*gr; z=rand_get(weighted_sum_z)+1; /* +1 as rand_get returns values 0...max-1 */ - for(i=1;;i++) { - z-=(start_nel+i*slope_nel); + for(i=1;;i++) + { + z-=(start+i*slope); if(z<=0) break; } return(i-1); /* return values 0...z_cell-1 */