56 for (i = 0; i < RP->
Xsize; i++) {
57 for (j = 0; j < RP->
Ysize; j++) {
58 if (layout[i][j] == 0)
60 printf(
"%c", layout[i][j]);
61 if (layout[i][j] ==
' ')
135 strncpy(theMap->
path, OutFileName,
sizeof(theMap->
path));
178 for (i = 0; i < RP->
Xsize; i++)
330 int Xsize_orig, Ysize_orig;
332 Xsize_orig = RP->
Xsize;
333 Ysize_orig = RP->
Ysize;
336 RP->
Xsize = Xsize_orig;
337 RP->
Ysize = Ysize_orig;
344 sym_maze = (
char **)calloc(
sizeof(
char *), RP->
Xsize);
345 for (i = 0; i < RP->
Xsize; i++)
346 sym_maze[i] = (
char *)calloc(
sizeof(
char), RP->
Ysize);
349 for (i = 0; i < RP->
Xsize/2+1; i++)
350 for (j = 0; j < RP->
Ysize; j++) {
351 sym_maze[i][j] = maze[i][j];
352 sym_maze[RP->
Xsize-i-1][j] = maze[i][j];
355 for (i = 0; i < RP->
Xsize; i++)
356 for (j = 0; j < RP->
Ysize/2+1; j++) {
357 sym_maze[i][j] = maze[i][j];
358 sym_maze[i][RP->
Ysize-j-1] = maze[i][j];
361 for (i = 0; i < RP->
Xsize/2+1; i++)
362 for (j = 0; j < RP->
Ysize/2+1; j++) {
363 sym_maze[i][j] = maze[i][j];
364 sym_maze[i][RP->
Ysize-j-1] = maze[i][j];
365 sym_maze[RP->
Xsize-i-1][j] = maze[i][j];
366 sym_maze[RP->
Xsize-i-1][RP->
Ysize-j-1] = maze[i][j];
370 for (i = 0; i < Xsize_orig; i++)
413 char *
new = malloc(
sizeof(
char)*RP->
Xsize*RP->
Ysize);
415 for (i = 0; i < RP->
Xsize; i++) {
416 for (j = 0; j < RP->
Ysize; j++) {
417 new[i*RP->
Ysize+j] = maze[i][j];
420 for (i = 0; i < RP->
Xsize; i++) {
421 for (j = 0; j < RP->
Ysize; j++) {
434 new_maze = (
char **)calloc(
sizeof(
char *), RP->
Ysize);
435 for (i = 0; i < RP->
Ysize; i++) {
436 new_maze[i] = (
char *)calloc(
sizeof(
char), RP->
Xsize);
439 for (i = 0; i < RP->
Xsize; i++)
440 for (j = 0; j < RP->
Ysize; j++)
441 new_maze[j][i] = maze[i][j];
444 for (i = 0; i < RP->
Xsize; i++)
445 for (j = 0; j < RP->
Ysize; j++)
446 new_maze[j][i] = maze[RP->
Xsize-i-1][RP->
Ysize-j-1];
450 for (i = 0; i < RP->
Xsize; i++)
475 for (ti = 0; ti < tries; ti++) {
479 dx = RANDOM()%RP->
Xsize;
480 dy = RANDOM()%RP->
Ysize;
521 if (dx == 0 || dx == (RP->
Xsize-1) || dy == 0 || dy == (RP->
Ysize-1))
525 if (maze[dx][dy] != 0)
532 for (i1 = dx-1; i1 > 0; i1--) {
539 if (maze[i1][y] != 0)
544 for (i1 = dx+1; i1 < RP->
Xsize-1; i1++) {
551 if (maze[i1][y] != 0)
560 for (i1 = dy-1; i1 > 0; i1--) {
567 if (maze[x][i1] != 0)
572 for (i1 = dy+1; i1 < RP->
Ysize-1; i1++) {
579 if (maze[x][i1] != 0)
608 for (i1 = x-1; maze[i1][y] == 0; i1--)
610 for (i1 = x+1; maze[i1][y] == 0; i1++)
618 for (i1 = y-1; maze[x][i1] == 0; i1--)
620 for (i1 = y+1; maze[x][i1] == 0; i1++)
643 doorlist_x = malloc(
sizeof(
int)*RP->
Xsize*RP->
Ysize);
644 doorlist_y = malloc(
sizeof(
int)*RP->
Xsize*RP->
Ysize);
648 for (i = 1; i < RP->
Xsize-1; i++)
649 for (j = 1; j < RP->
Ysize-1; j++) {
651 if (sindex == 3 || sindex == 12) {
653 doorlist_x[doorlocs] = i;
654 doorlist_y[doorlocs] = j;
659 while (ndoors > 0 && doorlocs > 0) {
663 di = RANDOM()%doorlocs;
667 if (sindex == 3 || sindex == 12) {
673 doorlist_x[di] = doorlist_x[doorlocs];
674 doorlist_y[di] = doorlist_y[doorlocs];
699 strncat(buf, small_buf, bufsize);
704 strncat(buf, small_buf, bufsize);
709 strncat(buf, small_buf, bufsize);
714 strncat(buf, small_buf, bufsize);
719 strncat(buf, small_buf, bufsize);
724 strncat(buf, small_buf, bufsize);
729 strncat(buf, small_buf, bufsize);
734 strncat(buf, small_buf, bufsize);
739 strncat(buf, small_buf, bufsize);
744 strncat(buf, small_buf, bufsize);
749 strncat(buf, small_buf, bufsize);
754 strncat(buf, small_buf, bufsize);
759 strncat(buf, small_buf, bufsize);
764 strncat(buf, small_buf, bufsize);
769 strncat(buf, small_buf, bufsize);
774 strncat(buf, small_buf, bufsize);
779 strncat(buf, small_buf, bufsize);
784 strncat(buf, small_buf, bufsize);
789 strncat(buf, small_buf, bufsize);
793 strncat(buf, small_buf, bufsize);
797 strncat(buf, small_buf, bufsize);
802 strncat(buf, small_buf, bufsize);
807 strncat(buf, small_buf, bufsize);
812 strncat(buf, small_buf, bufsize);
817 strncat(buf, small_buf, bufsize);
822 strncat(buf, small_buf, bufsize);
827 strncat(buf, small_buf, bufsize);
832 strncat(buf, small_buf, bufsize);
837 strncat(buf, small_buf, bufsize);
880 const char *wallstyle_n,
881 const char *floorstyle_n,
882 const char *monsterstyle_n,
883 const char *treasurestyle_n,
884 const char *layoutstyle_n,
885 const char *decorstyle_n,
886 const char *doorstyle_n,
887 const char *exitstyle_n,
888 const char *final_map_n,
889 const char *exit_on_final_map_n,
890 const char *this_map_n,
891 int layoutoptions1_n,
892 int layoutoptions2_n,
893 int layoutoptions3_n,
898 int difficulty_given_n,
904 int treasureoptions_n,
905 float difficulty_increase) {
907 sprintf(buf,
"xsize %d\nysize %d\n", xsize_n, ysize_n);
909 if (wallstyle_n && wallstyle_n[0]) {
910 snprintf(small_buf,
sizeof(small_buf),
"wallstyle %s\n", wallstyle_n);
911 strcat(buf, small_buf);
914 if (floorstyle_n && floorstyle_n[0]) {
915 snprintf(small_buf,
sizeof(small_buf),
"floorstyle %s\n", floorstyle_n);
916 strcat(buf, small_buf);
919 if (monsterstyle_n && monsterstyle_n[0]) {
920 snprintf(small_buf,
sizeof(small_buf),
"monsterstyle %s\n", monsterstyle_n);
921 strcat(buf, small_buf);
924 if (treasurestyle_n && treasurestyle_n[0]) {
925 snprintf(small_buf,
sizeof(small_buf),
"treasurestyle %s\n", treasurestyle_n);
926 strcat(buf, small_buf);
929 if (layoutstyle_n &&layoutstyle_n[0]) {
930 snprintf(small_buf,
sizeof(small_buf),
"layoutstyle %s\n", layoutstyle_n);
931 strcat(buf, small_buf);
934 if (decorstyle_n && decorstyle_n[0]) {
935 snprintf(small_buf,
sizeof(small_buf),
"decorstyle %s\n", decorstyle_n);
936 strcat(buf, small_buf);
939 if (doorstyle_n && doorstyle_n[0]) {
940 snprintf(small_buf,
sizeof(small_buf),
"doorstyle %s\n", doorstyle_n);
941 strcat(buf, small_buf);
944 if (exitstyle_n && exitstyle_n[0]) {
945 snprintf(small_buf,
sizeof(small_buf),
"exitstyle %s\n", exitstyle_n);
946 strcat(buf, small_buf);
949 if (final_map_n && final_map_n[0]) {
950 snprintf(small_buf,
sizeof(small_buf),
"final_map %s\n", final_map_n);
951 strcat(buf, small_buf);
954 if (exit_on_final_map_n && exit_on_final_map_n[0]) {
955 snprintf(small_buf,
sizeof(small_buf),
"exit_on_final_map %s\n", exit_on_final_map_n);
956 strcat(buf, small_buf);
959 if (this_map_n && this_map_n[0]) {
960 snprintf(small_buf,
sizeof(small_buf),
"origin_map %s\n", this_map_n);
961 strcat(buf, small_buf);
964 if (layoutoptions1_n) {
965 snprintf(small_buf,
sizeof(small_buf),
"layoutoptions1 %d\n", layoutoptions1_n);
966 strcat(buf, small_buf);
970 if (layoutoptions2_n) {
971 snprintf(small_buf,
sizeof(small_buf),
"layoutoptions2 %d\n", layoutoptions2_n);
972 strcat(buf, small_buf);
976 if (layoutoptions3_n) {
977 snprintf(small_buf,
sizeof(small_buf),
"layoutoptions3 %d\n", layoutoptions3_n);
978 strcat(buf, small_buf);
982 snprintf(small_buf,
sizeof(small_buf),
"symmetry %d\n", symmetry_n);
983 strcat(buf, small_buf);
987 if (difficulty_n && difficulty_given_n) {
988 snprintf(small_buf,
sizeof(small_buf),
"difficulty %d\n", difficulty_n);
989 strcat(buf, small_buf);
992 if (difficulty_increase > 0.001) {
993 snprintf(small_buf,
sizeof(small_buf),
"difficulty_increase %f\n", difficulty_increase);
994 strcat(buf, small_buf);
997 snprintf(small_buf,
sizeof(small_buf),
"dungeon_level %d\n", dungeon_level_n);
998 strcat(buf, small_buf);
1000 if (dungeon_depth_n) {
1001 snprintf(small_buf,
sizeof(small_buf),
"dungeon_depth %d\n", dungeon_depth_n);
1002 strcat(buf, small_buf);
1005 if (decoroptions_n) {
1006 snprintf(small_buf,
sizeof(small_buf),
"decoroptions %d\n", decoroptions_n);
1007 strcat(buf, small_buf);
1010 if (orientation_n) {
1011 snprintf(small_buf,
sizeof(small_buf),
"orientation %d\n", orientation_n);
1012 strcat(buf, small_buf);
1016 snprintf(small_buf,
sizeof(small_buf),
"origin_x %d\n", origin_x_n);
1017 strcat(buf, small_buf);
1021 snprintf(small_buf,
sizeof(small_buf),
"origin_y %d\n", origin_y_n);
1022 strcat(buf, small_buf);
1025 if (random_seed_n) {
1027 snprintf(small_buf,
sizeof(small_buf),
"random_seed %d\n", random_seed_n+1);
1028 strcat(buf, small_buf);
1031 if (treasureoptions_n) {
1032 snprintf(small_buf,
sizeof(small_buf),
"treasureoptions %d\n", treasureoptions_n);
1033 strcat(buf, small_buf);
mapstruct * make_map_floor(char **layout, char *floorstyle, RMParms *RP)
char final_exit_archetype[RM_SIZE]
char ** roguelike_layout_gen(int xsize, int ysize, int options)
int make_wall(char **maze, int x, int y, int dir)
mapstruct * generate_random_map(const char *OutFileName, RMParms *RP, char **use_layout)
void place_treasure(mapstruct *map, char **layout, char *treasure_style, int treasureoptions, RMParms *RP)
int gettimeofday(struct timeval *time_Info, struct timezone *timezone_Info)
char ** make_snake_layout(int xsize, int ysize)
char exit_on_final_map[RM_SIZE]
int calculate_difficulty(mapstruct *m)
void dump_layout(char **layout, RMParms *RP)
void place_exits(mapstruct *map, char **maze, char *exitstyle, int orientation, RMParms *RP)
char ** layoutgen(RMParms *RP)
void make_map_walls(mapstruct *map, char **layout, char *w_style, RMParms *RP)
void roomify_layout(char **maze, RMParms *RP)
void unblock_exits(mapstruct *map, char **maze, RMParms *RP)
char ** make_square_spiral_layout(int xsize, int ysize)
void put_decor(mapstruct *map, char **maze, char *decorstyle, int decor_option, RMParms *RP)
void fix_auto_apply(mapstruct *m)
char ** expand2x(char **layout, int xsize, int ysize)
void write_map_parameters_to_string(RMParms *RP, char *buf, int bufsize)
char monsterstyle[RM_SIZE]
void doorify_layout(char **maze, RMParms *RP)
char ** map_gen_spiral(int xsize, int ysize, int option)
int surround_flag2(char **layout, int i, int j, RMParms *RP)
char ** rotate_layout(char **maze, int rotation, RMParms *RP)
struct timeval last_reset_time
char dungeon_name[RM_SIZE]
#define MIN_RANDOM_MAP_SIZE
int can_make_wall(char **maze, int dx, int dy, int dir, RMParms *RP)
#define SQUARE_SPIRAL_LAYOUT
void connect_spirals(int xsize, int ysize, int sym, char **layout)
char layoutstyle[RM_SIZE]
char * strdup_local(const char *str)
int snprintf(char *dest, int max, const char *format,...)
float difficulty_increase
char ** symmetrize_layout(char **maze, int sym, RMParms *RP)
void write_parameters_to_string(char *buf, int xsize_n, int ysize_n, const char *wallstyle_n, const char *floorstyle_n, const char *monsterstyle_n, const char *treasurestyle_n, const char *layoutstyle_n, const char *decorstyle_n, const char *doorstyle_n, const char *exitstyle_n, const char *final_map_n, const char *exit_on_final_map_n, const char *this_map_n, int layoutoptions1_n, int layoutoptions2_n, int layoutoptions3_n, int symmetry_n, int dungeon_depth_n, int dungeon_level_n, int difficulty_n, int difficulty_given_n, int decoroptions_n, int orientation_n, int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase)
struct regiondef * region
char ** map_gen_onion(int xsize, int ysize, int option, int layers)
void place_specials_in_map(mapstruct *map, char **layout, RMParms *RP)
char ** maze_gen(int xsize, int ysize, int option)
char treasurestyle[RM_SIZE]
int surround_flag(char **layout, int i, int j, RMParms *RP)
void put_doors(mapstruct *the_map, char **maze, const char *doorstyle, RMParms *RP)
void place_monsters(mapstruct *map, char *monsterstyle, int difficulty, RMParms *RP)
struct regiondef * region