ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/layout.C
(Generate patch)

Comparing deliantra/server/random_maps/layout.C (file contents):
Revision 1.14 by root, Sat Jul 3 02:19:10 2010 UTC vs.
Revision 1.15 by root, Sat Jul 3 03:09:27 2010 UTC

77} 77}
78 78
79void 79void
80layout::fill (char fill) 80layout::fill (char fill)
81{ 81{
82 memset (data [0], fill, w * h); 82 //memset (data [0], fill, w * h); // only when contiguous :/
83 fill_rect (0, 0, w, h, fill);
83} 84}
84 85
85void 86void
86layout::rect (int x1, int y1, int x2, int y2, char fill) 87layout::rect (int x1, int y1, int x2, int y2, char fill)
87{ 88{
811 make_wall (*this, dx, dy, 1); 812 make_wall (*this, dx, dy, 1);
812 } 813 }
813} 814}
814 815
815///////////////////////////////////////////////////////////////////////////// 816/////////////////////////////////////////////////////////////////////////////
817
818static void
819gen_mixed_ (layout &maze, random_map_params *RP, int dir)
820{
821 if (maze.w < 20 && maze.h < 20 && !rmg_rndm (3))
822 dir = 2; // stop recursion randomly
823
824 if (dir == 0 && maze.w > 16)
825 {
826 int m = rmg_rndm (8, maze.w - 8);
827
828 layout m1 (maze, 0, 0, m , maze.h); gen_mixed_ (m1, RP, !dir);
829 layout m2 (maze, m, 0, maze.w, maze.h); gen_mixed_ (m2, RP, !dir);
830 }
831 else if (dir == 1 && maze.h > 16)
832 {
833 int m = rmg_rndm (8, maze.h - 8);
834
835 layout m1 (maze, 0, 0, maze.w, m ); gen_mixed_ (m1, RP, !dir);
836 layout m2 (maze, 0, m, maze.w, maze.h); gen_mixed_ (m2, RP, !dir);
837 }
838 else
839 {
840 RP->map_layout_style = rmg_rndm (NROFLAYOUTS - 2) + 1;
841
842 if (RP->map_layout_style == LAYOUT_MULTIPLE)
843 ++RP->map_layout_style;
844
845 maze.generate (RP);
846 }
847}
848
849static void
850gen_mixed (layout &maze, random_map_params *RP)
851{
852 random_map_params &rp = *new random_map_params (RP);
853 gen_mixed_ (maze, &rp, rmg_rndm (2));
854 delete &rp;
855
856 maze.border ();
857 maze.isolation_remover ();
858}
816 859
817/* function selects the maze function and gives it whatever 860/* function selects the maze function and gives it whatever
818 arguments it needs. */ 861 arguments it needs. */
819void 862void
820layout::generate (random_map_params *RP) 863layout::generate (random_map_params *RP)
880 if (rmg_rndm (2)) 923 if (rmg_rndm (2))
881 doorify (); 924 doorify ();
882 925
883 break; 926 break;
884 927
928 case LAYOUT_MULTIPLE:
929 gen_mixed (*this, RP);
930 break;
931
885 default: 932 default:
886 abort (); 933 abort ();
887 } 934 }
888
889 /* rotate the maze randomly */
890 rotate (rmg_rndm (4));
891
892 symmetrize (RP->symmetry_used);
893
894#if 0
895 print ();//D
896#endif
897
898 if (RP->expand2x)
899 expand2x ();
900} 935}
901 936
902//-GPL 937//-GPL
903 938
904#if 0 939#if 0

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines