Atrinik Server  4.0
random_map.c
Go to the documentation of this file.
1 /*************************************************************************
2  * Atrinik, a Multiplayer Online Role Playing Game *
3  * *
4  * Copyright (C) 2009-2014 Alex Tokar and Atrinik Development Team *
5  * *
6  * Fork from Crossfire (Multiplayer game for X-windows). *
7  * *
8  * This program is free software; you can redistribute it and/or modify *
9  * it under the terms of the GNU General Public License as published by *
10  * the Free Software Foundation; either version 2 of the License, or *
11  * (at your option) any later version. *
12  * *
13  * This program is distributed in the hope that it will be useful, *
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16  * GNU General Public License for more details. *
17  * *
18  * You should have received a copy of the GNU General Public License *
19  * along with this program; if not, write to the Free Software *
20  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
21  * *
22  * The author can be reached at admin@atrinik.org *
23  ************************************************************************/
24 
31 #include <global.h>
32 #include <toolkit/string.h>
33 
41 void dump_layout(char **layout, RMParms *RP)
42 {
43  int i, j;
44 
45  for (i = 0; i < RP->Xsize; i++) {
46  for (j = 0; j < RP->Ysize; j++) {
47  if (layout[i][j] == '\0') {
48  layout[i][j] = ' ';
49  }
50 
51  printf("%c", layout[i][j]);
52 
53  if (layout[i][j] == ' ') {
54  layout[i][j] = '\0';
55  }
56  }
57 
58  printf("\n");
59  }
60 }
61 
72 mapstruct *generate_random_map(char *OutFileName, RMParms *RP)
73 {
74  char **layout;
75  mapstruct *theMap;
76  int i;
77 
78  /* pick a random seed, or use the one from the input file */
79  if (RP->random_seed == 0) {
80  SRANDOM(time(0));
81  } else {
82  SRANDOM(RP->random_seed);
83  }
84 
85  if (RP->difficulty == 0) {
86  /* use this instead of a map difficulty */
87  RP->difficulty = RP->dungeon_level;
88  } else {
89  RP->difficulty_given = 1;
90  }
91 
92  if (RP->expand2x > 0) {
93  RP->Xsize /= 2;
94  RP->Ysize /= 2;
95  }
96 
97  layout = layoutgen(RP);
98 
99  if (RP->level_increment > 0) {
100  RP->dungeon_level += RP->level_increment;
101  } else {
102  RP->dungeon_level++;
103  }
104 
105  /* rotate the layout randomly */
106  layout = rotate_layout(layout, RANDOM() % 4, RP);
107 
108 #ifdef RMAP_DEBUG
109  dump_layout(layout, RP);
110 #endif
111 
112  /* allocate the map and set the floor */
113  theMap = make_map_floor(RP->floorstyle, RP);
114 
115  /* set the name of the map. */
116  FREE_AND_COPY_HASH(theMap->path, OutFileName);
117 
118  FREE_AND_COPY_HASH(theMap->name,
119  RP->dungeon_name[0] ? RP->dungeon_name : OutFileName);
120 
121  if (RP->bg_music[0] != '\0') {
122  FREE_AND_COPY_HASH(theMap->bg_music, RP->bg_music);
123  }
124 
125  theMap->difficulty = RP->dungeon_level;
126 
127  make_map_walls(theMap, layout, RP->wallstyle, RP);
128 
129  put_doors(theMap, layout, RP->doorstyle, RP);
130 
131  place_exits(theMap, layout, RP->exitstyle, RP->orientation, RP);
132 
133  place_monsters(theMap, RP->monsterstyle, RP->difficulty, RP);
134 
135  put_decor(theMap, layout, RP);
136 
137  unblock_exits(theMap, layout, RP);
138  set_map_darkness(theMap, RP->darkness);
139 
140  for (i = 0; i < RP->Xsize; i++) {
141  efree(layout[i]);
142  }
143 
144  efree(layout);
145 
146  return theMap;
147 }
148 
158 char **layoutgen(RMParms *RP)
159 {
160  char **maze = NULL;
161 
162  if (RP->symmetry != NO_SYM) {
163  if (RP->Xsize < 15) {
164  RP->Xsize = 15 + RANDOM() % 25;
165  }
166 
167  if (RP->Ysize < 15) {
168  RP->Ysize = 15 + RANDOM() % 25;
169  }
170  } else {
171  /* Has to be at least 7 for square spirals to work */
172  if (RP->Xsize < 7) {
173  RP->Xsize = 15 + RANDOM() % 25;
174  }
175 
176  if (RP->Ysize < 7) {
177  RP->Ysize = 15 + RANDOM() % 25;
178  }
179  }
180 
181  if (RP->symmetry == RANDOM_SYM) {
182  RP->symmetry_used = (RANDOM() % ( XY_SYM)) + 1;
183 
184  if (RP->symmetry_used == Y_SYM || RP->symmetry_used == XY_SYM) {
185  RP->Ysize = RP->Ysize / 2 + 1;
186  }
187 
188  if (RP->symmetry_used == X_SYM || RP->symmetry_used == XY_SYM) {
189  RP->Xsize = RP->Xsize / 2 + 1;
190  }
191  } else {
192  RP->symmetry_used = RP->symmetry;
193  }
194 
195  if (RP->symmetry == Y_SYM || RP->symmetry == XY_SYM) {
196  RP->Ysize = RP->Ysize / 2 + 1;
197  }
198 
199  if (RP->symmetry == X_SYM || RP->symmetry == XY_SYM) {
200  RP->Xsize = RP->Xsize / 2 + 1;
201  }
202 
203  if (strstr(RP->layoutstyle, "onion")) {
204  maze = map_gen_onion(RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2);
205 
206  RP->map_layout_style = ONION_LAYOUT;
207 
208  if (!(RANDOM() % 3) && !(RP->layoutoptions1 & OPT_WALLS_ONLY)) {
209  roomify_layout(maze, RP);
210  }
211  } else if (strstr(RP->layoutstyle, "maze")) {
212  maze = maze_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
213 
214  RP->map_layout_style = MAZE_LAYOUT;
215 
216  if (!(RANDOM() % 2)) {
217  doorify_layout(maze, RP);
218  }
219  } else if (strstr(RP->layoutstyle, "spiral")) {
220  maze = map_gen_spiral(RP->Xsize, RP->Ysize, RP->layoutoptions1);
221 
222  RP->map_layout_style = SPIRAL_LAYOUT;
223 
224  if (!(RANDOM() % 2)) {
225  doorify_layout(maze, RP);
226  }
227  } else if (strstr(RP->layoutstyle, "rogue")) {
228  maze = roguelike_layout_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
229 
230  RP->map_layout_style = ROGUELIKE_LAYOUT;
231  } else if (strstr(RP->layoutstyle, "snake")) {
232  maze = make_snake_layout(RP->Xsize, RP->Ysize);
233 
234  RP->map_layout_style = SNAKE_LAYOUT;
235 
236  if (RANDOM() % 2) {
237  roomify_layout(maze, RP);
238  }
239  } else if (strstr(RP->layoutstyle, "squarespiral")) {
240  maze = make_square_spiral_layout(RP->Xsize, RP->Ysize);
241 
242  RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;
243 
244  if (RANDOM() % 2) {
245  roomify_layout(maze, RP);
246  }
247  }
248 
249  /* unknown or unspecified layout type, pick one at random */
250  if (maze == NULL) {
251  switch (RANDOM() % NROFLAYOUTS) {
252  case 0:
253  maze = maze_gen(RP->Xsize, RP->Ysize, RANDOM() % 2);
254 
255  RP->map_layout_style = MAZE_LAYOUT;
256 
257  if (!(RANDOM() % 2)) {
258  doorify_layout(maze, RP);
259  }
260 
261  break;
262 
263  case 1:
264  maze = map_gen_onion(RP->Xsize, RP->Ysize, RP->layoutoptions1, RP->layoutoptions2);
265 
266  RP->map_layout_style = ONION_LAYOUT;
267 
268  if (!(RANDOM() % 3) && !(RP->layoutoptions1 & OPT_WALLS_ONLY)) {
269  roomify_layout(maze, RP);
270  }
271 
272  break;
273 
274  case 2:
275  maze = map_gen_spiral(RP->Xsize, RP->Ysize, RP->layoutoptions1);
276 
277  RP->map_layout_style = SPIRAL_LAYOUT;
278 
279  if (!(RANDOM() % 2)) {
280  doorify_layout(maze, RP);
281  }
282 
283  break;
284 
285  case 3:
286  maze = roguelike_layout_gen(RP->Xsize, RP->Ysize, RP->layoutoptions1);
287 
288  RP->map_layout_style = ROGUELIKE_LAYOUT;
289 
290  break;
291 
292  case 4:
293  maze = make_snake_layout(RP->Xsize, RP->Ysize);
294 
295  RP->map_layout_style = SNAKE_LAYOUT;
296 
297  if (RANDOM() % 2) {
298  roomify_layout(maze, RP);
299  }
300 
301  break;
302 
303  case 5:
304  maze = make_square_spiral_layout(RP->Xsize, RP->Ysize);
305 
306  RP->map_layout_style = SQUARE_SPIRAL_LAYOUT;
307 
308  if (RANDOM() % 2) {
309  roomify_layout(maze, RP);
310  }
311 
312  break;
313  }
314  }
315 
316  maze = symmetrize_layout(maze, RP->symmetry_used, RP);
317 
318 #ifdef RMAP_DEBUG
319  dump_layout(maze, RP);
320 #endif
321 
322  if (RP->expand2x) {
323  maze = expand2x(maze, RP->Xsize, RP->Ysize);
324 
325  RP->Xsize = RP->Xsize * 2 - 1;
326  RP->Ysize = RP->Ysize * 2 - 1;
327  }
328 
329  return maze;
330 }
331 
344 char **symmetrize_layout(char **maze, int sym, RMParms *RP)
345 {
346  int i, j, Xsize_orig = RP->Xsize, Ysize_orig = RP->Ysize;
347  char **sym_maze;
348 
349  /* tell everyone else what sort of symmetry is used.*/
350  RP->symmetry_used = sym;
351 
352  if (sym == NO_SYM) {
353  RP->Xsize = Xsize_orig;
354  RP->Ysize = Ysize_orig;
355 
356  return maze;
357  }
358 
359  /* pick new sizes */
360  RP->Xsize = ((sym == X_SYM || sym == XY_SYM) ? RP->Xsize * 2 - 3 : RP->Xsize);
361  RP->Ysize = ((sym == Y_SYM || sym == XY_SYM) ? RP->Ysize * 2 - 3 : RP->Ysize);
362 
363  sym_maze = ecalloc(sizeof(char *), RP->Xsize);
364 
365  for (i = 0; i < RP->Xsize; i++) {
366  sym_maze[i] = ecalloc(sizeof(char), RP->Ysize);
367  }
368 
369  if (sym == X_SYM) {
370  for (i = 0; i < RP->Xsize / 2 + 1; i++) {
371  for (j = 0; j < RP->Ysize; j++) {
372  sym_maze[i][j] = maze[i][j];
373  sym_maze[RP->Xsize - i - 1][j] = maze[i][j];
374  }
375  }
376  }
377 
378  if (sym == Y_SYM) {
379  for (i = 0; i < RP->Xsize; i++) {
380  for (j = 0; j < RP->Ysize / 2 + 1; j++) {
381  sym_maze[i][j] = maze[i][j];
382  sym_maze[i][RP->Ysize - j - 1] = maze[i][j];
383  }
384  }
385  }
386 
387  if (sym == XY_SYM) {
388  for (i = 0; i < RP->Xsize / 2 + 1; i++) {
389  for (j = 0; j < RP->Ysize / 2 + 1; j++) {
390  sym_maze[i][j] = maze[i][j];
391  sym_maze[i][RP->Ysize - j - 1] = maze[i][j];
392 
393  sym_maze[RP->Xsize - i - 1][j] = maze[i][j];
394  sym_maze[RP->Xsize - i - 1][RP->Ysize - j - 1] = maze[i][j];
395  }
396  }
397  }
398 
399  /* delete the old maze */
400  for (i = 0; i < Xsize_orig; i++) {
401  efree(maze[i]);
402  }
403 
404  efree(maze);
405 
406  /* reconnect disjointed spirals */
407  if (RP->map_layout_style == SPIRAL_LAYOUT) {
408  connect_spirals(RP->Xsize, RP->Ysize, sym, sym_maze);
409  }
410 
411  /* reconnect disjointed nethack mazes: the routine for
412  * spirals will do the trick?*/
413  if (RP->map_layout_style == ROGUELIKE_LAYOUT) {
414  connect_spirals(RP->Xsize, RP->Ysize, sym, sym_maze);
415  }
416 
417  return sym_maze;
418 }
419 
439 char **rotate_layout(char **maze, int rotation, RMParms *RP)
440 {
441  char **new_maze;
442  int i, j;
443 
444  switch (rotation) {
445  case 0:
446  return maze;
447  break;
448 
449  /* a reflection */
450  case 2:
451  {
452  char *new = emalloc(sizeof(char) * RP->Xsize * RP->Ysize);
453 
454  /* make a copy */
455  for (i = 0; i < RP->Xsize; i++) {
456  for (j = 0; j < RP->Ysize; j++) {
457  new[i * RP->Ysize + j] = maze[i][j];
458  }
459  }
460 
461  /* copy a reflection back */
462  for (i = 0; i < RP->Xsize; i++) {
463  for (j = 0; j < RP->Ysize; j++) {
464  maze[i][j] = new[(RP->Xsize - i - 1) * RP->Ysize + RP->Ysize - j - 1];
465  }
466  }
467 
468  efree(new);
469  return maze;
470  break;
471  }
472 
473  case 1:
474  case 3:
475  {
476  int swap;
477 
478  new_maze = ecalloc(sizeof(char *), RP->Ysize);
479 
480  for (i = 0; i < RP->Ysize; i++) {
481  new_maze[i] = ecalloc(sizeof(char), RP->Xsize);
482  }
483 
484  /* swap x and y */
485  if (rotation == 1) {
486  for (i = 0; i < RP->Xsize; i++) {
487  for (j = 0; j < RP->Ysize; j++) {
488  new_maze[j][i] = maze[i][j];
489  }
490  }
491  }
492 
493  /* swap x and y */
494  if (rotation == 3) {
495  for (i = 0; i < RP->Xsize; i++) {
496  for (j = 0; j < RP->Ysize; j++) {
497  new_maze[j][i] = maze[RP->Xsize - i - 1][RP->Ysize - j - 1];
498  }
499  }
500  }
501 
502  /* delete the old layout */
503  for (i = 0; i < RP->Xsize; i++) {
504  efree(maze[i]);
505  }
506 
507  efree(maze);
508 
509  swap = RP->Ysize;
510  RP->Ysize = RP->Xsize;
511  RP->Xsize = swap;
512  return new_maze;
513  break;
514  }
515  }
516 
517  return NULL;
518 }
519 
527 void roomify_layout(char **maze, RMParms *RP)
528 {
529  int tries = RP->Xsize * RP->Ysize / 30, ti;
530 
531  for (ti = 0; ti < tries; ti++) {
532  /* starting location for looking at creating a door */
533  int dx, dy;
534  /* results of checking on creating walls. */
535  int cx, cy;
536 
537  dx = RANDOM() % RP->Xsize;
538  dy = RANDOM() % RP->Ysize;
539 
540  /* horizontal */
541  cx = can_make_wall(maze, dx, dy, 0, RP);
542 
543  /* vertical */
544  cy = can_make_wall(maze, dx, dy, 1, RP);
545 
546  if (cx == -1) {
547  if (cy != -1) {
548  make_wall(maze, dx, dy, 1);
549  }
550 
551  continue;
552  }
553 
554  if (cy == -1) {
555  make_wall(maze, dx, dy, 0);
556 
557  continue;
558  }
559 
560  if (cx < cy) {
561  make_wall(maze, dx, dy, 0);
562  } else {
563  make_wall(maze, dx, dy, 1);
564  }
565  }
566 }
567 
586 int can_make_wall(char **maze, int dx, int dy, int dir, RMParms *RP)
587 {
588  int i1, length = 0;
589 
590  /* don't make walls if we're on the edge. */
591  if (dx == 0 || dx == (RP->Xsize - 1) || dy == 0 || dy == (RP->Ysize - 1)) {
592  return -1;
593  }
594 
595  /* don't make walls if we're ON a wall. */
596  if (maze[dx][dy] != '\0') {
597  return -1;
598  }
599 
600  /* horizontal */
601  if (dir == 0) {
602  int y = dy;
603 
604  for (i1 = dx - 1; i1 > 0; i1--) {
605  int sindex = surround_flag2(maze, i1, y, RP);
606 
607  if (sindex == 1) {
608  break;
609  }
610 
611  /* can't make horizontal wall here */
612  if (sindex != 0) {
613  return -1;
614  }
615 
616  /* can't make horizontal wall here */
617  if (maze[i1][y] != '\0') {
618  return -1;
619  }
620 
621  length++;
622  }
623 
624  for (i1 = dx + 1; i1 < RP->Xsize - 1; i1++) {
625  int sindex = surround_flag2(maze, i1, y, RP);
626 
627  if (sindex == 2) {
628  break;
629  }
630 
631  /* can't make horizontal wall here */
632  if (sindex != 0) {
633  return -1;
634  }
635 
636  /* can't make horizontal wall here */
637  if (maze[i1][y] != '\0') {
638  return -1;
639  }
640 
641  length++;
642  }
643 
644  return length;
645  } else {
646  int x = dx;
647 
648  /* vertical */
649 
650  for (i1 = dy - 1; i1 > 0; i1--) {
651  int sindex = surround_flag2(maze, x, i1, RP);
652 
653  if (sindex == 4) {
654  break;
655  }
656 
657  /* can't make vertical wall here */
658  if (sindex != 0) {
659  return -1;
660  }
661 
662  /* can't make vertical wall here */
663  if (maze[x][i1] != '\0') {
664  return -1;
665  }
666 
667  length++;
668  }
669 
670  for (i1 = dy + 1; i1 < RP->Ysize - 1; i1++) {
671  int sindex = surround_flag2(maze, x, i1, RP);
672 
673  if (sindex == 8) {
674  break;
675  }
676 
677  /* can't make vertical wall here */
678  if (sindex != 0) {
679  return -1;
680  }
681 
682  /* can't make vertical wall here */
683  if (maze[x][i1] != '\0') {
684  return -1;
685  }
686 
687  length++;
688  }
689 
690  return length;
691  }
692 }
693 
709 int make_wall(char **maze, int x, int y, int dir)
710 {
711  int i1;
712 
713  /* mark a door */
714  maze[x][y] = 'D';
715 
716  switch (dir) {
717  /* horizontal */
718  case 0:
719  for (i1 = x - 1; maze[i1][y] == '\0'; i1--) {
720  maze[i1][y] = '#';
721  }
722 
723  for (i1 = x + 1; maze[i1][y] == '\0'; i1++) {
724  maze[i1][y] = '#';
725  }
726 
727  break;
728 
729  /* vertical */
730  case 1:
731  for (i1 = y - 1; maze[x][i1] == '\0'; i1--) {
732  maze[x][i1] = '#';
733  }
734 
735  for (i1 = y + 1; maze[x][i1] == '\0'; i1++) {
736  maze[x][i1] = '#';
737  }
738 
739  break;
740  }
741 
742  return 0;
743 }
744 
752 void doorify_layout(char **maze, RMParms *RP)
753 {
754  /* reasonable number of doors. */
755  int ndoors = RP->Xsize * RP->Ysize / 60;
756  int *doorlist_x, *doorlist_y;
757  /* # of available doorlocations */
758  int doorlocs = 0;
759  int i, j;
760 
761  doorlist_x = emalloc(sizeof(int) * RP->Xsize * RP->Ysize);
762  doorlist_y = emalloc(sizeof(int) * RP->Xsize * RP->Ysize);
763 
764  /* make a list of possible door locations */
765  for (i = 1; i < RP->Xsize - 1; i++) {
766  for (j = 1; j < RP->Ysize - 1; j++) {
767  int sindex = surround_flag(maze, i, j, RP);
768 
769  /* these are possible door sindex */
770  if (sindex == 3 || sindex == 12) {
771  doorlist_x[doorlocs] = i;
772  doorlist_y[doorlocs] = j;
773 
774  doorlocs++;
775  }
776  }
777  }
778 
779  while (ndoors > 0 && doorlocs > 0) {
780  int di = RANDOM() % doorlocs, sindex;
781 
782  i = doorlist_x[di];
783  j = doorlist_y[di];
784 
785  sindex = surround_flag(maze, i, j, RP);
786 
787  /* these are possible door sindex */
788  if (sindex == 3 || sindex == 12) {
789  maze[i][j] = 'D';
790  ndoors--;
791  }
792 
793  /* reduce the size of the list */
794  doorlocs--;
795 
796  doorlist_x[di] = doorlist_x[doorlocs];
797  doorlist_y[di] = doorlist_y[doorlocs];
798  }
799 
800  efree(doorlist_x);
801  efree(doorlist_y);
802 }
803 
812 {
813  char small_buf[256];
814 
815  sprintf(buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize);
816 
817  if (RP->wallstyle[0]) {
818  sprintf(small_buf, "wallstyle %s\n", RP->wallstyle);
819  strcat(buf, small_buf);
820  }
821 
822  if (RP->floorstyle[0]) {
823  sprintf(small_buf, "floorstyle %s\n", RP->floorstyle);
824  strcat(buf, small_buf);
825  }
826 
827  if (RP->monsterstyle[0]) {
828  sprintf(small_buf, "monsterstyle %s\n", RP->monsterstyle);
829  strcat(buf, small_buf);
830  }
831 
832  if (RP->layoutstyle[0]) {
833  sprintf(small_buf, "layoutstyle %s\n", RP->layoutstyle);
834  strcat(buf, small_buf);
835  }
836 
837  if (RP->decorstyle[0]) {
838  sprintf(small_buf, "decorstyle %s\n", RP->decorstyle);
839  strcat(buf, small_buf);
840  }
841 
842  if (RP->doorstyle[0]) {
843  sprintf(small_buf, "doorstyle %s\n", RP->doorstyle);
844  strcat(buf, small_buf);
845  }
846 
847  if (RP->dungeon_name[0]) {
848  sprintf(small_buf, "dungeon_name %s\n", RP->dungeon_name);
849  strcat(buf, small_buf);
850  }
851 
852  if (RP->exitstyle[0]) {
853  sprintf(small_buf, "exitstyle %s\n", RP->exitstyle);
854  strcat(buf, small_buf);
855  }
856 
857  if (RP->final_map[0]) {
858  sprintf(small_buf, "final_map %s\n", RP->final_map);
859  strcat(buf, small_buf);
860  }
861 
862  if (RP->expand2x) {
863  sprintf(small_buf, "expand2x %d\n", RP->expand2x);
864  strcat(buf, small_buf);
865  }
866 
867  if (RP->layoutoptions1) {
868  sprintf(small_buf, "layoutoptions1 %d\n", RP->layoutoptions1);
869  strcat(buf, small_buf);
870  }
871 
872  if (RP->layoutoptions2) {
873  sprintf(small_buf, "layoutoptions2 %d\n", RP->layoutoptions2);
874  strcat(buf, small_buf);
875  }
876 
877  if (RP->layoutoptions3) {
878  sprintf(small_buf, "layoutoptions3 %d\n", RP->layoutoptions3);
879  strcat(buf, small_buf);
880  }
881 
882  if (RP->symmetry) {
883  sprintf(small_buf, "symmetry %d\n", RP->symmetry);
884  strcat(buf, small_buf);
885  }
886 
887  if (RP->difficulty && RP->difficulty_given) {
888  sprintf(small_buf, "difficulty %d\n", RP->difficulty);
889  strcat(buf, small_buf);
890  }
891 
892  sprintf(small_buf, "dungeon_level %d\n", RP->dungeon_level);
893  strcat(buf, small_buf);
894 
895  if (RP->dungeon_depth) {
896  sprintf(small_buf, "dungeon_depth %d\n", RP->dungeon_depth);
897  strcat(buf, small_buf);
898  }
899 
900  if (RP->decorchance) {
901  sprintf(small_buf, "decorchance %d\n", RP->decorchance);
902  strcat(buf, small_buf);
903  }
904 
905  if (RP->orientation) {
906  sprintf(small_buf, "orientation %d\n", RP->orientation);
907  strcat(buf, small_buf);
908  }
909 
910  if (RP->random_seed) {
911  sprintf(small_buf, "random_seed %d\n", RP->random_seed + 1);
912  strcat(buf, small_buf);
913  }
914 
915  if (RP->num_monsters) {
916  sprintf(small_buf, "num_monsters %d\n", RP->num_monsters);
917  strcat(buf, small_buf);
918  }
919 
920  if (RP->darkness) {
921  sprintf(small_buf, "darkness %d\n", RP->darkness);
922  strcat(buf, small_buf);
923  }
924 
925  if (RP->level_increment) {
926  sprintf(small_buf, "level_increment %d\n", RP->level_increment);
927  strcat(buf, small_buf);
928  }
929 
930  if (RP->bg_music[0]) {
931  sprintf(small_buf, "bg_music %s\n", RP->bg_music);
932  strcat(buf, small_buf);
933  }
934 }
void doorify_layout(char **maze, RMParms *RP)
Definition: random_map.c:752
#define FREE_AND_COPY_HASH(_sv_, _nv_)
Definition: global.h:100
void roomify_layout(char **maze, RMParms *RP)
Definition: random_map.c:527
char ** roguelike_layout_gen(int xsize, int ysize, int options)
Definition: rogue_layout.c:108
shstr * name
Definition: map.h:553
char floorstyle[RM_SIZE]
Definition: random_map.h:44
char final_map[RM_SIZE]
Definition: random_map.h:62
shstr * path
Definition: map.h:568
int can_make_wall(char **maze, int dx, int dy, int dir, RMParms *RP)
Definition: random_map.c:586
void write_map_parameters_to_string(char *buf, RMParms *RP)
Definition: random_map.c:811
int difficulty_given
Definition: random_map.h:98
char doorstyle[RM_SIZE]
Definition: random_map.h:53
char bg_music[RM_SIZE]
Definition: random_map.h:71
void place_exits(mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms *RP)
Definition: exit.c:155
int random_seed
Definition: random_map.h:119
void dump_layout(char **layout, RMParms *RP)
Definition: random_map.c:41
char ** layoutgen(RMParms *RP)
Definition: random_map.c:158
char ** make_snake_layout(int xsize, int ysize)
Definition: snake.c:41
int expand2x
Definition: random_map.h:80
void unblock_exits(mapstruct *map, char **maze, RMParms *RP)
Definition: exit.c:406
void make_map_walls(mapstruct *map, char **layout, char *w_style, RMParms *RP)
Definition: wall.c:193
char ** symmetrize_layout(char **maze, int sym, RMParms *RP)
Definition: random_map.c:344
int map_layout_style
Definition: random_map.h:122
int layoutoptions2
Definition: random_map.h:86
int symmetry
Definition: random_map.h:92
char monsterstyle[RM_SIZE]
Definition: random_map.h:47
char ** map_gen_spiral(int xsize, int ysize, int option)
int layoutoptions1
Definition: random_map.h:83
shstr * bg_music
Definition: map.h:556
int orientation
Definition: random_map.h:110
char dungeon_name[RM_SIZE]
Definition: random_map.h:68
int surround_flag2(char **layout, int i, int j, RMParms *RP)
Definition: wall.c:80
int dungeon_level
Definition: random_map.h:101
char exitstyle[RM_SIZE]
Definition: random_map.h:65
int darkness
Definition: random_map.h:131
int layoutoptions3
Definition: random_map.h:89
int decorchance
Definition: random_map.h:107
void connect_spirals(int xsize, int ysize, int sym, char **layout)
#define NO_SYM
Definition: random_map.h:181
char layoutstyle[RM_SIZE]
Definition: random_map.h:50
int symmetry_used
Definition: random_map.h:125
int make_wall(char **maze, int x, int y, int dir)
Definition: random_map.c:709
int Ysize
Definition: random_map.h:77
mapstruct * generate_random_map(char *OutFileName, RMParms *RP)
Definition: random_map.c:72
char ** rotate_layout(char **maze, int rotation, RMParms *RP)
Definition: random_map.c:439
int Xsize
Definition: random_map.h:74
void put_doors(mapstruct *the_map, char **maze, char *doorstyle, RMParms *RP)
Definition: door.c:90
int level_increment
Definition: random_map.h:134
int difficulty
Definition: map.h:650
#define RANDOM_SYM
Definition: random_map.h:179
int dungeon_depth
Definition: random_map.h:104
int surround_flag(char **layout, int i, int j, RMParms *RP)
Definition: wall.c:45
void set_map_darkness(mapstruct *m, int value)
Definition: map.c:933
mapstruct * make_map_floor(char *floorstyle, RMParms *RP)
Definition: floor.c:43
#define OPT_WALLS_ONLY
Definition: random_map.h:167
int difficulty
Definition: random_map.h:95
char ** maze_gen(int xsize, int ysize, int option)
Definition: maze_gen.c:69
void put_decor(mapstruct *map, char **layout, RMParms *RP)
Definition: decor.c:42
Definition: map.h:536
char ** map_gen_onion(int xsize, int ysize, int option, int layers)
#define Y_SYM
Definition: random_map.h:185
char decorstyle[RM_SIZE]
Definition: random_map.h:56
char ** make_square_spiral_layout(int xsize, int ysize)
Definition: square_spiral.c:66
void place_monsters(mapstruct *map, char *monsterstyle, int difficulty, RMParms *RP)
Definition: monster.c:46
char wallstyle[RM_SIZE]
Definition: random_map.h:38
#define X_SYM
Definition: random_map.h:183
#define XY_SYM
Definition: random_map.h:187
int num_monsters
Definition: random_map.h:128