--- deliantra/server/random_maps/room_gen_onion.C 2007/01/18 19:42:10 1.9 +++ deliantra/server/random_maps/room_gen_onion.C 2007/01/27 02:19:37 1.10 @@ -132,14 +132,16 @@ maxlayers = (MIN (xsize, ysize) - 2) / 5; if (!maxlayers) return; /* map too small to onionize */ + if (layers > maxlayers) layers = maxlayers; + if (layers == 0) - layers = (RANDOM () % maxlayers) + 1; + layers = rndm (maxlayers) + 1; + xlocations = (float *) calloc (sizeof (float), 2 * layers); ylocations = (float *) calloc (sizeof (float), 2 * layers); - /* place all the walls */ if (option & RMOPT_IRR_SPACE) /* randomly spaced */ { @@ -156,10 +158,11 @@ float xpitch = 2, ypitch = 2; if (x_spaces_available > 0) - xpitch = 2 + (RANDOM () % x_spaces_available + RANDOM () % x_spaces_available + RANDOM () % x_spaces_available) / 3; + xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; if (y_spaces_available > 0) - ypitch = 2 + (RANDOM () % y_spaces_available + RANDOM () % y_spaces_available + RANDOM () % y_spaces_available) / 3; + ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; + xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; x_spaces_available -= (int) (xpitch - 2); @@ -202,7 +205,7 @@ if (layers > maxlayers) layers = maxlayers; if (layers == 0) - layers = (RANDOM () % maxlayers) + 1; + layers = rndm (maxlayers) + 1; xlocations = (float *) calloc (sizeof (float), 2 * layers); ylocations = (float *) calloc (sizeof (float), 2 * layers); @@ -223,15 +226,17 @@ float xpitch = 2, ypitch = 2; if (x_spaces_available > 0) - xpitch = 2 + (RANDOM () % x_spaces_available + RANDOM () % x_spaces_available + RANDOM () % x_spaces_available) / 3; + xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; if (y_spaces_available > 0) - ypitch = 2 + (RANDOM () % y_spaces_available + RANDOM () % y_spaces_available + RANDOM () % y_spaces_available) / 3; + ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; + xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; if (i < layers) ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; else ylocations[i] = ysize - 1; + x_spaces_available -= (int) (xpitch - 2); y_spaces_available -= (int) (ypitch - 2); } @@ -309,8 +314,9 @@ freedoms = 2; if (layers <= 0) return; + /* pick which wall will have a door. */ - which_wall = RANDOM () % freedoms + 1; + which_wall = rndm (freedoms) + 1; for (l = 0; l < layers; l++) { if (options & RMOPT_LINEAR) @@ -345,7 +351,7 @@ } else { /* random door placement. */ - which_wall = RANDOM () % freedoms + 1; + which_wall = rndm (freedoms) + 1; switch (which_wall) { case 1: @@ -353,7 +359,7 @@ x1 = (int) xlocations[l]; y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1); if (y2 > 0) - y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); + y1 = (int) (ylocations[l] + rndm (y2) + 1); else y1 = (int) (ylocations[l] + 1); break; @@ -362,7 +368,7 @@ { /* top wall placement */ x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; if (x2 > 0) - x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); + x1 = (int) (xlocations[l] + rndm (x2) + 1); else x1 = (int) (xlocations[l] + 1); y1 = (int) ylocations[l]; @@ -373,7 +379,7 @@ x1 = (int) xlocations[2 * layers - l - 1]; y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1; if (y2 > 0) - y1 = (int) (ylocations[l] + RANDOM () % y2 + 1); + y1 = (int) (ylocations[l] + rndm (y2) + 1); else y1 = (int) (ylocations[l] + 1); @@ -383,7 +389,7 @@ { /* bottom wall placement */ x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; if (x2 > 0) - x1 = (int) (xlocations[l] + RANDOM () % x2 + 1); + x1 = (int) (xlocations[l] + rndm (x2) + 1); else x1 = (int) (xlocations[l] + 1); y1 = (int) ylocations[2 * layers - l - 1]; @@ -423,11 +429,11 @@ if (layers > maxlayers) layers = maxlayers; if (layers == 0) - layers = (RANDOM () % maxlayers) + 1; + layers = rndm (maxlayers) + 1; + xlocations = (float *) calloc (sizeof (float), 2 * layers); ylocations = (float *) calloc (sizeof (float), 2 * layers); - /* place all the walls */ if (option & RMOPT_IRR_SPACE) /* randomly spaced */ { @@ -444,10 +450,11 @@ float xpitch = 2, ypitch = 2; if (x_spaces_available > 0) - xpitch = 2 + (RANDOM () % x_spaces_available + RANDOM () % x_spaces_available + RANDOM () % x_spaces_available) / 3; + xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; if (y_spaces_available > 0) - ypitch = 2 + (RANDOM () % y_spaces_available + RANDOM () % y_spaces_available + RANDOM () % y_spaces_available) / 3; + ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; + if (i < layers) xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; else