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.15 by root, Fri Jul 2 15:03:57 2010 UTC vs.
Revision 1.16 by root, Sun Jul 4 22:12:26 2010 UTC

38 int rtype; /* circle or rectangular */ 38 int rtype; /* circle or rectangular */
39} Room; 39} Room;
40 40
41static int roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms); 41static int roguelike_place_room (Room *rooms, int xsize, int ysize, int nrooms);
42static void roguelike_make_rooms (Room *rooms, char **maze, int options); 42static void roguelike_make_rooms (Room *rooms, char **maze, int options);
43static void roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize); 43static void roguelike_link_rooms (Room *rooms, layout &maze);
44 44
45int 45int
46surround_check (char **maze, int i, int j, int Xsize, int Ysize) 46surround_check (layout &maze, int i, int j)
47{ 47{
48 /* 1 = wall to left, 48 /* 1 = wall to left,
49 2 = wall to right, 49 2 = wall to right,
50 4 = wall above 50 4 = wall above
51 8 = wall below */ 51 8 = wall below */
52 int surround_index = 0; 52 int surround_index = 0;
53 53
54 if ((i > 0) && (maze[i - 1][j] != 0 && maze[i - 1][j] != '.')) surround_index |= 1; 54 if ((i > 0) && (maze[i - 1][j] != 0 && maze[i - 1][j] != '.')) surround_index |= 1;
55 if ((i < Xsize - 1) && (maze[i + 1][j] != 0 && maze[i + 1][j] != '.')) surround_index |= 2; 55 if ((i < maze.w - 1) && (maze[i + 1][j] != 0 && maze[i + 1][j] != '.')) surround_index |= 2;
56 if ((j > 0) && (maze[i][j - 1] != 0 && maze[i][j - 1] != '.')) surround_index |= 4; 56 if ((j > 0) && (maze[i][j - 1] != 0 && maze[i][j - 1] != '.')) surround_index |= 4;
57 if ((j < Ysize - 1) && (maze[i][j + 1] != 0 && maze[i][j + 1] != '.')) surround_index |= 8; 57 if ((j < maze.h - 1) && (maze[i][j + 1] != 0 && maze[i][j + 1] != '.')) surround_index |= 8;
58 58
59 return surround_index; 59 return surround_index;
60} 60}
61 61
62/* actually make the maze: we work by a reduction process: 62/* actually make the maze: we work by a reduction process:
117 } 117 }
118 118
119 /* erase the areas occupied by the rooms */ 119 /* erase the areas occupied by the rooms */
120 roguelike_make_rooms (rooms, maze, options); 120 roguelike_make_rooms (rooms, maze, options);
121 121
122 roguelike_link_rooms (rooms, maze, xsize, ysize); 122 roguelike_link_rooms (rooms, maze);
123 123
124 /* put in the stairs */ 124 /* put in the stairs */
125 125
126 maze[rooms->x][rooms->y] = '<'; 126 maze[rooms->x][rooms->y] = '<';
127 127
154 if (maze[i][j] == '.') 154 if (maze[i][j] == '.')
155 maze[i][j] = 0; 155 maze[i][j] = 0;
156 156
157 if (maze[i][j] == 'D') 157 if (maze[i][j] == 'D')
158 { /* remove bad door. */ 158 { /* remove bad door. */
159 int si = surround_check (maze, i, j, xsize, ysize); 159 int si = surround_check (maze, i, j);
160 160
161 if (si != 3 && si != 12) 161 if (si != 3 && si != 12)
162 { 162 {
163 maze[i][j] = 0; 163 maze[i][j] = 0;
164 /* back up and recheck any nearby doors */ 164 /* back up and recheck any nearby doors */
274 maze[i][j] = '.'; 274 maze[i][j] = '.';
275 } 275 }
276} 276}
277 277
278static void 278static void
279roguelike_link_rooms (Room *rooms, char **maze, int xsize, int ysize) 279roguelike_link_rooms (Room *rooms, layout &maze)
280{ 280{
281 Room *walk; 281 Room *walk;
282 int i, j; 282 int i, j;
283 283
284 /* link each room to the previous room */ 284 /* link each room to the previous room */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines