|
|
1 | |
1 | /* |
2 | /* |
2 | * static char *rcsid_random_map_c = |
3 | * static char *rcsid_random_map_c = |
3 | * "$Id: random_map.C,v 1.2 2006/08/29 08:01:36 root Exp $"; |
4 | * "$Id: random_map.C,v 1.3 2006/09/10 16:06:37 root Exp $"; |
4 | */ |
5 | */ |
5 | |
6 | |
6 | /* |
7 | /* |
7 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
8 | |
9 | |
… | |
… | |
33 | #include <room_gen.h> |
34 | #include <room_gen.h> |
34 | #include <random_map.h> |
35 | #include <random_map.h> |
35 | #include <rproto.h> |
36 | #include <rproto.h> |
36 | #include <sproto.h> |
37 | #include <sproto.h> |
37 | |
38 | |
|
|
39 | void |
38 | void dump_layout(char **layout,RMParms *RP) { |
40 | dump_layout (char **layout, RMParms * RP) |
|
|
41 | { |
|
|
42 | { |
39 | { int i,j; |
43 | int i, j; |
|
|
44 | |
40 | for(i=0;i<RP->Xsize;i++) { |
45 | for (i = 0; i < RP->Xsize; i++) |
|
|
46 | { |
41 | for(j=0;j<RP->Ysize;j++) { |
47 | for (j = 0; j < RP->Ysize; j++) |
42 | if(layout[i][j]==0) layout[i][j]=' '; |
48 | { |
|
|
49 | if (layout[i][j] == 0) |
|
|
50 | layout[i][j] = ' '; |
43 | printf("%c",layout[i][j]); |
51 | printf ("%c", layout[i][j]); |
44 | if(layout[i][j]==' ') layout[i][j]=0; |
52 | if (layout[i][j] == ' ') |
|
|
53 | layout[i][j] = 0; |
|
|
54 | } |
|
|
55 | printf ("\n"); |
45 | } |
56 | } |
|
|
57 | } |
46 | printf("\n"); |
58 | printf ("\n"); |
47 | }} |
|
|
48 | printf("\n"); |
|
|
49 | } |
59 | } |
50 | EXTERN FILE *logfile; |
60 | EXTERN FILE *logfile; |
|
|
61 | mapstruct * |
51 | mapstruct *generate_random_map(const char *OutFileName, RMParms *RP) { |
62 | generate_random_map (const char *OutFileName, RMParms * RP) |
|
|
63 | { |
52 | char **layout, buf[HUGE_BUF]; |
64 | char **layout, buf[HUGE_BUF]; |
53 | mapstruct *theMap; |
65 | mapstruct *theMap; |
54 | int i; |
66 | int i; |
55 | |
67 | |
56 | /* pick a random seed, or use the one from the input file */ |
68 | /* pick a random seed, or use the one from the input file */ |
57 | if(RP->random_seed == 0) |
69 | if (RP->random_seed == 0) |
58 | RP->random_seed=time(0); |
70 | RP->random_seed = time (0); |
59 | |
71 | |
60 | SRANDOM(RP->random_seed); |
72 | SRANDOM (RP->random_seed); |
61 | |
73 | |
62 | write_map_parameters_to_string(buf, RP); |
74 | write_map_parameters_to_string (buf, RP); |
63 | |
75 | |
64 | if(RP->difficulty==0) { |
76 | if (RP->difficulty == 0) |
|
|
77 | { |
65 | RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */ |
78 | RP->difficulty = RP->dungeon_level; /* use this instead of a map difficulty */ |
66 | if (RP->difficulty_increase > 0.001) { |
79 | if (RP->difficulty_increase > 0.001) |
|
|
80 | { |
67 | RP->difficulty = (int)((float)RP->dungeon_level * RP->difficulty_increase); |
81 | RP->difficulty = (int) ((float) RP->dungeon_level * RP->difficulty_increase); |
68 | if (RP->difficulty < 1) RP->difficulty=1; |
82 | if (RP->difficulty < 1) |
|
|
83 | RP->difficulty = 1; |
69 | } |
84 | } |
70 | } |
85 | } |
71 | else |
86 | else |
72 | RP->difficulty_given=1; |
87 | RP->difficulty_given = 1; |
73 | |
88 | |
74 | if(RP->Xsize<MIN_RANDOM_MAP_SIZE) RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM()%25 + 5; |
89 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
75 | if(RP->Ysize<MIN_RANDOM_MAP_SIZE) RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM()%25 + 5; |
90 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
|
|
91 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
|
|
92 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 25 + 5; |
76 | |
93 | |
77 | if(RP->expand2x > 0) { |
94 | if (RP->expand2x > 0) |
|
|
95 | { |
78 | RP->Xsize /=2; |
96 | RP->Xsize /= 2; |
79 | RP->Ysize /=2; |
97 | RP->Ysize /= 2; |
80 | } |
98 | } |
81 | |
99 | |
82 | layout = layoutgen(RP); |
100 | layout = layoutgen (RP); |
83 | |
101 | |
84 | #ifdef RMAP_DEBUG |
102 | #ifdef RMAP_DEBUG |
85 | dump_layout(layout,RP); |
103 | dump_layout (layout, RP); |
86 | #endif |
104 | #endif |
87 | |
105 | |
88 | /* increment these for the current map */ |
106 | /* increment these for the current map */ |
89 | RP->dungeon_level+=1; |
107 | RP->dungeon_level += 1; |
90 | /* allow constant-difficulty maps. */ |
108 | /* allow constant-difficulty maps. */ |
91 | /* difficulty+=1; */ |
109 | /* difficulty+=1; */ |
92 | |
110 | |
93 | /* rotate the layout randomly */ |
111 | /* rotate the layout randomly */ |
94 | layout=rotate_layout(layout,RANDOM()%4,RP); |
112 | layout = rotate_layout (layout, RANDOM () % 4, RP); |
95 | #ifdef RMAP_DEBUG |
113 | #ifdef RMAP_DEBUG |
96 | dump_layout(layout,RP); |
114 | dump_layout (layout, RP); |
97 | #endif |
115 | #endif |
98 | |
116 | |
99 | /* allocate the map and set the floor */ |
117 | /* allocate the map and set the floor */ |
100 | theMap = make_map_floor(layout,RP->floorstyle,RP); |
118 | theMap = make_map_floor (layout, RP->floorstyle, RP); |
101 | |
119 | |
102 | /* set the name of the map. */ |
120 | /* set the name of the map. */ |
103 | strcpy(theMap->path,OutFileName); |
121 | strcpy (theMap->path, OutFileName); |
104 | |
122 | |
105 | /* set region */ |
123 | /* set region */ |
106 | theMap->region=RP->region; |
124 | theMap->region = RP->region; |
107 | |
125 | |
108 | /* create walls unless the wallstyle is "none" */ |
126 | /* create walls unless the wallstyle is "none" */ |
109 | if (strcmp (RP->wallstyle, "none")) { |
127 | if (strcmp (RP->wallstyle, "none")) |
|
|
128 | { |
110 | make_map_walls(theMap,layout,RP->wallstyle,RP); |
129 | make_map_walls (theMap, layout, RP->wallstyle, RP); |
111 | |
130 | |
112 | /* place doors unless doorstyle or wallstyle is "none"*/ |
131 | /* place doors unless doorstyle or wallstyle is "none" */ |
113 | if (strcmp (RP->doorstyle, "none")) |
132 | if (strcmp (RP->doorstyle, "none")) |
114 | put_doors(theMap,layout,RP->doorstyle,RP); |
133 | put_doors (theMap, layout, RP->doorstyle, RP); |
115 | |
|
|
116 | } |
|
|
117 | |
134 | |
|
|
135 | } |
|
|
136 | |
118 | /* create exits unless the exitstyle is "none" */ |
137 | /* create exits unless the exitstyle is "none" */ |
119 | if (strcmp (RP->exitstyle, "none")) |
138 | if (strcmp (RP->exitstyle, "none")) |
120 | place_exits(theMap,layout,RP->exitstyle,RP->orientation,RP); |
139 | place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); |
121 | |
140 | |
122 | place_specials_in_map(theMap,layout,RP); |
141 | place_specials_in_map (theMap, layout, RP); |
123 | |
142 | |
124 | /* create monsters unless the monsterstyle is "none" */ |
143 | /* create monsters unless the monsterstyle is "none" */ |
125 | if (strcmp (RP->monsterstyle, "none")) |
144 | if (strcmp (RP->monsterstyle, "none")) |
126 | place_monsters(theMap,RP->monsterstyle,RP->difficulty,RP); |
145 | place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); |
127 | |
146 | |
128 | /* treasures needs to have a proper difficulty set for the map. */ |
147 | /* treasures needs to have a proper difficulty set for the map. */ |
129 | theMap->difficulty=calculate_difficulty(theMap); |
148 | theMap->difficulty = calculate_difficulty (theMap); |
130 | |
149 | |
131 | /* create treasure unless the treasurestyle is "none" */ |
150 | /* create treasure unless the treasurestyle is "none" */ |
132 | if (strcmp (RP->treasurestyle, "none")) |
151 | if (strcmp (RP->treasurestyle, "none")) |
133 | place_treasure(theMap,layout,RP->treasurestyle,RP->treasureoptions,RP); |
152 | place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); |
134 | |
153 | |
135 | /* create decor unless the decorstyle is "none" */ |
154 | /* create decor unless the decorstyle is "none" */ |
136 | if (strcmp (RP->decorstyle, "none")) |
155 | if (strcmp (RP->decorstyle, "none")) |
137 | put_decor(theMap,layout,RP->decorstyle,RP->decoroptions,RP); |
156 | put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); |
138 | |
157 | |
139 | /* generate treasures, etc. */ |
158 | /* generate treasures, etc. */ |
140 | fix_auto_apply(theMap); |
159 | fix_auto_apply (theMap); |
141 | |
160 | |
142 | unblock_exits(theMap,layout,RP); |
161 | unblock_exits (theMap, layout, RP); |
143 | |
162 | |
144 | /* free the layout */ |
163 | /* free the layout */ |
145 | for(i=0;i<RP->Xsize;i++) |
164 | for (i = 0; i < RP->Xsize; i++) |
146 | free(layout[i]); |
165 | free (layout[i]); |
147 | free(layout); |
166 | free (layout); |
148 | |
167 | |
149 | theMap->msg = strdup_local(buf); |
168 | theMap->msg = strdup_local (buf); |
150 | |
169 | |
151 | return theMap; |
170 | return theMap; |
152 | } |
171 | } |
153 | |
172 | |
154 | |
173 | |
155 | /* function selects the layout function and gives it whatever |
174 | /* function selects the layout function and gives it whatever |
156 | arguments it needs. */ |
175 | arguments it needs. */ |
|
|
176 | char ** |
157 | char **layoutgen(RMParms *RP) { |
177 | layoutgen (RMParms * RP) |
|
|
178 | { |
158 | char **maze=0; |
179 | char **maze = 0; |
159 | int oxsize= RP->Xsize, oysize=RP->Ysize; |
180 | int oxsize = RP->Xsize, oysize = RP->Ysize; |
160 | |
181 | |
161 | if(RP->symmetry == RANDOM_SYM) |
182 | if (RP->symmetry == RANDOM_SYM) |
162 | RP->symmetry_used = (RANDOM() % ( XY_SYM))+1; |
183 | RP->symmetry_used = (RANDOM () % (XY_SYM)) + 1; |
|
|
184 | else |
163 | else RP->symmetry_used = RP->symmetry; |
185 | RP->symmetry_used = RP->symmetry; |
164 | |
186 | |
165 | if(RP->symmetry_used==Y_SYM||RP->symmetry_used==XY_SYM) RP->Ysize = RP->Ysize/2+1; |
187 | if (RP->symmetry_used == Y_SYM || RP->symmetry_used == XY_SYM) |
|
|
188 | RP->Ysize = RP->Ysize / 2 + 1; |
166 | if(RP->symmetry_used==X_SYM||RP->symmetry_used==XY_SYM) RP->Xsize = RP->Xsize/2+1; |
189 | if (RP->symmetry_used == X_SYM || RP->symmetry_used == XY_SYM) |
|
|
190 | RP->Xsize = RP->Xsize / 2 + 1; |
167 | |
191 | |
168 | if(RP->Xsize<MIN_RANDOM_MAP_SIZE) RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM()%5; |
192 | if (RP->Xsize < MIN_RANDOM_MAP_SIZE) |
169 | if(RP->Ysize<MIN_RANDOM_MAP_SIZE) RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM()%5; |
193 | RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
|
|
194 | if (RP->Ysize < MIN_RANDOM_MAP_SIZE) |
|
|
195 | RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM () % 5; |
170 | RP->map_layout_style = 0; |
196 | RP->map_layout_style = 0; |
171 | |
197 | |
172 | /* Redo this - there was a lot of redundant code of checking for preset |
198 | /* Redo this - there was a lot of redundant code of checking for preset |
173 | * layout style and then random layout style. Instead, figure out |
199 | * layout style and then random layout style. Instead, figure out |
174 | * the numeric layoutstyle, so there is only one area that actually |
200 | * the numeric layoutstyle, so there is only one area that actually |
175 | * calls the code to make the maps. |
201 | * calls the code to make the maps. |
176 | */ |
202 | */ |
177 | if(strstr(RP->layoutstyle,"onion")) { |
203 | if (strstr (RP->layoutstyle, "onion")) |
|
|
204 | { |
178 | RP->map_layout_style = ONION_LAYOUT; |
205 | RP->map_layout_style = ONION_LAYOUT; |
179 | } |
206 | } |
180 | |
207 | |
181 | if(strstr(RP->layoutstyle,"maze")) { |
208 | if (strstr (RP->layoutstyle, "maze")) |
|
|
209 | { |
182 | RP->map_layout_style = MAZE_LAYOUT; |
210 | RP->map_layout_style = MAZE_LAYOUT; |
183 | } |
211 | } |
184 | |
212 | |
185 | if(strstr(RP->layoutstyle,"spiral")) { |
213 | if (strstr (RP->layoutstyle, "spiral")) |
|
|
214 | { |
186 | RP->map_layout_style = SPIRAL_LAYOUT; |
215 | RP->map_layout_style = SPIRAL_LAYOUT; |
187 | } |
216 | } |
188 | |
217 | |
189 | if(strstr(RP->layoutstyle,"rogue")) { |
218 | if (strstr (RP->layoutstyle, "rogue")) |
|
|
219 | { |
190 | RP->map_layout_style = ROGUELIKE_LAYOUT; |
220 | RP->map_layout_style = ROGUELIKE_LAYOUT; |
191 | } |
221 | } |
192 | |
222 | |
193 | if(strstr(RP->layoutstyle,"snake")) { |
223 | if (strstr (RP->layoutstyle, "snake")) |
|
|
224 | { |
194 | RP->map_layout_style = SNAKE_LAYOUT; |
225 | RP->map_layout_style = SNAKE_LAYOUT; |
195 | } |
226 | } |
196 | |
227 | |
197 | if(strstr(RP->layoutstyle,"squarespiral")) { |
228 | if (strstr (RP->layoutstyle, "squarespiral")) |
|
|
229 | { |
198 | RP->map_layout_style = SQUARE_SPIRAL_LAYOUT; |
230 | RP->map_layout_style = SQUARE_SPIRAL_LAYOUT; |
199 | } |
231 | } |
200 | /* No style found - choose one ranomdly */ |
232 | /* No style found - choose one ranomdly */ |
201 | if (RP->map_layout_style == 0) { |
233 | if (RP->map_layout_style == 0) |
|
|
234 | { |
202 | RP->map_layout_style = (RANDOM() % NROFLAYOUTS) + 1; |
235 | RP->map_layout_style = (RANDOM () % NROFLAYOUTS) + 1; |
203 | } |
236 | } |
204 | |
237 | |
205 | switch(RP->map_layout_style) { |
238 | switch (RP->map_layout_style) |
|
|
239 | { |
206 | |
240 | |
207 | case ONION_LAYOUT: |
241 | case ONION_LAYOUT: |
208 | 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); |
209 | if(!(RANDOM()%3)&& !(RP->layoutoptions1 & OPT_WALLS_ONLY)) roomify_layout(maze,RP); |
243 | if (!(RANDOM () % 3) && !(RP->layoutoptions1 & OPT_WALLS_ONLY)) |
|
|
244 | roomify_layout (maze, RP); |
210 | break; |
245 | break; |
211 | |
246 | |
212 | case MAZE_LAYOUT: |
247 | case MAZE_LAYOUT: |
213 | maze = maze_gen(RP->Xsize,RP->Ysize,RANDOM()%2); |
248 | maze = maze_gen (RP->Xsize, RP->Ysize, RANDOM () % 2); |
|
|
249 | if (!(RANDOM () % 2)) |
214 | if(!(RANDOM()%2)) doorify_layout(maze,RP); |
250 | doorify_layout (maze, RP); |
215 | break; |
251 | break; |
216 | |
252 | |
217 | case SPIRAL_LAYOUT: |
253 | case SPIRAL_LAYOUT: |
218 | maze = map_gen_spiral(RP->Xsize,RP->Ysize,RP->layoutoptions1); |
254 | maze = map_gen_spiral (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
|
|
255 | if (!(RANDOM () % 2)) |
219 | if(!(RANDOM()%2)) doorify_layout(maze,RP); |
256 | doorify_layout (maze, RP); |
220 | break; |
257 | break; |
221 | |
258 | |
222 | case ROGUELIKE_LAYOUT: |
259 | case ROGUELIKE_LAYOUT: |
223 | /* 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 |
224 | * do so in the first place (doesn't make it any more interesting), |
261 | * do so in the first place (doesn't make it any more interesting), |
225 | * but more importantly, the symmetry code presumes we are symmetrizing |
262 | * but more importantly, the symmetry code presumes we are symmetrizing |
226 | * spirals, or maps with lots of passages - making a symmetric rogue |
263 | * spirals, or maps with lots of passages - making a symmetric rogue |
227 | * map fails because its likely that the passages the symmetry process |
264 | * map fails because its likely that the passages the symmetry process |
228 | * creates may not connect the rooms. |
265 | * creates may not connect the rooms. |
229 | */ |
266 | */ |
230 | RP->symmetry_used = NO_SYM; |
267 | RP->symmetry_used = NO_SYM; |
231 | RP->Ysize = oysize; |
268 | RP->Ysize = oysize; |
232 | RP->Xsize = oxsize; |
269 | RP->Xsize = oxsize; |
233 | maze = roguelike_layout_gen(RP->Xsize,RP->Ysize,RP->layoutoptions1); |
270 | maze = roguelike_layout_gen (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
234 | /* no doorifying... done already */ |
271 | /* no doorifying... done already */ |
235 | break; |
272 | break; |
236 | |
273 | |
237 | case SNAKE_LAYOUT: |
274 | case SNAKE_LAYOUT: |
238 | maze = make_snake_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1); |
275 | maze = make_snake_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
|
|
276 | if (RANDOM () % 2) |
239 | if(RANDOM()%2) roomify_layout(maze,RP); |
277 | roomify_layout (maze, RP); |
240 | break; |
278 | break; |
241 | |
279 | |
242 | case SQUARE_SPIRAL_LAYOUT: |
280 | case SQUARE_SPIRAL_LAYOUT: |
243 | maze = make_square_spiral_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1); |
281 | maze = make_square_spiral_layout (RP->Xsize, RP->Ysize, RP->layoutoptions1); |
|
|
282 | if (RANDOM () % 2) |
244 | if(RANDOM()%2) roomify_layout(maze,RP); |
283 | roomify_layout (maze, RP); |
245 | break; |
284 | break; |
246 | } |
285 | } |
247 | |
286 | |
248 | maze = symmetrize_layout(maze, RP->symmetry_used,RP); |
287 | maze = symmetrize_layout (maze, RP->symmetry_used, RP); |
249 | #ifdef RMAP_DEBUG |
288 | #ifdef RMAP_DEBUG |
250 | dump_layout(maze,RP); |
289 | dump_layout (maze, RP); |
251 | #endif |
290 | #endif |
252 | if(RP->expand2x) { |
291 | if (RP->expand2x) |
|
|
292 | { |
253 | maze = expand2x(maze,RP->Xsize,RP->Ysize); |
293 | maze = expand2x (maze, RP->Xsize, RP->Ysize); |
254 | RP->Xsize = RP->Xsize * 2 -1; |
294 | RP->Xsize = RP->Xsize * 2 - 1; |
255 | RP->Ysize = RP->Ysize * 2 -1; |
295 | RP->Ysize = RP->Ysize * 2 - 1; |
256 | } |
296 | } |
257 | return maze; |
297 | return maze; |
258 | } |
298 | } |
259 | |
299 | |
260 | |
300 | |
261 | /* takes a map and makes it symmetric: adjusts Xsize and |
301 | /* takes a map and makes it symmetric: adjusts Xsize and |
262 | Ysize to produce a symmetric map. */ |
302 | Ysize to produce a symmetric map. */ |
263 | |
303 | |
|
|
304 | char ** |
264 | char **symmetrize_layout(char **maze, int sym,RMParms *RP) { |
305 | symmetrize_layout (char **maze, int sym, RMParms * RP) |
|
|
306 | { |
265 | int i,j; |
307 | int i, j; |
266 | char **sym_maze; |
308 | char **sym_maze; |
267 | int Xsize_orig,Ysize_orig; |
309 | int Xsize_orig, Ysize_orig; |
|
|
310 | |
268 | Xsize_orig = RP->Xsize; |
311 | Xsize_orig = RP->Xsize; |
269 | Ysize_orig = RP->Ysize; |
312 | Ysize_orig = RP->Ysize; |
270 | RP->symmetry_used = sym; /* tell everyone else what sort of symmetry is used.*/ |
313 | RP->symmetry_used = sym; /* tell everyone else what sort of symmetry is used. */ |
271 | if(sym == NO_SYM) { |
314 | if (sym == NO_SYM) |
|
|
315 | { |
272 | RP->Xsize = Xsize_orig; |
316 | RP->Xsize = Xsize_orig; |
273 | RP->Ysize = Ysize_orig; |
317 | RP->Ysize = Ysize_orig; |
274 | return maze; |
318 | return maze; |
275 | } |
319 | } |
276 | /* pick new sizes */ |
320 | /* pick new sizes */ |
277 | RP->Xsize = ((sym==X_SYM||sym==XY_SYM)?RP->Xsize*2-3:RP->Xsize); |
321 | RP->Xsize = ((sym == X_SYM || sym == XY_SYM) ? RP->Xsize * 2 - 3 : RP->Xsize); |
278 | RP->Ysize = ((sym==Y_SYM||sym==XY_SYM)?RP->Ysize*2-3:RP->Ysize); |
322 | RP->Ysize = ((sym == Y_SYM || sym == XY_SYM) ? RP->Ysize * 2 - 3 : RP->Ysize); |
279 | |
323 | |
280 | sym_maze = (char **)calloc(sizeof(char*),RP->Xsize); |
324 | sym_maze = (char **) calloc (sizeof (char *), RP->Xsize); |
281 | for(i=0;i<RP->Xsize;i++) |
325 | for (i = 0; i < RP->Xsize; i++) |
282 | sym_maze[i] = (char *)calloc(sizeof(char),RP->Ysize); |
326 | sym_maze[i] = (char *) calloc (sizeof (char), RP->Ysize); |
283 | |
327 | |
284 | if(sym==X_SYM) |
328 | if (sym == X_SYM) |
285 | for(i=0;i<RP->Xsize/2+1;i++) |
329 | for (i = 0; i < RP->Xsize / 2 + 1; i++) |
286 | for(j=0;j<RP->Ysize;j++) { |
330 | for (j = 0; j < RP->Ysize; j++) |
|
|
331 | { |
287 | sym_maze[i][j] = maze[i][j]; |
332 | sym_maze[i][j] = maze[i][j]; |
288 | sym_maze[RP->Xsize - i-1][j] = maze[i][j]; |
333 | sym_maze[RP->Xsize - i - 1][j] = maze[i][j]; |
289 | }; |
334 | }; |
290 | if(sym==Y_SYM) |
335 | if (sym == Y_SYM) |
291 | for(i=0;i<RP->Xsize;i++) |
336 | for (i = 0; i < RP->Xsize; i++) |
292 | for(j=0;j<RP->Ysize/2+1;j++) { |
337 | for (j = 0; j < RP->Ysize / 2 + 1; j++) |
|
|
338 | { |
293 | sym_maze[i][j] = maze[i][j]; |
339 | sym_maze[i][j] = maze[i][j]; |
294 | sym_maze[i][RP->Ysize-j-1] = maze[i][j]; |
340 | sym_maze[i][RP->Ysize - j - 1] = maze[i][j]; |
295 | } |
341 | } |
296 | if(sym==XY_SYM) |
342 | if (sym == XY_SYM) |
297 | for(i=0;i<RP->Xsize/2+1;i++) |
343 | for (i = 0; i < RP->Xsize / 2 + 1; i++) |
298 | for(j=0;j<RP->Ysize/2+1;j++) { |
344 | for (j = 0; j < RP->Ysize / 2 + 1; j++) |
|
|
345 | { |
299 | sym_maze[i][j] = maze[i][j]; |
346 | sym_maze[i][j] = maze[i][j]; |
300 | sym_maze[i][RP->Ysize-j-1] = maze[i][j]; |
347 | sym_maze[i][RP->Ysize - j - 1] = maze[i][j]; |
301 | sym_maze[RP->Xsize - i-1][j] = maze[i][j]; |
348 | sym_maze[RP->Xsize - i - 1][j] = maze[i][j]; |
302 | sym_maze[RP->Xsize - i-1][RP->Ysize-j-1] = maze[i][j]; |
349 | sym_maze[RP->Xsize - i - 1][RP->Ysize - j - 1] = maze[i][j]; |
303 | } |
350 | } |
304 | /* delete the old maze */ |
351 | /* delete the old maze */ |
305 | for(i=0;i<Xsize_orig;i++) |
352 | for (i = 0; i < Xsize_orig; i++) |
306 | free(maze[i]); |
353 | free (maze[i]); |
307 | free(maze); |
354 | free (maze); |
308 | /* reconnect disjointed spirals */ |
355 | /* reconnect disjointed spirals */ |
309 | if(RP->map_layout_style==SPIRAL_LAYOUT) |
356 | if (RP->map_layout_style == SPIRAL_LAYOUT) |
310 | connect_spirals(RP->Xsize,RP->Ysize,sym,sym_maze); |
357 | connect_spirals (RP->Xsize, RP->Ysize, sym, sym_maze); |
311 | /* reconnect disjointed nethackmazes: the routine for |
358 | /* reconnect disjointed nethackmazes: the routine for |
312 | spirals will do the trick?*/ |
359 | spirals will do the trick? */ |
313 | if(RP->map_layout_style==ROGUELIKE_LAYOUT) |
360 | if (RP->map_layout_style == ROGUELIKE_LAYOUT) |
314 | connect_spirals(RP->Xsize,RP->Ysize,sym,sym_maze); |
361 | connect_spirals (RP->Xsize, RP->Ysize, sym, sym_maze); |
315 | |
362 | |
316 | return sym_maze; |
363 | return sym_maze; |
317 | } |
364 | } |
318 | |
365 | |
319 | |
366 | |
320 | /* takes a map and rotates it. This completes the |
367 | /* takes a map and rotates it. This completes the |
321 | onion layouts, making them possibly centered on any wall. |
368 | onion layouts, making them possibly centered on any wall. |
322 | It'll modify Xsize and Ysize if they're swapped. |
369 | It'll modify Xsize and Ysize if they're swapped. |
323 | */ |
370 | */ |
324 | |
371 | |
|
|
372 | char ** |
325 | char ** rotate_layout(char **maze,int rotation,RMParms *RP) { |
373 | rotate_layout (char **maze, int rotation, RMParms * RP) |
|
|
374 | { |
326 | char **new_maze; |
375 | char **new_maze; |
327 | int i,j; |
376 | int i, j; |
328 | |
377 | |
329 | switch(rotation) { |
378 | switch (rotation) |
|
|
379 | { |
330 | case 0: |
380 | case 0: |
331 | return maze; |
381 | return maze; |
332 | break; |
382 | break; |
333 | case 2: /* a reflection */ |
383 | case 2: /* a reflection */ |
334 | { |
384 | { |
335 | char *newmaze= (char *) malloc(sizeof(char) * RP->Xsize*RP->Ysize); |
385 | char *newmaze = (char *) malloc (sizeof (char) * RP->Xsize * RP->Ysize); |
336 | for(i=0;i<RP->Xsize;i++) { /* make a copy */ |
386 | |
|
|
387 | for (i = 0; i < RP->Xsize; i++) |
|
|
388 | { /* make a copy */ |
337 | for(j=0;j<RP->Ysize;j++) { |
389 | for (j = 0; j < RP->Ysize; j++) |
|
|
390 | { |
338 | newmaze[i * RP->Ysize + j] = maze[i][j]; |
391 | newmaze[i * RP->Ysize + j] = maze[i][j]; |
|
|
392 | } |
|
|
393 | } |
|
|
394 | for (i = 0; i < RP->Xsize; i++) |
|
|
395 | { /* copy a reflection back */ |
|
|
396 | for (j = 0; j < RP->Ysize; j++) |
|
|
397 | { |
|
|
398 | maze[i][j] = newmaze[(RP->Xsize - i - 1) * RP->Ysize + RP->Ysize - j - 1]; |
|
|
399 | } |
|
|
400 | } |
|
|
401 | free (newmaze); |
|
|
402 | return maze; |
|
|
403 | break; |
339 | } |
404 | } |
340 | } |
405 | case 1: |
341 | for(i=0;i<RP->Xsize;i++) { /* copy a reflection back */ |
406 | case 3: |
342 | for(j=0;j<RP->Ysize;j++) { |
|
|
343 | maze[i][j]= newmaze[(RP->Xsize-i-1)*RP->Ysize + RP->Ysize-j-1]; |
|
|
344 | } |
407 | { |
345 | } |
|
|
346 | free(newmaze); |
|
|
347 | return maze; |
|
|
348 | break; |
|
|
349 | } |
|
|
350 | case 1: |
|
|
351 | case 3: |
|
|
352 | { int swap; |
408 | int swap; |
353 | new_maze = (char **) calloc(sizeof(char *),RP->Ysize); |
409 | new_maze = (char **) calloc (sizeof (char *), RP->Ysize); |
354 | for(i=0;i<RP->Ysize;i++) { |
410 | for (i = 0; i < RP->Ysize; i++) |
|
|
411 | { |
355 | new_maze[i] = (char *) calloc(sizeof(char),RP->Xsize); |
412 | new_maze[i] = (char *) calloc (sizeof (char), RP->Xsize); |
356 | } |
413 | } |
357 | if(rotation == 1) /* swap x and y */ |
414 | if (rotation == 1) /* swap x and y */ |
358 | for(i=0;i<RP->Xsize;i++) |
415 | for (i = 0; i < RP->Xsize; i++) |
359 | for(j=0;j<RP->Ysize;j++) |
416 | for (j = 0; j < RP->Ysize; j++) |
360 | new_maze[j][i] = maze[i][j]; |
417 | new_maze[j][i] = maze[i][j]; |
361 | |
418 | |
362 | if(rotation == 3) { /* swap x and y */ |
419 | if (rotation == 3) |
|
|
420 | { /* swap x and y */ |
363 | for(i=0;i<RP->Xsize;i++) |
421 | for (i = 0; i < RP->Xsize; i++) |
364 | for(j=0;j<RP->Ysize;j++) |
422 | for (j = 0; j < RP->Ysize; j++) |
365 | new_maze[j][i] = maze[RP->Xsize -i-1][RP->Ysize - j-1]; |
423 | new_maze[j][i] = maze[RP->Xsize - i - 1][RP->Ysize - j - 1]; |
366 | } |
424 | } |
367 | |
425 | |
368 | /* delete the old layout */ |
426 | /* delete the old layout */ |
369 | for(i=0;i<RP->Xsize;i++) |
427 | for (i = 0; i < RP->Xsize; i++) |
370 | free(maze[i]); |
428 | free (maze[i]); |
371 | free(maze); |
429 | free (maze); |
372 | |
430 | |
373 | swap = RP->Ysize; |
431 | swap = RP->Ysize; |
374 | RP->Ysize = RP->Xsize; |
432 | RP->Ysize = RP->Xsize; |
375 | RP->Xsize = swap; |
433 | RP->Xsize = swap; |
376 | return new_maze; |
434 | return new_maze; |
377 | break; |
435 | break; |
378 | } |
436 | } |
379 | } |
437 | } |
380 | return NULL; |
438 | return NULL; |
381 | } |
439 | } |
382 | |
440 | |
383 | /* take a layout and make some rooms in it. |
441 | /* take a layout and make some rooms in it. |
384 | --works best on onions.*/ |
442 | --works best on onions.*/ |
|
|
443 | void |
385 | void roomify_layout(char **maze,RMParms *RP) { |
444 | roomify_layout (char **maze, RMParms * RP) |
|
|
445 | { |
386 | int tries = RP->Xsize*RP->Ysize/30; |
446 | int tries = RP->Xsize * RP->Ysize / 30; |
387 | int ti; |
447 | int ti; |
388 | |
448 | |
389 | for(ti=0;ti<tries;ti++) { |
449 | for (ti = 0; ti < tries; ti++) |
|
|
450 | { |
390 | int dx,dy; /* starting location for looking at creating a door */ |
451 | int dx, dy; /* starting location for looking at creating a door */ |
391 | int cx,cy; /* results of checking on creating walls. */ |
452 | int cx, cy; /* results of checking on creating walls. */ |
|
|
453 | |
392 | dx = RANDOM() % RP->Xsize; |
454 | dx = RANDOM () % RP->Xsize; |
393 | dy = RANDOM() % RP->Ysize; |
455 | dy = RANDOM () % RP->Ysize; |
394 | cx = can_make_wall(maze,dx,dy,0,RP); /* horizontal */ |
456 | cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */ |
395 | cy = can_make_wall(maze,dx,dy,1,RP); /* vertical */ |
457 | cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */ |
396 | if(cx == -1) { |
458 | if (cx == -1) |
|
|
459 | { |
|
|
460 | if (cy != -1) |
|
|
461 | make_wall (maze, dx, dy, 1); |
|
|
462 | continue; |
|
|
463 | } |
397 | if(cy != -1) |
464 | if (cy == -1) |
|
|
465 | { |
|
|
466 | make_wall (maze, dx, dy, 0); |
|
|
467 | continue; |
|
|
468 | } |
|
|
469 | if (cx < cy) |
|
|
470 | make_wall (maze, dx, dy, 0); |
|
|
471 | else |
398 | make_wall(maze,dx,dy,1); |
472 | make_wall (maze, dx, dy, 1); |
399 | continue; |
|
|
400 | } |
|
|
401 | if(cy == -1) { |
|
|
402 | make_wall(maze,dx,dy,0); |
|
|
403 | continue; |
|
|
404 | } |
|
|
405 | if(cx < cy) make_wall(maze,dx,dy,0); |
|
|
406 | else make_wall(maze,dx,dy,1); |
|
|
407 | } |
473 | } |
408 | } |
474 | } |
409 | |
475 | |
410 | /* checks the layout to see if I can stick a horizontal(dir = 0) wall |
476 | /* checks the layout to see if I can stick a horizontal(dir = 0) wall |
411 | (or vertical, dir == 1) |
477 | (or vertical, dir == 1) |
412 | here which ends up on other walls sensibly. */ |
478 | here which ends up on other walls sensibly. */ |
413 | |
479 | |
|
|
480 | int |
414 | int can_make_wall(char **maze,int dx,int dy,int dir,RMParms *RP) { |
481 | can_make_wall (char **maze, int dx, int dy, int dir, RMParms * RP) |
|
|
482 | { |
415 | int i1; |
483 | int i1; |
416 | int length=0; |
484 | int length = 0; |
417 | |
485 | |
418 | /* dont make walls if we're on the edge. */ |
486 | /* dont make walls if we're on the edge. */ |
419 | if(dx == 0 || dx == (RP->Xsize -1) || dy == 0 || dy == (RP->Ysize-1)) return -1; |
487 | if (dx == 0 || dx == (RP->Xsize - 1) || dy == 0 || dy == (RP->Ysize - 1)) |
|
|
488 | return -1; |
420 | |
489 | |
421 | /* don't make walls if we're ON a wall. */ |
490 | /* don't make walls if we're ON a wall. */ |
422 | if(maze[dx][dy]!=0) return -1; |
491 | if (maze[dx][dy] != 0) |
|
|
492 | return -1; |
423 | |
493 | |
424 | if(dir==0) /* horizontal */ |
494 | if (dir == 0) /* horizontal */ |
425 | { |
495 | { |
426 | int y = dy; |
496 | int y = dy; |
|
|
497 | |
427 | for(i1=dx-1;i1>0;i1--) { |
498 | for (i1 = dx - 1; i1 > 0; i1--) |
|
|
499 | { |
428 | int sindex=surround_flag2(maze,i1,y,RP); |
500 | int sindex = surround_flag2 (maze, i1, y, RP); |
|
|
501 | |
429 | if(sindex == 1) break; |
502 | if (sindex == 1) |
|
|
503 | break; |
|
|
504 | if (sindex != 0) |
430 | if(sindex != 0) return -1; /* can't make horiz. wall here */ |
505 | return -1; /* can't make horiz. wall here */ |
|
|
506 | if (maze[i1][y] != 0) |
431 | if(maze[i1][y]!=0) return -1; /* can't make horiz. wall here */ |
507 | return -1; /* can't make horiz. wall here */ |
432 | length++; |
508 | length++; |
433 | } |
|
|
434 | |
509 | } |
|
|
510 | |
435 | for(i1=dx+1;i1<RP->Xsize-1;i1++) { |
511 | for (i1 = dx + 1; i1 < RP->Xsize - 1; i1++) |
|
|
512 | { |
436 | int sindex=surround_flag2(maze,i1,y,RP); |
513 | int sindex = surround_flag2 (maze, i1, y, RP); |
|
|
514 | |
437 | if(sindex == 2) break; |
515 | if (sindex == 2) |
|
|
516 | break; |
|
|
517 | if (sindex != 0) |
438 | if(sindex != 0) return -1; /* can't make horiz. wall here */ |
518 | return -1; /* can't make horiz. wall here */ |
|
|
519 | if (maze[i1][y] != 0) |
439 | if(maze[i1][y]!=0) return -1; /* can't make horiz. wall here */ |
520 | return -1; /* can't make horiz. wall here */ |
440 | length++; |
521 | length++; |
441 | } |
522 | } |
442 | return length; |
523 | return length; |
443 | } |
524 | } |
444 | else { /* vertical */ |
525 | else |
|
|
526 | { /* vertical */ |
445 | int x = dx; |
527 | int x = dx; |
|
|
528 | |
446 | for(i1=dy-1;i1>0;i1--) { |
529 | for (i1 = dy - 1; i1 > 0; i1--) |
447 | int sindex=surround_flag2(maze,x,i1,RP); |
|
|
448 | if(sindex == 4) break; |
|
|
449 | if(sindex != 0) return -1; /* can't make vert. wall here */ |
|
|
450 | if(maze[x][i1]!=0) return -1; /* can't make horiz. wall here */ |
|
|
451 | length++; |
|
|
452 | } |
|
|
453 | |
530 | { |
454 | for(i1=dy+1;i1<RP->Ysize-1;i1++) { |
|
|
455 | int sindex=surround_flag2(maze,x,i1,RP); |
531 | int sindex = surround_flag2 (maze, x, i1, RP); |
456 | if(sindex == 8) break; |
532 | |
|
|
533 | if (sindex == 4) |
|
|
534 | break; |
|
|
535 | if (sindex != 0) |
457 | if(sindex != 0) return -1; /* can't make verti. wall here */ |
536 | return -1; /* can't make vert. wall here */ |
|
|
537 | if (maze[x][i1] != 0) |
458 | if(maze[x][i1]!=0) return -1; /* can't make horiz. wall here */ |
538 | return -1; /* can't make horiz. wall here */ |
459 | length++; |
539 | length++; |
460 | } |
540 | } |
|
|
541 | |
|
|
542 | for (i1 = dy + 1; i1 < RP->Ysize - 1; i1++) |
|
|
543 | { |
|
|
544 | int sindex = surround_flag2 (maze, x, i1, RP); |
|
|
545 | |
|
|
546 | if (sindex == 8) |
|
|
547 | break; |
|
|
548 | if (sindex != 0) |
|
|
549 | return -1; /* can't make verti. wall here */ |
|
|
550 | if (maze[x][i1] != 0) |
|
|
551 | return -1; /* can't make horiz. wall here */ |
|
|
552 | length++; |
|
|
553 | } |
461 | return length; |
554 | return length; |
462 | } |
555 | } |
463 | return -1; |
556 | return -1; |
464 | } |
557 | } |
465 | |
558 | |
466 | |
559 | |
|
|
560 | int |
467 | int make_wall(char **maze,int x, int y, int dir){ |
561 | make_wall (char **maze, int x, int y, int dir) |
|
|
562 | { |
468 | maze[x][y] = 'D'; /* mark a door */ |
563 | maze[x][y] = 'D'; /* mark a door */ |
469 | switch(dir) { |
564 | switch (dir) |
470 | case 0: /* horizontal */ |
|
|
471 | { |
565 | { |
|
|
566 | case 0: /* horizontal */ |
|
|
567 | { |
472 | int i1; |
568 | int i1; |
|
|
569 | |
473 | for(i1 = x-1;maze[i1][y]==0;i1--) |
570 | for (i1 = x - 1; maze[i1][y] == 0; i1--) |
474 | maze[i1][y]='#'; |
571 | maze[i1][y] = '#'; |
475 | for(i1 = x+1;maze[i1][y]==0;i1++) |
572 | for (i1 = x + 1; maze[i1][y] == 0; i1++) |
476 | maze[i1][y]='#'; |
573 | maze[i1][y] = '#'; |
477 | break; |
574 | break; |
478 | } |
575 | } |
479 | case 1: /* vertical */ |
576 | case 1: /* vertical */ |
480 | { |
577 | { |
481 | int i1; |
578 | int i1; |
|
|
579 | |
482 | for(i1 = y-1;maze[x][i1]==0;i1--) |
580 | for (i1 = y - 1; maze[x][i1] == 0; i1--) |
483 | maze[x][i1]='#'; |
581 | maze[x][i1] = '#'; |
484 | for(i1 = y+1;maze[x][i1]==0;i1++) |
582 | for (i1 = y + 1; maze[x][i1] == 0; i1++) |
485 | maze[x][i1]='#'; |
583 | maze[x][i1] = '#'; |
486 | break; |
584 | break; |
|
|
585 | } |
487 | } |
586 | } |
488 | } |
|
|
489 | |
587 | |
490 | return 0; |
588 | return 0; |
491 | } |
589 | } |
492 | |
590 | |
493 | /* puts doors at appropriate locations in a layout. */ |
591 | /* puts doors at appropriate locations in a layout. */ |
494 | |
592 | |
|
|
593 | void |
495 | void doorify_layout(char **maze,RMParms *RP) { |
594 | doorify_layout (char **maze, RMParms * RP) |
|
|
595 | { |
496 | int ndoors = RP->Xsize*RP->Ysize/60; /* reasonable number of doors. */ |
596 | int ndoors = RP->Xsize * RP->Ysize / 60; /* reasonable number of doors. */ |
497 | char *doorlist_x; |
597 | char *doorlist_x; |
498 | char *doorlist_y; |
598 | char *doorlist_y; |
499 | int doorlocs = 0; /* # of available doorlocations */ |
599 | int doorlocs = 0; /* # of available doorlocations */ |
500 | int i,j; |
600 | int i, j; |
501 | |
601 | |
502 | doorlist_x = (char *) malloc(sizeof(int) * RP->Xsize*RP->Ysize); |
602 | doorlist_x = (char *) malloc (sizeof (int) * RP->Xsize * RP->Ysize); |
503 | doorlist_y = (char *) malloc(sizeof(int) * RP->Xsize*RP->Ysize); |
603 | doorlist_y = (char *) malloc (sizeof (int) * RP->Xsize * RP->Ysize); |
504 | |
604 | |
505 | |
605 | |
506 | /* make a list of possible door locations */ |
606 | /* make a list of possible door locations */ |
507 | for(i=1;i<RP->Xsize-1;i++) |
607 | for (i = 1; i < RP->Xsize - 1; i++) |
508 | for(j=1;j<RP->Ysize-1;j++) { |
608 | for (j = 1; j < RP->Ysize - 1; j++) |
|
|
609 | { |
509 | int sindex = surround_flag(maze,i,j,RP); |
610 | int sindex = surround_flag (maze, i, j, RP); |
|
|
611 | |
|
|
612 | if (sindex == 3 || sindex == 12) /* these are possible door sindex */ |
|
|
613 | { |
|
|
614 | doorlist_x[doorlocs] = i; |
|
|
615 | doorlist_y[doorlocs] = j; |
|
|
616 | doorlocs++; |
|
|
617 | } |
|
|
618 | } |
|
|
619 | while (ndoors > 0 && doorlocs > 0) |
|
|
620 | { |
|
|
621 | int di; |
|
|
622 | int sindex; |
|
|
623 | |
|
|
624 | di = RANDOM () % doorlocs; |
|
|
625 | i = doorlist_x[di]; |
|
|
626 | j = doorlist_y[di]; |
|
|
627 | sindex = surround_flag (maze, i, j, RP); |
510 | if(sindex == 3 || sindex == 12) /* these are possible door sindex*/ |
628 | if (sindex == 3 || sindex == 12) /* these are possible door sindex */ |
511 | { |
629 | { |
512 | doorlist_x[doorlocs]=i; |
630 | maze[i][j] = 'D'; |
513 | doorlist_y[doorlocs]=j; |
|
|
514 | doorlocs++; |
631 | ndoors--; |
515 | } |
632 | } |
516 | } |
|
|
517 | while(ndoors > 0 && doorlocs > 0) { |
|
|
518 | int di; |
|
|
519 | int sindex; |
|
|
520 | di = RANDOM() % doorlocs; |
|
|
521 | i=doorlist_x[di]; |
|
|
522 | j=doorlist_y[di]; |
|
|
523 | sindex= surround_flag(maze,i,j,RP); |
|
|
524 | if(sindex == 3 || sindex == 12) /* these are possible door sindex*/ |
|
|
525 | { |
|
|
526 | maze[i][j] = 'D'; |
|
|
527 | ndoors--; |
|
|
528 | } |
|
|
529 | /* reduce the size of the list */ |
633 | /* reduce the size of the list */ |
530 | doorlocs--; |
634 | doorlocs--; |
531 | doorlist_x[di]=doorlist_x[doorlocs]; |
635 | doorlist_x[di] = doorlist_x[doorlocs]; |
532 | doorlist_y[di]=doorlist_y[doorlocs]; |
636 | doorlist_y[di] = doorlist_y[doorlocs]; |
533 | } |
637 | } |
534 | free(doorlist_x); |
638 | free (doorlist_x); |
535 | free(doorlist_y); |
639 | free (doorlist_y); |
536 | } |
640 | } |
537 | |
641 | |
538 | |
642 | |
|
|
643 | void |
539 | void write_map_parameters_to_string(char *buf,RMParms *RP) { |
644 | write_map_parameters_to_string (char *buf, RMParms * RP) |
|
|
645 | { |
540 | |
646 | |
541 | char small_buf[256]; |
647 | char small_buf[256]; |
|
|
648 | |
542 | sprintf(buf,"xsize %d\nysize %d\n",RP->Xsize,RP->Ysize); |
649 | sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); |
543 | |
650 | |
544 | if(RP->wallstyle[0]) { |
651 | if (RP->wallstyle[0]) |
|
|
652 | { |
545 | sprintf(small_buf,"wallstyle %s\n",RP->wallstyle); |
653 | sprintf (small_buf, "wallstyle %s\n", RP->wallstyle); |
546 | strcat(buf,small_buf); |
654 | strcat (buf, small_buf); |
547 | } |
655 | } |
548 | |
656 | |
549 | if(RP->floorstyle[0]) { |
657 | if (RP->floorstyle[0]) |
|
|
658 | { |
550 | sprintf(small_buf,"floorstyle %s\n",RP->floorstyle); |
659 | sprintf (small_buf, "floorstyle %s\n", RP->floorstyle); |
551 | strcat(buf,small_buf); |
660 | strcat (buf, small_buf); |
552 | } |
661 | } |
553 | |
662 | |
554 | if(RP->monsterstyle[0]) { |
663 | if (RP->monsterstyle[0]) |
|
|
664 | { |
555 | sprintf(small_buf,"monsterstyle %s\n",RP->monsterstyle); |
665 | sprintf (small_buf, "monsterstyle %s\n", RP->monsterstyle); |
556 | strcat(buf,small_buf); |
666 | strcat (buf, small_buf); |
557 | } |
667 | } |
558 | |
668 | |
559 | if(RP->treasurestyle[0]) { |
669 | if (RP->treasurestyle[0]) |
|
|
670 | { |
560 | sprintf(small_buf,"treasurestyle %s\n",RP->treasurestyle); |
671 | sprintf (small_buf, "treasurestyle %s\n", RP->treasurestyle); |
561 | strcat(buf,small_buf); |
672 | strcat (buf, small_buf); |
562 | } |
673 | } |
563 | |
674 | |
564 | if(RP->layoutstyle[0]) { |
675 | if (RP->layoutstyle[0]) |
|
|
676 | { |
565 | sprintf(small_buf,"layoutstyle %s\n",RP->layoutstyle); |
677 | sprintf (small_buf, "layoutstyle %s\n", RP->layoutstyle); |
566 | strcat(buf,small_buf); |
678 | strcat (buf, small_buf); |
567 | } |
679 | } |
568 | |
680 | |
569 | if(RP->decorstyle[0]) { |
681 | if (RP->decorstyle[0]) |
|
|
682 | { |
570 | sprintf(small_buf,"decorstyle %s\n",RP->decorstyle); |
683 | sprintf (small_buf, "decorstyle %s\n", RP->decorstyle); |
571 | strcat(buf,small_buf); |
684 | strcat (buf, small_buf); |
572 | } |
685 | } |
573 | |
686 | |
574 | if(RP->doorstyle[0]) { |
687 | if (RP->doorstyle[0]) |
|
|
688 | { |
575 | sprintf(small_buf,"doorstyle %s\n",RP->doorstyle); |
689 | sprintf (small_buf, "doorstyle %s\n", RP->doorstyle); |
576 | strcat(buf,small_buf); |
690 | strcat (buf, small_buf); |
577 | } |
691 | } |
578 | |
692 | |
579 | if(RP->exitstyle[0]) { |
693 | if (RP->exitstyle[0]) |
|
|
694 | { |
580 | sprintf(small_buf,"exitstyle %s\n",RP->exitstyle); |
695 | sprintf (small_buf, "exitstyle %s\n", RP->exitstyle); |
581 | strcat(buf,small_buf); |
696 | strcat (buf, small_buf); |
582 | } |
697 | } |
583 | |
698 | |
584 | if(RP->final_map[0]) { |
699 | if (RP->final_map[0]) |
|
|
700 | { |
585 | sprintf(small_buf,"final_map %s\n",RP->final_map); |
701 | sprintf (small_buf, "final_map %s\n", RP->final_map); |
586 | strcat(buf,small_buf); |
702 | strcat (buf, small_buf); |
587 | } |
703 | } |
588 | |
704 | |
589 | if(RP->exit_on_final_map[0]) { |
705 | if (RP->exit_on_final_map[0]) |
|
|
706 | { |
590 | 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); |
591 | strcat(buf,small_buf); |
708 | strcat (buf, small_buf); |
592 | } |
709 | } |
593 | |
710 | |
594 | if(RP->this_map[0]) { |
711 | if (RP->this_map[0]) |
|
|
712 | { |
595 | sprintf(small_buf,"origin_map %s\n",RP->this_map); |
713 | sprintf (small_buf, "origin_map %s\n", RP->this_map); |
596 | strcat(buf,small_buf); |
714 | strcat (buf, small_buf); |
597 | } |
715 | } |
598 | |
716 | |
599 | if(RP->expand2x) { |
717 | if (RP->expand2x) |
|
|
718 | { |
600 | sprintf(small_buf,"expand2x %d\n",RP->expand2x); |
719 | sprintf (small_buf, "expand2x %d\n", RP->expand2x); |
601 | strcat(buf,small_buf); |
720 | strcat (buf, small_buf); |
602 | } |
721 | } |
603 | |
722 | |
604 | if(RP->layoutoptions1) { |
723 | if (RP->layoutoptions1) |
|
|
724 | { |
605 | sprintf(small_buf,"layoutoptions1 %d\n",RP->layoutoptions1); |
725 | sprintf (small_buf, "layoutoptions1 %d\n", RP->layoutoptions1); |
606 | strcat(buf,small_buf); |
726 | strcat (buf, small_buf); |
607 | } |
727 | } |
608 | |
728 | |
609 | |
729 | |
610 | if(RP->layoutoptions2) { |
730 | if (RP->layoutoptions2) |
|
|
731 | { |
611 | sprintf(small_buf,"layoutoptions2 %d\n",RP->layoutoptions2); |
732 | sprintf (small_buf, "layoutoptions2 %d\n", RP->layoutoptions2); |
612 | strcat(buf,small_buf); |
733 | strcat (buf, small_buf); |
613 | } |
734 | } |
614 | |
735 | |
615 | |
736 | |
616 | if(RP->layoutoptions3) { |
737 | if (RP->layoutoptions3) |
|
|
738 | { |
617 | sprintf(small_buf,"layoutoptions3 %d\n",RP->layoutoptions3); |
739 | sprintf (small_buf, "layoutoptions3 %d\n", RP->layoutoptions3); |
618 | strcat(buf,small_buf); |
740 | strcat (buf, small_buf); |
619 | } |
741 | } |
620 | |
742 | |
621 | if(RP->symmetry) { |
743 | if (RP->symmetry) |
|
|
744 | { |
622 | sprintf(small_buf,"symmetry %d\n",RP->symmetry); |
745 | sprintf (small_buf, "symmetry %d\n", RP->symmetry); |
623 | strcat(buf,small_buf); |
746 | strcat (buf, small_buf); |
624 | } |
747 | } |
625 | |
748 | |
626 | |
749 | |
627 | if(RP->difficulty && RP->difficulty_given ) { |
750 | if (RP->difficulty && RP->difficulty_given) |
|
|
751 | { |
628 | sprintf(small_buf,"difficulty %d\n",RP->difficulty); |
752 | sprintf (small_buf, "difficulty %d\n", RP->difficulty); |
629 | strcat(buf,small_buf); |
753 | strcat (buf, small_buf); |
630 | } |
754 | } |
631 | |
755 | |
632 | if(RP->difficulty_increase != 1.0 ) { |
756 | if (RP->difficulty_increase != 1.0) |
|
|
757 | { |
633 | sprintf(small_buf,"difficulty_increase %f\n",RP->difficulty_increase); |
758 | sprintf (small_buf, "difficulty_increase %f\n", RP->difficulty_increase); |
634 | strcat(buf,small_buf); |
759 | strcat (buf, small_buf); |
635 | } |
760 | } |
636 | |
761 | |
637 | sprintf(small_buf,"dungeon_level %d\n",RP->dungeon_level); |
762 | sprintf (small_buf, "dungeon_level %d\n", RP->dungeon_level); |
638 | strcat(buf,small_buf); |
763 | strcat (buf, small_buf); |
639 | |
764 | |
640 | if(RP->dungeon_depth) { |
765 | if (RP->dungeon_depth) |
|
|
766 | { |
641 | sprintf(small_buf,"dungeon_depth %d\n",RP->dungeon_depth); |
767 | sprintf (small_buf, "dungeon_depth %d\n", RP->dungeon_depth); |
642 | strcat(buf,small_buf); |
768 | strcat (buf, small_buf); |
643 | } |
769 | } |
644 | |
770 | |
645 | if(RP->decoroptions) { |
771 | if (RP->decoroptions) |
|
|
772 | { |
646 | sprintf(small_buf,"decoroptions %d\n",RP->decoroptions); |
773 | sprintf (small_buf, "decoroptions %d\n", RP->decoroptions); |
647 | strcat(buf,small_buf); |
774 | strcat (buf, small_buf); |
648 | } |
775 | } |
649 | |
776 | |
650 | if(RP->orientation) { |
777 | if (RP->orientation) |
|
|
778 | { |
651 | sprintf(small_buf,"orientation %d\n",RP->orientation); |
779 | sprintf (small_buf, "orientation %d\n", RP->orientation); |
652 | strcat(buf,small_buf); |
780 | strcat (buf, small_buf); |
653 | } |
781 | } |
654 | |
782 | |
655 | if(RP->origin_x) { |
783 | if (RP->origin_x) |
|
|
784 | { |
656 | sprintf(small_buf,"origin_x %d\n",RP->origin_x); |
785 | sprintf (small_buf, "origin_x %d\n", RP->origin_x); |
657 | strcat(buf,small_buf); |
786 | strcat (buf, small_buf); |
658 | } |
787 | } |
659 | |
788 | |
660 | if(RP->origin_y) { |
789 | if (RP->origin_y) |
|
|
790 | { |
661 | sprintf(small_buf,"origin_y %d\n",RP->origin_y); |
791 | sprintf (small_buf, "origin_y %d\n", RP->origin_y); |
662 | strcat(buf,small_buf); |
792 | strcat (buf, small_buf); |
663 | } |
793 | } |
664 | if(RP->random_seed) { |
794 | if (RP->random_seed) |
|
|
795 | { |
665 | /* Add one so that the next map is a bit different */ |
796 | /* Add one so that the next map is a bit different */ |
666 | sprintf(small_buf,"random_seed %d\n",RP->random_seed + 1); |
797 | sprintf (small_buf, "random_seed %d\n", RP->random_seed + 1); |
667 | strcat(buf,small_buf); |
798 | strcat (buf, small_buf); |
668 | } |
799 | } |
669 | |
800 | |
670 | if(RP->treasureoptions) { |
801 | if (RP->treasureoptions) |
|
|
802 | { |
671 | sprintf(small_buf,"treasureoptions %d\n",RP->treasureoptions); |
803 | sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions); |
672 | strcat(buf,small_buf); |
804 | strcat (buf, small_buf); |
673 | } |
805 | } |
674 | |
806 | |
675 | |
807 | |
676 | } |
808 | } |
677 | |
809 | |
|
|
810 | void |
678 | void write_parameters_to_string(char *buf, |
811 | write_parameters_to_string (char *buf, |
679 | int xsize_n, |
812 | int xsize_n, |
680 | int ysize_n, |
813 | int ysize_n, |
681 | char *wallstyle_n, |
814 | char *wallstyle_n, |
682 | char *floorstyle_n, |
815 | char *floorstyle_n, |
683 | char *monsterstyle_n, |
816 | char *monsterstyle_n, |
684 | char *treasurestyle_n, |
817 | char *treasurestyle_n, |
685 | char *layoutstyle_n, |
818 | char *layoutstyle_n, |
686 | char *decorstyle_n, |
819 | char *decorstyle_n, |
687 | char *doorstyle_n, |
820 | char *doorstyle_n, |
688 | char *exitstyle_n, |
821 | char *exitstyle_n, |
689 | char *final_map_n, |
822 | char *final_map_n, |
690 | char *exit_on_final_map_n, |
823 | char *exit_on_final_map_n, |
691 | char *this_map_n, |
824 | char *this_map_n, |
692 | int layoutoptions1_n, |
825 | int layoutoptions1_n, |
693 | int layoutoptions2_n, |
826 | int layoutoptions2_n, |
694 | int layoutoptions3_n, |
827 | int layoutoptions3_n, |
695 | int symmetry_n, |
828 | int symmetry_n, |
696 | int dungeon_depth_n, |
829 | int dungeon_depth_n, |
697 | int dungeon_level_n, |
830 | int dungeon_level_n, |
698 | int difficulty_n, |
831 | int difficulty_n, |
699 | int difficulty_given_n, |
832 | int difficulty_given_n, |
700 | int decoroptions_n, |
833 | int decoroptions_n, |
701 | int orientation_n, |
834 | int orientation_n, |
702 | int origin_x_n, |
835 | int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) |
703 | int origin_y_n, |
|
|
704 | int random_seed_n, |
|
|
705 | int treasureoptions_n, |
|
|
706 | float difficulty_increase) |
|
|
707 | { |
836 | { |
708 | |
837 | |
709 | char small_buf[256]; |
838 | char small_buf[256]; |
|
|
839 | |
710 | sprintf(buf,"xsize %d\nysize %d\n",xsize_n,ysize_n); |
840 | sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); |
711 | |
841 | |
712 | if(wallstyle_n && wallstyle_n[0]) { |
842 | if (wallstyle_n && wallstyle_n[0]) |
|
|
843 | { |
713 | sprintf(small_buf,"wallstyle %s\n",wallstyle_n); |
844 | sprintf (small_buf, "wallstyle %s\n", wallstyle_n); |
714 | strcat(buf,small_buf); |
845 | strcat (buf, small_buf); |
715 | } |
846 | } |
716 | |
847 | |
717 | if(floorstyle_n && floorstyle_n[0]) { |
848 | if (floorstyle_n && floorstyle_n[0]) |
|
|
849 | { |
718 | sprintf(small_buf,"floorstyle %s\n",floorstyle_n); |
850 | sprintf (small_buf, "floorstyle %s\n", floorstyle_n); |
719 | strcat(buf,small_buf); |
851 | strcat (buf, small_buf); |
720 | } |
852 | } |
721 | |
853 | |
722 | if(monsterstyle_n && monsterstyle_n[0]) { |
854 | if (monsterstyle_n && monsterstyle_n[0]) |
|
|
855 | { |
723 | sprintf(small_buf,"monsterstyle %s\n",monsterstyle_n); |
856 | sprintf (small_buf, "monsterstyle %s\n", monsterstyle_n); |
724 | strcat(buf,small_buf); |
857 | strcat (buf, small_buf); |
725 | } |
858 | } |
726 | |
859 | |
727 | if(treasurestyle_n && treasurestyle_n[0]) { |
860 | if (treasurestyle_n && treasurestyle_n[0]) |
|
|
861 | { |
728 | sprintf(small_buf,"treasurestyle %s\n",treasurestyle_n); |
862 | sprintf (small_buf, "treasurestyle %s\n", treasurestyle_n); |
729 | strcat(buf,small_buf); |
863 | strcat (buf, small_buf); |
730 | } |
864 | } |
731 | |
865 | |
732 | if(layoutstyle_n &&layoutstyle_n[0]) { |
866 | if (layoutstyle_n && layoutstyle_n[0]) |
|
|
867 | { |
733 | sprintf(small_buf,"layoutstyle %s\n",layoutstyle_n); |
868 | sprintf (small_buf, "layoutstyle %s\n", layoutstyle_n); |
734 | strcat(buf,small_buf); |
869 | strcat (buf, small_buf); |
735 | } |
870 | } |
736 | |
871 | |
737 | if(decorstyle_n && decorstyle_n[0]) { |
872 | if (decorstyle_n && decorstyle_n[0]) |
|
|
873 | { |
738 | sprintf(small_buf,"decorstyle %s\n",decorstyle_n); |
874 | sprintf (small_buf, "decorstyle %s\n", decorstyle_n); |
739 | strcat(buf,small_buf); |
875 | strcat (buf, small_buf); |
740 | } |
876 | } |
741 | |
877 | |
742 | if(doorstyle_n && doorstyle_n[0]) { |
878 | if (doorstyle_n && doorstyle_n[0]) |
|
|
879 | { |
743 | sprintf(small_buf,"doorstyle %s\n",doorstyle_n); |
880 | sprintf (small_buf, "doorstyle %s\n", doorstyle_n); |
744 | strcat(buf,small_buf); |
881 | strcat (buf, small_buf); |
745 | } |
882 | } |
746 | |
883 | |
747 | if(exitstyle_n && exitstyle_n[0]) { |
884 | if (exitstyle_n && exitstyle_n[0]) |
|
|
885 | { |
748 | sprintf(small_buf,"exitstyle %s\n",exitstyle_n); |
886 | sprintf (small_buf, "exitstyle %s\n", exitstyle_n); |
749 | strcat(buf,small_buf); |
887 | strcat (buf, small_buf); |
750 | } |
888 | } |
751 | |
889 | |
752 | if(final_map_n && final_map_n[0]) { |
890 | if (final_map_n && final_map_n[0]) |
|
|
891 | { |
753 | sprintf(small_buf,"final_map %s\n",final_map_n); |
892 | sprintf (small_buf, "final_map %s\n", final_map_n); |
754 | strcat(buf,small_buf); |
893 | strcat (buf, small_buf); |
755 | } |
894 | } |
756 | |
895 | |
757 | if(exit_on_final_map_n && exit_on_final_map_n[0]) { |
896 | if (exit_on_final_map_n && exit_on_final_map_n[0]) |
|
|
897 | { |
758 | sprintf(small_buf,"exit_on_final_map %s\n",exit_on_final_map_n); |
898 | sprintf (small_buf, "exit_on_final_map %s\n", exit_on_final_map_n); |
759 | strcat(buf,small_buf); |
899 | strcat (buf, small_buf); |
760 | } |
900 | } |
761 | |
901 | |
762 | if(this_map_n && this_map_n[0]) { |
902 | if (this_map_n && this_map_n[0]) |
|
|
903 | { |
763 | sprintf(small_buf,"origin_map %s\n",this_map_n); |
904 | sprintf (small_buf, "origin_map %s\n", this_map_n); |
764 | strcat(buf,small_buf); |
905 | strcat (buf, small_buf); |
765 | } |
906 | } |
766 | |
907 | |
767 | if(layoutoptions1_n) { |
908 | if (layoutoptions1_n) |
|
|
909 | { |
768 | sprintf(small_buf,"layoutoptions1 %d\n",layoutoptions1_n); |
910 | sprintf (small_buf, "layoutoptions1 %d\n", layoutoptions1_n); |
769 | strcat(buf,small_buf); |
911 | strcat (buf, small_buf); |
770 | } |
912 | } |
771 | |
913 | |
772 | |
914 | |
773 | if(layoutoptions2_n) { |
915 | if (layoutoptions2_n) |
|
|
916 | { |
774 | sprintf(small_buf,"layoutoptions2 %d\n",layoutoptions2_n); |
917 | sprintf (small_buf, "layoutoptions2 %d\n", layoutoptions2_n); |
775 | strcat(buf,small_buf); |
918 | strcat (buf, small_buf); |
776 | } |
919 | } |
777 | |
920 | |
778 | |
921 | |
779 | if(layoutoptions3_n) { |
922 | if (layoutoptions3_n) |
|
|
923 | { |
780 | sprintf(small_buf,"layoutoptions3 %d\n",layoutoptions3_n); |
924 | sprintf (small_buf, "layoutoptions3 %d\n", layoutoptions3_n); |
781 | strcat(buf,small_buf); |
925 | strcat (buf, small_buf); |
782 | } |
926 | } |
783 | |
927 | |
784 | if(symmetry_n) { |
928 | if (symmetry_n) |
|
|
929 | { |
785 | sprintf(small_buf,"symmetry %d\n",symmetry_n); |
930 | sprintf (small_buf, "symmetry %d\n", symmetry_n); |
786 | strcat(buf,small_buf); |
931 | strcat (buf, small_buf); |
787 | } |
932 | } |
788 | |
933 | |
789 | |
934 | |
790 | if(difficulty_n && difficulty_given_n ) { |
935 | if (difficulty_n && difficulty_given_n) |
|
|
936 | { |
791 | sprintf(small_buf,"difficulty %d\n",difficulty_n); |
937 | sprintf (small_buf, "difficulty %d\n", difficulty_n); |
792 | strcat(buf,small_buf); |
938 | strcat (buf, small_buf); |
793 | } |
939 | } |
794 | |
940 | |
795 | if(difficulty_increase > 0.001 ) { |
941 | if (difficulty_increase > 0.001) |
|
|
942 | { |
796 | sprintf(small_buf,"difficulty_increase %f\n",difficulty_increase); |
943 | sprintf (small_buf, "difficulty_increase %f\n", difficulty_increase); |
797 | strcat(buf,small_buf); |
944 | strcat (buf, small_buf); |
798 | } |
945 | } |
799 | |
946 | |
800 | sprintf(small_buf,"dungeon_level %d\n",dungeon_level_n); |
947 | sprintf (small_buf, "dungeon_level %d\n", dungeon_level_n); |
801 | strcat(buf,small_buf); |
948 | strcat (buf, small_buf); |
802 | |
949 | |
803 | if(dungeon_depth_n) { |
950 | if (dungeon_depth_n) |
|
|
951 | { |
804 | sprintf(small_buf,"dungeon_depth %d\n",dungeon_depth_n); |
952 | sprintf (small_buf, "dungeon_depth %d\n", dungeon_depth_n); |
805 | strcat(buf,small_buf); |
953 | strcat (buf, small_buf); |
806 | } |
954 | } |
807 | |
955 | |
808 | if(decoroptions_n) { |
956 | if (decoroptions_n) |
|
|
957 | { |
809 | sprintf(small_buf,"decoroptions %d\n",decoroptions_n); |
958 | sprintf (small_buf, "decoroptions %d\n", decoroptions_n); |
810 | strcat(buf,small_buf); |
959 | strcat (buf, small_buf); |
811 | } |
960 | } |
812 | |
961 | |
813 | if(orientation_n) { |
962 | if (orientation_n) |
|
|
963 | { |
814 | sprintf(small_buf,"orientation %d\n",orientation_n); |
964 | sprintf (small_buf, "orientation %d\n", orientation_n); |
815 | strcat(buf,small_buf); |
965 | strcat (buf, small_buf); |
816 | } |
966 | } |
817 | |
967 | |
818 | if(origin_x_n) { |
968 | if (origin_x_n) |
|
|
969 | { |
819 | sprintf(small_buf,"origin_x %d\n",origin_x_n); |
970 | sprintf (small_buf, "origin_x %d\n", origin_x_n); |
820 | strcat(buf,small_buf); |
971 | strcat (buf, small_buf); |
821 | } |
972 | } |
822 | |
973 | |
823 | if(origin_y_n) { |
974 | if (origin_y_n) |
|
|
975 | { |
824 | sprintf(small_buf,"origin_y %d\n",origin_y_n); |
976 | sprintf (small_buf, "origin_y %d\n", origin_y_n); |
825 | strcat(buf,small_buf); |
977 | strcat (buf, small_buf); |
826 | } |
978 | } |
827 | if(random_seed_n) { |
979 | if (random_seed_n) |
|
|
980 | { |
828 | /* Add one so that the next map is a bit different */ |
981 | /* Add one so that the next map is a bit different */ |
829 | sprintf(small_buf,"random_seed %d\n",random_seed_n + 1); |
982 | sprintf (small_buf, "random_seed %d\n", random_seed_n + 1); |
830 | strcat(buf,small_buf); |
983 | strcat (buf, small_buf); |
831 | } |
984 | } |
832 | |
985 | |
833 | if(treasureoptions_n) { |
986 | if (treasureoptions_n) |
|
|
987 | { |
834 | sprintf(small_buf,"treasureoptions %d\n",treasureoptions_n); |
988 | sprintf (small_buf, "treasureoptions %d\n", treasureoptions_n); |
835 | strcat(buf,small_buf); |
989 | strcat (buf, small_buf); |
836 | } |
990 | } |
837 | |
991 | |
838 | |
992 | |
839 | } |
993 | } |
840 | |
994 | |
841 | /* copy an object with an inventory... i.e., duplicate the inv too. */ |
995 | /* copy an object with an inventory... i.e., duplicate the inv too. */ |
|
|
996 | void |
842 | void copy_object_with_inv(object *src_ob, object *dest_ob) { |
997 | copy_object_with_inv (object *src_ob, object *dest_ob) |
|
|
998 | { |
843 | object *walk,*tmp; |
999 | object *walk, *tmp; |
844 | |
1000 | |
845 | copy_object(src_ob,dest_ob); |
1001 | copy_object (src_ob, dest_ob); |
846 | |
1002 | |
847 | for(walk=src_ob->inv;walk!=NULL;walk=walk->below) { |
1003 | for (walk = src_ob->inv; walk != NULL; walk = walk->below) |
|
|
1004 | { |
848 | tmp=get_object(); |
1005 | tmp = get_object (); |
849 | copy_object(walk,tmp); |
1006 | copy_object (walk, tmp); |
850 | insert_ob_in_ob(tmp,dest_ob); |
1007 | insert_ob_in_ob (tmp, dest_ob); |
851 | } |
1008 | } |
852 | } |
1009 | } |