Atrinik Server 2.5
random_maps/random_map.c
Go to the documentation of this file.
00001 /************************************************************************
00002 *            Atrinik, a Multiplayer Online Role Playing Game            *
00003 *                                                                       *
00004 *    Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team    *
00005 *                                                                       *
00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game)     *
00007 * and Crossfire (Multiplayer game for X-windows).                       *
00008 *                                                                       *
00009 * This program is free software; you can redistribute it and/or modify  *
00010 * it under the terms of the GNU General Public License as published by  *
00011 * the Free Software Foundation; either version 2 of the License, or     *
00012 * (at your option) any later version.                                   *
00013 *                                                                       *
00014 * This program is distributed in the hope that it will be useful,       *
00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00017 * GNU General Public License for more details.                          *
00018 *                                                                       *
00019 * You should have received a copy of the GNU General Public License     *
00020 * along with this program; if not, write to the Free Software           *
00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.             *
00022 *                                                                       *
00023 * The author can be reached at admin@atrinik.org                        *
00024 ************************************************************************/
00025 
00031 #include <global.h>
00032 
00037 void dump_layout(char **layout, RMParms *RP)
00038 {
00039     int i, j;
00040 
00041     for (i = 0; i < RP->Xsize; i++)
00042     {
00043         for (j = 0; j < RP->Ysize; j++)
00044         {
00045             if (layout[i][j] == '\0')
00046             {
00047                 layout[i][j] = ' ';
00048             }
00049 
00050             printf("%c", layout[i][j]);
00051 
00052             if (layout[i][j] == ' ')
00053             {
00054                 layout[i][j] = '\0';
00055             }
00056         }
00057 
00058         printf("\n");
00059     }
00060 }
00061 
00068 mapstruct *generate_random_map(char *OutFileName, RMParms *RP)
00069 {
00070     char **layout;
00071     mapstruct *theMap;
00072     int i;
00073 
00074     /* pick a random seed, or use the one from the input file */
00075     if (RP->random_seed == 0)
00076     {
00077         SRANDOM(time(0));
00078     }
00079     else
00080     {
00081         SRANDOM(RP->random_seed);
00082     }
00083 
00084     if (RP->difficulty == 0)
00085     {
00086         /* use this instead of a map difficulty */
00087         RP->difficulty = RP->dungeon_level;
00088     }
00089     else
00090     {
00091         RP->difficulty_given = 1;
00092     }
00093 
00094     if (RP->expand2x > 0)
00095     {
00096         RP->Xsize /= 2;
00097         RP->Ysize /= 2;
00098     }
00099 
00100     layout = layoutgen(RP);
00101 
00102     if (RP->level_increment > 0)
00103     {
00104         RP->dungeon_level += RP->level_increment;
00105     }
00106     else
00107     {
00108         RP->dungeon_level++;
00109     }
00110 
00111     /* rotate the layout randomly */
00112     layout = rotate_layout(layout, RANDOM() % 4, RP);
00113 
00114 #ifdef RMAP_DEBUG
00115     dump_layout(layout, RP);
00116 #endif
00117 
00118     /* allocate the map and set the floor */
00119     theMap = make_map_floor(RP->floorstyle, RP);
00120 
00121     /* set the name of the map. */
00122     FREE_AND_COPY_HASH(theMap->path, OutFileName);
00123 
00124     theMap->name = strdup_local(RP->dungeon_name[0] ? RP->dungeon_name : OutFileName);
00125 
00126     if (RP->bg_music[0])
00127     {
00128         theMap->bg_music = strdup_local(RP->bg_music);
00129     }
00130 
00131     theMap->difficulty = RP->dungeon_level;
00132 
00133     make_map_walls(theMap, layout, RP->wallstyle, RP);
00134 
00135     put_doors(theMap, layout, RP->doorstyle, RP);
00136 
00137     place_exits(theMap, layout, RP->exitstyle, RP->orientation,RP);
00138 
00139     place_monsters(theMap, RP->monsterstyle, RP->difficulty, RP);
00140 
00141     put_decor(theMap, layout, RP);
00142 
00143     unblock_exits(theMap, layout, RP);
00144     set_map_darkness(theMap, RP->darkness);
00145 
00146     for (i = 0; i < RP->Xsize; i++)
00147     {
00148         free(layout[i]);
00149     }
00150 
00151     free(layout);
00152 
00153     return theMap;
00154 }
00155 
00162 char **layoutgen(RMParms *RP)
00163 {
00164     char **maze = NULL;
00165 
00166     if (RP->symmetry != NO_SYM)
00167     {
00168         if (RP->Xsize < 15)
00169         {
00170             RP->Xsize = 15 + RANDOM() % 25;
00171         }
00172 
00173         if (RP->Ysize < 15)
00174         {
00175             RP->Ysize = 15 + RANDOM() % 25;
00176         }
00177     }
00178     else
00179     {
00180         /* Has to be at least 7 for square spirals to work */
00181         if (RP->Xsize < 7)
00182         {
00183             RP->Xsize = 15 + RANDOM() % 25;
00184         }
00185 
00186         if (RP->Ysize < 7)
00187         {
00188             RP->Ysize = 15 + RANDOM() % 25;
00189         }
00190     }
00191 
00192     if (RP->symmetry == RANDOM_SYM)
00193     {
00194         RP->symmetry_used = (RANDOM() % ( XY_SYM)) + 1;
00195 
00196         if (RP->symmetry_used == Y_SYM || RP->symmetry_used == XY_SYM)
00197         {
00198             RP->Ysize = RP->Ysize / 2 + 1;
00199         }
00200 
00201         if (RP->symmetry_used == X_SYM || RP->symmetry_used == XY_SYM)
00202         {
00203             RP->Xsize = RP->Xsize / 2 + 1;
00204         }
00205     }
00206     else
00207     {
00208         RP->symmetry_used = RP->symmetry;
00209     }
00210 
00211     if (RP->symmetry == Y_SYM || RP->symmetry == XY_SYM)
00212     {
00213         RP->Ysize = RP->Ysize / 2 + 1;
00214     }
00215 
00216     if (RP->symmetry == X_SYM || RP->symmetry == XY_SYM)
00217     {
00218         RP->Xsize = RP->Xsize / 2 + 1;
00219     }
00220 
00221     if (strstr(RP->layoutstyle, "onion"))
00222     {
00223         maze = map_gen_onion(RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2);
00224 
00225         RP->map_layout_style = ONION_LAYOUT;
00226 
00227         if (!(RANDOM() % 3) && !(RP->layoutoptions1 & OPT_WALLS_ONLY))
00228         {
00229             roomify_layout(maze, RP);
00230         }
00231     }
00232 
00233     if (strstr(RP->layoutstyle, "maze"))
00234     {
00235         maze = maze_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
00236 
00237         RP->map_layout_style = MAZE_LAYOUT;
00238 
00239         if (!(RANDOM() % 2))
00240         {
00241             doorify_layout(maze, RP);
00242         }
00243     }
00244 
00245     if (strstr(RP->layoutstyle, "spiral"))
00246     {
00247         maze = map_gen_spiral(RP->Xsize, RP->Ysize, RP->layoutoptions1);
00248 
00249         RP->map_layout_style = SPIRAL_LAYOUT;
00250 
00251         if (!(RANDOM() % 2))
00252         {
00253             doorify_layout(maze, RP);
00254         }
00255     }
00256 
00257     if (strstr(RP->layoutstyle, "rogue"))
00258     {
00259         maze = roguelike_layout_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
00260 
00261         RP->map_layout_style = ROGUELIKE_LAYOUT;
00262     }
00263 
00264     if (strstr(RP->layoutstyle, "snake"))
00265     {
00266         maze = make_snake_layout(RP->Xsize, RP->Ysize);
00267 
00268         RP->map_layout_style = SNAKE_LAYOUT;
00269 
00270         if (RANDOM() % 2)
00271         {
00272             roomify_layout(maze, RP);
00273         }
00274     }
00275 
00276     if (strstr(RP->layoutstyle, "squarespiral"))
00277     {
00278         maze = make_square_spiral_layout(RP->Xsize, RP->Ysize);
00279 
00280         RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;
00281 
00282         if (RANDOM() % 2)
00283         {
00284             roomify_layout(maze, RP);
00285         }
00286     }
00287 
00288     /* unknown or unspecified layout type, pick one at random */
00289     if (maze == 0)
00290     {
00291         switch (RANDOM() % NROFLAYOUTS)
00292         {
00293             case 0:
00294                 maze = maze_gen(RP->Xsize, RP->Ysize, RANDOM() % 2);
00295 
00296                 RP->map_layout_style = MAZE_LAYOUT;
00297 
00298                 if (!(RANDOM() % 2))
00299                 {
00300                     doorify_layout(maze, RP);
00301                 }
00302 
00303                 break;
00304 
00305             case 1:
00306                 maze = map_gen_onion(RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2);
00307 
00308                 RP->map_layout_style = ONION_LAYOUT;
00309 
00310                 if (!(RANDOM() % 3) && !(RP->layoutoptions1 & OPT_WALLS_ONLY))
00311                 {
00312                     roomify_layout(maze, RP);
00313                 }
00314 
00315                 break;
00316 
00317             case 2:
00318                 maze = map_gen_spiral(RP->Xsize, RP->Ysize, RP->layoutoptions1);
00319 
00320                 RP->map_layout_style = SPIRAL_LAYOUT;
00321 
00322                 if (!(RANDOM() % 2))
00323                 {
00324                     doorify_layout(maze, RP);
00325                 }
00326 
00327                 break;
00328 
00329             case 3:
00330                 maze = roguelike_layout_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
00331 
00332                 RP->map_layout_style = ROGUELIKE_LAYOUT;
00333 
00334                 break;
00335 
00336             case 4:
00337                 maze = make_snake_layout(RP->Xsize, RP->Ysize);
00338 
00339                 RP->map_layout_style = SNAKE_LAYOUT;
00340 
00341                 if (RANDOM() % 2)
00342                 {
00343                     roomify_layout(maze, RP);
00344                 }
00345 
00346                 break;
00347 
00348             case 5:
00349                 maze = make_square_spiral_layout(RP->Xsize, RP->Ysize);
00350 
00351                 RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;
00352 
00353                 if (RANDOM() % 2)
00354                 {
00355                     roomify_layout(maze, RP);
00356                 }
00357 
00358                 break;
00359         }
00360     }
00361 
00362     maze = symmetrize_layout(maze, RP->symmetry_used, RP);
00363 
00364 #ifdef RMAP_DEBUG
00365     dump_layout(maze,RP);
00366 #endif
00367 
00368     if (RP->expand2x)
00369     {
00370         maze = expand2x(maze, RP->Xsize, RP->Ysize);
00371 
00372         RP->Xsize = RP->Xsize * 2 -1;
00373         RP->Ysize = RP->Ysize * 2 -1;
00374     }
00375 
00376     return maze;
00377 }
00378 
00386 char **symmetrize_layout(char **maze, int sym, RMParms *RP)
00387 {
00388     int i, j, Xsize_orig = RP->Xsize, Ysize_orig = RP->Ysize;
00389     char **sym_maze;
00390 
00391     /* tell everyone else what sort of symmetry is used.*/
00392     RP->symmetry_used = sym;
00393 
00394     if (sym == NO_SYM)
00395     {
00396         RP->Xsize = Xsize_orig;
00397         RP->Ysize = Ysize_orig;
00398 
00399         return maze;
00400     }
00401 
00402     /* pick new sizes */
00403     RP->Xsize = ((sym == X_SYM || sym == XY_SYM) ? RP->Xsize * 2 - 3 : RP->Xsize);
00404     RP->Ysize = ((sym == Y_SYM || sym == XY_SYM) ? RP->Ysize * 2 - 3 : RP->Ysize);
00405 
00406     sym_maze = (char **) calloc(sizeof(char *), RP->Xsize);
00407 
00408     for (i = 0; i < RP->Xsize; i++)
00409     {
00410         sym_maze[i] = (char *) calloc(sizeof(char), RP->Ysize);
00411     }
00412 
00413     if (sym == X_SYM)
00414     {
00415         for (i = 0; i < RP->Xsize / 2 + 1; i++)
00416         {
00417             for (j = 0; j < RP->Ysize; j++)
00418             {
00419                 sym_maze[i][j] = maze[i][j];
00420                 sym_maze[RP->Xsize - i - 1][j] = maze[i][j];
00421             }
00422         }
00423     }
00424 
00425     if (sym == Y_SYM)
00426     {
00427         for (i = 0; i < RP->Xsize; i++)
00428         {
00429             for (j = 0; j < RP->Ysize / 2 + 1; j++)
00430             {
00431                 sym_maze[i][j] = maze[i][j];
00432                 sym_maze[i][RP->Ysize-j - 1] = maze[i][j];
00433             }
00434         }
00435     }
00436 
00437     if (sym == XY_SYM)
00438     {
00439         for (i = 0; i < RP->Xsize / 2 + 1;i++)
00440         {
00441             for (j = 0; j < RP->Ysize / 2 + 1; j++)
00442             {
00443                 sym_maze[i][j] = maze[i][j];
00444                 sym_maze[i][RP->Ysize - j - 1] = maze[i][j];
00445 
00446                 sym_maze[RP->Xsize - i - 1][j] = maze[i][j];
00447                 sym_maze[RP->Xsize - i - 1][RP->Ysize - j - 1] = maze[i][j];
00448             }
00449         }
00450     }
00451 
00452     /* delete the old maze */
00453     for (i = 0; i < Xsize_orig; i++)
00454     {
00455         free(maze[i]);
00456     }
00457 
00458     free(maze);
00459 
00460     /* reconnect disjointed spirals */
00461     if (RP->map_layout_style == SPIRAL_LAYOUT)
00462     {
00463         connect_spirals(RP->Xsize, RP->Ysize, sym, sym_maze);
00464     }
00465 
00466     /* reconnect disjointed nethack mazes:  the routine for
00467      spirals will do the trick?*/
00468     if (RP->map_layout_style == ROGUELIKE_LAYOUT)
00469     {
00470         connect_spirals(RP->Xsize, RP->Ysize, sym, sym_maze);
00471     }
00472 
00473     return sym_maze;
00474 }
00475 
00490 char **rotate_layout(char **maze, int rotation, RMParms *RP)
00491 {
00492     char **new_maze;
00493     int i, j;
00494 
00495     switch (rotation)
00496     {
00497         case 0:
00498             return maze;
00499             break;
00500 
00501         /* a reflection */
00502         case 2:
00503         {
00504             char *new = malloc(sizeof(char) * RP->Xsize * RP->Ysize);
00505 
00506             /* make a copy */
00507             for (i = 0; i < RP->Xsize; i++)
00508             {
00509                 for (j = 0; j < RP->Ysize; j++)
00510                 {
00511                     new[i * RP->Ysize + j] = maze[i][j];
00512                 }
00513             }
00514 
00515             /* copy a reflection back */
00516             for (i = 0; i < RP->Xsize;i++)
00517             {
00518                 for (j = 0; j < RP->Ysize; j++)
00519                 {
00520                     maze[i][j]= new[(RP->Xsize - i - 1) * RP->Ysize + RP->Ysize - j - 1];
00521                 }
00522             }
00523 
00524             free(new);
00525             return maze;
00526             break;
00527         }
00528 
00529         case 1:
00530         case 3:
00531         {
00532             int swap;
00533 
00534             new_maze = (char **) calloc(sizeof(char *), RP->Ysize);
00535 
00536             for (i = 0; i < RP->Ysize; i++)
00537             {
00538                 new_maze[i] = (char *) calloc(sizeof(char), RP->Xsize);
00539             }
00540 
00541             /* swap x and y */
00542             if (rotation == 1)
00543             {
00544                 for (i = 0; i < RP->Xsize; i++)
00545                 {
00546                     for (j = 0; j < RP->Ysize; j++)
00547                     {
00548                         new_maze[j][i] = maze[i][j];
00549                     }
00550                 }
00551             }
00552 
00553             /* swap x and y */
00554             if (rotation == 3)
00555             {
00556                 for (i = 0; i < RP->Xsize; i++)
00557                 {
00558                     for (j = 0; j < RP->Ysize; j++)
00559                     {
00560                         new_maze[j][i] = maze[RP->Xsize - i - 1][RP->Ysize - j - 1];
00561                     }
00562                 }
00563             }
00564 
00565             /* delete the old layout */
00566             for (i = 0; i < RP->Xsize; i++)
00567             {
00568                 free(maze[i]);
00569             }
00570 
00571             free(maze);
00572 
00573             swap = RP->Ysize;
00574             RP->Ysize = RP->Xsize;
00575             RP->Xsize = swap;
00576             return new_maze;
00577             break;
00578         }
00579     }
00580 
00581     return NULL;
00582 }
00583 
00588 void roomify_layout(char **maze,RMParms *RP)
00589 {
00590     int tries = RP->Xsize * RP->Ysize / 30, ti;
00591 
00592     for (ti = 0; ti < tries; ti++)
00593     {
00594         /* starting location for looking at creating a door */
00595         int dx, dy;
00596         /* results of checking on creating walls. */
00597         int cx, cy;
00598 
00599         dx = RANDOM() % RP->Xsize;
00600         dy = RANDOM() % RP->Ysize;
00601 
00602         /* horizontal */
00603         cx = can_make_wall(maze, dx, dy, 0, RP);
00604 
00605         /* vertical */
00606         cy = can_make_wall(maze, dx, dy, 1, RP);
00607 
00608         if (cx == -1)
00609         {
00610             if (cy != -1)
00611             {
00612                 make_wall(maze, dx, dy, 1);
00613             }
00614 
00615             continue;
00616         }
00617 
00618         if (cy == -1)
00619         {
00620             make_wall(maze, dx, dy, 0);
00621 
00622             continue;
00623         }
00624 
00625         if (cx < cy)
00626         {
00627             make_wall(maze, dx, dy, 0);
00628         }
00629         else
00630         {
00631             make_wall(maze, dx, dy, 1);
00632         }
00633     }
00634 }
00635 
00647 int can_make_wall(char **maze, int dx, int dy, int dir, RMParms *RP)
00648 {
00649     int i1, length = 0;
00650 
00651     /* don't make walls if we're on the edge. */
00652     if (dx == 0 || dx == (RP->Xsize - 1) || dy == 0 || dy == (RP->Ysize - 1))
00653     {
00654         return -1;
00655     }
00656 
00657     /* don't make walls if we're ON a wall. */
00658     if (maze[dx][dy] != '\0')
00659     {
00660         return -1;
00661     }
00662 
00663     /* horizontal */
00664     if (dir == 0)
00665     {
00666         int y = dy;
00667 
00668         for (i1 = dx - 1; i1 > 0; i1--)
00669         {
00670             int sindex = surround_flag2(maze, i1, y, RP);
00671 
00672             if (sindex == 1)
00673             {
00674                 break;
00675             }
00676 
00677             /* can't make horizontal wall here */
00678             if (sindex != 0)
00679             {
00680                 return -1;
00681             }
00682 
00683             /* can't make horizontal wall here */
00684             if (maze[i1][y] != '\0')
00685             {
00686                 return -1;
00687             }
00688 
00689             length++;
00690         }
00691 
00692         for (i1 = dx + 1; i1 < RP->Xsize - 1; i1++)
00693         {
00694             int sindex = surround_flag2(maze, i1, y, RP);
00695 
00696             if (sindex == 2)
00697             {
00698                 break;
00699             }
00700 
00701             /* can't make horizontal wall here */
00702             if (sindex != 0)
00703             {
00704                 return -1;
00705             }
00706 
00707             /* can't make horizontal wall here */
00708             if (maze[i1][y] != '\0')
00709             {
00710                 return -1;
00711             }
00712 
00713             length++;
00714         }
00715 
00716         return length;
00717     }
00718     /* vertical */
00719     else
00720     {
00721         int x = dx;
00722 
00723         for (i1 = dy - 1; i1 > 0; i1--)
00724         {
00725             int sindex = surround_flag2(maze, x, i1, RP);
00726 
00727             if (sindex == 4)
00728             {
00729                 break;
00730             }
00731 
00732             /* can't make vertical wall here */
00733             if (sindex != 0)
00734             {
00735                 return -1;
00736             }
00737 
00738             /* can't make vertical wall here */
00739             if (maze[x][i1] != '\0')
00740             {
00741                 return -1;
00742             }
00743 
00744             length++;
00745         }
00746 
00747         for (i1 = dy + 1; i1 < RP->Ysize - 1; i1++)
00748         {
00749             int sindex = surround_flag2(maze, x, i1, RP);
00750 
00751             if (sindex == 8)
00752             {
00753                 break;
00754             }
00755 
00756             /* can't make vertical wall here */
00757             if (sindex != 0)
00758             {
00759                 return -1;
00760             }
00761 
00762             /* can't make vertical wall here */
00763             if (maze[x][i1] != '\0')
00764             {
00765                 return -1;
00766             }
00767 
00768             length++;
00769         }
00770 
00771         return length;
00772     }
00773 }
00774 
00784 int make_wall(char **maze,int x, int y, int dir)
00785 {
00786     int i1;
00787 
00788     /* mark a door */
00789     maze[x][y] = 'D';
00790 
00791     switch (dir)
00792     {
00793         /* horizontal */
00794         case 0:
00795             for (i1 = x - 1; maze[i1][y] == '\0'; i1--)
00796             {
00797                 maze[i1][y] = '#';
00798             }
00799 
00800             for (i1 = x + 1; maze[i1][y] == '\0'; i1++)
00801             {
00802                 maze[i1][y] = '#';
00803             }
00804 
00805             break;
00806 
00807         /* vertical */
00808         case 1:
00809             for (i1 = y - 1; maze[x][i1] == '\0'; i1--)
00810             {
00811                 maze[x][i1] = '#';
00812             }
00813 
00814             for (i1 = y + 1; maze[x][i1] == '\0'; i1++)
00815             {
00816                 maze[x][i1] = '#';
00817             }
00818 
00819             break;
00820     }
00821 
00822     return 0;
00823 }
00824 
00829 void doorify_layout(char **maze, RMParms *RP)
00830 {
00831     /* reasonable number of doors. */
00832     int ndoors = RP->Xsize * RP->Ysize / 60;
00833     int *doorlist_x, *doorlist_y;
00834     /* # of available doorlocations */
00835     int doorlocs = 0;
00836     int i, j;
00837 
00838     doorlist_x = malloc(sizeof(int) * RP->Xsize * RP->Ysize);
00839     doorlist_y = malloc(sizeof(int) * RP->Xsize * RP->Ysize);
00840 
00841     /* make a list of possible door locations */
00842     for (i = 1; i < RP->Xsize - 1; i++)
00843     {
00844         for (j = 1; j < RP->Ysize - 1; j++)
00845         {
00846             int sindex = surround_flag(maze, i, j, RP);
00847 
00848             /* these are possible door sindex */
00849             if (sindex == 3 || sindex == 12)
00850             {
00851                 doorlist_x[doorlocs] = i;
00852                 doorlist_y[doorlocs] = j;
00853 
00854                 doorlocs++;
00855             }
00856         }
00857     }
00858 
00859     while (ndoors > 0 && doorlocs > 0)
00860     {
00861         int di = RANDOM() % doorlocs, sindex;
00862 
00863         i = doorlist_x[di];
00864         j = doorlist_y[di];
00865 
00866         sindex = surround_flag(maze, i, j, RP);
00867 
00868         /* these are possible door sindex */
00869         if (sindex == 3 || sindex == 12)
00870         {
00871             maze[i][j] = 'D';
00872             ndoors--;
00873         }
00874 
00875         /* reduce the size of the list */
00876         doorlocs--;
00877 
00878         doorlist_x[di] = doorlist_x[doorlocs];
00879         doorlist_y[di] = doorlist_y[doorlocs];
00880     }
00881 
00882     free(doorlist_x);
00883     free(doorlist_y);
00884 }
00885 
00890 void write_map_parameters_to_string(char *buf, RMParms *RP)
00891 {
00892     char small_buf[256];
00893 
00894     sprintf(buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize);
00895 
00896     if (RP->wallstyle[0])
00897     {
00898         sprintf(small_buf, "wallstyle %s\n", RP->wallstyle);
00899         strcat(buf, small_buf);
00900     }
00901 
00902     if (RP->floorstyle[0])
00903     {
00904         sprintf(small_buf, "floorstyle %s\n", RP->floorstyle);
00905         strcat(buf, small_buf);
00906     }
00907 
00908     if (RP->monsterstyle[0])
00909     {
00910         sprintf(small_buf, "monsterstyle %s\n", RP->monsterstyle);
00911         strcat(buf, small_buf);
00912     }
00913 
00914     if (RP->layoutstyle[0])
00915     {
00916         sprintf(small_buf, "layoutstyle %s\n", RP->layoutstyle);
00917         strcat(buf, small_buf);
00918     }
00919 
00920     if (RP->decorstyle[0])
00921     {
00922         sprintf(small_buf, "decorstyle %s\n", RP->decorstyle);
00923         strcat(buf, small_buf);
00924     }
00925 
00926     if (RP->doorstyle[0])
00927     {
00928         sprintf(small_buf, "doorstyle %s\n", RP->doorstyle);
00929         strcat(buf, small_buf);
00930     }
00931 
00932     if (RP->dungeon_name[0])
00933     {
00934         sprintf(small_buf, "dungeon_name %s\n", RP->dungeon_name);
00935         strcat(buf, small_buf);
00936     }
00937 
00938     if (RP->exitstyle[0])
00939     {
00940         sprintf(small_buf, "exitstyle %s\n", RP->exitstyle);
00941         strcat(buf, small_buf);
00942     }
00943 
00944     if (RP->final_map[0])
00945     {
00946         sprintf(small_buf, "final_map %s\n", RP->final_map);
00947         strcat(buf, small_buf);
00948     }
00949 
00950     if (RP->expand2x)
00951     {
00952         sprintf(small_buf, "expand2x %d\n", RP->expand2x);
00953         strcat(buf, small_buf);
00954     }
00955 
00956     if (RP->layoutoptions1)
00957     {
00958         sprintf(small_buf, "layoutoptions1 %d\n", RP->layoutoptions1);
00959         strcat(buf, small_buf);
00960     }
00961 
00962     if (RP->layoutoptions2)
00963     {
00964         sprintf(small_buf, "layoutoptions2 %d\n", RP->layoutoptions2);
00965         strcat(buf, small_buf);
00966     }
00967 
00968     if (RP->layoutoptions3)
00969     {
00970         sprintf(small_buf, "layoutoptions3 %d\n", RP->layoutoptions3);
00971         strcat(buf, small_buf);
00972     }
00973 
00974     if (RP->symmetry)
00975     {
00976         sprintf(small_buf, "symmetry %d\n", RP->symmetry);
00977         strcat(buf, small_buf);
00978     }
00979 
00980     if (RP->difficulty && RP->difficulty_given)
00981     {
00982         sprintf(small_buf, "difficulty %d\n", RP->difficulty);
00983         strcat(buf, small_buf);
00984     }
00985 
00986     sprintf(small_buf, "dungeon_level %d\n", RP->dungeon_level);
00987     strcat(buf, small_buf);
00988 
00989     if (RP->dungeon_depth)
00990     {
00991         sprintf(small_buf, "dungeon_depth %d\n", RP->dungeon_depth);
00992         strcat(buf, small_buf);
00993     }
00994 
00995     if (RP->decorchance)
00996     {
00997         sprintf(small_buf, "decorchance %d\n", RP->decorchance);
00998         strcat(buf, small_buf);
00999     }
01000 
01001     if (RP->orientation)
01002     {
01003         sprintf(small_buf, "orientation %d\n", RP->orientation);
01004         strcat(buf, small_buf);
01005     }
01006 
01007     if (RP->random_seed)
01008     {
01009         sprintf(small_buf, "random_seed %d\n", RP->random_seed + 1);
01010         strcat(buf, small_buf);
01011     }
01012 
01013     if (RP->num_monsters)
01014     {
01015         sprintf(small_buf, "num_monsters %d\n", RP->num_monsters);
01016         strcat(buf, small_buf);
01017     }
01018 
01019     if (RP->darkness)
01020     {
01021         sprintf(small_buf, "darkness %d\n", RP->darkness);
01022         strcat(buf, small_buf);
01023     }
01024 
01025     if (RP->level_increment)
01026     {
01027         sprintf(small_buf, "level_increment %d\n", RP->level_increment);
01028         strcat(buf, small_buf);
01029     }
01030 
01031     if (RP->bg_music[0])
01032     {
01033         sprintf(small_buf, "bg_music %s\n", RP->bg_music);
01034         strcat(buf, small_buf);
01035     }
01036 }