--- deliantra/server/random_maps/exit.C 2006/09/10 16:06:37 1.4 +++ deliantra/server/random_maps/exit.C 2006/12/31 17:17:23 1.15 @@ -1,9 +1,3 @@ - -/* - * static char *rcsid_exit_c = - * "$Id: exit.C,v 1.4 2006/09/10 16:06:37 root Exp $"; - */ - /* CrossFire, A Multiplayer game for X-windows @@ -24,7 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - The authors can be reached via e-mail at crossfire-devel@real-time.com + The authors can be reached via e-mail at */ #include @@ -32,11 +26,10 @@ #include #include - /* find a character in the layout. fx and fy are pointers to where to find the char. fx,fy = -1 if not found. */ void -find_in_layout (int mode, char target, int *fx, int *fy, char **layout, RMParms * RP) +find_in_layout (int mode, char target, int *fx, int *fy, char **layout, random_map_params * RP) { int M; int i, j; @@ -114,11 +107,6 @@ } } - - - - - /* orientation: 0 means random, 1 means descending dungeon 2 means ascending dungeon @@ -127,13 +115,12 @@ 5 means northward 6 means southward */ - void -place_exits (mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms * RP) +place_exits (maptile *map, char **maze, char *exitstyle, int orientation, random_map_params *RP) { char styledirname[256]; - mapstruct *style_map_down = 0; /* harder maze */ - mapstruct *style_map_up = 0; /* easier maze */ + maptile *style_map_down = 0; /* harder maze */ + maptile *style_map_up = 0; /* easier maze */ object *the_exit_down; /* harder maze */ object *the_exit_up; /* easier maze */ object *random_sign; /* magic mouth saying this is a random map. */ @@ -154,32 +141,35 @@ switch (orientation) { - case 1: - { - sprintf (styledirname, "/styles/exitstyles/up"); - style_map_up = find_style (styledirname, exitstyle, -1); - sprintf (styledirname, "/styles/exitstyles/down"); - style_map_down = find_style (styledirname, exitstyle, -1); - break; - } - case 2: - { - sprintf (styledirname, "/styles/exitstyles/down"); - style_map_up = find_style (styledirname, exitstyle, -1); - sprintf (styledirname, "/styles/exitstyles/up"); - style_map_down = find_style (styledirname, exitstyle, -1); - break; - } - default: - { - sprintf (styledirname, "/styles/exitstyles/generic"); - style_map_up = find_style (styledirname, exitstyle, -1); - style_map_down = style_map_up; - break; - } + case 1: + { + sprintf (styledirname, "/styles/exitstyles/up"); + style_map_up = find_style (styledirname, exitstyle, -1); + sprintf (styledirname, "/styles/exitstyles/down"); + style_map_down = find_style (styledirname, exitstyle, -1); + break; + } + + case 2: + { + sprintf (styledirname, "/styles/exitstyles/down"); + style_map_up = find_style (styledirname, exitstyle, -1); + sprintf (styledirname, "/styles/exitstyles/up"); + style_map_down = find_style (styledirname, exitstyle, -1); + break; + } + + default: + { + sprintf (styledirname, "/styles/exitstyles/generic"); + style_map_up = find_style (styledirname, exitstyle, -1); + style_map_down = style_map_up; + break; + } } + if (style_map_up == 0) - the_exit_up = arch_to_object (find_archetype ("exit")); + the_exit_up = arch_to_object (archetype::find ("exit")); else { object *tmp; @@ -191,7 +181,7 @@ /* we need a down exit only if we're recursing. */ if (RP->dungeon_level < RP->dungeon_depth || RP->final_map[0] != 0) if (style_map_down == 0) - the_exit_down = arch_to_object (find_archetype ("exit")); + the_exit_down = arch_to_object (archetype::find ("exit")); else { object *tmp; @@ -205,7 +195,7 @@ /* set up the up exit */ the_exit_up->stats.hp = RP->origin_x; the_exit_up->stats.sp = RP->origin_y; - the_exit_up->slaying = RP->origin_map; + the_exit_up->slaying = RP->origin_map; /* figure out where to put the entrance */ /* begin a logical block */ @@ -270,8 +260,8 @@ maze[the_exit_up->x][the_exit_up->y] = '<'; /* set the starting x,y for this map */ - MAP_ENTER_X (map) = the_exit_up->x; - MAP_ENTER_Y (map) = the_exit_up->y; + map->enter_x = the_exit_up->x; + map->enter_y = the_exit_up->y; /* first, look for a '>' character */ find_in_layout (0, '>', &downx, &downy, maze, RP); @@ -322,7 +312,7 @@ /* the identifier for making a random map. */ if (RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0] != 0) { - mapstruct *new_map; + maptile *new_map; object *the_exit_back = arch_to_object (the_exit_up->arch), *tmp; #if 0 @@ -339,13 +329,12 @@ /* set the exit down. */ #endif /* load it */ - if ((new_map = ready_map_name (RP->final_map, 0)) == NULL) + if (!(new_map = maptile::load_map_sync (RP->final_map))) return; the_exit_down->slaying = RP->final_map; - strcpy (new_map->path, RP->final_map); - for (tmp = GET_MAP_OB (new_map, MAP_ENTER_X (new_map), MAP_ENTER_Y (new_map)); tmp; tmp = tmp->above) + for (tmp = new_map->at (new_map->enter_x, new_map->enter_y).bot; tmp; tmp = tmp->above) /* Remove exit back to previous random map. There should only be one * which is why we break out. To try to process more than one * would require keeping a 'next' pointer, ad free_object kills tmp, which @@ -353,8 +342,7 @@ */ if (tmp->type == EXIT && EXIT_PATH (tmp) && !strncmp (EXIT_PATH (tmp), "/random/", 8)) { - remove_ob (tmp); - free_object (tmp); + tmp->destroy (); break; } @@ -364,13 +352,11 @@ the_exit_back->slaying = map->path; the_exit_back->stats.hp = the_exit_down->x; the_exit_back->stats.sp = the_exit_down->y; - the_exit_back->x = MAP_ENTER_X (new_map); - the_exit_back->y = MAP_ENTER_Y (new_map); + the_exit_back->x = new_map->enter_x; + the_exit_back->y = new_map->enter_y; insert_ob_in_map (the_exit_back, new_map, NULL, 0); } - - set_map_timeout (new_map); /* So it gets swapped out */ } else the_exit_down->slaying = "/!"; @@ -384,13 +370,11 @@ } - - /* this function unblocks the exits. We blocked them to keep things from being dumped on them during the other phases of random map generation. */ void -unblock_exits (mapstruct *map, char **maze, RMParms * RP) +unblock_exits (maptile *map, char **maze, random_map_params * RP) { int i = 0, j = 0; object *walk; @@ -399,7 +383,7 @@ for (j = 0; j < RP->Ysize; j++) if (maze[i][j] == '>' || maze[i][j] == '<') { - for (walk = get_map_ob (map, i, j); walk != NULL; walk = walk->above) + for (walk = GET_MAP_OB (map, i, j); walk != NULL; walk = walk->above) { if (walk->move_block == MOVE_ALL && walk->type != LOCKED_DOOR) {