#include "defines.h"
/* global and extern variables */
-extern u32 sum_z_cells;
+extern u32 gr;
extern int random_fd;
/* return random integer between 0 - max-1 */
}
/* get z value (linear growth of probability with depths) */
-u32 rand_get_lgp(int slope_nel,int start_nel) {
+u32 rand_get_lgp(int slope_nel,int start_nel,u32 z_max)
+{
int z;
- u32 i;
- z=rand_get(sum_z_cells)+1; /* +1 as rand_get returns values 0...max-1 */
+ u32 i,weighted_sum_z;
+ weighted_sum_z=z_max*start_nel+slope_nel*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);
if(z<=0) break;