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.7 by root, Sat Sep 16 22:24:12 2006 UTC vs.
Revision 1.14 by root, Sun Dec 31 10:28:36 2006 UTC

28 28
29 29
30/* find a character in the layout. fx and fy are pointers to 30/* find a character in the layout. fx and fy are pointers to
31 where to find the char. fx,fy = -1 if not found. */ 31 where to find the char. fx,fy = -1 if not found. */
32void 32void
33find_in_layout (int mode, char target, int *fx, int *fy, char **layout, RMParms * RP) 33find_in_layout (int mode, char target, int *fx, int *fy, char **layout, random_map_params * RP)
34{ 34{
35 int M; 35 int M;
36 int i, j; 36 int i, j;
37 37
38 *fx = -1; 38 *fx = -1;
106 break; 106 break;
107 } 107 }
108 } 108 }
109} 109}
110 110
111
112
113
114
115
116/* orientation: 0 means random, 111/* orientation: 0 means random,
117 1 means descending dungeon 112 1 means descending dungeon
118 2 means ascending dungeon 113 2 means ascending dungeon
119 3 means rightward 114 3 means rightward
120 4 means leftward 115 4 means leftward
121 5 means northward 116 5 means northward
122 6 means southward 117 6 means southward
123*/ 118*/
124
125void 119void
126place_exits (maptile *map, char **maze, char *exitstyle, int orientation, RMParms * RP) 120place_exits (maptile *map, char **maze, char *exitstyle, int orientation, random_map_params *RP)
127{ 121{
128 char styledirname[256]; 122 char styledirname[256];
129 maptile *style_map_down = 0; /* harder maze */ 123 maptile *style_map_down = 0; /* harder maze */
130 maptile *style_map_up = 0; /* easier maze */ 124 maptile *style_map_up = 0; /* easier maze */
131 object *the_exit_down; /* harder maze */ 125 object *the_exit_down; /* harder maze */
262 256
263 insert_ob_in_map (the_exit_up, map, NULL, 0); 257 insert_ob_in_map (the_exit_up, map, NULL, 0);
264 maze[the_exit_up->x][the_exit_up->y] = '<'; 258 maze[the_exit_up->x][the_exit_up->y] = '<';
265 259
266 /* set the starting x,y for this map */ 260 /* set the starting x,y for this map */
267 MAP_ENTER_X (map) = the_exit_up->x; 261 map->enter_x = the_exit_up->x;
268 MAP_ENTER_Y (map) = the_exit_up->y; 262 map->enter_y = the_exit_up->y;
269 263
270 /* first, look for a '>' character */ 264 /* first, look for a '>' character */
271 find_in_layout (0, '>', &downx, &downy, maze, RP); 265 find_in_layout (0, '>', &downx, &downy, maze, RP);
272 /* if no > is found use C */ 266 /* if no > is found use C */
273 if (downx == -1) 267 if (downx == -1)
331 /* give the final map a name */ 325 /* give the final map a name */
332 sprintf (new_map_name, "%sfinal_map", RP->final_map); 326 sprintf (new_map_name, "%sfinal_map", RP->final_map);
333 /* set the exit down. */ 327 /* set the exit down. */
334#endif 328#endif
335 /* load it */ 329 /* load it */
336 if ((new_map = ready_map_name (RP->final_map, 0)) == NULL) 330 if (!(new_map = maptile::load_map_sync (RP->final_map)))
337 return; 331 return;
338 332
339 the_exit_down->slaying = RP->final_map; 333 the_exit_down->slaying = RP->final_map;
340 strcpy (new_map->path, RP->final_map);
341 334
342 for (tmp = GET_MAP_OB (new_map, MAP_ENTER_X (new_map), MAP_ENTER_Y (new_map)); tmp; tmp = tmp->above) 335 for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above)
343 /* Remove exit back to previous random map. There should only be one 336 /* Remove exit back to previous random map. There should only be one
344 * which is why we break out. To try to process more than one 337 * which is why we break out. To try to process more than one
345 * would require keeping a 'next' pointer, ad free_object kills tmp, which 338 * would require keeping a 'next' pointer, ad free_object kills tmp, which
346 * breaks the for loop. 339 * breaks the for loop.
347 */ 340 */
348 if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8)) 341 if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8))
349 { 342 {
350 remove_ob (tmp); 343 tmp->destroy ();
351 free_object (tmp);
352 break; 344 break;
353 } 345 }
354 346
355 if (final_map_exit == 1) 347 if (final_map_exit == 1)
356 { 348 {
357 /* setup the exit back */ 349 /* setup the exit back */
358 the_exit_back->slaying = map->path; 350 the_exit_back->slaying = map->path;
359 the_exit_back->stats.hp = the_exit_down->x; 351 the_exit_back->stats.hp = the_exit_down->x;
360 the_exit_back->stats.sp = the_exit_down->y; 352 the_exit_back->stats.sp = the_exit_down->y;
361 the_exit_back->x = MAP_ENTER_X (new_map); 353 the_exit_back->x = new_map->enter_x;
362 the_exit_back->y = MAP_ENTER_Y (new_map); 354 the_exit_back->y = new_map->enter_y;
363 355
364 insert_ob_in_map (the_exit_back, new_map, NULL, 0); 356 insert_ob_in_map (the_exit_back, new_map, NULL, 0);
365 } 357 }
366
367 set_map_timeout (new_map); /* So it gets swapped out */
368 } 358 }
369 else 359 else
370 the_exit_down->slaying = "/!"; 360 the_exit_down->slaying = "/!";
371 361
372 /* Block the exit so things don't get dumped on top of it. */ 362 /* Block the exit so things don't get dumped on top of it. */
376 } 366 }
377 } 367 }
378 368
379} 369}
380 370
381
382
383/* this function unblocks the exits. We blocked them to 371/* this function unblocks the exits. We blocked them to
384 keep things from being dumped on them during the other 372 keep things from being dumped on them during the other
385 phases of random map generation. */ 373 phases of random map generation. */
386void 374void
387unblock_exits (maptile *map, char **maze, RMParms * RP) 375unblock_exits (maptile *map, char **maze, random_map_params * RP)
388{ 376{
389 int i = 0, j = 0; 377 int i = 0, j = 0;
390 object *walk; 378 object *walk;
391 379
392 for (i = 0; i < RP->Xsize; i++) 380 for (i = 0; i < RP->Xsize; i++)
393 for (j = 0; j < RP->Ysize; j++) 381 for (j = 0; j < RP->Ysize; j++)
394 if (maze[i][j] == '>' || maze[i][j] == '<') 382 if (maze[i][j] == '>' || maze[i][j] == '<')
395 { 383 {
396 for (walk = get_map_ob (map, i, j); walk != NULL; walk = walk->above) 384 for (walk = GET_MAP_OB (map, i, j); walk != NULL; walk = walk->above)
397 { 385 {
398 if (walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) 386 if (walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR)
399 { 387 {
400 walk->move_block = MOVE_BLOCK_DEFAULT; 388 walk->move_block = MOVE_BLOCK_DEFAULT;
401 update_object (walk, UP_OBJ_CHANGE); 389 update_object (walk, UP_OBJ_CHANGE);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines