--- deliantra/server/random_maps/layout.C 2010/07/03 02:19:10 1.14 +++ deliantra/server/random_maps/layout.C 2010/07/03 03:09:27 1.15 @@ -79,7 +79,8 @@ void layout::fill (char fill) { - memset (data [0], fill, w * h); + //memset (data [0], fill, w * h); // only when contiguous :/ + fill_rect (0, 0, w, h, fill); } void @@ -814,6 +815,48 @@ ///////////////////////////////////////////////////////////////////////////// +static void +gen_mixed_ (layout &maze, random_map_params *RP, int dir) +{ + if (maze.w < 20 && maze.h < 20 && !rmg_rndm (3)) + dir = 2; // stop recursion randomly + + if (dir == 0 && maze.w > 16) + { + int m = rmg_rndm (8, maze.w - 8); + + layout m1 (maze, 0, 0, m , maze.h); gen_mixed_ (m1, RP, !dir); + layout m2 (maze, m, 0, maze.w, maze.h); gen_mixed_ (m2, RP, !dir); + } + else if (dir == 1 && maze.h > 16) + { + int m = rmg_rndm (8, maze.h - 8); + + layout m1 (maze, 0, 0, maze.w, m ); gen_mixed_ (m1, RP, !dir); + layout m2 (maze, 0, m, maze.w, maze.h); gen_mixed_ (m2, RP, !dir); + } + else + { + RP->map_layout_style = rmg_rndm (NROFLAYOUTS - 2) + 1; + + if (RP->map_layout_style == LAYOUT_MULTIPLE) + ++RP->map_layout_style; + + maze.generate (RP); + } +} + +static void +gen_mixed (layout &maze, random_map_params *RP) +{ + random_map_params &rp = *new random_map_params (RP); + gen_mixed_ (maze, &rp, rmg_rndm (2)); + delete &rp; + + maze.border (); + maze.isolation_remover (); +} + /* function selects the maze function and gives it whatever arguments it needs. */ void @@ -882,21 +925,13 @@ break; + case LAYOUT_MULTIPLE: + gen_mixed (*this, RP); + break; + default: abort (); } - - /* rotate the maze randomly */ - rotate (rmg_rndm (4)); - - symmetrize (RP->symmetry_used); - -#if 0 - print ();//D -#endif - - if (RP->expand2x) - expand2x (); } //-GPL