--- deliantra/server/random_maps/random_map.C 2007/01/19 15:29:52 1.22 +++ deliantra/server/random_maps/random_map.C 2007/01/27 02:19:37 1.27 @@ -61,6 +61,9 @@ char **layout, buf[16384]; int i; + RP->Xsize = RP->xsize; + RP->Ysize = RP->ysize; + /* pick a random seed, or use the one from the input file */ RP->random_seed = RP->random_seed ? RP->random_seed + RP->dungeon_level @@ -89,12 +92,13 @@ RP->Ysize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; if (RP->symmetry == SYMMETRY_RANDOM) - RP->symmetry_used = (RANDOM () % (SYMMETRY_XY)) + 1; + RP->symmetry_used = rndm (SYMMETRY_XY) + 1; else RP->symmetry_used = RP->symmetry; if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) RP->Ysize = RP->Ysize / 2 + 1; + if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY) RP->Xsize = RP->Xsize / 2 + 1; @@ -131,7 +135,7 @@ /* No style found - choose one randomly */ if (RP->map_layout_style == LAYOUT_NONE) - RP->map_layout_style = (RANDOM () % (NROFLAYOUTS - 1)) + 1; + RP->map_layout_style = rndm (NROFLAYOUTS - 1) + 1; layout = layoutgen (RP); @@ -154,7 +158,7 @@ make_map_floor (layout, RP->floorstyle, RP); /* set region */ - region = RP->region; + default_region = RP->region; CEDE; @@ -166,7 +170,6 @@ /* place doors unless doorstyle or wallstyle is "none" */ if (strcmp (RP->doorstyle, "none")) put_doors (this, layout, RP->doorstyle, RP); - } CEDE; @@ -449,21 +452,25 @@ int dx, dy; /* starting location for looking at creating a door */ int cx, cy; /* results of checking on creating walls. */ - dx = RANDOM () % RP->Xsize; - dy = RANDOM () % RP->Ysize; + dx = rndm (RP->Xsize); + dy = rndm (RP->Ysize); + cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */ cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */ if (cx == -1) { if (cy != -1) make_wall (maze, dx, dy, 1); + continue; } + if (cy == -1) { make_wall (maze, dx, dy, 0); continue; } + if (cx < cy) make_wall (maze, dx, dy, 0); else @@ -619,15 +626,17 @@ int di; int sindex; - di = RANDOM () % doorlocs; + di = rndm (doorlocs); i = doorlist_x[di]; j = doorlist_y[di]; sindex = surround_flag (maze, i, j, RP); + if (sindex == 3 || sindex == 12) /* these are possible door sindex */ { maze[i][j] = 'D'; ndoors--; } + /* reduce the size of the list */ doorlocs--; doorlist_x[di] = doorlist_x[doorlocs]; @@ -643,7 +652,7 @@ { char small_buf[16384]; - sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); + sprintf (buf, "xsize %d\nysize %d\n", RP->xsize, RP->ysize); if (RP->wallstyle[0]) { @@ -794,7 +803,7 @@ if (RP->random_seed) { - sprintf (small_buf, "random_seed %d\n", RP->random_seed); + sprintf (small_buf, "random_seed %u\n", RP->random_seed); strcat (buf, small_buf); } @@ -830,7 +839,7 @@ int difficulty_given_n, int decoroptions_n, int orientation_n, - int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) + int origin_x_n, int origin_y_n, uint32_t random_seed_n, int treasureoptions_n, float difficulty_increase) { char small_buf[16384]; @@ -976,7 +985,7 @@ if (random_seed_n) { /* Add one so that the next map is a bit different */ - sprintf (small_buf, "random_seed %d\n", random_seed_n + 1); + sprintf (small_buf, "random_seed %u\n", random_seed_n + 1); strcat (buf, small_buf); }