1 | /* |
1 | /* |
2 | * CrossFire, A Multiplayer game for X-windows |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
6 | * Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
7 | * |
7 | * |
8 | * This program is free software; you can redistribute it and/or modify |
8 | * Deliantra is free software: you can redistribute it and/or modify |
9 | * it under the terms of the GNU General Public License as published by |
9 | * it under the terms of the GNU General Public License as published by |
10 | * the Free Software Foundation; either version 2 of the License, or |
10 | * the Free Software Foundation, either version 3 of the License, or |
11 | * (at your option) any later version. |
11 | * (at your option) any later version. |
12 | * |
12 | * |
13 | * This program is distributed in the hope that it will be useful, |
13 | * This program is distributed in the hope that it will be useful, |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 | * GNU General Public License for more details. |
16 | * GNU General Public License for more details. |
17 | * |
17 | * |
18 | * You should have received a copy of the GNU General Public License |
18 | * You should have received a copy of the GNU General Public License |
19 | * along with this program; if not, write to the Free Software |
19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
|
|
21 | * |
20 | * |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
21 | * The authors can be reached via e-mail to <support@deliantra.net> |
23 | */ |
22 | */ |
24 | |
|
|
25 | |
23 | |
26 | /* The onion room generator: |
24 | /* The onion room generator: |
27 | Onion rooms are like this: |
25 | Onion rooms are like this: |
28 | |
26 | |
29 | char **map_gen_onion(int xsize, int ysize, int option, int layers); |
27 | char **map_gen_onion(int xsize, int ysize, int option, int layers); |
… | |
… | |
59 | #endif |
57 | #endif |
60 | void centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
58 | void centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
61 | void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
59 | void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
62 | void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
60 | void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
63 | |
61 | |
64 | |
|
|
65 | void draw_onion (char **maze, float *xlocations, float *ylocations, int layers); |
62 | void draw_onion (char **maze, float *xlocations, float *ylocations, int layers); |
66 | void make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options); |
63 | void make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options); |
67 | |
64 | |
68 | char ** |
65 | void |
69 | map_gen_onion (int xsize, int ysize, int option, int layers) |
66 | map_gen_onion (Layout maze, int option, int layers) |
70 | { |
67 | { |
71 | int i, j; |
68 | int i, j; |
72 | |
69 | |
73 | /* allocate that array, set it up */ |
70 | int xsize = maze->w; |
74 | char **maze = (char **) calloc (sizeof (char *), xsize); |
71 | int ysize = maze->h; |
75 | |
72 | |
76 | for (i = 0; i < xsize; i++) |
73 | maze->clear (); |
77 | { |
|
|
78 | maze[i] = (char *) calloc (sizeof (char), ysize); |
|
|
79 | } |
|
|
80 | |
74 | |
81 | /* pick some random options if option = 0 */ |
75 | /* pick some random options if option = 0 */ |
82 | if (option == 0) |
76 | if (option == 0) |
83 | { |
77 | { |
84 | switch (rndm (3)) |
78 | switch (rndm (3)) |
… | |
… | |
91 | break; |
85 | break; |
92 | case 2: |
86 | case 2: |
93 | option |= RMOPT_BOTTOM_R; |
87 | option |= RMOPT_BOTTOM_R; |
94 | break; |
88 | break; |
95 | } |
89 | } |
96 | if (rndm (2)) |
90 | |
97 | option |= RMOPT_LINEAR; |
91 | if (rndm (2)) option |= RMOPT_LINEAR; |
98 | if (rndm (2)) |
|
|
99 | option |= RMOPT_IRR_SPACE; |
92 | if (rndm (2)) option |= RMOPT_IRR_SPACE; |
100 | } |
93 | } |
101 | |
94 | |
102 | /* write the outer walls, if appropriate. */ |
95 | /* write the outer walls, if appropriate. */ |
103 | if (!(option & RMOPT_WALL_OFF)) |
96 | if (!(option & RMOPT_WALL_OFF)) |
104 | { |
97 | maze->border (); |
105 | for (i = 0; i < xsize; i++) |
|
|
106 | maze[i][0] = maze[i][ysize - 1] = '#'; |
|
|
107 | for (j = 0; j < ysize; j++) |
|
|
108 | maze[0][j] = maze[xsize - 1][j] = '#'; |
|
|
109 | }; |
|
|
110 | |
98 | |
111 | if (option & RMOPT_WALLS_ONLY) |
99 | if (option & RMOPT_WALLS_ONLY) |
112 | return maze; |
100 | return; |
113 | |
101 | |
114 | /* pick off the mutually exclusive options */ |
102 | /* pick off the mutually exclusive options */ |
115 | if (option & RMOPT_BOTTOM_R) |
103 | if (option & RMOPT_BOTTOM_R) |
116 | bottom_right_centered_onion (maze, xsize, ysize, option, layers); |
104 | bottom_right_centered_onion (maze, xsize, ysize, option, layers); |
117 | else if (option & RMOPT_BOTTOM_C) |
105 | else if (option & RMOPT_BOTTOM_C) |
118 | bottom_centered_onion (maze, xsize, ysize, option, layers); |
106 | bottom_centered_onion (maze, xsize, ysize, option, layers); |
119 | else if (option & RMOPT_CENTERED) |
107 | else if (option & RMOPT_CENTERED) |
120 | centered_onion (maze, xsize, ysize, option, layers); |
108 | centered_onion (maze, xsize, ysize, option, layers); |
121 | |
|
|
122 | return maze; |
|
|
123 | } |
109 | } |
124 | |
110 | |
125 | void |
111 | void |
126 | centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
112 | centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
127 | { |
113 | { |
128 | int i, maxlayers; |
114 | int i, maxlayers; |
129 | float *xlocations; |
|
|
130 | float *ylocations; |
|
|
131 | |
115 | |
132 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
116 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
|
|
117 | |
133 | if (!maxlayers) |
118 | if (!maxlayers) |
134 | return; /* map too small to onionize */ |
119 | return; /* map too small to onionize */ |
135 | |
120 | |
136 | if (layers > maxlayers) |
121 | if (layers > maxlayers) |
137 | layers = maxlayers; |
122 | layers = maxlayers; |
138 | |
123 | |
139 | if (layers == 0) |
124 | if (layers == 0) |
140 | layers = rndm (maxlayers) + 1; |
125 | layers = rndm (maxlayers) + 1; |
141 | |
126 | |
142 | xlocations = (float *) calloc (sizeof (float), 2 * layers); |
127 | float *xlocations = salloc0<float> (2 * layers); |
143 | ylocations = (float *) calloc (sizeof (float), 2 * layers); |
128 | float *ylocations = salloc0<float> (2 * layers); |
144 | |
129 | |
145 | /* place all the walls */ |
130 | /* place all the walls */ |
146 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
131 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
147 | { |
132 | { |
148 | int x_spaces_available, y_spaces_available; |
133 | int x_spaces_available, y_spaces_available; |
149 | |
134 | |
150 | /* the "extra" spaces available for spacing between layers */ |
135 | /* the "extra" spaces available for spacing between layers */ |
151 | x_spaces_available = (xsize - 2) - 6 * layers + 1; |
136 | x_spaces_available = (xsize - 2) - 6 * layers + 1; |
152 | y_spaces_available = (ysize - 2) - 6 * layers + 1; |
137 | y_spaces_available = (ysize - 2) - 6 * layers + 1; |
153 | |
|
|
154 | |
138 | |
155 | /* pick an initial random pitch */ |
139 | /* pick an initial random pitch */ |
156 | for (i = 0; i < 2 * layers; i++) |
140 | for (i = 0; i < 2 * layers; i++) |
157 | { |
141 | { |
158 | float xpitch = 2, ypitch = 2; |
142 | float xpitch = 2, ypitch = 2; |
… | |
… | |
168 | x_spaces_available -= (int) (xpitch - 2); |
152 | x_spaces_available -= (int) (xpitch - 2); |
169 | y_spaces_available -= (int) (ypitch - 2); |
153 | y_spaces_available -= (int) (ypitch - 2); |
170 | } |
154 | } |
171 | |
155 | |
172 | } |
156 | } |
|
|
157 | |
173 | if (!(option & RMOPT_IRR_SPACE)) |
158 | if (!(option & RMOPT_IRR_SPACE)) |
174 | { /* evenly spaced */ |
159 | { /* evenly spaced */ |
175 | float xpitch, ypitch; /* pitch of the onion layers */ |
160 | float xpitch, ypitch; /* pitch of the onion layers */ |
176 | |
161 | |
177 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
162 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
178 | ypitch = (ysize - 2.0) / (2.0 * layers + 1); |
163 | ypitch = (ysize - 2.0) / (2.0 * layers + 1); |
|
|
164 | |
179 | xlocations[0] = xpitch; |
165 | xlocations[0] = xpitch; |
180 | ylocations[0] = ypitch; |
166 | ylocations[0] = ypitch; |
|
|
167 | |
181 | for (i = 1; i < 2 * layers; i++) |
168 | for (i = 1; i < 2 * layers; i++) |
182 | { |
169 | { |
183 | xlocations[i] = xlocations[i - 1] + xpitch; |
170 | xlocations[i] = xlocations[i - 1] + xpitch; |
184 | ylocations[i] = ylocations[i - 1] + ypitch; |
171 | ylocations[i] = ylocations[i - 1] + ypitch; |
185 | } |
172 | } |
186 | } |
173 | } |
187 | |
174 | |
188 | /* draw all the onion boxes. */ |
175 | /* draw all the onion boxes. */ |
189 | |
|
|
190 | draw_onion (maze, xlocations, ylocations, layers); |
176 | draw_onion (maze, xlocations, ylocations, layers); |
191 | make_doors (maze, xlocations, ylocations, layers, option); |
177 | make_doors (maze, xlocations, ylocations, layers, option); |
192 | |
178 | |
|
|
179 | sfree (xlocations, 2 * layers); |
|
|
180 | sfree (ylocations, 2 * layers); |
193 | } |
181 | } |
194 | |
182 | |
195 | void |
183 | void |
196 | bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
184 | bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
197 | { |
185 | { |
198 | int i, maxlayers; |
186 | int i, maxlayers; |
199 | float *xlocations; |
|
|
200 | float *ylocations; |
|
|
201 | |
187 | |
202 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
188 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
|
|
189 | |
203 | if (!maxlayers) |
190 | if (!maxlayers) |
204 | return; /* map too small to onionize */ |
191 | return; /* map too small to onionize */ |
|
|
192 | |
205 | if (layers > maxlayers) |
193 | if (layers > maxlayers) |
206 | layers = maxlayers; |
194 | layers = maxlayers; |
|
|
195 | |
207 | if (layers == 0) |
196 | if (layers == 0) |
208 | layers = rndm (maxlayers) + 1; |
197 | layers = rndm (maxlayers) + 1; |
209 | xlocations = (float *) calloc (sizeof (float), 2 * layers); |
|
|
210 | ylocations = (float *) calloc (sizeof (float), 2 * layers); |
|
|
211 | |
198 | |
|
|
199 | float *xlocations = salloc0<float> (2 * layers); |
|
|
200 | float *ylocations = salloc0<float> (2 * layers); |
212 | |
201 | |
213 | /* place all the walls */ |
202 | /* place all the walls */ |
214 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
203 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
215 | { |
204 | { |
216 | int x_spaces_available, y_spaces_available; |
205 | int x_spaces_available, y_spaces_available; |
217 | |
206 | |
218 | /* the "extra" spaces available for spacing between layers */ |
207 | /* the "extra" spaces available for spacing between layers */ |
219 | x_spaces_available = (xsize - 2) - 6 * layers + 1; |
208 | x_spaces_available = (xsize - 2) - 6 * layers + 1; |
220 | y_spaces_available = (ysize - 2) - 3 * layers + 1; |
209 | y_spaces_available = (ysize - 2) - 3 * layers + 1; |
221 | |
210 | |
222 | |
|
|
223 | /* pick an initial random pitch */ |
211 | /* pick an initial random pitch */ |
224 | for (i = 0; i < 2 * layers; i++) |
212 | for (i = 0; i < 2 * layers; i++) |
225 | { |
213 | { |
226 | float xpitch = 2, ypitch = 2; |
214 | float xpitch = 2, ypitch = 2; |
227 | |
215 | |
… | |
… | |
230 | |
218 | |
231 | if (y_spaces_available > 0) |
219 | if (y_spaces_available > 0) |
232 | ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; |
220 | ypitch = 2 + (rndm (y_spaces_available) + rndm (y_spaces_available) + rndm (y_spaces_available)) / 3; |
233 | |
221 | |
234 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
222 | xlocations[i] = ((i > 0) ? xlocations[i - 1] : 0) + xpitch; |
|
|
223 | |
235 | if (i < layers) |
224 | if (i < layers) |
236 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
225 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
237 | else |
226 | else |
238 | ylocations[i] = ysize - 1; |
227 | ylocations[i] = ysize - 1; |
239 | |
228 | |
240 | x_spaces_available -= (int) (xpitch - 2); |
229 | x_spaces_available -= (int) (xpitch - 2); |
241 | y_spaces_available -= (int) (ypitch - 2); |
230 | y_spaces_available -= (int) (ypitch - 2); |
242 | } |
231 | } |
243 | |
|
|
244 | } |
232 | } |
|
|
233 | |
245 | if (!(option & RMOPT_IRR_SPACE)) |
234 | if (!(option & RMOPT_IRR_SPACE)) |
246 | { /* evenly spaced */ |
235 | { /* evenly spaced */ |
247 | float xpitch, ypitch; /* pitch of the onion layers */ |
236 | float xpitch, ypitch; /* pitch of the onion layers */ |
248 | |
237 | |
249 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
238 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
250 | ypitch = (ysize - 2.0) / (layers + 1); |
239 | ypitch = (ysize - 2.0) / (layers + 1); |
|
|
240 | |
251 | xlocations[0] = xpitch; |
241 | xlocations[0] = xpitch; |
252 | ylocations[0] = ypitch; |
242 | ylocations[0] = ypitch; |
|
|
243 | |
253 | for (i = 1; i < 2 * layers; i++) |
244 | for (i = 1; i < 2 * layers; i++) |
254 | { |
245 | { |
255 | xlocations[i] = xlocations[i - 1] + xpitch; |
246 | xlocations[i] = xlocations[i - 1] + xpitch; |
|
|
247 | |
256 | if (i < layers) |
248 | if (i < layers) |
257 | ylocations[i] = ylocations[i - 1] + ypitch; |
249 | ylocations[i] = ylocations[i - 1] + ypitch; |
258 | else |
250 | else |
259 | ylocations[i] = ysize - 1; |
251 | ylocations[i] = ysize - 1; |
260 | } |
252 | } |
… | |
… | |
263 | /* draw all the onion boxes. */ |
255 | /* draw all the onion boxes. */ |
264 | |
256 | |
265 | draw_onion (maze, xlocations, ylocations, layers); |
257 | draw_onion (maze, xlocations, ylocations, layers); |
266 | make_doors (maze, xlocations, ylocations, layers, option); |
258 | make_doors (maze, xlocations, ylocations, layers, option); |
267 | |
259 | |
|
|
260 | sfree (xlocations, 2 * layers); |
|
|
261 | sfree (ylocations, 2 * layers); |
268 | } |
262 | } |
269 | |
|
|
270 | |
263 | |
271 | /* draw_boxes: draws the lines in the maze defining the onion layers */ |
264 | /* draw_boxes: draws the lines in the maze defining the onion layers */ |
272 | |
|
|
273 | void |
265 | void |
274 | draw_onion (char **maze, float *xlocations, float *ylocations, int layers) |
266 | draw_onion (char **maze, float *xlocations, float *ylocations, int layers) |
275 | { |
267 | { |
276 | int i, j, l; |
268 | int i, j, l; |
277 | |
269 | |
… | |
… | |
306 | int freedoms; /* number of different walls on which we could place a door */ |
298 | int freedoms; /* number of different walls on which we could place a door */ |
307 | int which_wall; /* left, 1, top, 2, right, 3, bottom 4 */ |
299 | int which_wall; /* left, 1, top, 2, right, 3, bottom 4 */ |
308 | int l, x1 = 0, x2, y1 = 0, y2; |
300 | int l, x1 = 0, x2, y1 = 0, y2; |
309 | |
301 | |
310 | freedoms = 4; /* centered */ |
302 | freedoms = 4; /* centered */ |
|
|
303 | |
311 | if (options & RMOPT_BOTTOM_C) |
304 | if (options & RMOPT_BOTTOM_C) |
312 | freedoms = 3; |
305 | freedoms = 3; |
|
|
306 | |
313 | if (options & RMOPT_BOTTOM_R) |
307 | if (options & RMOPT_BOTTOM_R) |
314 | freedoms = 2; |
308 | freedoms = 2; |
|
|
309 | |
315 | if (layers <= 0) |
310 | if (layers <= 0) |
316 | return; |
311 | return; |
317 | |
312 | |
318 | /* pick which wall will have a door. */ |
313 | /* pick which wall will have a door. */ |
319 | which_wall = rndm (freedoms) + 1; |
314 | which_wall = rndm (freedoms) + 1; |
… | |
… | |
396 | break; |
391 | break; |
397 | } |
392 | } |
398 | |
393 | |
399 | } |
394 | } |
400 | } |
395 | } |
|
|
396 | |
401 | if (options & RMOPT_NO_DOORS) |
397 | if (options & RMOPT_NO_DOORS) |
402 | maze[x1][y1] = '#'; /* no door. */ |
398 | maze[x1][y1] = '#'; /* no door. */ |
403 | else |
399 | else |
404 | maze[x1][y1] = 'D'; /* write the door */ |
400 | maze[x1][y1] = 'D'; /* write the door */ |
405 | |
401 | |
406 | } |
402 | } |
407 | /* mark the center of the maze with a C */ |
403 | /* mark the center of the maze with a C */ |
408 | l = layers - 1; |
404 | l = layers - 1; |
409 | x1 = (int) (xlocations[l] + xlocations[2 * layers - l - 1]) / 2; |
405 | x1 = (int) (xlocations[l] + xlocations[2 * layers - l - 1]) / 2; |
410 | y1 = (int) (ylocations[l] + ylocations[2 * layers - l - 1]) / 2; |
406 | y1 = (int) (ylocations[l] + ylocations[2 * layers - l - 1]) / 2; |
|
|
407 | |
411 | maze[x1][y1] = 'C'; |
408 | maze[x1][y1] = 'C'; |
412 | |
|
|
413 | /* not needed anymore */ |
|
|
414 | free (xlocations); |
|
|
415 | free (ylocations); |
|
|
416 | |
|
|
417 | } |
409 | } |
418 | |
410 | |
419 | void |
411 | void |
420 | bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
412 | bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
421 | { |
413 | { |
422 | int i, maxlayers; |
414 | int i, maxlayers; |
423 | float *xlocations; |
|
|
424 | float *ylocations; |
|
|
425 | |
415 | |
426 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
416 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
|
|
417 | |
427 | if (!maxlayers) |
418 | if (!maxlayers) |
428 | return; /* map too small to onionize */ |
419 | return; /* map too small to onionize */ |
|
|
420 | |
429 | if (layers > maxlayers) |
421 | if (layers > maxlayers) |
430 | layers = maxlayers; |
422 | layers = maxlayers; |
|
|
423 | |
431 | if (layers == 0) |
424 | if (layers == 0) |
432 | layers = rndm (maxlayers) + 1; |
425 | layers = rndm (maxlayers) + 1; |
433 | |
426 | |
434 | xlocations = (float *) calloc (sizeof (float), 2 * layers); |
427 | float *xlocations = salloc0<float> (2 * layers); |
435 | ylocations = (float *) calloc (sizeof (float), 2 * layers); |
428 | float *ylocations = salloc0<float> (2 * layers); |
436 | |
429 | |
437 | /* place all the walls */ |
430 | /* place all the walls */ |
438 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
431 | if (option & RMOPT_IRR_SPACE) /* randomly spaced */ |
439 | { |
432 | { |
440 | int x_spaces_available, y_spaces_available; |
433 | int x_spaces_available, y_spaces_available; |
… | |
… | |
462 | |
455 | |
463 | if (i < layers) |
456 | if (i < layers) |
464 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
457 | ylocations[i] = ((i > 0) ? ylocations[i - 1] : 0) + ypitch; |
465 | else |
458 | else |
466 | ylocations[i] = ysize - 1; |
459 | ylocations[i] = ysize - 1; |
|
|
460 | |
467 | x_spaces_available -= (int) (xpitch - 2); |
461 | x_spaces_available -= (int) (xpitch - 2); |
468 | y_spaces_available -= (int) (ypitch - 2); |
462 | y_spaces_available -= (int) (ypitch - 2); |
469 | } |
463 | } |
470 | |
|
|
471 | } |
464 | } |
|
|
465 | |
472 | if (!(option & RMOPT_IRR_SPACE)) |
466 | if (!(option & RMOPT_IRR_SPACE)) |
473 | { /* evenly spaced */ |
467 | { /* evenly spaced */ |
474 | float xpitch, ypitch; /* pitch of the onion layers */ |
468 | float xpitch, ypitch; /* pitch of the onion layers */ |
475 | |
469 | |
476 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
470 | xpitch = (xsize - 2.0) / (2.0 * layers + 1); |
477 | ypitch = (ysize - 2.0) / (layers + 1); |
471 | ypitch = (ysize - 2.0) / (layers + 1); |
|
|
472 | |
478 | xlocations[0] = xpitch; |
473 | xlocations[0] = xpitch; |
479 | ylocations[0] = ypitch; |
474 | ylocations[0] = ypitch; |
|
|
475 | |
480 | for (i = 1; i < 2 * layers; i++) |
476 | for (i = 1; i < 2 * layers; i++) |
481 | { |
477 | { |
482 | if (i < layers) |
478 | if (i < layers) |
483 | xlocations[i] = xlocations[i - 1] + xpitch; |
479 | xlocations[i] = xlocations[i - 1] + xpitch; |
484 | else |
480 | else |
485 | xlocations[i] = xsize - 1; |
481 | xlocations[i] = xsize - 1; |
|
|
482 | |
486 | if (i < layers) |
483 | if (i < layers) |
487 | ylocations[i] = ylocations[i - 1] + ypitch; |
484 | ylocations[i] = ylocations[i - 1] + ypitch; |
488 | else |
485 | else |
489 | ylocations[i] = ysize - 1; |
486 | ylocations[i] = ysize - 1; |
490 | } |
487 | } |
… | |
… | |
493 | /* draw all the onion boxes. */ |
490 | /* draw all the onion boxes. */ |
494 | |
491 | |
495 | draw_onion (maze, xlocations, ylocations, layers); |
492 | draw_onion (maze, xlocations, ylocations, layers); |
496 | make_doors (maze, xlocations, ylocations, layers, option); |
493 | make_doors (maze, xlocations, ylocations, layers, option); |
497 | |
494 | |
|
|
495 | sfree (xlocations, 2 * layers); |
|
|
496 | sfree (ylocations, 2 * layers); |
498 | } |
497 | } |
|
|
498 | |