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

Comparing deliantra/server/random_maps/rogue_layout.C (file contents):
Revision 1.7 by root, Fri Apr 11 21:09:53 2008 UTC vs.
Revision 1.8 by root, Mon Apr 14 22:41:17 2008 UTC

41} 41}
42 42
43/* actually make the layout: we work by a reduction process: 43/* actually make the layout: we work by a reduction process:
44 * first we make everything a wall, then we remove areas to make rooms 44 * first we make everything a wall, then we remove areas to make rooms
45 */ 45 */
46Maze 46void
47roguelike_layout_gen (int xsize, int ysize, int options) 47roguelike_layout_gen (Maze maze, int options)
48{ 48{
49 int i, j; 49 int i, j;
50 Room *walk; 50 Room *walk;
51 int nrooms = 0; 51 int nrooms = 0;
52 int tries = 0; 52 int tries = 0;
53 53
54 Maze maze (xsize, ysize); 54 int xsize = maze->w;
55 55 int ysize = maze->h;
56 for (i = 0; i < xsize; i++)
57 for (j = 0; j < ysize; j++)
58 maze[i][j] = '#';
59 56
60 /* minimum room size is basically 5x5: if xsize/ysize is 57 /* minimum room size is basically 5x5: if xsize/ysize is
61 less than 3x that then hollow things out, stick in 58 less than 3x that then hollow things out, stick in
62 a stairsup and stairs down, and exit */ 59 a stairsup and stairs down, and exit */
63
64 if (xsize < 11 || ysize < 11) 60 if (xsize < 11 || ysize < 11)
65 { 61 {
66 for (i = 1; i < xsize - 1; i++) 62 maze->clear ();
67 for (j = 1; j < ysize - 1; j++) 63 maze->border ();
68 maze[i][j] = 0;
69 64
70 maze[(xsize - 1) / 2][(ysize - 1) / 2 ] = '>'; 65 maze[(xsize - 1) / 2][(ysize - 1) / 2 ] = '>';
71 maze[(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<'; 66 maze[(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<';
72 67
73 return maze; 68 return;
74 } 69 }
70
71 maze->clear ('#');
75 72
76 /* decide on the number of rooms */ 73 /* decide on the number of rooms */
77 nrooms = rndm (10) + 6; 74 nrooms = rndm (10) + 6;
78 Room *rooms = salloc0<Room> (nrooms + 1); 75 Room *rooms = salloc0<Room> (nrooms + 1);
79 76
88 i++; 85 i++;
89 } 86 }
90 87
91 if (i == 0) 88 if (i == 0)
92 { /* no can do! */ 89 { /* no can do! */
93 for (i = 1; i < xsize - 1; i++) 90 maze->clear ();
94 for (j = 1; j < ysize - 1; j++) 91 maze->border ();
95 maze[i][j] = 0;
96 92
97 maze [(xsize - 1) / 2][(ysize - 1) / 2 ] = '>'; 93 maze [(xsize - 1) / 2][(ysize - 1) / 2 ] = '>';
98 maze [(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<'; 94 maze [(xsize - 1) / 2][(ysize - 1) / 2 + 1] = '<';
99 95
100 sfree (rooms, nrooms + 1); 96 sfree (rooms, nrooms + 1);
101 return maze; 97 return;
102 } 98 }
103 99
104 100
105 /* erase the areas occupied by the rooms */ 101 /* erase the areas occupied by the rooms */
106 roguelike_make_rooms (rooms, maze, options); 102 roguelike_make_rooms (rooms, maze, options);
153 } 149 }
154 } 150 }
155 } 151 }
156 152
157 sfree (rooms, nrooms + 1); 153 sfree (rooms, nrooms + 1);
158 return maze;
159} 154}
160 155
161static int 156static int
162roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms) 157roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms)
163{ 158{

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines