1 | |
|
|
2 | /* |
|
|
3 | * static char *rcsid_exit_c = |
|
|
4 | * "$Id: exit.C,v 1.4 2006/09/10 16:06:37 root Exp $"; |
|
|
5 | */ |
|
|
6 | |
|
|
7 | /* |
1 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
2 | CrossFire, A Multiplayer game for X-windows |
9 | |
3 | |
10 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
4 | Copyright (C) 2001 Mark Wedel & Crossfire Development Team |
11 | Copyright (C) 1992 Frank Tore Johansen |
5 | Copyright (C) 1992 Frank Tore Johansen |
… | |
… | |
22 | |
16 | |
23 | You should have received a copy of the GNU General Public License |
17 | You should have received a copy of the GNU General Public License |
24 | along with this program; if not, write to the Free Software |
18 | along with this program; if not, write to the Free Software |
25 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
19 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
26 | |
20 | |
27 | The authors can be reached via e-mail at crossfire-devel@real-time.com |
21 | The authors can be reached via e-mail at <crossfire@schmorp.de> |
28 | */ |
22 | */ |
29 | |
23 | |
30 | #include <global.h> |
24 | #include <global.h> |
31 | #include <random_map.h> |
25 | #include <random_map.h> |
32 | #include <sproto.h> |
26 | #include <sproto.h> |
… | |
… | |
127 | 5 means northward |
121 | 5 means northward |
128 | 6 means southward |
122 | 6 means southward |
129 | */ |
123 | */ |
130 | |
124 | |
131 | void |
125 | void |
132 | place_exits (mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms * RP) |
126 | place_exits (maptile *map, char **maze, char *exitstyle, int orientation, RMParms * RP) |
133 | { |
127 | { |
134 | char styledirname[256]; |
128 | char styledirname[256]; |
135 | mapstruct *style_map_down = 0; /* harder maze */ |
129 | maptile *style_map_down = 0; /* harder maze */ |
136 | mapstruct *style_map_up = 0; /* easier maze */ |
130 | maptile *style_map_up = 0; /* easier maze */ |
137 | object *the_exit_down; /* harder maze */ |
131 | object *the_exit_down; /* harder maze */ |
138 | object *the_exit_up; /* easier maze */ |
132 | object *the_exit_up; /* easier maze */ |
139 | object *random_sign; /* magic mouth saying this is a random map. */ |
133 | object *random_sign; /* magic mouth saying this is a random map. */ |
140 | char buf[512]; |
134 | char buf[512]; |
141 | int cx = -1, cy = -1; /* location of a map center */ |
135 | int cx = -1, cy = -1; /* location of a map center */ |
… | |
… | |
177 | style_map_down = style_map_up; |
171 | style_map_down = style_map_up; |
178 | break; |
172 | break; |
179 | } |
173 | } |
180 | } |
174 | } |
181 | if (style_map_up == 0) |
175 | if (style_map_up == 0) |
182 | the_exit_up = arch_to_object (find_archetype ("exit")); |
176 | the_exit_up = arch_to_object (archetype::find ("exit")); |
183 | else |
177 | else |
184 | { |
178 | { |
185 | object *tmp; |
179 | object *tmp; |
186 | |
180 | |
187 | tmp = pick_random_object (style_map_up); |
181 | tmp = pick_random_object (style_map_up); |
… | |
… | |
189 | } |
183 | } |
190 | |
184 | |
191 | /* we need a down exit only if we're recursing. */ |
185 | /* we need a down exit only if we're recursing. */ |
192 | if (RP->dungeon_level < RP->dungeon_depth || RP->final_map[0] != 0) |
186 | if (RP->dungeon_level < RP->dungeon_depth || RP->final_map[0] != 0) |
193 | if (style_map_down == 0) |
187 | if (style_map_down == 0) |
194 | the_exit_down = arch_to_object (find_archetype ("exit")); |
188 | the_exit_down = arch_to_object (archetype::find ("exit")); |
195 | else |
189 | else |
196 | { |
190 | { |
197 | object *tmp; |
191 | object *tmp; |
198 | |
192 | |
199 | tmp = pick_random_object (style_map_down); |
193 | tmp = pick_random_object (style_map_down); |
… | |
… | |
320 | write_map_parameters_to_string (buf, RP); |
314 | write_map_parameters_to_string (buf, RP); |
321 | the_exit_down->msg = buf; |
315 | the_exit_down->msg = buf; |
322 | /* the identifier for making a random map. */ |
316 | /* the identifier for making a random map. */ |
323 | if (RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0] != 0) |
317 | if (RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0] != 0) |
324 | { |
318 | { |
325 | mapstruct *new_map; |
319 | maptile *new_map; |
326 | object *the_exit_back = arch_to_object (the_exit_up->arch), *tmp; |
320 | object *the_exit_back = arch_to_object (the_exit_up->arch), *tmp; |
327 | |
321 | |
328 | #if 0 |
322 | #if 0 |
329 | /* I'm not sure if there was any reason to change the path to the |
323 | /* I'm not sure if there was any reason to change the path to the |
330 | * map other than to maybe make it more descriptive in the 'maps' |
324 | * map other than to maybe make it more descriptive in the 'maps' |
… | |
… | |
351 | * would require keeping a 'next' pointer, ad free_object kills tmp, which |
345 | * would require keeping a 'next' pointer, ad free_object kills tmp, which |
352 | * breaks the for loop. |
346 | * breaks the for loop. |
353 | */ |
347 | */ |
354 | if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8)) |
348 | if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8)) |
355 | { |
349 | { |
356 | remove_ob (tmp); |
350 | tmp->remove (); |
357 | free_object (tmp); |
351 | tmp->destroy (); |
358 | break; |
352 | break; |
359 | } |
353 | } |
360 | |
354 | |
361 | if (final_map_exit == 1) |
355 | if (final_map_exit == 1) |
362 | { |
356 | { |
… | |
… | |
388 | |
382 | |
389 | /* this function unblocks the exits. We blocked them to |
383 | /* this function unblocks the exits. We blocked them to |
390 | keep things from being dumped on them during the other |
384 | keep things from being dumped on them during the other |
391 | phases of random map generation. */ |
385 | phases of random map generation. */ |
392 | void |
386 | void |
393 | unblock_exits (mapstruct *map, char **maze, RMParms * RP) |
387 | unblock_exits (maptile *map, char **maze, RMParms * RP) |
394 | { |
388 | { |
395 | int i = 0, j = 0; |
389 | int i = 0, j = 0; |
396 | object *walk; |
390 | object *walk; |
397 | |
391 | |
398 | for (i = 0; i < RP->Xsize; i++) |
392 | for (i = 0; i < RP->Xsize; i++) |