Difference for random_maps/exit.c from version 1.7 to 1.8


version 1.7 version 1.8
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_exit_c =   * static char *rcsid_exit_c =
  *   "$Id: exit.c,v 1.7 2000/12/11 08:34:05 peterm Exp $";   *   "$Id: exit.c,v 1.8 2000/12/15 03:09:19 peterm Exp $";
  */   */
   
 /*  /*
Line 28
 
Line 28
 #include <global.h>  #include <global.h>
 #include <random_map.h>  #include <random_map.h>
 #include <sproto.h>  #include <sproto.h>
   #include <rproto.h>
   
 /* orientation:  0 means random,  /* orientation:  0 means random,
   1 means descending dungeon    1 means descending dungeon
Line 39
 
Line 39
   6 means southward    6 means southward
 */  */
   
 void place_exits(mapstruct *map, char **maze,char *exitstyle,int orientation) {  void place_exits(mapstruct *map, char **maze,char *exitstyle,int orientation,RMParms *RP) {
   char styledirname[256];    char styledirname[256];
   mapstruct *style_map_down=0;  /* harder maze */    mapstruct *style_map_down=0;  /* harder maze */
   mapstruct *style_map_up=0;    /* easier maze */    mapstruct *style_map_up=0;    /* easier maze */
Line 83
 
Line 83
   }    }
   
   /* we need a down exit only if we're recursing. */    /* we need a down exit only if we're recursing. */
   if(dungeon_level < dungeon_depth || final_map[0]!=0)    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"));      if(style_map_down == 0) the_exit_down = arch_to_object(find_archetype("exit"));
     else {      else {
       object *tmp;        object *tmp;
Line 93
 
Line 93
   else the_exit_down = 0;    else the_exit_down = 0;
   
   /* set up the down exit */    /* set up the down exit */
   the_exit_up->stats.hp = origin_x;    the_exit_up->stats.hp = RP->origin_x;
   the_exit_up->stats.sp = origin_y;    the_exit_up->stats.sp = RP->origin_y;
   the_exit_up->slaying = add_string(origin_map);    the_exit_up->slaying = add_string(RP->origin_map);
   
   /* figure out where to put the entrance */    /* figure out where to put the entrance */
   /* begin a logical block */    /* begin a logical block */
Line 103
 
Line 103
     int ex=-1,ey=-1;      int ex=-1,ey=-1;
     int i,j;      int i,j;
     /* first, look for a C, the map center.  */      /* first, look for a C, the map center.  */
     for(i=0;i<Xsize&&cx==-1;i++)      for(i=0;i<RP->Xsize&&cx==-1;i++)
       for(j=0;j<Ysize;j++) {        for(j=0;j<RP->Ysize;j++) {
    if(maze[i][j]=='C') {     if(maze[i][j]=='C') {
  cx = i; cy=j; break;   cx = i; cy=j; break;
    }     }
       }        }
     if(cx!=-1) {      if(cx!=-1) {
       if(cx > Xsize/2) ex = 1;        if(cx > RP->Xsize/2) ex = 1;
       else ex = Xsize -2;        else ex = RP->Xsize -2;
       if(cy > Ysize/2) ey = 1;        if(cy > RP->Ysize/2) ey = 1;
       else ey = Ysize -2;        else ey = RP->Ysize -2;
     }      }
     else {      else {
  ex = RANDOM() % (Xsize-2) +1;   ex = RANDOM() % (RP->Xsize-2) +1;
  ey = RANDOM() % (Ysize-2) +1;   ey = RANDOM() % (RP->Ysize-2) +1;
     }      }
  i = find_first_free_spot(the_exit_up->arch,map,ex,ey);   i = find_first_free_spot(the_exit_up->arch,map,ex,ey);
  the_exit_up->x = ex + freearr_x[i];   the_exit_up->x = ex + freearr_x[i];
Line 143
 
Line 143
  /* make the other exit far away from this one if   /* make the other exit far away from this one if
  there's no center. */   there's no center. */
  if(cx==-1) {   if(cx==-1) {
  if(ex > Xsize/2) cx = 1;   if(ex > RP->Xsize/2) cx = 1;
  else cx = Xsize -2;   else cx = RP->Xsize -2;
  if(ey > Ysize/2) cy = 1;   if(ey > RP->Ysize/2) cy = 1;
  else cy = Ysize -2;   else cy = RP->Ysize -2;
  };   };
   
  if(the_exit_down) {   if(the_exit_down) {
Line 154
 
Line 154
  i = find_first_free_spot(the_exit_down->arch,map,cx,cy);   i = find_first_free_spot(the_exit_down->arch,map,cx,cy);
  the_exit_down->x = cx + freearr_x[i];   the_exit_down->x = cx + freearr_x[i];
  the_exit_down->y = cy + freearr_y[i];   the_exit_down->y = cy + freearr_y[i];
  origin_x = the_exit_down->x;   RP->origin_x = the_exit_down->x;
  origin_y = the_exit_down->y;   RP->origin_y = the_exit_down->y;
  write_map_parameters_to_string(buf);   write_map_parameters_to_string(buf,RP);
  the_exit_down->msg = add_string(buf);   the_exit_down->msg = add_string(buf);
  /* the identifier for making a random map. */   /* the identifier for making a random map. */
  if(dungeon_level >= dungeon_depth && final_map[0]!=0) {   if(RP->dungeon_level >= RP->dungeon_depth && RP->final_map[0]!=0) {
    mapstruct *new_map;     mapstruct *new_map;
    char new_map_name[MAX_BUF];     char new_map_name[MAX_BUF];
    object *the_exit_back = arch_to_object(the_exit_up->arch);     object *the_exit_back = arch_to_object(the_exit_up->arch);
    /* give the final map a name */     /* give the final map a name */
    sprintf(new_map_name,"%sfinal_map",final_map);     sprintf(new_map_name,"%sfinal_map",RP->final_map);
    /* set the exit down. */     /* set the exit down. */
    the_exit_down->slaying = add_string(new_map_name);     the_exit_down->slaying = add_string(new_map_name);
    /* load it */     /* load it */
    if( (new_map=has_been_loaded(final_map)) == NULL)     if( (new_map=has_been_loaded(RP->final_map)) == NULL)
      new_map = load_original_map(final_map,0);       new_map = load_original_map(RP->final_map,0);
    /* leave if we couldn't find it. */     /* leave if we couldn't find it. */
    if(new_map==NULL) return;     if(new_map==NULL) return;
    /* fix the treasures in the map. */     /* fix the treasures in the map. */


Legend:
line(s) removed in v.1.7 
line(s) changed
 line(s) added in v.1.8

File made using version 1.98 of cvs2html by leaf at 2011-07-21 17:55