1 | /* |
1 | /* |
2 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
3 | |
3 | * |
4 | Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
4 | * Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team |
5 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
5 | * Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
6 | Copyright (C) 1992 Frank Tore Johansen |
6 | * Copyright (C) 1992 Frank Tore Johansen |
7 | |
7 | * |
8 | This program is free software; you can redistribute it and/or modify |
8 | * This program 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 2 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, write to the Free Software |
20 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
21 | |
21 | * |
22 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
22 | * The authors can be reached via e-mail at <crossfire@schmorp.de> |
23 | */ |
23 | */ |
24 | |
24 | |
25 | #include <time.h> |
25 | #include <time.h> |
26 | #include <stdio.h> |
26 | #include <stdio.h> |
27 | #include <global.h> |
27 | #include <global.h> |
28 | #include <maze_gen.h> |
28 | #include <maze_gen.h> |
29 | #include <room_gen.h> |
29 | #include <room_gen.h> |
30 | #include <random_map.h> |
30 | #include <random_map.h> |
31 | #include <rproto.h> |
31 | #include <rproto.h> |
32 | #include <sproto.h> |
32 | #include <sproto.h> |
|
|
33 | |
|
|
34 | #define CEDE coroapi::cede_to_tick (); rndm.seed (RP->random_seed + __LINE__); |
33 | |
35 | |
34 | void |
36 | void |
35 | dump_layout (char **layout, random_map_params *RP) |
37 | dump_layout (char **layout, random_map_params *RP) |
36 | { |
38 | { |
37 | { |
39 | { |
… | |
… | |
51 | } |
53 | } |
52 | } |
54 | } |
53 | printf ("\n"); |
55 | printf ("\n"); |
54 | } |
56 | } |
55 | |
57 | |
56 | maptile * |
58 | bool |
57 | generate_random_map (const char *OutFileName, random_map_params *RP) |
59 | maptile::generate_random_map (random_map_params *RP) |
58 | { |
60 | { |
59 | char **layout, buf[16384]; |
61 | char **layout, buf[16384]; |
60 | maptile *theMap; |
|
|
61 | int i; |
62 | int i; |
62 | |
63 | |
|
|
64 | RP->Xsize = RP->xsize; |
|
|
65 | RP->Ysize = RP->ysize; |
|
|
66 | |
63 | /* pick a random seed, or use the one from the input file */ |
67 | /* pick a random seed, or use the one from the input file */ |
64 | SRANDOM (RP->random_seed ? RP->random_seed + RP->dungeon_level : time (0)); |
68 | RP->random_seed = RP->random_seed |
|
|
69 | ? RP->random_seed + RP->dungeon_level |
|
|
70 | : time (0); |
|
|
71 | CEDE; |
65 | |
72 | |
66 | write_map_parameters_to_string (buf, RP); |
73 | write_map_parameters_to_string (buf, RP); |
67 | |
74 | |
68 | if (RP->difficulty == 0) |
75 | if (RP->difficulty == 0) |
69 | { |
76 | { |
… | |
… | |
77 | } |
84 | } |
78 | else |
85 | else |
79 | RP->difficulty_given = 1; |
86 | RP->difficulty_given = 1; |
80 | |
87 | |
81 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
88 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
82 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
89 | RP->Xsize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; |
83 | |
90 | |
84 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
91 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
85 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
92 | RP->Ysize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; |
|
|
93 | |
|
|
94 | if (RP->symmetry == SYMMETRY_RANDOM) |
|
|
95 | RP->symmetry_used = rndm (SYMMETRY_XY) + 1; |
|
|
96 | else |
|
|
97 | RP->symmetry_used = RP->symmetry; |
|
|
98 | |
|
|
99 | if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) |
|
|
100 | RP->Ysize = RP->Ysize / 2 + 1; |
|
|
101 | |
|
|
102 | if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY) |
|
|
103 | RP->Xsize = RP->Xsize / 2 + 1; |
86 | |
104 | |
87 | if (RP->expand2x > 0) |
105 | if (RP->expand2x > 0) |
88 | { |
106 | { |
89 | RP->Xsize /= 2; |
107 | RP->Xsize /= 2; |
90 | RP->Ysize /= 2; |
108 | RP->Ysize /= 2; |
91 | } |
109 | } |
92 | |
110 | |
93 | layout = layoutgen (RP); |
|
|
94 | |
|
|
95 | #ifdef RMAP_DEBUG |
|
|
96 | dump_layout (layout, RP); |
|
|
97 | #endif |
|
|
98 | |
|
|
99 | /* increment these for the current map */ |
|
|
100 | RP->dungeon_level += 1; |
|
|
101 | /* allow constant-difficulty maps. */ |
|
|
102 | /* difficulty+=1; */ |
|
|
103 | |
|
|
104 | /* rotate the layout randomly */ |
|
|
105 | layout = rotate_layout (layout, RANDOM () % 4, RP); |
|
|
106 | #ifdef RMAP_DEBUG |
|
|
107 | dump_layout (layout, RP); |
|
|
108 | #endif |
|
|
109 | |
|
|
110 | /* allocate the map and set the floor */ |
|
|
111 | theMap = make_map_floor (layout, RP->floorstyle, RP); |
|
|
112 | |
|
|
113 | /* set the name of the map. */ |
|
|
114 | theMap->path = OutFileName; |
|
|
115 | |
|
|
116 | /* set region */ |
|
|
117 | theMap->region = RP->region; |
|
|
118 | |
|
|
119 | coroapi::cede (); |
|
|
120 | /* create walls unless the wallstyle is "none" */ |
|
|
121 | if (strcmp (RP->wallstyle, "none")) |
|
|
122 | { |
|
|
123 | make_map_walls (theMap, layout, RP->wallstyle, RP); |
|
|
124 | |
|
|
125 | /* place doors unless doorstyle or wallstyle is "none" */ |
|
|
126 | if (strcmp (RP->doorstyle, "none")) |
|
|
127 | put_doors (theMap, layout, RP->doorstyle, RP); |
|
|
128 | |
|
|
129 | } |
|
|
130 | |
|
|
131 | coroapi::cede (); |
|
|
132 | /* create exits unless the exitstyle is "none" */ |
|
|
133 | if (strcmp (RP->exitstyle, "none")) |
|
|
134 | place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); |
|
|
135 | |
|
|
136 | coroapi::cede (); |
|
|
137 | place_specials_in_map (theMap, layout, RP); |
|
|
138 | |
|
|
139 | coroapi::cede (); |
|
|
140 | /* create monsters unless the monsterstyle is "none" */ |
|
|
141 | if (strcmp (RP->monsterstyle, "none")) |
|
|
142 | place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); |
|
|
143 | |
|
|
144 | coroapi::cede (); |
|
|
145 | /* treasures needs to have a proper difficulty set for the map. */ |
|
|
146 | theMap->difficulty = theMap->estimate_difficulty (); |
|
|
147 | |
|
|
148 | coroapi::cede (); |
|
|
149 | /* create treasure unless the treasurestyle is "none" */ |
|
|
150 | if (strcmp (RP->treasurestyle, "none")) |
|
|
151 | place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); |
|
|
152 | |
|
|
153 | coroapi::cede (); |
|
|
154 | /* create decor unless the decorstyle is "none" */ |
|
|
155 | if (strcmp (RP->decorstyle, "none")) |
|
|
156 | put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); |
|
|
157 | |
|
|
158 | coroapi::cede (); |
|
|
159 | /* generate treasures, etc. */ |
|
|
160 | theMap->fix_auto_apply (); |
|
|
161 | |
|
|
162 | coroapi::cede (); |
|
|
163 | unblock_exits (theMap, layout, RP); |
|
|
164 | |
|
|
165 | /* free the layout */ |
|
|
166 | for (i = 0; i < RP->Xsize; i++) |
|
|
167 | free (layout[i]); |
|
|
168 | |
|
|
169 | free (layout); |
|
|
170 | |
|
|
171 | theMap->msg = strdup (buf); |
|
|
172 | theMap->in_memory = MAP_IN_MEMORY; |
|
|
173 | |
|
|
174 | return theMap; |
|
|
175 | } |
|
|
176 | |
|
|
177 | /* function selects the layout function and gives it whatever |
|
|
178 | arguments it needs. */ |
|
|
179 | char ** |
|
|
180 | layoutgen (random_map_params *RP) |
|
|
181 | { |
|
|
182 | char **maze = 0; |
|
|
183 | int oxsize = RP->Xsize, oysize = RP->Ysize; |
|
|
184 | |
|
|
185 | if (RP->symmetry == SYMMETRY_RANDOM) |
|
|
186 | RP->symmetry_used = (RANDOM () % (SYMMETRY_XY)) + 1; |
|
|
187 | else |
|
|
188 | RP->symmetry_used = RP->symmetry; |
|
|
189 | |
|
|
190 | if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) |
|
|
191 | RP->Ysize = RP->Ysize / 2 + 1; |
|
|
192 | if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY) |
|
|
193 | RP->Xsize = RP->Xsize / 2 + 1; |
|
|
194 | |
|
|
195 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
|
|
196 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
|
|
197 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
|
|
198 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
|
|
199 | RP->map_layout_style = 0; |
111 | RP->map_layout_style = LAYOUT_NONE; |
200 | |
112 | |
201 | /* Redo this - there was a lot of redundant code of checking for preset |
113 | /* Redo this - there was a lot of redundant code of checking for preset |
202 | * layout style and then random layout style. Instead, figure out |
114 | * layout style and then random layout style. Instead, figure out |
203 | * the numeric layoutstyle, so there is only one area that actually |
115 | * the numeric layoutstyle, so there is only one area that actually |
204 | * calls the code to make the maps. |
116 | * calls the code to make the maps. |
… | |
… | |
219 | RP->map_layout_style = LAYOUT_SNAKE; |
131 | RP->map_layout_style = LAYOUT_SNAKE; |
220 | |
132 | |
221 | if (strstr (RP->layoutstyle, "squarespiral")) |
133 | if (strstr (RP->layoutstyle, "squarespiral")) |
222 | RP->map_layout_style = LAYOUT_SQUARE_SPIRAL; |
134 | RP->map_layout_style = LAYOUT_SQUARE_SPIRAL; |
223 | |
135 | |
224 | /* No style found - choose one ranomdly */ |
136 | /* No style found - choose one randomly */ |
225 | if (RP->map_layout_style == LAYOUT_NONE) |
137 | if (RP->map_layout_style == LAYOUT_NONE) |
226 | RP->map_layout_style = (RANDOM () % (NROFLAYOUTS - 1)) + 1; |
138 | RP->map_layout_style = rndm (NROFLAYOUTS - 1) + 1; |
|
|
139 | |
|
|
140 | layout = layoutgen (RP); |
|
|
141 | |
|
|
142 | #ifdef RMAP_DEBUG |
|
|
143 | dump_layout (layout, RP); |
|
|
144 | #endif |
|
|
145 | |
|
|
146 | /* increment these for the current map */ |
|
|
147 | RP->dungeon_level += 1; |
|
|
148 | /* allow constant-difficulty maps. */ |
|
|
149 | /* difficulty+=1; */ |
|
|
150 | |
|
|
151 | /* rotate the layout randomly */ |
|
|
152 | layout = rotate_layout (layout, rndm (4), RP); |
|
|
153 | #ifdef RMAP_DEBUG |
|
|
154 | dump_layout (layout, RP); |
|
|
155 | #endif |
|
|
156 | |
|
|
157 | /* allocate the map and set the floor */ |
|
|
158 | make_map_floor (layout, RP->floorstyle, RP); |
|
|
159 | |
|
|
160 | /* set region */ |
|
|
161 | default_region = RP->region; |
|
|
162 | |
|
|
163 | CEDE; |
|
|
164 | |
|
|
165 | /* create walls unless the wallstyle is "none" */ |
|
|
166 | if (strcmp (RP->wallstyle, "none")) |
|
|
167 | { |
|
|
168 | make_map_walls (this, layout, RP->wallstyle, RP); |
|
|
169 | |
|
|
170 | /* place doors unless doorstyle or wallstyle is "none" */ |
|
|
171 | if (strcmp (RP->doorstyle, "none")) |
|
|
172 | put_doors (this, layout, RP->doorstyle, RP); |
|
|
173 | } |
|
|
174 | |
|
|
175 | CEDE; |
|
|
176 | |
|
|
177 | /* create exits unless the exitstyle is "none" */ |
|
|
178 | if (strcmp (RP->exitstyle, "none")) |
|
|
179 | place_exits (this, layout, RP->exitstyle, RP->orientation, RP); |
|
|
180 | |
|
|
181 | CEDE; |
|
|
182 | |
|
|
183 | place_specials_in_map (this, layout, RP); |
|
|
184 | |
|
|
185 | CEDE; |
|
|
186 | |
|
|
187 | /* create monsters unless the monsterstyle is "none" */ |
|
|
188 | if (strcmp (RP->monsterstyle, "none")) |
|
|
189 | place_monsters (this, RP->monsterstyle, RP->difficulty, RP); |
|
|
190 | |
|
|
191 | CEDE; |
|
|
192 | |
|
|
193 | /* treasures needs to have a proper difficulty set for the map. */ |
|
|
194 | difficulty = estimate_difficulty (); |
|
|
195 | |
|
|
196 | CEDE; |
|
|
197 | |
|
|
198 | /* create treasure unless the treasurestyle is "none" */ |
|
|
199 | if (strcmp (RP->treasurestyle, "none")) |
|
|
200 | place_treasure (this, layout, RP->treasurestyle, RP->treasureoptions, RP); |
|
|
201 | |
|
|
202 | CEDE; |
|
|
203 | |
|
|
204 | /* create decor unless the decorstyle is "none" */ |
|
|
205 | if (strcmp (RP->decorstyle, "none")) |
|
|
206 | put_decor (this, layout, RP->decorstyle, RP->decoroptions, RP); |
|
|
207 | |
|
|
208 | CEDE; |
|
|
209 | |
|
|
210 | /* generate treasures, etc. */ |
|
|
211 | fix_auto_apply (); |
|
|
212 | |
|
|
213 | CEDE; |
|
|
214 | |
|
|
215 | unblock_exits (this, layout, RP); |
|
|
216 | |
|
|
217 | /* free the layout */ |
|
|
218 | for (i = 0; i < RP->Xsize; i++) |
|
|
219 | free (layout[i]); |
|
|
220 | |
|
|
221 | free (layout); |
|
|
222 | |
|
|
223 | msg = strdup (buf); |
|
|
224 | in_memory = MAP_IN_MEMORY; |
|
|
225 | |
|
|
226 | CEDE; |
|
|
227 | |
|
|
228 | return 1; |
|
|
229 | } |
|
|
230 | |
|
|
231 | /* function selects the layout function and gives it whatever |
|
|
232 | arguments it needs. */ |
|
|
233 | char ** |
|
|
234 | layoutgen (random_map_params *RP) |
|
|
235 | { |
|
|
236 | char **maze = 0; |
|
|
237 | int oxsize = RP->Xsize, oysize = RP->Ysize; |
227 | |
238 | |
228 | switch (RP->map_layout_style) |
239 | switch (RP->map_layout_style) |
229 | { |
240 | { |
230 | case LAYOUT_ONION: |
241 | case LAYOUT_ONION: |
231 | maze = map_gen_onion (RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2); |
242 | maze = map_gen_onion (RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2); |
232 | if (!(RANDOM () % 3) && !(RP->layoutoptions1 & RMOPT_WALLS_ONLY)) |
243 | if (!(rndm (3)) && !(RP->layoutoptions1 & RMOPT_WALLS_ONLY)) |
233 | roomify_layout (maze, RP); |
244 | roomify_layout (maze, RP); |
234 | break; |
245 | break; |
235 | |
246 | |
236 | case LAYOUT_MAZE: |
247 | case LAYOUT_MAZE: |
237 | maze = maze_gen (RP->Xsize, RP->Ysize, RANDOM () % 2); |
248 | maze = maze_gen (RP->Xsize, RP->Ysize, rndm (2)); |
238 | if (!(RANDOM () % 2)) |
249 | if (!(rndm (2))) |
239 | doorify_layout (maze, RP); |
250 | doorify_layout (maze, RP); |
240 | break; |
251 | break; |
241 | |
252 | |
242 | case LAYOUT_SPIRAL: |
253 | case LAYOUT_SPIRAL: |
243 | maze = map_gen_spiral (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
254 | maze = map_gen_spiral (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
244 | if (!(RANDOM () % 2)) |
255 | if (!(rndm (2))) |
245 | doorify_layout (maze, RP); |
256 | doorify_layout (maze, RP); |
246 | break; |
257 | break; |
247 | |
258 | |
248 | case LAYOUT_ROGUELIKE: |
259 | case LAYOUT_ROGUELIKE: |
249 | /* Don't put symmetry in rogue maps. There isn't much reason to |
260 | /* Don't put symmetry in rogue maps. There isn't much reason to |
… | |
… | |
260 | /* no doorifying... done already */ |
271 | /* no doorifying... done already */ |
261 | break; |
272 | break; |
262 | |
273 | |
263 | case LAYOUT_SNAKE: |
274 | case LAYOUT_SNAKE: |
264 | maze = make_snake_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
275 | maze = make_snake_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
265 | if (RANDOM () % 2) |
276 | if (rndm (2)) |
266 | roomify_layout (maze, RP); |
277 | roomify_layout (maze, RP); |
267 | break; |
278 | break; |
268 | |
279 | |
269 | case LAYOUT_SQUARE_SPIRAL: |
280 | case LAYOUT_SQUARE_SPIRAL: |
270 | maze = make_square_spiral_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
281 | maze = make_square_spiral_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
271 | if (RANDOM () % 2) |
282 | if (rndm (2)) |
272 | roomify_layout (maze, RP); |
283 | roomify_layout (maze, RP); |
273 | break; |
284 | break; |
274 | } |
285 | } |
275 | |
286 | |
276 | maze = symmetrize_layout (maze, RP->symmetry_used, RP); |
287 | maze = symmetrize_layout (maze, RP->symmetry_used, RP); |
… | |
… | |
439 | for (ti = 0; ti < tries; ti++) |
450 | for (ti = 0; ti < tries; ti++) |
440 | { |
451 | { |
441 | int dx, dy; /* starting location for looking at creating a door */ |
452 | int dx, dy; /* starting location for looking at creating a door */ |
442 | int cx, cy; /* results of checking on creating walls. */ |
453 | int cx, cy; /* results of checking on creating walls. */ |
443 | |
454 | |
444 | dx = RANDOM () % RP->Xsize; |
455 | dx = rndm (RP->Xsize); |
445 | dy = RANDOM () % RP->Ysize; |
456 | dy = rndm (RP->Ysize); |
|
|
457 | |
446 | cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */ |
458 | cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */ |
447 | cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */ |
459 | cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */ |
448 | if (cx == -1) |
460 | if (cx == -1) |
449 | { |
461 | { |
450 | if (cy != -1) |
462 | if (cy != -1) |
451 | make_wall (maze, dx, dy, 1); |
463 | make_wall (maze, dx, dy, 1); |
|
|
464 | |
452 | continue; |
465 | continue; |
453 | } |
466 | } |
|
|
467 | |
454 | if (cy == -1) |
468 | if (cy == -1) |
455 | { |
469 | { |
456 | make_wall (maze, dx, dy, 0); |
470 | make_wall (maze, dx, dy, 0); |
457 | continue; |
471 | continue; |
458 | } |
472 | } |
|
|
473 | |
459 | if (cx < cy) |
474 | if (cx < cy) |
460 | make_wall (maze, dx, dy, 0); |
475 | make_wall (maze, dx, dy, 0); |
461 | else |
476 | else |
462 | make_wall (maze, dx, dy, 1); |
477 | make_wall (maze, dx, dy, 1); |
463 | } |
478 | } |
… | |
… | |
609 | while (ndoors > 0 && doorlocs > 0) |
624 | while (ndoors > 0 && doorlocs > 0) |
610 | { |
625 | { |
611 | int di; |
626 | int di; |
612 | int sindex; |
627 | int sindex; |
613 | |
628 | |
614 | di = RANDOM () % doorlocs; |
629 | di = rndm (doorlocs); |
615 | i = doorlist_x[di]; |
630 | i = doorlist_x[di]; |
616 | j = doorlist_y[di]; |
631 | j = doorlist_y[di]; |
617 | sindex = surround_flag (maze, i, j, RP); |
632 | sindex = surround_flag (maze, i, j, RP); |
|
|
633 | |
618 | if (sindex == 3 || sindex == 12) /* these are possible door sindex */ |
634 | if (sindex == 3 || sindex == 12) /* these are possible door sindex */ |
619 | { |
635 | { |
620 | maze[i][j] = 'D'; |
636 | maze[i][j] = 'D'; |
621 | ndoors--; |
637 | ndoors--; |
622 | } |
638 | } |
|
|
639 | |
623 | /* reduce the size of the list */ |
640 | /* reduce the size of the list */ |
624 | doorlocs--; |
641 | doorlocs--; |
625 | doorlist_x[di] = doorlist_x[doorlocs]; |
642 | doorlist_x[di] = doorlist_x[doorlocs]; |
626 | doorlist_y[di] = doorlist_y[doorlocs]; |
643 | doorlist_y[di] = doorlist_y[doorlocs]; |
627 | } |
644 | } |
… | |
… | |
633 | void |
650 | void |
634 | write_map_parameters_to_string (char *buf, random_map_params *RP) |
651 | write_map_parameters_to_string (char *buf, random_map_params *RP) |
635 | { |
652 | { |
636 | char small_buf[16384]; |
653 | char small_buf[16384]; |
637 | |
654 | |
638 | sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); |
655 | sprintf (buf, "xsize %d\nysize %d\n", RP->xsize, RP->ysize); |
639 | |
656 | |
640 | if (RP->wallstyle[0]) |
657 | if (RP->wallstyle[0]) |
641 | { |
658 | { |
642 | sprintf (small_buf, "wallstyle %s\n", RP->wallstyle); |
659 | sprintf (small_buf, "wallstyle %s\n", RP->wallstyle); |
643 | strcat (buf, small_buf); |
660 | strcat (buf, small_buf); |
… | |
… | |
784 | strcat (buf, small_buf); |
801 | strcat (buf, small_buf); |
785 | } |
802 | } |
786 | |
803 | |
787 | if (RP->random_seed) |
804 | if (RP->random_seed) |
788 | { |
805 | { |
789 | sprintf (small_buf, "random_seed %d\n", RP->random_seed); |
806 | sprintf (small_buf, "random_seed %u\n", RP->random_seed); |
790 | strcat (buf, small_buf); |
807 | strcat (buf, small_buf); |
791 | } |
808 | } |
792 | |
809 | |
793 | if (RP->custom) |
810 | if (RP->custom) |
794 | { |
811 | { |
… | |
… | |
799 | |
816 | |
800 | void |
817 | void |
801 | write_parameters_to_string (char *buf, |
818 | write_parameters_to_string (char *buf, |
802 | int xsize_n, |
819 | int xsize_n, |
803 | int ysize_n, |
820 | int ysize_n, |
804 | char *wallstyle_n, |
821 | const char *wallstyle_n, |
805 | char *floorstyle_n, |
822 | const char *floorstyle_n, |
806 | char *monsterstyle_n, |
823 | const char *monsterstyle_n, |
807 | char *treasurestyle_n, |
824 | const char *treasurestyle_n, |
808 | char *layoutstyle_n, |
825 | const char *layoutstyle_n, |
809 | char *decorstyle_n, |
826 | const char *decorstyle_n, |
810 | char *doorstyle_n, |
827 | const char *doorstyle_n, |
811 | char *exitstyle_n, |
828 | const char *exitstyle_n, |
812 | char *final_map_n, |
829 | const char *final_map_n, |
813 | char *exit_on_final_map_n, |
830 | const char *exit_on_final_map_n, |
814 | char *this_map_n, |
831 | const char *this_map_n, |
815 | int layoutoptions1_n, |
832 | int layoutoptions1_n, |
816 | int layoutoptions2_n, |
833 | int layoutoptions2_n, |
817 | int layoutoptions3_n, |
834 | int layoutoptions3_n, |
818 | int symmetry_n, |
835 | int symmetry_n, |
819 | int dungeon_depth_n, |
836 | int dungeon_depth_n, |
820 | int dungeon_level_n, |
837 | int dungeon_level_n, |
821 | int difficulty_n, |
838 | int difficulty_n, |
822 | int difficulty_given_n, |
839 | int difficulty_given_n, |
823 | int decoroptions_n, |
840 | int decoroptions_n, |
824 | int orientation_n, |
841 | int orientation_n, |
825 | int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) |
842 | int origin_x_n, |
|
|
843 | int origin_y_n, |
|
|
844 | uint32_t random_seed_n, |
|
|
845 | int treasureoptions_n, |
|
|
846 | float difficulty_increase) |
826 | { |
847 | { |
827 | char small_buf[16384]; |
848 | char small_buf[16384]; |
828 | |
849 | |
829 | sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); |
850 | sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); |
830 | |
851 | |
… | |
… | |
966 | } |
987 | } |
967 | |
988 | |
968 | if (random_seed_n) |
989 | if (random_seed_n) |
969 | { |
990 | { |
970 | /* Add one so that the next map is a bit different */ |
991 | /* Add one so that the next map is a bit different */ |
971 | sprintf (small_buf, "random_seed %d\n", random_seed_n + 1); |
992 | sprintf (small_buf, "random_seed %u\n", random_seed_n + 1); |
972 | strcat (buf, small_buf); |
993 | strcat (buf, small_buf); |
973 | } |
994 | } |
974 | |
995 | |
975 | if (treasureoptions_n) |
996 | if (treasureoptions_n) |
976 | { |
997 | { |