… | |
… | |
73 | maze->clear (); |
73 | maze->clear (); |
74 | |
74 | |
75 | /* pick some random options if option = 0 */ |
75 | /* pick some random options if option = 0 */ |
76 | if (option == 0) |
76 | if (option == 0) |
77 | { |
77 | { |
78 | switch (rndm (3)) |
78 | switch (rmg_rndm (3)) |
79 | { |
79 | { |
80 | case 0: |
80 | case 0: |
81 | option |= RMOPT_CENTERED; |
81 | option |= RMOPT_CENTERED; |
82 | break; |
82 | break; |
83 | case 1: |
83 | case 1: |
… | |
… | |
86 | case 2: |
86 | case 2: |
87 | option |= RMOPT_BOTTOM_R; |
87 | option |= RMOPT_BOTTOM_R; |
88 | break; |
88 | break; |
89 | } |
89 | } |
90 | |
90 | |
91 | if (rndm (2)) option |= RMOPT_LINEAR; |
91 | if (rmg_rndm (2)) option |= RMOPT_LINEAR; |
92 | if (rndm (2)) option |= RMOPT_IRR_SPACE; |
92 | if (rmg_rndm (2)) option |= RMOPT_IRR_SPACE; |
93 | } |
93 | } |
94 | |
94 | |
95 | /* write the outer walls, if appropriate. */ |
95 | /* write the outer walls, if appropriate. */ |
96 | if (!(option & RMOPT_WALL_OFF)) |
96 | if (!(option & RMOPT_WALL_OFF)) |
97 | maze->border (); |
97 | maze->border (); |
… | |
… | |
120 | |
120 | |
121 | if (layers > maxlayers) |
121 | if (layers > maxlayers) |
122 | layers = maxlayers; |
122 | layers = maxlayers; |
123 | |
123 | |
124 | if (layers == 0) |
124 | if (layers == 0) |
125 | layers = rndm (maxlayers) + 1; |
125 | layers = rmg_rndm (maxlayers) + 1; |
126 | |
126 | |
127 | float *xlocations = salloc0<float> (2 * layers); |
127 | float *xlocations = salloc0<float> (2 * layers); |
128 | float *ylocations = salloc0<float> (2 * layers); |
128 | float *ylocations = salloc0<float> (2 * layers); |
129 | |
129 | |
130 | /* place all the walls */ |
130 | /* place all the walls */ |
… | |
… | |
140 | for (i = 0; i < 2 * layers; i++) |
140 | for (i = 0; i < 2 * layers; i++) |
141 | { |
141 | { |
142 | float xpitch = 2, ypitch = 2; |
142 | float xpitch = 2, ypitch = 2; |
143 | |
143 | |
144 | if (x_spaces_available > 0) |
144 | if (x_spaces_available > 0) |
145 | xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; |
145 | xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3; |
146 | |
146 | |
147 | if (y_spaces_available > 0) |
147 | if (y_spaces_available > 0) |
148 | ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; |
148 | ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3; |
149 | |
149 | |
150 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
150 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
151 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
151 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
152 | x_spaces_available -= (int) (xpitch - 2); |
152 | x_spaces_available -= (int) (xpitch - 2); |
153 | y_spaces_available -= (int) (ypitch - 2); |
153 | y_spaces_available -= (int) (ypitch - 2); |
… | |
… | |
192 | |
192 | |
193 | if (layers > maxlayers) |
193 | if (layers > maxlayers) |
194 | layers = maxlayers; |
194 | layers = maxlayers; |
195 | |
195 | |
196 | if (layers == 0) |
196 | if (layers == 0) |
197 | layers = rndm (maxlayers) + 1; |
197 | layers = rmg_rndm (maxlayers) + 1; |
198 | |
198 | |
199 | float *xlocations = salloc0<float> (2 * layers); |
199 | float *xlocations = salloc0<float> (2 * layers); |
200 | float *ylocations = salloc0<float> (2 * layers); |
200 | float *ylocations = salloc0<float> (2 * layers); |
201 | |
201 | |
202 | /* place all the walls */ |
202 | /* place all the walls */ |
… | |
… | |
212 | for (i = 0; i < 2 * layers; i++) |
212 | for (i = 0; i < 2 * layers; i++) |
213 | { |
213 | { |
214 | float xpitch = 2, ypitch = 2; |
214 | float xpitch = 2, ypitch = 2; |
215 | |
215 | |
216 | if (x_spaces_available > 0) |
216 | if (x_spaces_available > 0) |
217 | xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; |
217 | xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3; |
218 | |
218 | |
219 | if (y_spaces_available > 0) |
219 | if (y_spaces_available > 0) |
220 | ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; |
220 | ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3; |
221 | |
221 | |
222 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
222 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
223 | |
223 | |
224 | if (i < layers) |
224 | if (i < layers) |
225 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
225 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
… | |
… | |
309 | |
309 | |
310 | if (layers <= 0) |
310 | if (layers <= 0) |
311 | return; |
311 | return; |
312 | |
312 | |
313 | /* pick which wall will have a door. */ |
313 | /* pick which wall will have a door. */ |
314 | which_wall = rndm (freedoms) + 1; |
314 | which_wall = rmg_rndm (freedoms) + 1; |
315 | for (l = 0; l < layers; l++) |
315 | for (l = 0; l < layers; l++) |
316 | { |
316 | { |
317 | if (options & RMOPT_LINEAR) |
317 | if (options & RMOPT_LINEAR) |
318 | { /* linear door placement. */ |
318 | { /* linear door placement. */ |
319 | switch (which_wall) |
319 | switch (which_wall) |
… | |
… | |
344 | } |
344 | } |
345 | } |
345 | } |
346 | } |
346 | } |
347 | else |
347 | else |
348 | { /* random door placement. */ |
348 | { /* random door placement. */ |
349 | which_wall = rndm (freedoms) + 1; |
349 | which_wall = rmg_rndm (freedoms) + 1; |
350 | switch (which_wall) |
350 | switch (which_wall) |
351 | { |
351 | { |
352 | case 1: |
352 | case 1: |
353 | { /* left hand wall */ |
353 | { /* left hand wall */ |
354 | x1 = (int) xlocations[l]; |
354 | x1 = (int) xlocations[l]; |
355 | y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1); |
355 | y2 = (int) (ylocations[2 * layers - l - 1] - ylocations[l] - 1); |
356 | if (y2 > 0) |
356 | if (y2 > 0) |
357 | y1 = (int) (ylocations[l] + rndm (y2) + 1); |
357 | y1 = (int) (ylocations[l] + rmg_rndm (y2) + 1); |
358 | else |
358 | else |
359 | y1 = (int) (ylocations[l] + 1); |
359 | y1 = (int) (ylocations[l] + 1); |
360 | break; |
360 | break; |
361 | } |
361 | } |
362 | case 2: |
362 | case 2: |
363 | { /* top wall placement */ |
363 | { /* top wall placement */ |
364 | x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; |
364 | x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; |
365 | if (x2 > 0) |
365 | if (x2 > 0) |
366 | x1 = (int) (xlocations[l] + rndm (x2) + 1); |
366 | x1 = (int) (xlocations[l] + rmg_rndm (x2) + 1); |
367 | else |
367 | else |
368 | x1 = (int) (xlocations[l] + 1); |
368 | x1 = (int) (xlocations[l] + 1); |
369 | y1 = (int) ylocations[l]; |
369 | y1 = (int) ylocations[l]; |
370 | break; |
370 | break; |
371 | } |
371 | } |
372 | case 3: |
372 | case 3: |
373 | { /* right wall placement */ |
373 | { /* right wall placement */ |
374 | x1 = (int) xlocations[2 * layers - l - 1]; |
374 | x1 = (int) xlocations[2 * layers - l - 1]; |
375 | y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1; |
375 | y2 = (int) ((-ylocations[l] + ylocations[2 * layers - l - 1])) - 1; |
376 | if (y2 > 0) |
376 | if (y2 > 0) |
377 | y1 = (int) (ylocations[l] + rndm (y2) + 1); |
377 | y1 = (int) (ylocations[l] + rmg_rndm (y2) + 1); |
378 | else |
378 | else |
379 | y1 = (int) (ylocations[l] + 1); |
379 | y1 = (int) (ylocations[l] + 1); |
380 | |
380 | |
381 | break; |
381 | break; |
382 | } |
382 | } |
383 | case 4: |
383 | case 4: |
384 | { /* bottom wall placement */ |
384 | { /* bottom wall placement */ |
385 | x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; |
385 | x2 = (int) ((-xlocations[l] + xlocations[2 * layers - l - 1])) - 1; |
386 | if (x2 > 0) |
386 | if (x2 > 0) |
387 | x1 = (int) (xlocations[l] + rndm (x2) + 1); |
387 | x1 = (int) (xlocations[l] + rmg_rndm (x2) + 1); |
388 | else |
388 | else |
389 | x1 = (int) (xlocations[l] + 1); |
389 | x1 = (int) (xlocations[l] + 1); |
390 | y1 = (int) ylocations[2 * layers - l - 1]; |
390 | y1 = (int) ylocations[2 * layers - l - 1]; |
391 | break; |
391 | break; |
392 | } |
392 | } |
… | |
… | |
420 | |
420 | |
421 | if (layers > maxlayers) |
421 | if (layers > maxlayers) |
422 | layers = maxlayers; |
422 | layers = maxlayers; |
423 | |
423 | |
424 | if (layers == 0) |
424 | if (layers == 0) |
425 | layers = rndm (maxlayers) + 1; |
425 | layers = rmg_rndm (maxlayers) + 1; |
426 | |
426 | |
427 | float *xlocations = salloc0<float> (2 * layers); |
427 | float *xlocations = salloc0<float> (2 * layers); |
428 | float *ylocations = salloc0<float> (2 * layers); |
428 | float *ylocations = salloc0<float> (2 * layers); |
429 | |
429 | |
430 | /* place all the walls */ |
430 | /* place all the walls */ |
… | |
… | |
441 | for (i = 0; i < 2 * layers; i++) |
441 | for (i = 0; i < 2 * layers; i++) |
442 | { |
442 | { |
443 | float xpitch = 2, ypitch = 2; |
443 | float xpitch = 2, ypitch = 2; |
444 | |
444 | |
445 | if (x_spaces_available > 0) |
445 | if (x_spaces_available > 0) |
446 | xpitch = 2 + (rndm (x_spaces_available) + rndm (x_spaces_available) + rndm (x_spaces_available)) / 3; |
446 | xpitch = 2 + (rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available) + rmg_rndm (x_spaces_available)) / 3; |
447 | |
447 | |
448 | if (y_spaces_available > 0) |
448 | if (y_spaces_available > 0) |
449 | ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; |
449 | ypitch = 2 + (rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available) + rmg_rndm (y_spaces_available)) / 3; |
450 | |
450 | |
451 | if (i < layers) |
451 | if (i < layers) |
452 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
452 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
453 | else |
453 | else |
454 | xlocations[i] = xsize - 1; |
454 | xlocations[i] = xsize - 1; |