ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/exit.C
(Generate patch)

Comparing deliantra/server/random_maps/exit.C (file contents):
Revision 1.48 by root, Sun Jul 4 22:12:26 2010 UTC vs.
Revision 1.49 by root, Mon Jul 5 00:07:21 2010 UTC

76 } 76 }
77 } 77 }
78 break; 78 break;
79 79
80 case 3: 80 case 3:
81 /* search from bottom-right up-left */
82 for (i = maze.w - 2; i > 0; i--)
83 for (j = maze.h - 2; j > 0; j--)
84 {
85 if (maze[i][j] == target)
86 {
87 fx = i;
88 fy = j;
89 return;
90 }
91 }
92 break;
93
94 case 4:
81 /* search from bottom-left up-right */ 95 /* search from bottom-left up-right */
82 for (i = 1; i < maze.w - 1; i++) 96 for (i = 1; i < maze.w - 1; i++)
83 for (j = maze.h - 2; j > 0; j--) 97 for (j = maze.h - 2; j > 0; j--)
84 { 98 {
85 if (maze[i][j] == target) 99 if (maze[i][j] == target)
88 fy = j; 102 fy = j;
89 return; 103 return;
90 } 104 }
91 } 105 }
92 break; 106 break;
93
94 case 4:
95 /* search from bottom-right up-left */
96 for (i = maze.w - 2; i > 0; i--)
97 for (j = maze.h - 2; j > 0; j--)
98 {
99 if (maze[i][j] == target)
100 {
101 fx = i;
102 fy = j;
103 return;
104 }
105 }
106 break;
107 } 107 }
108}
109
110point
111layout::find (char target, int mode)
112{
113 int x, y;
114
115 find_in_layout (mode, target, x, y, *this);
116
117 return point (x, y);
108} 118}
109 119
110/* orientation: 0 means random, 120/* orientation: 0 means random,
111 1 means descending dungeon 121 1 means descending dungeon
112 2 means ascending dungeon 122 2 means ascending dungeon
198 upy = 1; 208 upy = 1;
199 else 209 else
200 upy = RP->Ysize - 2; 210 upy = RP->Ysize - 2;
201 211
202 /* find an empty place far from the center */ 212 /* find an empty place far from the center */
203 if (upx == 1 && upy == 1)
204 find_in_layout (1, 0, upx, upy, maze); 213 if (upx == 1 && upy == 1) find_in_layout (1, 0, upx, upy, maze);
205 else if (upx == 1 && upy > 1)
206 find_in_layout (3, 0, upx, upy, maze);
207 else if (upx > 1 && upy == 1)
208 find_in_layout (2, 0, upx, upy, maze);
209 else if (upx > 1 && upy > 1)
210 find_in_layout (4, 0, upx, upy, maze); 214 else if (upx == 1 && upy > 1) find_in_layout (4, 0, upx, upy, maze);
215 else if (upx > 1 && upy == 1) find_in_layout (2, 0, upx, upy, maze);
216 else if (upx > 1 && upy > 1) find_in_layout (3, 0, upx, upy, maze);
211 } 217 }
212 218
213 /* no indication of where to place the exit, so just place it. */ 219 /* no indication of where to place the exit, so just place it. */
214 if (upx == -1) 220 if (upx == -1)
215 find_in_layout (0, 0, upx, upy, maze); 221 find_in_layout (0, 0, upx, upy, maze);
259 downy = 1; 265 downy = 1;
260 else 266 else
261 downy = RP->Ysize - 2; 267 downy = RP->Ysize - 2;
262 268
263 /* find an empty place far from the entrance */ 269 /* find an empty place far from the entrance */
264 if (downx == 1 && downy == 1) 270 if (downx == 1 && downy == 1) find_in_layout (1, 0, downx, downy, maze);
265 find_in_layout (1, 0, downx, downy, maze); 271 else if (downx == 1 && downy > 1) find_in_layout (4, 0, downx, downy, maze);
266 else if (downx == 1 && downy > 1) 272 else if (downx > 1 && downy == 1) find_in_layout (2, 0, downx, downy, maze);
267 find_in_layout (3, 0, downx, downy, maze); 273 else if (downx > 1 && downy > 1) find_in_layout (3, 0, downx, downy, maze);
268 else if (downx > 1 && downy == 1)
269 find_in_layout (2, 0, downx, downy, maze);
270 else if (downx > 1 && downy > 1)
271 find_in_layout (4, 0, downx, downy, maze);
272 } 274 }
273 275
274 /* no indication of where to place the down exit, so just place it */ 276 /* no indication of where to place the down exit, so just place it */
275 if (downx == -1) 277 if (downx == -1)
276 find_in_layout (0, 0, downx, downy, maze); 278 find_in_layout (0, 0, downx, downy, maze);
277 279
278 if (the_exit_down) 280 if (the_exit_down)
279 { 281 {
280 int i = rmg_find_free_spot (the_exit_down, map, downx, downy, 1, SIZEOFFREE1 + 1); 282 int i = rmg_find_free_spot (the_exit_down, map, downx, downy, 1, SIZEOFFREE1 + 1);
283
281 the_exit_down->x = downx + freearr_x[i]; 284 the_exit_down->x = downx + freearr_x[i];
282 the_exit_down->y = downy + freearr_y[i]; 285 the_exit_down->y = downy + freearr_y[i];
286
283 RP->set ("origin_x", (IV)the_exit_down->x); 287 RP->set ("origin_x", (IV)the_exit_down->x);
284 RP->set ("origin_y", (IV)the_exit_down->y); 288 RP->set ("origin_y", (IV)the_exit_down->y);
285 289
286 the_exit_down->msg = RP->as_shstr (); 290 the_exit_down->msg = RP->as_shstr ();
291 the_exit_down->slaying = shstr_random_map_exit;
287 292
288 /* the identifier for making a random map. */ 293 /* the identifier for making a random map. */
289 if (RP->dungeon_level >= RP->dungeon_depth && final_map) 294 if (RP->dungeon_level >= RP->dungeon_depth && final_map)
290 { 295 {
291 maptile *new_map; 296 the_exit_down->msg = 0;
292 object *the_exit_back = the_exit_up->arch->instance ();
293
294 /* load it */
295 if (!(new_map = maptile::find_sync (final_map)))
296 return;
297
298 new_map->load_sync ();
299
300 the_exit_down->slaying = final_map; 297 the_exit_down->slaying = final_map;
301 298
302 for (object *tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above)
303 /* Remove exit back to previous random map. There should only be one
304 * which is why we break out. To try to process more than one
305 * would require keeping a 'next' pointer, ad free_object kills tmp, which
306 * breaks the for loop.
307 */
308 if (tmp->type == EXIT && EXIT_PATH (tmp).starts_with ("?random/"))
309 {
310 tmp->destroy ();
311 break;
312 }
313
314 if (final_map_exit) 299 if (final_map_exit)
300 if (maptile *new_map = maptile::find_sync (final_map))
315 { 301 {
302 object *the_exit_back = the_exit_up->arch->instance ();
303
304 new_map->load_sync ();
305
306 for (object *tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above)
307 /* Remove exit back to previous random map. There should only be one
308 * which is why we break out. To try to process more than one
309 * would require keeping a 'next' pointer, ad free_object kills tmp, which
310 * breaks the for loop.
311 */
312 if (tmp->type == EXIT && EXIT_PATH (tmp).starts_with ("?random/"))
313 {
314 tmp->destroy ();
315 break;
316 }
317
316 /* setup the exit back */ 318 /* setup the exit back */
317 the_exit_back->slaying = map->path; 319 the_exit_back->slaying = map->path;
318 the_exit_back->stats.hp = the_exit_down->x; 320 the_exit_back->stats.hp = the_exit_down->x;
319 the_exit_back->stats.sp = the_exit_down->y; 321 the_exit_back->stats.sp = the_exit_down->y;
320 the_exit_back->x = new_map->enter_x; 322 the_exit_back->x = new_map->enter_x;
321 the_exit_back->y = new_map->enter_y; 323 the_exit_back->y = new_map->enter_y;
322 324
323 insert_ob_in_map (the_exit_back, new_map, NULL, 0); 325 insert_ob_in_map (the_exit_back, new_map, NULL, 0);
324 } 326 }
325 } 327 }
326 else
327 the_exit_down->slaying = shstr_random_map_exit;
328 328
329 /* Block the exit so things don't get dumped on top of it. */ 329 /* Block the exit so things don't get dumped on top of it. */
330 the_exit_down->move_block = MOVE_ALL; 330 the_exit_down->move_block = MOVE_ALL;
331 insert_ob_in_map (the_exit_down, map, NULL, 0); 331 insert_ob_in_map (the_exit_down, map, NULL, 0);
332 maze[the_exit_down->x][the_exit_down->y] = '>'; 332 maze[the_exit_down->x][the_exit_down->y] = '>';

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines