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


version 1.7 version 1.8
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_treasure_c =   * static char *rcsid_treasure_c =
  *   "$Id: treasure.c,v 1.7 2000/07/26 18:24:38 peterm Exp $";   *   "$Id: treasure.c,v 1.8 2000/12/15 03:09:19 peterm Exp $";
  */   */
   
 /*  /*
Line 31
 
Line 31
   
 #include <global.h>  #include <global.h>
 #include <random_map.h>  #include <random_map.h>
   #include <rproto.h>
   
 /* some defines for various options which can be set. */  /* some defines for various options which can be set. */
   
Line 68
 
Line 69
 treasureoptions   (may be 0 for random choices or positive)  treasureoptions   (may be 0 for random choices or positive)
 */  */
   
 void place_treasure(mapstruct *map,char **layout, char *treasure_style,int treasureoptions) {  void place_treasure(mapstruct *map,char **layout, char *treasure_style,int treasureoptions,RMParms *RP) {
   char styledirname[256];    char styledirname[256];
   char stylefilepath[256];    char stylefilepath[256];
   mapstruct *style_map=0;    mapstruct *style_map=0;
Line 85
 
Line 86
   
   /* pick the number of treasures */    /* pick the number of treasures */
   if(treasureoptions & SPARSE)    if(treasureoptions & SPARSE)
     num_treasures = BC_RANDOM(total_map_hp/600+difficulty/2+1);      num_treasures = BC_RANDOM(RP->total_map_hp/600+RP->difficulty/2+1);
   else if(treasureoptions & RICH)    else if(treasureoptions & RICH)
     num_treasures = BC_RANDOM(total_map_hp/150+2*difficulty+1);      num_treasures = BC_RANDOM(RP->total_map_hp/150+2*RP->difficulty+1);
   else num_treasures = BC_RANDOM(total_map_hp/300+difficulty+1);      else num_treasures = BC_RANDOM(RP->total_map_hp/300+RP->difficulty+1); 
          
   if(num_treasures <= 0 ) return;    if(num_treasures <= 0 ) return;
   
Line 101
 
Line 102
   if(treasureoptions & CONCENTRATED) {    if(treasureoptions & CONCENTRATED) {
   
  /* map_layout_style global, and is previously set */   /* map_layout_style global, and is previously set */
     switch(map_layout_style) {      switch(RP->map_layout_style) {
     case ONION_LAYOUT:      case ONION_LAYOUT:
       {        {
    int i,j;     int i,j;
    /* search the onion for C's or '>', and put treasure there. */     /* search the onion for C's or '>', and put treasure there. */
    for(i=0;i<Xsize;i++) {     for(i=0;i<RP->Xsize;i++) {
  for(j=0;j<Xsize;j++) {   for(j=0;j<RP->Xsize;j++) {
  if(layout[i][j]=='C' || layout[i][j]=='>') {   if(layout[i][j]=='C' || layout[i][j]=='>') {
    int tdiv = symmetry_used;     int tdiv = RP->symmetry_used;
    object **doorlist;     object **doorlist;
    object *chest;     object *chest;
    if(tdiv==3) tdiv = 2; /* this symmetry uses a divisor of 2*/     if(tdiv==3) tdiv = 2; /* this symmetry uses a divisor of 2*/
    chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures/tdiv);     chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures/tdiv,RP);
    if(treasureoptions & (DOORED|HIDDEN)) {     if(treasureoptions & (DOORED|HIDDEN)) {
  doorlist=find_doors_in_room(map,i,j);   doorlist=find_doors_in_room(map,i,j,RP);
  lock_and_hide_doors(doorlist,map,treasureoptions);   lock_and_hide_doors(doorlist,map,treasureoptions,RP);
  free(doorlist);   free(doorlist);
    }     }
  }   }
Line 131
 
Line 132
    object **doorlist;     object **doorlist;
    i=j=-1;tries=0;     i=j=-1;tries=0;
    while(i==-1&&tries<100) {     while(i==-1&&tries<100) {
  i = RANDOM()%(Xsize-2)+1;   i = RANDOM()%(RP->Xsize-2)+1;
  j = RANDOM()%(Ysize-2)+1;   j = RANDOM()%(RP->Ysize-2)+1;
  find_enclosed_spot(map,&i,&j);   find_enclosed_spot(map,&i,&j,RP);
  if(wall_blocked(map,i,j)) i=-1;   if(wall_blocked(map,i,j)) i=-1;
  tries++;   tries++;
    }     }
    chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures);     chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures,RP);
    i = chest->x; j = chest->y;     i = chest->x; j = chest->y;
    if(treasureoptions &( DOORED|HIDDEN)) {     if(treasureoptions &( DOORED|HIDDEN)) {
  doorlist=surround_by_doors(map,i,j,treasureoptions);   doorlist=surround_by_doors(map,i,j,treasureoptions);
  lock_and_hide_doors(doorlist,map,treasureoptions);   lock_and_hide_doors(doorlist,map,treasureoptions,RP);
  free(doorlist);   free(doorlist);
    }     }
       }        }
Line 150
 
Line 151
   else { /* DIFFUSE treasure layout */    else { /* DIFFUSE treasure layout */
     int ti,i,j;      int ti,i,j;
     for(ti=0;ti<num_treasures;ti++) {      for(ti=0;ti<num_treasures;ti++) {
       i = RANDOM()%(Xsize-2)+1;        i = RANDOM()%(RP->Xsize-2)+1;
       j = RANDOM()%(Ysize-2)+1;        j = RANDOM()%(RP->Ysize-2)+1;
       place_chest(treasureoptions,i,j,map,style_map,1);        place_chest(treasureoptions,i,j,map,style_map,1,RP);
     }      }
   }    }
 }  }
Line 163
 
Line 164
  determined (may be null, or may be a treasure list from lib/treasures,   determined (may be null, or may be a treasure list from lib/treasures,
  if the global variable "treasurestyle" is set to that treasure list's name */   if the global variable "treasurestyle" is set to that treasure list's name */
   
 object * place_chest(int treasureoptions,int x, int y,mapstruct *map, mapstruct *style_map,int n_treasures) {  object * place_chest(int treasureoptions,int x, int y,mapstruct *map, mapstruct *style_map,int n_treasures,RMParms *RP) {
   object *the_chest;    object *the_chest;
   int i;    int i;
   
Line 179
 
Line 180
   if(0) {  /* don't use treasure style maps for now!  */    if(0) {  /* don't use treasure style maps for now!  */
     int ti;      int ti;
     /* if treasurestyle lists a treasure list, use it. */      /* if treasurestyle lists a treasure list, use it. */
     treasurelist *tlist=find_treasurelist(treasurestyle);      treasurelist *tlist=find_treasurelist(RP->treasurestyle);
     if(tlist!=NULL)      if(tlist!=NULL)
       for(ti=0;ti<n_treasures;ti++) {  /* use the treasure list */        for(ti=0;ti<n_treasures;ti++) {  /* use the treasure list */
    object *new_treasure=pick_random_object(style_map);     object *new_treasure=pick_random_object(style_map);
Line 202
 
Line 203
  object *the_trap;   object *the_trap;
  if(trap_map) {   if(trap_map) {
  the_trap= pick_random_object(trap_map);   the_trap= pick_random_object(trap_map);
  the_trap->stats.Cha = 10+difficulty;   the_trap->stats.Cha = 10+RP->difficulty;
  the_trap->level = BC_RANDOM((3*difficulty)/2);   the_trap->level = BC_RANDOM((3*RP->difficulty)/2);
  if(the_trap) {   if(the_trap) {
    object *new_trap;     object *new_trap;
    new_trap = arch_to_object(the_trap->arch);     new_trap = arch_to_object(the_trap->arch);
Line 223
 
Line 224
     char keybuf[256];      char keybuf[256];
     sprintf(keybuf,"%d",RANDOM());      sprintf(keybuf,"%d",RANDOM());
     the_chest->slaying = add_string(keybuf);      the_chest->slaying = add_string(keybuf);
     keyplace(map,x,y,keybuf,PASS_DOORS,1);      keyplace(map,x,y,keybuf,PASS_DOORS,1,RP);
   }    }
   
   /* actually place the chest. */    /* actually place the chest. */
Line 236
 
Line 237
   
 /* finds the closest monster and returns him, regardless of doors  /* finds the closest monster and returns him, regardless of doors
  or walls */   or walls */
 object *find_closest_monster(mapstruct *map,int x,int y) {  object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) {
   int i;    int i;
   for(i=0;i<SIZEOFFREE;i++) {    for(i=0;i<SIZEOFFREE;i++) {
     int lx,ly;      int lx,ly;
     lx=x+freearr_x[i];      lx=x+freearr_x[i];
     ly=y+freearr_y[i];      ly=y+freearr_y[i];
  /* boundscheck */   /* boundscheck */
     if(lx > 0 && ly > 0 && lx < Xsize && ly < Ysize)      if(lx > 0 && ly > 0 && lx < RP->Xsize && ly < RP->Ysize)
  /* don't bother searching this square unless the map says life exists.*/   /* don't bother searching this square unless the map says life exists.*/
       if(get_map(map,lx,ly)->flags & P_IS_ALIVE) {        if(get_map(map,lx,ly)->flags & P_IS_ALIVE) {
    object *the_monster=get_map_ob(map,lx,ly);     object *the_monster=get_map_ob(map,lx,ly);
Line 268
 
Line 269
  sure a key is placed on both sides of the door.   sure a key is placed on both sides of the door.
 */  */
    
 void keyplace(mapstruct *map,int x,int y,char *keycode,int door_flag,int n_keys) {  void keyplace(mapstruct *map,int x,int y,char *keycode,int door_flag,int n_keys,RMParms *RP) {
   int i,j;    int i,j;
   int kx,ky;    int kx,ky;
   object *the_keymaster; /* the monster that gets the key. */    object *the_keymaster; /* the monster that gets the key. */
Line 283
 
Line 284
     int tries=0;      int tries=0;
     the_keymaster=NULL;      the_keymaster=NULL;
     while(tries<5&&the_keymaster==NULL) {      while(tries<5&&the_keymaster==NULL) {
       i = (RANDOM()%(Xsize-2))+1;        i = (RANDOM()%(RP->Xsize-2))+1;
       j = (RANDOM()%(Ysize-2))+1;        j = (RANDOM()%(RP->Ysize-2))+1;
  tries++;   tries++;
       the_keymaster=find_closest_monster(map,i,j);        the_keymaster=find_closest_monster(map,i,j,RP);
     }      }
     /* if we don't find a good keymaster, drop the key on the ground. */      /* if we don't find a good keymaster, drop the key on the ground. */
     if(the_keymaster==NULL) {      if(the_keymaster==NULL) {
Line 300
 
Line 301
        NO_PASS_DOORS is set. */         NO_PASS_DOORS is set. */
     if(n_keys==1) {      if(n_keys==1) {
       if(wall_blocked(map,x,y)) return;        if(wall_blocked(map,x,y)) return;
       the_keymaster=find_monster_in_room(map,x,y);        the_keymaster=find_monster_in_room(map,x,y,RP);
       if(the_keymaster==NULL)  /* if fail, find a spot to drop the key. */        if(the_keymaster==NULL)  /* if fail, find a spot to drop the key. */
    find_spot_in_room(map,x,y,&kx,&ky);     find_spot_in_room(map,x,y,&kx,&ky,RP);
     }      }
     else {      else {
       /* I'm lazy, so just try to place in all 4 directions. */        /* I'm lazy, so just try to place in all 4 directions. */
       keyplace(map,x+1,y,keycode,NO_PASS_DOORS,1);        keyplace(map,x+1,y,keycode,NO_PASS_DOORS,1,RP);
       keyplace(map,x,y+1,keycode,NO_PASS_DOORS,1);        keyplace(map,x,y+1,keycode,NO_PASS_DOORS,1,RP);
       keyplace(map,x-1,y,keycode,NO_PASS_DOORS,1);        keyplace(map,x-1,y,keycode,NO_PASS_DOORS,1,RP);
       keyplace(map,x,y-1,keycode,NO_PASS_DOORS,1);        keyplace(map,x,y-1,keycode,NO_PASS_DOORS,1,RP);
       return;        return;
     }          }   
   }    }
Line 333
 
Line 334
 /* a recursive routine which will return a monster, eventually,if there is one.  /* a recursive routine which will return a monster, eventually,if there is one.
    it does a check-off on the layout, converting 0's to 1's */       it does a check-off on the layout, converting 0's to 1's */ 
   
 object *find_monster_in_room_recursive(char **layout, mapstruct *map, int x, int y) {  object *find_monster_in_room_recursive(char **layout, mapstruct *map, int x, int y, RMParms *RP) {
   int i,j;    int i,j;
   /* if we've found a monster already, leave */    /* if we've found a monster already, leave */
   if(theMonsterToFind!=NULL) return theMonsterToFind;    if(theMonsterToFind!=NULL) return theMonsterToFind;
   
   /* bounds check x and y */    /* bounds check x and y */
   if(!(x >= 0 && y >= 0 && x < Xsize && y < Ysize)) return theMonsterToFind;    if(!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) return theMonsterToFind;
   
   /* if the square is blocked or searched already, leave */    /* if the square is blocked or searched already, leave */
   if(layout[x][y]!=0) return theMonsterToFind; /* might be NULL, that's fine.*/    if(layout[x][y]!=0) return theMonsterToFind; /* might be NULL, that's fine.*/
Line 359
 
Line 360
      
   /* now search all the 8 squares around recursively for a monster,in random order */    /* now search all the 8 squares around recursively for a monster,in random order */
   for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {    for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {
     theMonsterToFind = find_monster_in_room_recursive(layout,map,x+freearr_x[i%8+1],y+freearr_y[i%8+1]);      theMonsterToFind = find_monster_in_room_recursive(layout,map,x+freearr_x[i%8+1],y+freearr_y[i%8+1],RP);
     if(theMonsterToFind!=NULL) return theMonsterToFind;      if(theMonsterToFind!=NULL) return theMonsterToFind;
   }    }
   return theMonsterToFind;    return theMonsterToFind;
Line 369
 
Line 370
 /* sets up some data structures:  the _recursive form does the  /* sets up some data structures:  the _recursive form does the
    real work.  */     real work.  */
   
 object *find_monster_in_room(mapstruct *map,int x,int y) {  object *find_monster_in_room(mapstruct *map,int x,int y,RMParms *RP) {
   char **layout2;    char **layout2;
   int i,j;    int i,j;
   theMonsterToFind=0;    theMonsterToFind=0;
   layout2 = (char **) calloc(sizeof(char *),Xsize);    layout2 = (char **) calloc(sizeof(char *),RP->Xsize);
   /* allocate and copy the layout, converting C to 0. */    /* allocate and copy the layout, converting C to 0. */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     layout2[i]=(char *)calloc(sizeof(char),Ysize);      layout2[i]=(char *)calloc(sizeof(char),RP->Ysize);
     for(j=0;j<Ysize;j++) {      for(j=0;j<RP->Ysize;j++) {
       if(wall_blocked(map,i,j)) layout2[i][j] = '#';        if(wall_blocked(map,i,j)) layout2[i][j] = '#';
     }      }
   }    }
   theMonsterToFind = find_monster_in_room_recursive(layout2,map,x,y);    theMonsterToFind = find_monster_in_room_recursive(layout2,map,x,y,RP);
      
   /* deallocate the temp. layout */    /* deallocate the temp. layout */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     free(layout2[i]);      free(layout2[i]);
   }    }
   free(layout2);    free(layout2);
Line 404
 
Line 405
 a datastructure of free points is set up, and a position chosen from  a datastructure of free points is set up, and a position chosen from
 that datastructure. */  that datastructure. */
   
 void find_spot_in_room_recursive(char **layout,int x,int y) {  void find_spot_in_room_recursive(char **layout,int x,int y,RMParms *RP) {
   int i,j;    int i,j;
   
   /* bounds check x and y */    /* bounds check x and y */
   if(!(x >= 0 && y >= 0 && x < Xsize && y < Ysize)) return;    if(!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) return;
   
   /* if the square is blocked or searched already, leave */    /* if the square is blocked or searched already, leave */
   if(layout[x][y]!=0) return;    if(layout[x][y]!=0) return;
Line 422
 
Line 423
   number_of_free_spots_in_room++;    number_of_free_spots_in_room++;
   /* now search all the 8 squares around recursively for free spots,in random order */    /* now search all the 8 squares around recursively for free spots,in random order */
   for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {    for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {
     find_spot_in_room_recursive(layout,x+freearr_x[i%8+1],y+freearr_y[i%8+1]);      find_spot_in_room_recursive(layout,x+freearr_x[i%8+1],y+freearr_y[i%8+1],RP);
   }    }
   
 }  }
   
 /* find a random non-blocked spot in this room to drop a key. */  /* find a random non-blocked spot in this room to drop a key. */
 void find_spot_in_room(mapstruct *map,int x,int y,int *kx,int *ky) {  void find_spot_in_room(mapstruct *map,int x,int y,int *kx,int *ky,RMParms *RP) {
   char **layout2;    char **layout2;
   int i,j;    int i,j;
   number_of_free_spots_in_room=0;    number_of_free_spots_in_room=0;
   room_free_spots_x = (int *)calloc(sizeof(int),Xsize * Ysize);    room_free_spots_x = (int *)calloc(sizeof(int),RP->Xsize * RP->Ysize);
   room_free_spots_y = (int *)calloc(sizeof(int),Xsize * Ysize);    room_free_spots_y = (int *)calloc(sizeof(int),RP->Xsize * RP->Ysize);
   
   layout2 = (char **) calloc(sizeof(char *),Xsize);    layout2 = (char **) calloc(sizeof(char *),RP->Xsize);
   /* allocate and copy the layout, converting C to 0. */    /* allocate and copy the layout, converting C to 0. */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     layout2[i]=(char *)calloc(sizeof(char),Ysize);      layout2[i]=(char *)calloc(sizeof(char),RP->Ysize);
     for(j=0;j<Ysize;j++) {      for(j=0;j<RP->Ysize;j++) {
       if(wall_blocked(map,i,j)) layout2[i][j] = '#';        if(wall_blocked(map,i,j)) layout2[i][j] = '#';
     }      }
   }    }
      
   /* setup num_free_spots and room_free_spots */     /* setup num_free_spots and room_free_spots */
   find_spot_in_room_recursive(layout2,x,y);    find_spot_in_room_recursive(layout2,x,y,RP);
      
   if(number_of_free_spots_in_room > 0) {    if(number_of_free_spots_in_room > 0) {
     i = RANDOM()%number_of_free_spots_in_room;      i = RANDOM()%number_of_free_spots_in_room;
Line 454
 
Line 455
   }    }
   
   /* deallocate the temp. layout */    /* deallocate the temp. layout */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     free(layout2[i]);      free(layout2[i]);
   }    }
   free(layout2);    free(layout2);
Line 467
 
Line 468
  walls the better, but it'll settle for 1 wall, or even 0, but   walls the better, but it'll settle for 1 wall, or even 0, but
  it'll return 0 if no FREE spots are found.*/   it'll return 0 if no FREE spots are found.*/
   
 void find_enclosed_spot(mapstruct *map, int *cx, int *cy) {  void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) {
   int x,y;    int x,y;
   int i;    int i;
   x = *cx;y=*cy;    x = *cx;y=*cy;
Line 476
 
Line 477
     int lx,ly,sindex;      int lx,ly,sindex;
     lx = x +freearr_x[i];      lx = x +freearr_x[i];
     ly = y +freearr_y[i];      ly = y +freearr_y[i];
     sindex = surround_flag3(map,lx,ly);      sindex = surround_flag3(map,lx,ly,RP);
     /* if it's blocked on 3 sides, it's enclosed */      /* if it's blocked on 3 sides, it's enclosed */
     if(sindex==7 || sindex == 11 || sindex == 13 || sindex == 14) {      if(sindex==7 || sindex == 11 || sindex == 13 || sindex == 14) {
       *cx= lx;*cy= ly;        *cx= lx;*cy= ly;
Line 490
 
Line 491
     int lx,ly,sindex;      int lx,ly,sindex;
     lx = x +freearr_x[i];      lx = x +freearr_x[i];
     ly = y +freearr_y[i];      ly = y +freearr_y[i];
     sindex = surround_flag3(map,lx,ly);      sindex = surround_flag3(map,lx,ly,RP);
     /* if it's blocked on 3 sides, it's enclosed */      /* if it's blocked on 3 sides, it's enclosed */
     if(sindex==3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex==10 || sindex==12) {      if(sindex==3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex==10 || sindex==12) {
       *cx= lx;*cy= ly;        *cx= lx;*cy= ly;
Line 503
 
Line 504
     int lx,ly,sindex;      int lx,ly,sindex;
     lx = x +freearr_x[i];      lx = x +freearr_x[i];
     ly = y +freearr_y[i];      ly = y +freearr_y[i];
     sindex = surround_flag3(map,lx,ly);      sindex = surround_flag3(map,lx,ly,RP);
     /* if it's blocked on 3 sides, it's enclosed */      /* if it's blocked on 3 sides, it's enclosed */
     if(sindex) {      if(sindex) {
       *cx= lx;*cy= ly;        *cx= lx;*cy= ly;
Line 581
 
Line 582
         
   
 /* the workhorse routine, which finds the doors in a room */  /* the workhorse routine, which finds the doors in a room */
 void find_doors_in_room_recursive(char **layout,mapstruct *map,int x,int y,object **doorlist,int *ndoors) {  void find_doors_in_room_recursive(char **layout,mapstruct *map,int x,int y,object **doorlist,int *ndoors,RMParms *RP) {
   int i,j;    int i,j;
   object *door;    object *door;
   
   /* bounds check x and y */    /* bounds check x and y */
   if(!(x >= 0 && y >= 0 && x < Xsize && y < Ysize)) return;    if(!(x >= 0 && y >= 0 && x < RP->Xsize && y < RP->Ysize)) return;
   
   /* if the square is blocked or searched already, leave */    /* if the square is blocked or searched already, leave */
   if(layout[x][y]==1) return;    if(layout[x][y]==1) return;
Line 609
 
Line 610
     layout[x][y]=1;      layout[x][y]=1;
     /* now search all the 8 squares around recursively for free spots,in random order */      /* now search all the 8 squares around recursively for free spots,in random order */
     for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {      for(i=RANDOM()%8,j=0; j<8 && theMonsterToFind==NULL;i++,j++) {
       find_doors_in_room_recursive(layout,map,x+freearr_x[i%8+1],y+freearr_y[i%8+1],doorlist,ndoors);        find_doors_in_room_recursive(layout,map,x+freearr_x[i%8+1],y+freearr_y[i%8+1],doorlist,ndoors,RP);
     }      }
   }    }
 }  }
   
 /* find a random non-blocked spot in this room to drop a key. */  /* find a random non-blocked spot in this room to drop a key. */
 object** find_doors_in_room(mapstruct *map,int x,int y) {  object** find_doors_in_room(mapstruct *map,int x,int y,RMParms *RP) {
   char **layout2;    char **layout2;
   object **doorlist;    object **doorlist;
   int i,j;    int i,j;
Line 624
 
Line 625
   doorlist = (object **)calloc(sizeof(int),256);    doorlist = (object **)calloc(sizeof(int),256);
   
   
   layout2 = (char **) calloc(sizeof(char *),Xsize);    layout2 = (char **) calloc(sizeof(char *),RP->Xsize);
   /* allocate and copy the layout, converting C to 0. */    /* allocate and copy the layout, converting C to 0. */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     layout2[i]=(char *)calloc(sizeof(char),Ysize);      layout2[i]=(char *)calloc(sizeof(char),RP->Ysize);
     for(j=0;j<Ysize;j++) {      for(j=0;j<RP->Ysize;j++) {
       if(wall_blocked(map,i,j)) layout2[i][j] = '#';        if(wall_blocked(map,i,j)) layout2[i][j] = '#';
     }      }
   }    }
      
   /* setup num_free_spots and room_free_spots */     /* setup num_free_spots and room_free_spots */
   find_doors_in_room_recursive(layout2,map,x,y,doorlist,&ndoors);    find_doors_in_room_recursive(layout2,map,x,y,doorlist,&ndoors,RP);
   
   /* deallocate the temp. layout */    /* deallocate the temp. layout */
   for(i=0;i<Xsize;i++) {    for(i=0;i<RP->Xsize;i++) {
     free(layout2[i]);      free(layout2[i]);
   }    }
   free(layout2);    free(layout2);
Line 649
 
Line 650
 /* locks and/or hides all the doors in doorlist, or does nothing if  /* locks and/or hides all the doors in doorlist, or does nothing if
  opts doesn't say to lock/hide doors. */   opts doesn't say to lock/hide doors. */
   
 void lock_and_hide_doors(object **doorlist,mapstruct *map,int opts) {  void lock_and_hide_doors(object **doorlist,mapstruct *map,int opts,RMParms *RP) {
   object *door;    object *door;
   int i;    int i;
   /* lock the doors and hide the keys. */    /* lock the doors and hide the keys. */
Line 668
 
Line 669
       insert_ob_in_map(new_door,map,NULL);        insert_ob_in_map(new_door,map,NULL);
       sprintf(keybuf,"%d",RANDOM());        sprintf(keybuf,"%d",RANDOM());
       new_door->slaying = add_string(keybuf);        new_door->slaying = add_string(keybuf);
       keyplace(map,new_door->x,new_door->y,keybuf,NO_PASS_DOORS,2);        keyplace(map,new_door->x,new_door->y,keybuf,NO_PASS_DOORS,2,RP);
     }      }
   }    }
   
Line 677
 
Line 678
     for(i=0,door=doorlist[0];doorlist[i]!=NULL;i++) {      for(i=0,door=doorlist[0];doorlist[i]!=NULL;i++) {
       object *wallface;        object *wallface;
       door=doorlist[i];        door=doorlist[i];
       wallface=retrofit_joined_wall(map,door->x,door->y,1);        wallface=retrofit_joined_wall(map,door->x,door->y,1,RP);
  if(wallface!=NULL) {   if(wallface!=NULL) {
    retrofit_joined_wall(map,door->x-1,door->y,0);     retrofit_joined_wall(map,door->x-1,door->y,0,RP);
    retrofit_joined_wall(map,door->x+1,door->y,0);     retrofit_joined_wall(map,door->x+1,door->y,0,RP);
    retrofit_joined_wall(map,door->x,door->y-1,0);     retrofit_joined_wall(map,door->x,door->y-1,0,RP);
    retrofit_joined_wall(map,door->x,door->y+1,0);     retrofit_joined_wall(map,door->x,door->y+1,0,RP);
    door->face = wallface->face;     door->face = wallface->face;
    if(!QUERY_FLAG(wallface,FLAG_REMOVED)) remove_ob(wallface);     if(!QUERY_FLAG(wallface,FLAG_REMOVED)) remove_ob(wallface);
    free_object(wallface);     free_object(wallface);


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:58