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