1 | |
|
|
2 | /* |
1 | /* |
3 | CrossFire, A Multiplayer game for X-windows |
2 | * CrossFire, A Multiplayer game for X-windows |
4 | |
3 | * |
|
|
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 (); 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 | extern FILE *logfile; |
58 | bool |
57 | |
59 | maptile::generate_random_map (random_map_params *RP) |
58 | maptile * |
|
|
59 | generate_random_map (const char *OutFileName, random_map_params *RP) |
|
|
60 | { |
60 | { |
61 | char **layout, buf[HUGE_BUF]; |
61 | char **layout, buf[16384]; |
62 | maptile *theMap; |
|
|
63 | int i; |
62 | int i; |
64 | |
63 | |
|
|
64 | RP->Xsize = RP->xsize; |
|
|
65 | RP->Ysize = RP->ysize; |
|
|
66 | |
65 | /* 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 */ |
66 | if (RP->random_seed == 0) |
68 | RP->random_seed = RP->random_seed |
67 | RP->random_seed = time (0); |
69 | ? RP->random_seed + RP->dungeon_level |
68 | |
70 | : time (0); |
69 | SRANDOM (RP->random_seed); |
71 | CEDE; |
70 | |
72 | |
71 | write_map_parameters_to_string (buf, RP); |
73 | write_map_parameters_to_string (buf, RP); |
72 | |
74 | |
73 | if (RP->difficulty == 0) |
75 | if (RP->difficulty == 0) |
74 | { |
76 | { |
… | |
… | |
82 | } |
84 | } |
83 | else |
85 | else |
84 | RP->difficulty_given = 1; |
86 | RP->difficulty_given = 1; |
85 | |
87 | |
86 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
88 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
87 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
89 | RP->Xsize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; |
88 | |
90 | |
89 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
91 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
90 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
92 | RP->Ysize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; |
91 | |
|
|
92 | if (RP->expand2x > 0) |
|
|
93 | { |
|
|
94 | RP->Xsize /= 2; |
|
|
95 | RP->Ysize /= 2; |
|
|
96 | } |
|
|
97 | |
|
|
98 | layout = layoutgen (RP); |
|
|
99 | |
|
|
100 | #ifdef RMAP_DEBUG |
|
|
101 | dump_layout (layout, RP); |
|
|
102 | #endif |
|
|
103 | |
|
|
104 | /* increment these for the current map */ |
|
|
105 | RP->dungeon_level += 1; |
|
|
106 | /* allow constant-difficulty maps. */ |
|
|
107 | /* difficulty+=1; */ |
|
|
108 | |
|
|
109 | /* rotate the layout randomly */ |
|
|
110 | layout = rotate_layout (layout, RANDOM () % 4, RP); |
|
|
111 | #ifdef RMAP_DEBUG |
|
|
112 | dump_layout (layout, RP); |
|
|
113 | #endif |
|
|
114 | |
|
|
115 | /* allocate the map and set the floor */ |
|
|
116 | theMap = make_map_floor (layout, RP->floorstyle, RP); |
|
|
117 | |
|
|
118 | /* set the name of the map. */ |
|
|
119 | theMap->path = OutFileName; |
|
|
120 | |
|
|
121 | /* set region */ |
|
|
122 | theMap->region = RP->region; |
|
|
123 | |
|
|
124 | /* create walls unless the wallstyle is "none" */ |
|
|
125 | if (strcmp (RP->wallstyle, "none")) |
|
|
126 | { |
|
|
127 | make_map_walls (theMap, layout, RP->wallstyle, RP); |
|
|
128 | |
|
|
129 | /* place doors unless doorstyle or wallstyle is "none" */ |
|
|
130 | if (strcmp (RP->doorstyle, "none")) |
|
|
131 | put_doors (theMap, layout, RP->doorstyle, RP); |
|
|
132 | |
|
|
133 | } |
|
|
134 | |
|
|
135 | /* create exits unless the exitstyle is "none" */ |
|
|
136 | if (strcmp (RP->exitstyle, "none")) |
|
|
137 | place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); |
|
|
138 | |
|
|
139 | place_specials_in_map (theMap, layout, RP); |
|
|
140 | |
|
|
141 | /* create monsters unless the monsterstyle is "none" */ |
|
|
142 | if (strcmp (RP->monsterstyle, "none")) |
|
|
143 | place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); |
|
|
144 | |
|
|
145 | /* treasures needs to have a proper difficulty set for the map. */ |
|
|
146 | theMap->difficulty = theMap->estimate_difficulty (); |
|
|
147 | |
|
|
148 | /* create treasure unless the treasurestyle is "none" */ |
|
|
149 | if (strcmp (RP->treasurestyle, "none")) |
|
|
150 | place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); |
|
|
151 | |
|
|
152 | /* create decor unless the decorstyle is "none" */ |
|
|
153 | if (strcmp (RP->decorstyle, "none")) |
|
|
154 | put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); |
|
|
155 | |
|
|
156 | /* generate treasures, etc. */ |
|
|
157 | theMap->fix_auto_apply (); |
|
|
158 | |
|
|
159 | unblock_exits (theMap, layout, RP); |
|
|
160 | |
|
|
161 | /* free the layout */ |
|
|
162 | for (i = 0; i < RP->Xsize; i++) |
|
|
163 | free (layout[i]); |
|
|
164 | |
|
|
165 | free (layout); |
|
|
166 | |
|
|
167 | theMap->msg = strdup (buf); |
|
|
168 | theMap->in_memory = MAP_IN_MEMORY; |
|
|
169 | |
|
|
170 | return theMap; |
|
|
171 | } |
|
|
172 | |
|
|
173 | /* function selects the layout function and gives it whatever |
|
|
174 | arguments it needs. */ |
|
|
175 | char ** |
|
|
176 | layoutgen (random_map_params *RP) |
|
|
177 | { |
|
|
178 | char **maze = 0; |
|
|
179 | int oxsize = RP->Xsize, oysize = RP->Ysize; |
|
|
180 | |
93 | |
181 | if (RP->symmetry == SYMMETRY_RANDOM) |
94 | if (RP->symmetry == SYMMETRY_RANDOM) |
182 | RP->symmetry_used = (RANDOM () % (SYMMETRY_XY)) + 1; |
95 | RP->symmetry_used = (RANDOM () % (SYMMETRY_XY)) + 1; |
183 | else |
96 | else |
184 | RP->symmetry_used = RP->symmetry; |
97 | RP->symmetry_used = RP->symmetry; |
185 | |
98 | |
186 | if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) |
99 | if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) |
187 | RP->Ysize = RP->Ysize / 2 + 1; |
100 | RP->Ysize = RP->Ysize / 2 + 1; |
|
|
101 | |
188 | if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY) |
102 | if (RP->symmetry_used == SYMMETRY_X || RP->symmetry_used == SYMMETRY_XY) |
189 | RP->Xsize = RP->Xsize / 2 + 1; |
103 | RP->Xsize = RP->Xsize / 2 + 1; |
190 | |
104 | |
191 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
105 | if (RP->expand2x > 0) |
192 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
106 | { |
193 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
107 | RP->Xsize /= 2; |
194 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
108 | RP->Ysize /= 2; |
|
|
109 | } |
|
|
110 | |
195 | RP->map_layout_style = 0; |
111 | RP->map_layout_style = LAYOUT_NONE; |
196 | |
112 | |
197 | /* 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 |
198 | * layout style and then random layout style. Instead, figure out |
114 | * layout style and then random layout style. Instead, figure out |
199 | * the numeric layoutstyle, so there is only one area that actually |
115 | * the numeric layoutstyle, so there is only one area that actually |
200 | * calls the code to make the maps. |
116 | * calls the code to make the maps. |
… | |
… | |
215 | RP->map_layout_style = LAYOUT_SNAKE; |
131 | RP->map_layout_style = LAYOUT_SNAKE; |
216 | |
132 | |
217 | if (strstr (RP->layoutstyle, "squarespiral")) |
133 | if (strstr (RP->layoutstyle, "squarespiral")) |
218 | RP->map_layout_style = LAYOUT_SQUARE_SPIRAL; |
134 | RP->map_layout_style = LAYOUT_SQUARE_SPIRAL; |
219 | |
135 | |
220 | /* No style found - choose one ranomdly */ |
136 | /* No style found - choose one randomly */ |
221 | if (RP->map_layout_style == LAYOUT_NONE) |
137 | if (RP->map_layout_style == LAYOUT_NONE) |
222 | RP->map_layout_style = (RANDOM () % (NROFLAYOUTS - 1)) + 1; |
138 | RP->map_layout_style = (RANDOM () % (NROFLAYOUTS - 1)) + 1; |
223 | |
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; |
|
|
238 | |
224 | switch (RP->map_layout_style) |
239 | switch (RP->map_layout_style) |
225 | { |
240 | { |
226 | case LAYOUT_ONION: |
241 | case LAYOUT_ONION: |
227 | 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); |
228 | if (!(RANDOM () % 3) && !(RP->layoutoptions1 & RMOPT_WALLS_ONLY)) |
243 | if (!(rndm (3)) && !(RP->layoutoptions1 & RMOPT_WALLS_ONLY)) |
229 | roomify_layout (maze, RP); |
244 | roomify_layout (maze, RP); |
230 | break; |
245 | break; |
231 | |
246 | |
232 | case LAYOUT_MAZE: |
247 | case LAYOUT_MAZE: |
233 | maze = maze_gen (RP->Xsize, RP->Ysize, RANDOM () % 2); |
248 | maze = maze_gen (RP->Xsize, RP->Ysize, rndm (2)); |
234 | if (!(RANDOM () % 2)) |
249 | if (!(rndm (2))) |
235 | doorify_layout (maze, RP); |
250 | doorify_layout (maze, RP); |
236 | break; |
251 | break; |
237 | |
252 | |
238 | case LAYOUT_SPIRAL: |
253 | case LAYOUT_SPIRAL: |
239 | maze = map_gen_spiral (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
254 | maze = map_gen_spiral (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
240 | if (!(RANDOM () % 2)) |
255 | if (!(rndm (2))) |
241 | doorify_layout (maze, RP); |
256 | doorify_layout (maze, RP); |
242 | break; |
257 | break; |
243 | |
258 | |
244 | case LAYOUT_ROGUELIKE: |
259 | case LAYOUT_ROGUELIKE: |
245 | /* 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 |
… | |
… | |
256 | /* no doorifying... done already */ |
271 | /* no doorifying... done already */ |
257 | break; |
272 | break; |
258 | |
273 | |
259 | case LAYOUT_SNAKE: |
274 | case LAYOUT_SNAKE: |
260 | maze = make_snake_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
275 | maze = make_snake_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
261 | if (RANDOM () % 2) |
276 | if (rndm (2)) |
262 | roomify_layout (maze, RP); |
277 | roomify_layout (maze, RP); |
263 | break; |
278 | break; |
264 | |
279 | |
265 | case LAYOUT_SQUARE_SPIRAL: |
280 | case LAYOUT_SQUARE_SPIRAL: |
266 | maze = make_square_spiral_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
281 | maze = make_square_spiral_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
267 | if (RANDOM () % 2) |
282 | if (rndm (2)) |
268 | roomify_layout (maze, RP); |
283 | roomify_layout (maze, RP); |
269 | break; |
284 | break; |
270 | } |
285 | } |
271 | |
286 | |
272 | maze = symmetrize_layout (maze, RP->symmetry_used, RP); |
287 | maze = symmetrize_layout (maze, RP->symmetry_used, RP); |
… | |
… | |
627 | } |
642 | } |
628 | |
643 | |
629 | void |
644 | void |
630 | write_map_parameters_to_string (char *buf, random_map_params *RP) |
645 | write_map_parameters_to_string (char *buf, random_map_params *RP) |
631 | { |
646 | { |
632 | char small_buf[256]; |
647 | char small_buf[16384]; |
633 | |
648 | |
634 | sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); |
649 | sprintf (buf, "xsize %d\nysize %d\n", RP->xsize, RP->ysize); |
635 | |
650 | |
636 | if (RP->wallstyle[0]) |
651 | if (RP->wallstyle[0]) |
637 | { |
652 | { |
638 | sprintf (small_buf, "wallstyle %s\n", RP->wallstyle); |
653 | sprintf (small_buf, "wallstyle %s\n", RP->wallstyle); |
639 | strcat (buf, small_buf); |
654 | strcat (buf, small_buf); |
… | |
… | |
679 | { |
694 | { |
680 | sprintf (small_buf, "exitstyle %s\n", RP->exitstyle); |
695 | sprintf (small_buf, "exitstyle %s\n", RP->exitstyle); |
681 | strcat (buf, small_buf); |
696 | strcat (buf, small_buf); |
682 | } |
697 | } |
683 | |
698 | |
684 | if (RP->final_map[0]) |
699 | if (RP->final_map.length ()) |
685 | { |
700 | { |
686 | sprintf (small_buf, "final_map %s\n", RP->final_map); |
701 | sprintf (small_buf, "final_map %s\n", &RP->final_map); |
687 | strcat (buf, small_buf); |
702 | strcat (buf, small_buf); |
688 | } |
703 | } |
689 | |
704 | |
690 | if (RP->exit_on_final_map[0]) |
705 | if (RP->exit_on_final_map[0]) |
691 | { |
706 | { |
692 | sprintf (small_buf, "exit_on_final_map %s\n", RP->exit_on_final_map); |
707 | sprintf (small_buf, "exit_on_final_map %s\n", RP->exit_on_final_map); |
693 | strcat (buf, small_buf); |
708 | strcat (buf, small_buf); |
694 | } |
709 | } |
695 | |
710 | |
696 | if (RP->this_map[0]) |
711 | if (RP->this_map.length ()) |
697 | { |
712 | { |
698 | sprintf (small_buf, "origin_map %s\n", RP->this_map); |
713 | sprintf (small_buf, "origin_map %s\n", &RP->this_map); |
699 | strcat (buf, small_buf); |
714 | strcat (buf, small_buf); |
700 | } |
715 | } |
701 | |
716 | |
702 | if (RP->expand2x) |
717 | if (RP->expand2x) |
703 | { |
718 | { |
… | |
… | |
709 | { |
724 | { |
710 | sprintf (small_buf, "layoutoptions1 %d\n", RP->layoutoptions1); |
725 | sprintf (small_buf, "layoutoptions1 %d\n", RP->layoutoptions1); |
711 | strcat (buf, small_buf); |
726 | strcat (buf, small_buf); |
712 | } |
727 | } |
713 | |
728 | |
714 | |
|
|
715 | if (RP->layoutoptions2) |
729 | if (RP->layoutoptions2) |
716 | { |
730 | { |
717 | sprintf (small_buf, "layoutoptions2 %d\n", RP->layoutoptions2); |
731 | sprintf (small_buf, "layoutoptions2 %d\n", RP->layoutoptions2); |
718 | strcat (buf, small_buf); |
732 | strcat (buf, small_buf); |
719 | } |
733 | } |
720 | |
734 | |
721 | |
|
|
722 | if (RP->layoutoptions3) |
735 | if (RP->layoutoptions3) |
723 | { |
736 | { |
724 | sprintf (small_buf, "layoutoptions3 %d\n", RP->layoutoptions3); |
737 | sprintf (small_buf, "layoutoptions3 %d\n", RP->layoutoptions3); |
725 | strcat (buf, small_buf); |
738 | strcat (buf, small_buf); |
726 | } |
739 | } |
… | |
… | |
728 | if (RP->symmetry) |
741 | if (RP->symmetry) |
729 | { |
742 | { |
730 | sprintf (small_buf, "symmetry %d\n", RP->symmetry); |
743 | sprintf (small_buf, "symmetry %d\n", RP->symmetry); |
731 | strcat (buf, small_buf); |
744 | strcat (buf, small_buf); |
732 | } |
745 | } |
733 | |
|
|
734 | |
746 | |
735 | if (RP->difficulty && RP->difficulty_given) |
747 | if (RP->difficulty && RP->difficulty_given) |
736 | { |
748 | { |
737 | sprintf (small_buf, "difficulty %d\n", RP->difficulty); |
749 | sprintf (small_buf, "difficulty %d\n", RP->difficulty); |
738 | strcat (buf, small_buf); |
750 | strcat (buf, small_buf); |
… | |
… | |
775 | { |
787 | { |
776 | sprintf (small_buf, "origin_y %d\n", RP->origin_y); |
788 | sprintf (small_buf, "origin_y %d\n", RP->origin_y); |
777 | strcat (buf, small_buf); |
789 | strcat (buf, small_buf); |
778 | } |
790 | } |
779 | |
791 | |
|
|
792 | if (RP->treasureoptions) |
|
|
793 | { |
|
|
794 | sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions); |
|
|
795 | strcat (buf, small_buf); |
|
|
796 | } |
|
|
797 | |
780 | if (RP->random_seed) |
798 | if (RP->random_seed) |
781 | { |
799 | { |
782 | /* Add one so that the next map is a bit different */ |
|
|
783 | sprintf (small_buf, "random_seed %d\n", RP->random_seed + 1); |
800 | sprintf (small_buf, "random_seed %u\n", RP->random_seed); |
784 | strcat (buf, small_buf); |
801 | strcat (buf, small_buf); |
785 | } |
|
|
786 | |
|
|
787 | if (RP->treasureoptions) |
|
|
788 | { |
802 | } |
789 | sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions); |
803 | |
|
|
804 | if (RP->custom) |
|
|
805 | { |
|
|
806 | sprintf (small_buf, "custom %s\n", RP->custom); |
790 | strcat (buf, small_buf); |
807 | strcat (buf, small_buf); |
791 | } |
808 | } |
792 | } |
809 | } |
793 | |
810 | |
794 | void |
811 | void |
… | |
… | |
814 | int dungeon_level_n, |
831 | int dungeon_level_n, |
815 | int difficulty_n, |
832 | int difficulty_n, |
816 | int difficulty_given_n, |
833 | int difficulty_given_n, |
817 | int decoroptions_n, |
834 | int decoroptions_n, |
818 | int orientation_n, |
835 | int orientation_n, |
819 | int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) |
836 | int origin_x_n, int origin_y_n, uint32_t random_seed_n, int treasureoptions_n, float difficulty_increase) |
820 | { |
837 | { |
821 | |
|
|
822 | char small_buf[256]; |
838 | char small_buf[16384]; |
823 | |
839 | |
824 | sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); |
840 | sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); |
825 | |
841 | |
826 | if (wallstyle_n && wallstyle_n[0]) |
842 | if (wallstyle_n && wallstyle_n[0]) |
827 | { |
843 | { |
… | |
… | |
961 | } |
977 | } |
962 | |
978 | |
963 | if (random_seed_n) |
979 | if (random_seed_n) |
964 | { |
980 | { |
965 | /* Add one so that the next map is a bit different */ |
981 | /* Add one so that the next map is a bit different */ |
966 | sprintf (small_buf, "random_seed %d\n", random_seed_n + 1); |
982 | sprintf (small_buf, "random_seed %u\n", random_seed_n + 1); |
967 | strcat (buf, small_buf); |
983 | strcat (buf, small_buf); |
968 | } |
984 | } |
969 | |
985 | |
970 | if (treasureoptions_n) |
986 | if (treasureoptions_n) |
971 | { |
987 | { |
972 | sprintf (small_buf, "treasureoptions %d\n", treasureoptions_n); |
988 | sprintf (small_buf, "treasureoptions %d\n", treasureoptions_n); |
973 | strcat (buf, small_buf); |
989 | strcat (buf, small_buf); |
974 | } |
990 | } |
975 | |
|
|
976 | |
|
|
977 | } |
991 | } |
978 | |
992 | |
979 | /* copy an object with an inventory... i.e., duplicate the inv too. */ |
993 | /* copy an object with an inventory... i.e., duplicate the inv too. */ |
980 | void |
994 | void |
981 | copy_object_with_inv (object *src_ob, object *dest_ob) |
995 | copy_object_with_inv (object *src_ob, object *dest_ob) |
982 | { |
996 | { |
983 | object *walk, *tmp; |
997 | object *walk, *tmp; |
984 | |
998 | |
985 | src_ob->copy_to (dest_ob); |
999 | src_ob->copy_to (dest_ob); |
986 | |
1000 | |
987 | for (walk = src_ob->inv; walk != NULL; walk = walk->below) |
1001 | for (walk = src_ob->inv; walk; walk = walk->below) |
988 | { |
1002 | { |
989 | tmp = object::create (); |
1003 | tmp = object::create (); |
990 | |
1004 | |
991 | walk->copy_to (tmp); |
1005 | walk->copy_to (tmp); |
992 | insert_ob_in_ob (tmp, dest_ob); |
1006 | insert_ob_in_ob (tmp, dest_ob); |