Difference for random_maps/random_map.c from version 1.34 to 1.35


version 1.34 version 1.35
Line 1
 
Line 1
 /*  /*
  * static char *rcsid_random_map_c =   * static char *rcsid_random_map_c =
  *   "$Id: random_map.c,v 1.34 2003/03/09 00:18:41 mwedel Exp $";   *   "$Id: random_map.c,v 1.35 2003/09/26 05:44:43 mwedel Exp $";
  */   */
   
 /*  /*
Line 45
 
Line 45
     }      }
     printf("\n");      printf("\n");
     }}      }}
       printf("\n");
 }  }
 EXTERN FILE *logfile;  EXTERN FILE *logfile;
 mapstruct *generate_random_map(char *OutFileName, RMParms *RP) {  mapstruct *generate_random_map(char *OutFileName, RMParms *RP) {
Line 134
 
Line 135
     arguments it needs.  */      arguments it needs.  */
 char **layoutgen(RMParms *RP) {  char **layoutgen(RMParms *RP) {
     char **maze=0;      char **maze=0;
       int oxsize= RP->Xsize, oysize=RP->Ysize;
   
     if(RP->symmetry == RANDOM_SYM)       if(RP->symmetry == RANDOM_SYM)
  RP->symmetry_used = (RANDOM() % ( XY_SYM))+1;   RP->symmetry_used = (RANDOM() % ( XY_SYM))+1;
Line 144
 
Line 146
   
     if(RP->Xsize<MIN_RANDOM_MAP_SIZE) RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM()%5;      if(RP->Xsize<MIN_RANDOM_MAP_SIZE) RP->Xsize = MIN_RANDOM_MAP_SIZE + RANDOM()%5;
     if(RP->Ysize<MIN_RANDOM_MAP_SIZE) RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM()%5;      if(RP->Ysize<MIN_RANDOM_MAP_SIZE) RP->Ysize = MIN_RANDOM_MAP_SIZE + RANDOM()%5;
       RP->map_layout_style = 0;
   
       /* Redo this - there was a lot of redundant code of checking for preset
        * layout style and then random layout style.  Instead, figure out
        * the numeric layoutstyle, so there is only one area that actually
        * calls the code to make the maps.
        */
     if(strstr(RP->layoutstyle,"onion")) {      if(strstr(RP->layoutstyle,"onion")) {
  maze = map_gen_onion(RP->Xsize,RP->Ysize,RP->layoutoptions1,RP->layoutoptions2);  
  RP->map_layout_style = ONION_LAYOUT;   RP->map_layout_style = ONION_LAYOUT;
  if(!(RANDOM()%3)&& !(RP->layoutoptions1 & OPT_WALLS_ONLY)) roomify_layout(maze,RP);  
     }      }
   
     if(strstr(RP->layoutstyle,"maze")) {      if(strstr(RP->layoutstyle,"maze")) {
  maze = maze_gen(RP->Xsize,RP->Ysize,RP->layoutoptions1);  
  RP->map_layout_style = MAZE_LAYOUT;   RP->map_layout_style = MAZE_LAYOUT;
   
  if(!(RANDOM()%2)) doorify_layout(maze,RP);  
     }      }
   
     if(strstr(RP->layoutstyle,"spiral")) {      if(strstr(RP->layoutstyle,"spiral")) {
  maze = map_gen_spiral(RP->Xsize,RP->Ysize,RP->layoutoptions1);  
  RP->map_layout_style = SPIRAL_LAYOUT;   RP->map_layout_style = SPIRAL_LAYOUT;
  if(!(RANDOM()%2)) doorify_layout(maze,RP);  
     }      }
   
     if(strstr(RP->layoutstyle,"rogue")) {      if(strstr(RP->layoutstyle,"rogue")) {
  maze = roguelike_layout_gen(RP->Xsize,RP->Ysize,RP->layoutoptions1);  
  RP->map_layout_style = ROGUELIKE_LAYOUT;   RP->map_layout_style = ROGUELIKE_LAYOUT;
  /* no doorification */  
     }      }
   
     if(strstr(RP->layoutstyle,"snake")) {      if(strstr(RP->layoutstyle,"snake")) {
  maze = make_snake_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);  
  RP->map_layout_style = SNAKE_LAYOUT;   RP->map_layout_style = SNAKE_LAYOUT;
  if(RANDOM()%2) roomify_layout(maze,RP);  
     }      }
   
     if(strstr(RP->layoutstyle,"squarespiral")) {      if(strstr(RP->layoutstyle,"squarespiral")) {
  maze = make_square_spiral_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);  
  RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;   RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;
  if(RANDOM()%2) roomify_layout(maze,RP);      }
       /* No style found - choose one ranomdly */
       if (RP->map_layout_style == 0) {
    RP->map_layout_style = (RANDOM() % NROFLAYOUTS) + 1;
     }      }
   
     /* unknown or unspecified layout type, pick one at random */      switch(RP->map_layout_style) {
     if(maze == 0)   
  switch(RANDOM()%NROFLAYOUTS) {  
      case 0:  
  maze = maze_gen(RP->Xsize,RP->Ysize,RANDOM()%2);  
  RP->map_layout_style = MAZE_LAYOUT;  
  if(!(RANDOM()%2)) doorify_layout(maze,RP);  
  break;  
   
      case 1:       case ONION_LAYOUT:
  maze = map_gen_onion(RP->Xsize,RP->Ysize,RP->layoutoptions1,RP->layoutoptions2);   maze = map_gen_onion(RP->Xsize,RP->Ysize,RP->layoutoptions1,RP->layoutoptions2);
  RP->map_layout_style = ONION_LAYOUT;  
  if(!(RANDOM()%3)&& !(RP->layoutoptions1 & OPT_WALLS_ONLY)) roomify_layout(maze,RP);   if(!(RANDOM()%3)&& !(RP->layoutoptions1 & OPT_WALLS_ONLY)) roomify_layout(maze,RP);
  break;   break;
   
      case 2:       case MAZE_LAYOUT:
    maze = maze_gen(RP->Xsize,RP->Ysize,RANDOM()%2);
    if(!(RANDOM()%2)) doorify_layout(maze,RP);
    break;
   
        case SPIRAL_LAYOUT:
  maze = map_gen_spiral(RP->Xsize,RP->Ysize,RP->layoutoptions1);   maze = map_gen_spiral(RP->Xsize,RP->Ysize,RP->layoutoptions1);
  RP->map_layout_style = SPIRAL_LAYOUT;  
  if(!(RANDOM()%2)) doorify_layout(maze,RP);   if(!(RANDOM()%2)) doorify_layout(maze,RP);
  break;   break;
   
      case 3:       case ROGUELIKE_LAYOUT:
    /* Don't put symmetry in rogue maps.  There isn't much reason to
    * do so in the first place (doesn't make it any more interesting),
    * but more importantly, the symmetry code presumes we are symmetrizing
    * spirals, or maps with lots of passages - making a symmetric rogue
    * map fails because its likely that the passages the symmetry process
    * creates may not connect the rooms.
    */
    RP->symmetry_used = NO_SYM;
    RP->Ysize = oysize;
    RP->Xsize = oxsize;
  maze = roguelike_layout_gen(RP->Xsize,RP->Ysize,RP->layoutoptions1);   maze = roguelike_layout_gen(RP->Xsize,RP->Ysize,RP->layoutoptions1);
  RP->map_layout_style = ROGUELIKE_LAYOUT;  
  /* no doorifying...  done already */   /* no doorifying...  done already */
  break;   break;
   
      case 4:       case SNAKE_LAYOUT:
  maze = make_snake_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);   maze = make_snake_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);
  RP->map_layout_style = SNAKE_LAYOUT;  
  if(RANDOM()%2) roomify_layout(maze,RP);   if(RANDOM()%2) roomify_layout(maze,RP);
  break;   break;
   
      case 5:       case SQUARE_SPIRAL_LAYOUT:
  maze = make_square_spiral_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);   maze = make_square_spiral_layout(RP->Xsize,RP->Ysize,RP->layoutoptions1);
  RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;  
  if(RANDOM()%2) roomify_layout(maze,RP);   if(RANDOM()%2) roomify_layout(maze,RP);
  break;   break;
  }   }


Legend:
line(s) removed in v.1.34 
line(s) changed
 line(s) added in v.1.35

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