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

Comparing deliantra/server/random_maps/room_gen_onion.C (file contents):
Revision 1.4 by root, Thu Sep 14 22:34:02 2006 UTC vs.
Revision 1.5 by root, Sat Dec 30 18:45:28 2006 UTC

81 if (option == 0) 81 if (option == 0)
82 { 82 {
83 switch (RANDOM () % 3) 83 switch (RANDOM () % 3)
84 { 84 {
85 case 0: 85 case 0:
86 option |= OPT_CENTERED; 86 option |= RMOPT_CENTERED;
87 break; 87 break;
88 case 1: 88 case 1:
89 option |= OPT_BOTTOM_C; 89 option |= RMOPT_BOTTOM_C;
90 break; 90 break;
91 case 2: 91 case 2:
92 option |= OPT_BOTTOM_R; 92 option |= RMOPT_BOTTOM_R;
93 break; 93 break;
94 } 94 }
95 if (RANDOM () % 2) 95 if (RANDOM () % 2)
96 option |= OPT_LINEAR; 96 option |= RMOPT_LINEAR;
97 if (RANDOM () % 2) 97 if (RANDOM () % 2)
98 option |= OPT_IRR_SPACE; 98 option |= RMOPT_IRR_SPACE;
99 } 99 }
100 100
101 /* write the outer walls, if appropriate. */ 101 /* write the outer walls, if appropriate. */
102 if (!(option & OPT_WALL_OFF)) 102 if (!(option & RMOPT_WALL_OFF))
103 { 103 {
104 for (i = 0; i < xsize; i++) 104 for (i = 0; i < xsize; i++)
105 maze[i][0] = maze[i][ysize - 1] = '#'; 105 maze[i][0] = maze[i][ysize - 1] = '#';
106 for (j = 0; j < ysize; j++) 106 for (j = 0; j < ysize; j++)
107 maze[0][j] = maze[xsize - 1][j] = '#'; 107 maze[0][j] = maze[xsize - 1][j] = '#';
108 }; 108 };
109 109
110 if (option & OPT_WALLS_ONLY) 110 if (option & RMOPT_WALLS_ONLY)
111 return maze; 111 return maze;
112 112
113 /* pick off the mutually exclusive options */ 113 /* pick off the mutually exclusive options */
114 if (option & OPT_BOTTOM_R) 114 if (option & RMOPT_BOTTOM_R)
115 bottom_right_centered_onion (maze, xsize, ysize, option, layers); 115 bottom_right_centered_onion (maze, xsize, ysize, option, layers);
116 else if (option & OPT_BOTTOM_C) 116 else if (option & RMOPT_BOTTOM_C)
117 bottom_centered_onion (maze, xsize, ysize, option, layers); 117 bottom_centered_onion (maze, xsize, ysize, option, layers);
118 else if (option & OPT_CENTERED) 118 else if (option & RMOPT_CENTERED)
119 centered_onion (maze, xsize, ysize, option, layers); 119 centered_onion (maze, xsize, ysize, option, layers);
120 120
121 return maze; 121 return maze;
122} 122}
123 123
138 xlocations = (float *) calloc (sizeof (float), 2 * layers); 138 xlocations = (float *) calloc (sizeof (float), 2 * layers);
139 ylocations = (float *) calloc (sizeof (float), 2 * layers); 139 ylocations = (float *) calloc (sizeof (float), 2 * layers);
140 140
141 141
142 /* place all the walls */ 142 /* place all the walls */
143 if (option & OPT_IRR_SPACE) /* randomly spaced */ 143 if (option & RMOPT_IRR_SPACE) /* randomly spaced */
144 { 144 {
145 int x_spaces_available, y_spaces_available; 145 int x_spaces_available, y_spaces_available;
146 146
147 /* the "extra" spaces available for spacing between layers */ 147 /* the "extra" spaces available for spacing between layers */
148 x_spaces_available = (xsize - 2) - 6 * layers + 1; 148 x_spaces_available = (xsize - 2) - 6 * layers + 1;
164 x_spaces_available -= (int) (xpitch - 2); 164 x_spaces_available -= (int) (xpitch - 2);
165 y_spaces_available -= (int) (ypitch - 2); 165 y_spaces_available -= (int) (ypitch - 2);
166 } 166 }
167 167
168 } 168 }
169 if (!(option & OPT_IRR_SPACE)) 169 if (!(option & RMOPT_IRR_SPACE))
170 { /* evenly spaced */ 170 { /* evenly spaced */
171 float xpitch, ypitch; /* pitch of the onion layers */ 171 float xpitch, ypitch; /* pitch of the onion layers */
172 172
173 xpitch = (xsize - 2.0) / (2.0 * layers + 1); 173 xpitch = (xsize - 2.0) / (2.0 * layers + 1);
174 ypitch = (ysize - 2.0) / (2.0 * layers + 1); 174 ypitch = (ysize - 2.0) / (2.0 * layers + 1);
205 xlocations = (float *) calloc (sizeof (float), 2 * layers); 205 xlocations = (float *) calloc (sizeof (float), 2 * layers);
206 ylocations = (float *) calloc (sizeof (float), 2 * layers); 206 ylocations = (float *) calloc (sizeof (float), 2 * layers);
207 207
208 208
209 /* place all the walls */ 209 /* place all the walls */
210 if (option & OPT_IRR_SPACE) /* randomly spaced */ 210 if (option & RMOPT_IRR_SPACE) /* randomly spaced */
211 { 211 {
212 int x_spaces_available, y_spaces_available; 212 int x_spaces_available, y_spaces_available;
213 213
214 /* the "extra" spaces available for spacing between layers */ 214 /* the "extra" spaces available for spacing between layers */
215 x_spaces_available = (xsize - 2) - 6 * layers + 1; 215 x_spaces_available = (xsize - 2) - 6 * layers + 1;
234 x_spaces_available -= (int) (xpitch - 2); 234 x_spaces_available -= (int) (xpitch - 2);
235 y_spaces_available -= (int) (ypitch - 2); 235 y_spaces_available -= (int) (ypitch - 2);
236 } 236 }
237 237
238 } 238 }
239 if (!(option & OPT_IRR_SPACE)) 239 if (!(option & RMOPT_IRR_SPACE))
240 { /* evenly spaced */ 240 { /* evenly spaced */
241 float xpitch, ypitch; /* pitch of the onion layers */ 241 float xpitch, ypitch; /* pitch of the onion layers */
242 242
243 xpitch = (xsize - 2.0) / (2.0 * layers + 1); 243 xpitch = (xsize - 2.0) / (2.0 * layers + 1);
244 ypitch = (ysize - 2.0) / (layers + 1); 244 ypitch = (ysize - 2.0) / (layers + 1);
300 int freedoms; /* number of different walls on which we could place a door */ 300 int freedoms; /* number of different walls on which we could place a door */
301 int which_wall; /* left, 1, top, 2, right, 3, bottom 4 */ 301 int which_wall; /* left, 1, top, 2, right, 3, bottom 4 */
302 int l, x1 = 0, x2, y1 = 0, y2; 302 int l, x1 = 0, x2, y1 = 0, y2;
303 303
304 freedoms = 4; /* centered */ 304 freedoms = 4; /* centered */
305 if (options & OPT_BOTTOM_C) 305 if (options & RMOPT_BOTTOM_C)
306 freedoms = 3; 306 freedoms = 3;
307 if (options & OPT_BOTTOM_R) 307 if (options & RMOPT_BOTTOM_R)
308 freedoms = 2; 308 freedoms = 2;
309 if (layers <= 0) 309 if (layers <= 0)
310 return; 310 return;
311 /* pick which wall will have a door. */ 311 /* pick which wall will have a door. */
312 which_wall = RANDOM () % freedoms + 1; 312 which_wall = RANDOM () % freedoms + 1;
313 for (l = 0; l < layers; l++) 313 for (l = 0; l < layers; l++)
314 { 314 {
315 if (options & OPT_LINEAR) 315 if (options & RMOPT_LINEAR)
316 { /* linear door placement. */ 316 { /* linear door placement. */
317 switch (which_wall) 317 switch (which_wall)
318 { 318 {
319 case 1: 319 case 1:
320 { /* left hand wall */ 320 { /* left hand wall */
389 break; 389 break;
390 } 390 }
391 391
392 } 392 }
393 } 393 }
394 if (options & OPT_NO_DOORS) 394 if (options & RMOPT_NO_DOORS)
395 maze[x1][y1] = '#'; /* no door. */ 395 maze[x1][y1] = '#'; /* no door. */
396 else 396 else
397 maze[x1][y1] = 'D'; /* write the door */ 397 maze[x1][y1] = 'D'; /* write the door */
398 398
399 } 399 }
426 xlocations = (float *) calloc (sizeof (float), 2 * layers); 426 xlocations = (float *) calloc (sizeof (float), 2 * layers);
427 ylocations = (float *) calloc (sizeof (float), 2 * layers); 427 ylocations = (float *) calloc (sizeof (float), 2 * layers);
428 428
429 429
430 /* place all the walls */ 430 /* place all the walls */
431 if (option & OPT_IRR_SPACE) /* randomly spaced */ 431 if (option & RMOPT_IRR_SPACE) /* randomly spaced */
432 { 432 {
433 int x_spaces_available, y_spaces_available; 433 int x_spaces_available, y_spaces_available;
434 434
435 /* the "extra" spaces available for spacing between layers */ 435 /* the "extra" spaces available for spacing between layers */
436 x_spaces_available = (xsize - 2) - 3 * layers + 1; 436 x_spaces_available = (xsize - 2) - 3 * layers + 1;
459 x_spaces_available -= (int) (xpitch - 2); 459 x_spaces_available -= (int) (xpitch - 2);
460 y_spaces_available -= (int) (ypitch - 2); 460 y_spaces_available -= (int) (ypitch - 2);
461 } 461 }
462 462
463 } 463 }
464 if (!(option & OPT_IRR_SPACE)) 464 if (!(option & RMOPT_IRR_SPACE))
465 { /* evenly spaced */ 465 { /* evenly spaced */
466 float xpitch, ypitch; /* pitch of the onion layers */ 466 float xpitch, ypitch; /* pitch of the onion layers */
467 467
468 xpitch = (xsize - 2.0) / (2.0 * layers + 1); 468 xpitch = (xsize - 2.0) / (2.0 * layers + 1);
469 ypitch = (ysize - 2.0) / (layers + 1); 469 ypitch = (ysize - 2.0) / (layers + 1);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines