ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/random_maps/random_map.C
(Generate patch)

Comparing deliantra/server/random_maps/random_map.C (file contents):
Revision 1.24 by root, Fri Jan 19 21:49:58 2007 UTC vs.
Revision 1.29 by root, Tue Apr 17 10:06:34 2007 UTC

29#include <room_gen.h> 29#include <room_gen.h>
30#include <random_map.h> 30#include <random_map.h>
31#include <rproto.h> 31#include <rproto.h>
32#include <sproto.h> 32#include <sproto.h>
33 33
34#define CEDE coroapi::cede (); rndm.seed (RP->random_seed + __LINE__); 34#define CEDE coroapi::cede_to_tick (); rndm.seed (RP->random_seed + __LINE__);
35 35
36void 36void
37dump_layout (char **layout, random_map_params *RP) 37dump_layout (char **layout, random_map_params *RP)
38{ 38{
39 { 39 {
90 90
91 if (RP->Ysize < MIN_RANDOM_MAP_SIZE) 91 if (RP->Ysize < MIN_RANDOM_MAP_SIZE)
92 RP->Ysize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5; 92 RP->Ysize = MIN_RANDOM_MAP_SIZE + rndm (25) + 5;
93 93
94 if (RP->symmetry == SYMMETRY_RANDOM) 94 if (RP->symmetry == SYMMETRY_RANDOM)
95 RP->symmetry_used = (RANDOM () % (SYMMETRY_XY)) + 1; 95 RP->symmetry_used = rndm (SYMMETRY_XY) + 1;
96 else 96 else
97 RP->symmetry_used = RP->symmetry; 97 RP->symmetry_used = RP->symmetry;
98 98
99 if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY) 99 if (RP->symmetry_used == SYMMETRY_Y || RP->symmetry_used == SYMMETRY_XY)
100 RP->Ysize = RP->Ysize / 2 + 1; 100 RP->Ysize = RP->Ysize / 2 + 1;
133 if (strstr (RP->layoutstyle, "squarespiral")) 133 if (strstr (RP->layoutstyle, "squarespiral"))
134 RP->map_layout_style = LAYOUT_SQUARE_SPIRAL; 134 RP->map_layout_style = LAYOUT_SQUARE_SPIRAL;
135 135
136 /* No style found - choose one randomly */ 136 /* No style found - choose one randomly */
137 if (RP->map_layout_style == LAYOUT_NONE) 137 if (RP->map_layout_style == LAYOUT_NONE)
138 RP->map_layout_style = (RANDOM () % (NROFLAYOUTS - 1)) + 1; 138 RP->map_layout_style = rndm (NROFLAYOUTS - 1) + 1;
139 139
140 layout = layoutgen (RP); 140 layout = layoutgen (RP);
141 141
142#ifdef RMAP_DEBUG 142#ifdef RMAP_DEBUG
143 dump_layout (layout, RP); 143 dump_layout (layout, RP);
156 156
157 /* allocate the map and set the floor */ 157 /* allocate the map and set the floor */
158 make_map_floor (layout, RP->floorstyle, RP); 158 make_map_floor (layout, RP->floorstyle, RP);
159 159
160 /* set region */ 160 /* set region */
161 region = RP->region; 161 default_region = RP->region;
162 162
163 CEDE; 163 CEDE;
164 164
165 /* create walls unless the wallstyle is "none" */ 165 /* create walls unless the wallstyle is "none" */
166 if (strcmp (RP->wallstyle, "none")) 166 if (strcmp (RP->wallstyle, "none"))
450 for (ti = 0; ti < tries; ti++) 450 for (ti = 0; ti < tries; ti++)
451 { 451 {
452 int dx, dy; /* starting location for looking at creating a door */ 452 int dx, dy; /* starting location for looking at creating a door */
453 int cx, cy; /* results of checking on creating walls. */ 453 int cx, cy; /* results of checking on creating walls. */
454 454
455 dx = RANDOM () % RP->Xsize; 455 dx = rndm (RP->Xsize);
456 dy = RANDOM () % RP->Ysize; 456 dy = rndm (RP->Ysize);
457
457 cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */ 458 cx = can_make_wall (maze, dx, dy, 0, RP); /* horizontal */
458 cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */ 459 cy = can_make_wall (maze, dx, dy, 1, RP); /* vertical */
459 if (cx == -1) 460 if (cx == -1)
460 { 461 {
461 if (cy != -1) 462 if (cy != -1)
462 make_wall (maze, dx, dy, 1); 463 make_wall (maze, dx, dy, 1);
464
463 continue; 465 continue;
464 } 466 }
467
465 if (cy == -1) 468 if (cy == -1)
466 { 469 {
467 make_wall (maze, dx, dy, 0); 470 make_wall (maze, dx, dy, 0);
468 continue; 471 continue;
469 } 472 }
473
470 if (cx < cy) 474 if (cx < cy)
471 make_wall (maze, dx, dy, 0); 475 make_wall (maze, dx, dy, 0);
472 else 476 else
473 make_wall (maze, dx, dy, 1); 477 make_wall (maze, dx, dy, 1);
474 } 478 }
620 while (ndoors > 0 && doorlocs > 0) 624 while (ndoors > 0 && doorlocs > 0)
621 { 625 {
622 int di; 626 int di;
623 int sindex; 627 int sindex;
624 628
625 di = RANDOM () % doorlocs; 629 di = rndm (doorlocs);
626 i = doorlist_x[di]; 630 i = doorlist_x[di];
627 j = doorlist_y[di]; 631 j = doorlist_y[di];
628 sindex = surround_flag (maze, i, j, RP); 632 sindex = surround_flag (maze, i, j, RP);
633
629 if (sindex == 3 || sindex == 12) /* these are possible door sindex */ 634 if (sindex == 3 || sindex == 12) /* these are possible door sindex */
630 { 635 {
631 maze[i][j] = 'D'; 636 maze[i][j] = 'D';
632 ndoors--; 637 ndoors--;
633 } 638 }
639
634 /* reduce the size of the list */ 640 /* reduce the size of the list */
635 doorlocs--; 641 doorlocs--;
636 doorlist_x[di] = doorlist_x[doorlocs]; 642 doorlist_x[di] = doorlist_x[doorlocs];
637 doorlist_y[di] = doorlist_y[doorlocs]; 643 doorlist_y[di] = doorlist_y[doorlocs];
638 } 644 }
795 strcat (buf, small_buf); 801 strcat (buf, small_buf);
796 } 802 }
797 803
798 if (RP->random_seed) 804 if (RP->random_seed)
799 { 805 {
800 sprintf (small_buf, "random_seed %d\n", RP->random_seed); 806 sprintf (small_buf, "random_seed %u\n", RP->random_seed);
801 strcat (buf, small_buf); 807 strcat (buf, small_buf);
802 } 808 }
803 809
804 if (RP->custom) 810 if (RP->custom)
805 { 811 {
810 816
811void 817void
812write_parameters_to_string (char *buf, 818write_parameters_to_string (char *buf,
813 int xsize_n, 819 int xsize_n,
814 int ysize_n, 820 int ysize_n,
815 char *wallstyle_n, 821 const char *wallstyle_n,
816 char *floorstyle_n, 822 const char *floorstyle_n,
817 char *monsterstyle_n, 823 const char *monsterstyle_n,
818 char *treasurestyle_n, 824 const char *treasurestyle_n,
819 char *layoutstyle_n, 825 const char *layoutstyle_n,
820 char *decorstyle_n, 826 const char *decorstyle_n,
821 char *doorstyle_n, 827 const char *doorstyle_n,
822 char *exitstyle_n, 828 const char *exitstyle_n,
823 char *final_map_n, 829 const char *final_map_n,
824 char *exit_on_final_map_n, 830 const char *exit_on_final_map_n,
825 char *this_map_n, 831 const char *this_map_n,
826 int layoutoptions1_n, 832 int layoutoptions1_n,
827 int layoutoptions2_n, 833 int layoutoptions2_n,
828 int layoutoptions3_n, 834 int layoutoptions3_n,
829 int symmetry_n, 835 int symmetry_n,
830 int dungeon_depth_n, 836 int dungeon_depth_n,
831 int dungeon_level_n, 837 int dungeon_level_n,
832 int difficulty_n, 838 int difficulty_n,
833 int difficulty_given_n, 839 int difficulty_given_n,
834 int decoroptions_n, 840 int decoroptions_n,
835 int orientation_n, 841 int orientation_n,
836 int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) 842 int origin_x_n,
843 int origin_y_n,
844 uint32_t random_seed_n,
845 int treasureoptions_n,
846 float difficulty_increase)
837{ 847{
838 char small_buf[16384]; 848 char small_buf[16384];
839 849
840 sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); 850 sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n);
841 851
977 } 987 }
978 988
979 if (random_seed_n) 989 if (random_seed_n)
980 { 990 {
981 /* Add one so that the next map is a bit different */ 991 /* Add one so that the next map is a bit different */
982 sprintf (small_buf, "random_seed %d\n", random_seed_n + 1); 992 sprintf (small_buf, "random_seed %u\n", random_seed_n + 1);
983 strcat (buf, small_buf); 993 strcat (buf, small_buf);
984 } 994 }
985 995
986 if (treasureoptions_n) 996 if (treasureoptions_n)
987 { 997 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines