1 | /* |
1 | /* |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
2 | * This file is part of Deliantra, the Roguelike Realtime MMORPG. |
3 | * |
3 | * |
4 | * Copyright (©) 2005,2006,2007,2008 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
4 | * Copyright (©) 2005,2006,2007,2008,2009,2010 Marc Alexander Lehmann / Robin Redeker / the Deliantra team |
5 | * Copyright (©) 2001,2007 Mark Wedel & Crossfire Development Team |
5 | * Copyright (©) 2001 Mark Wedel & Crossfire Development Team |
6 | * Copyright (©) 1992,2007 Frank Tore Johansen |
6 | * Copyright (©) 1992 Frank Tore Johansen |
7 | * |
7 | * |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
8 | * Deliantra is free software: you can redistribute it and/or modify it under |
9 | * the terms of the Affero GNU General Public License as published by the |
9 | * the terms of the Affero GNU General Public License as published by the |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
10 | * Free Software Foundation, either version 3 of the License, or (at your |
11 | * option) any later version. |
11 | * option) any later version. |
… | |
… | |
115 | 4 means leftward |
115 | 4 means leftward |
116 | 5 means northward |
116 | 5 means northward |
117 | 6 means southward |
117 | 6 means southward |
118 | */ |
118 | */ |
119 | void |
119 | void |
120 | place_exits (maptile *map, char **maze, char *exitstyle, int orientation, random_map_params *RP) |
120 | place_exits (maptile *map, char **maze, const char *exitstyle, int orientation, random_map_params *RP) |
121 | { |
121 | { |
122 | char styledirname[1024]; |
|
|
123 | maptile *style_map_down = 0; /* harder maze */ |
122 | maptile *style_map_down = 0; /* harder maze */ |
124 | maptile *style_map_up = 0; /* easier maze */ |
123 | maptile *style_map_up = 0; /* easier maze */ |
125 | object *the_exit_down; /* harder maze */ |
124 | object *the_exit_down; /* harder maze */ |
126 | object *the_exit_up; /* easier maze */ |
125 | object *the_exit_up; /* easier maze */ |
127 | int cx = -1, cy = -1; /* location of a map center */ |
126 | int cx = -1, cy = -1; /* location of a map center */ |
… | |
… | |
138 | |
137 | |
139 | switch (orientation) |
138 | switch (orientation) |
140 | { |
139 | { |
141 | case 1: |
140 | case 1: |
142 | { |
141 | { |
143 | sprintf (styledirname, "/styles/exitstyles/up"); |
|
|
144 | style_map_up = find_style (styledirname, exitstyle, -1); |
142 | style_map_up = find_style ("/styles/exitstyles/up" , exitstyle, RP->difficulty); |
145 | sprintf (styledirname, "/styles/exitstyles/down"); |
|
|
146 | style_map_down = find_style (styledirname, exitstyle, -1); |
143 | style_map_down = find_style ("/styles/exitstyles/down", exitstyle, RP->difficulty); |
147 | break; |
144 | break; |
148 | } |
145 | } |
149 | |
146 | |
150 | case 2: |
147 | case 2: |
151 | { |
148 | { |
152 | sprintf (styledirname, "/styles/exitstyles/down"); |
|
|
153 | style_map_up = find_style (styledirname, exitstyle, -1); |
149 | style_map_up = find_style ("/styles/exitstyles/down", exitstyle, RP->difficulty); |
154 | sprintf (styledirname, "/styles/exitstyles/up"); |
|
|
155 | style_map_down = find_style (styledirname, exitstyle, -1); |
150 | style_map_down = find_style ("/styles/exitstyles/up" , exitstyle, RP->difficulty); |
156 | break; |
151 | break; |
157 | } |
152 | } |
158 | |
153 | |
159 | default: |
154 | default: |
160 | { |
155 | { |
161 | sprintf (styledirname, "/styles/exitstyles/generic"); |
156 | style_map_up = |
162 | style_map_up = find_style (styledirname, exitstyle, -1); |
157 | style_map_down = find_style ("/styles/exitstyles/generic", exitstyle, RP->difficulty); |
163 | style_map_down = style_map_up; |
|
|
164 | break; |
158 | break; |
165 | } |
159 | } |
166 | } |
160 | } |
167 | |
161 | |
168 | the_exit_up = style_map_up |
162 | the_exit_up = style_map_up |
… | |
… | |
282 | if (downx == -1) |
276 | if (downx == -1) |
283 | find_in_layout (0, 0, &downx, &downy, maze, RP); |
277 | find_in_layout (0, 0, &downx, &downy, maze, RP); |
284 | |
278 | |
285 | if (the_exit_down) |
279 | if (the_exit_down) |
286 | { |
280 | { |
287 | char buf[16384]; |
|
|
288 | |
|
|
289 | int i = find_free_spot (the_exit_down, map, downx, downy, 1, SIZEOFFREE1 + 1); |
281 | int i = rmg_find_free_spot (the_exit_down, map, downx, downy, 1, SIZEOFFREE1 + 1); |
290 | the_exit_down->x = downx + freearr_x[i]; |
282 | the_exit_down->x = downx + freearr_x[i]; |
291 | the_exit_down->y = downy + freearr_y[i]; |
283 | the_exit_down->y = downy + freearr_y[i]; |
292 | RP->origin_x = the_exit_down->x; |
284 | RP->origin_x = the_exit_down->x; |
293 | RP->origin_y = the_exit_down->y; |
285 | RP->origin_y = the_exit_down->y; |
|
|
286 | |
|
|
287 | dynbuf_text buf; |
294 | write_map_parameters_to_string (buf, RP); |
288 | write_map_parameters_to_string (buf, RP); |
295 | the_exit_down->msg = buf; |
289 | the_exit_down->msg = buf; |
296 | |
290 | |
297 | /* the identifier for making a random map. */ |
291 | /* the identifier for making a random map. */ |
298 | if (RP->dungeon_level >= RP->dungeon_depth && *RP->final_map) |
292 | if (RP->dungeon_level >= RP->dungeon_depth && *RP->final_map) |
299 | { |
293 | { |
300 | maptile *new_map; |
294 | maptile *new_map; |
301 | object *the_exit_back = arch_to_object (the_exit_up->arch); |
295 | object *the_exit_back = the_exit_up->arch->instance (); |
302 | |
296 | |
303 | /* load it */ |
297 | /* load it */ |
304 | if (!(new_map = maptile::find_sync (RP->final_map))) |
298 | if (!(new_map = maptile::find_sync (RP->final_map))) |
305 | return; |
299 | return; |
306 | |
300 | |
… | |
… | |
331 | |
325 | |
332 | insert_ob_in_map (the_exit_back, new_map, NULL, 0); |
326 | insert_ob_in_map (the_exit_back, new_map, NULL, 0); |
333 | } |
327 | } |
334 | } |
328 | } |
335 | else |
329 | else |
336 | the_exit_down->slaying = "/!"; |
330 | the_exit_down->slaying = shstr_random_map_exit; |
337 | |
331 | |
338 | /* Block the exit so things don't get dumped on top of it. */ |
332 | /* Block the exit so things don't get dumped on top of it. */ |
339 | the_exit_down->move_block = MOVE_ALL; |
333 | the_exit_down->move_block = MOVE_ALL; |
340 | insert_ob_in_map (the_exit_down, map, NULL, 0); |
334 | insert_ob_in_map (the_exit_down, map, NULL, 0); |
341 | maze[the_exit_down->x][the_exit_down->y] = '>'; |
335 | maze[the_exit_down->x][the_exit_down->y] = '>'; |