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.9 by root, Tue Apr 15 03:00:24 2008 UTC vs.
Revision 1.10 by root, Sun May 4 14:12:37 2008 UTC

27 2 = wall to right, 27 2 = wall to right,
28 4 = wall above 28 4 = wall above
29 8 = wall below */ 29 8 = wall below */
30 int surround_index = 0; 30 int surround_index = 0;
31 31
32 if ((i > 0) && (layout[i - 1][j] != 0 && layout[i - 1][j] != '.')) 32 if ((i > 0) && (layout[i - 1][j] != 0 && layout[i - 1][j] != '.')) surround_index |= 1;
33 surround_index += 1;
34
35 if ((i < Xsize - 1) && (layout[i + 1][j] != 0 && layout[i + 1][j] != '.')) 33 if ((i < Xsize - 1) && (layout[i + 1][j] != 0 && layout[i + 1][j] != '.')) surround_index |= 2;
36 surround_index += 2;
37
38 if ((j > 0) && (layout[i][j - 1] != 0 && layout[i][j - 1] != '.')) 34 if ((j > 0) && (layout[i][j - 1] != 0 && layout[i][j - 1] != '.')) surround_index |= 4;
39 surround_index += 4;
40
41 if ((j < Ysize - 1) && (layout[i][j + 1] != 0 && layout[i][j + 1] != '.')) 35 if ((j < Ysize - 1) && (layout[i][j + 1] != 0 && layout[i][j + 1] != '.')) surround_index |= 8;
42 surround_index += 8;
43 36
44 return surround_index; 37 return surround_index;
45} 38}
46 39
47/* actually make the layout: we work by a reduction process: 40/* actually make the layout: we work by a reduction process:
73 } 66 }
74 67
75 maze->clear ('#'); 68 maze->clear ('#');
76 69
77 /* decide on the number of rooms */ 70 /* decide on the number of rooms */
78 nrooms = rndm (10) + 6; 71 nrooms = rmg_rndm (10) + 6;
79 Room *rooms = salloc0<Room> (nrooms + 1); 72 Room *rooms = salloc0<Room> (nrooms + 1);
80 73
81 /* actually place the rooms */ 74 /* actually place the rooms */
82 i = 0; 75 i = 0;
83 while (tries < 450 && i < nrooms) 76 while (tries < 450 && i < nrooms)
169 162
170 /* decide on the base x and y sizes */ 163 /* decide on the base x and y sizes */
171 x_basesize = xsize / isqrt (nrooms); 164 x_basesize = xsize / isqrt (nrooms);
172 y_basesize = ysize / isqrt (nrooms); 165 y_basesize = ysize / isqrt (nrooms);
173 166
174 tx = rndm (xsize); 167 tx = rmg_rndm (xsize);
175 ty = rndm (ysize); 168 ty = rmg_rndm (ysize);
176 169
177 /* generate a distribution of sizes centered about basesize */ 170 /* generate a distribution of sizes centered about basesize */
178 sx = rndm (x_basesize) + rndm (x_basesize) + rndm (x_basesize); 171 sx = rmg_rndm (x_basesize) + rmg_rndm (x_basesize) + rmg_rndm (x_basesize);
179 sy = rndm (y_basesize) + rndm (y_basesize) + rndm (y_basesize); 172 sy = rmg_rndm (y_basesize) + rmg_rndm (y_basesize) + rmg_rndm (y_basesize);
180 sy = (int) (sy * .5); /* renormalize */ 173 sy = (int) (sy * .5); /* renormalize */
181 174
182 /* find the corners */ 175 /* find the corners */
183 ax = tx - sx / 2; 176 ax = tx - sx / 2;
184 zx = tx + sx / 2 + sx % 2; 177 zx = tx + sx / 2 + sx % 2;
241 break; 234 break;
242 case 2: 235 case 2:
243 making_circle = 1; 236 making_circle = 1;
244 break; 237 break;
245 default: 238 default:
246 making_circle = ((rndm (3) == 0) ? 1 : 0); 239 making_circle = ((rmg_rndm (3) == 0) ? 1 : 0);
247 break; 240 break;
248 } 241 }
249 242
250 if (walk->sx < walk->sy) 243 if (walk->sx < walk->sy)
251 R = walk->sx / 2; 244 R = walk->sx / 2;
276 int y1 = walk->y; 269 int y1 = walk->y;
277 int x2 = (walk - 1)->x; 270 int x2 = (walk - 1)->x;
278 int y2 = (walk - 1)->y; 271 int y2 = (walk - 1)->y;
279 int in_wall = 0; 272 int in_wall = 0;
280 273
281 if (rndm (2)) 274 if (rmg_rndm (2))
282 { /* connect in x direction first */ 275 { /* connect in x direction first */
283 /* horizontal connect */ 276 /* horizontal connect */
284 /* swap (x1,y1) (x2,y2) if necessary */ 277 /* swap (x1,y1) (x2,y2) if necessary */
285 278
286 if (x2 < x1) 279 if (x2 < x1)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines