1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
50 | */ |
50 | */ |
51 | |
51 | |
52 | |
52 | |
53 | #include <global.h> |
53 | #include <global.h> |
54 | #include <random_map.h> |
54 | #include <random_map.h> |
55 | |
55 | #include <rproto.h> |
56 | #ifndef MIN |
|
|
57 | # define MIN(x,y) (((x)<(y))? (x):(y)) |
|
|
58 | #endif |
|
|
59 | |
56 | |
60 | static void centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
57 | static void centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
61 | static void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
58 | static void bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
62 | static void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
59 | static void bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers); |
63 | |
60 | |
… | |
… | |
113 | static void |
110 | static void |
114 | centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
111 | centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
115 | { |
112 | { |
116 | int i, maxlayers; |
113 | int i, maxlayers; |
117 | |
114 | |
118 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
115 | maxlayers = (min (xsize, ysize) - 2) / 5; |
119 | |
116 | |
120 | if (!maxlayers) |
117 | if (!maxlayers) |
121 | return; /* map too small to onionize */ |
118 | return; /* map too small to onionize */ |
122 | |
119 | |
123 | if (layers > maxlayers) |
120 | if (layers > maxlayers) |
… | |
… | |
185 | static void |
182 | static void |
186 | bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
183 | bottom_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
187 | { |
184 | { |
188 | int i, maxlayers; |
185 | int i, maxlayers; |
189 | |
186 | |
190 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
187 | maxlayers = (min (xsize, ysize) - 2) / 5; |
191 | |
188 | |
192 | if (!maxlayers) |
189 | if (!maxlayers) |
193 | return; /* map too small to onionize */ |
190 | return; /* map too small to onionize */ |
194 | |
191 | |
195 | if (layers > maxlayers) |
192 | if (layers > maxlayers) |
… | |
… | |
292 | } |
289 | } |
293 | |
290 | |
294 | } |
291 | } |
295 | } |
292 | } |
296 | |
293 | |
297 | void |
294 | static void |
298 | make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options) |
295 | make_doors (char **maze, float *xlocations, float *ylocations, int layers, int options) |
299 | { |
296 | { |
300 | int freedoms; /* number of different walls on which we could place a door */ |
297 | 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 */ |
298 | int which_wall; /* left, 1, top, 2, right, 3, bottom 4 */ |
302 | int l, x1 = 0, x2, y1 = 0, y2; |
299 | int l, x1 = 0, x2, y1 = 0, y2; |
… | |
… | |
413 | static void |
410 | static void |
414 | bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
411 | bottom_right_centered_onion (char **maze, int xsize, int ysize, int option, int layers) |
415 | { |
412 | { |
416 | int i, maxlayers; |
413 | int i, maxlayers; |
417 | |
414 | |
418 | maxlayers = (MIN (xsize, ysize) - 2) / 5; |
415 | maxlayers = (min (xsize, ysize) - 2) / 5; |
419 | |
416 | |
420 | if (!maxlayers) |
417 | if (!maxlayers) |
421 | return; /* map too small to onionize */ |
418 | return; /* map too small to onionize */ |
422 | |
419 | |
423 | if (layers > maxlayers) |
420 | if (layers > maxlayers) |