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.14 by root, Sun Dec 31 20:46:17 2006 UTC vs.
Revision 1.18 by root, Thu Jan 11 00:41:08 2007 UTC

1
2/* 1/*
3 CrossFire, A Multiplayer game for X-windows 2 CrossFire, A Multiplayer game for X-windows
4 3
4 Copyright (C) 2005, 2006, 2007 Marc Lehmann & Crossfire+ Development Team
5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team 5 Copyright (C) 2001 Mark Wedel & Crossfire Development Team
6 Copyright (C) 1992 Frank Tore Johansen 6 Copyright (C) 1992 Frank Tore Johansen
7 7
8 This program is free software; you can redistribute it and/or modify 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 9 it under the terms of the GNU General Public License as published by
54} 54}
55 55
56maptile * 56maptile *
57generate_random_map (const char *OutFileName, random_map_params *RP) 57generate_random_map (const char *OutFileName, random_map_params *RP)
58{ 58{
59 char **layout, buf[HUGE_BUF]; 59 char **layout, buf[16384];
60 maptile *theMap; 60 maptile *theMap;
61 int i; 61 int i;
62 62
63 /* pick a random seed, or use the one from the input file */ 63 /* pick a random seed, or use the one from the input file */
64 SRANDOM (RP->random_seed ? RP->random_seed + RP->dungeon_level : time (0)); 64 SRANDOM (RP->random_seed ? RP->random_seed + RP->dungeon_level : time (0));
114 theMap->path = OutFileName; 114 theMap->path = OutFileName;
115 115
116 /* set region */ 116 /* set region */
117 theMap->region = RP->region; 117 theMap->region = RP->region;
118 118
119 coroapi.cede (); 119 coroapi::cede ();
120 /* create walls unless the wallstyle is "none" */ 120 /* create walls unless the wallstyle is "none" */
121 if (strcmp (RP->wallstyle, "none")) 121 if (strcmp (RP->wallstyle, "none"))
122 { 122 {
123 make_map_walls (theMap, layout, RP->wallstyle, RP); 123 make_map_walls (theMap, layout, RP->wallstyle, RP);
124 124
126 if (strcmp (RP->doorstyle, "none")) 126 if (strcmp (RP->doorstyle, "none"))
127 put_doors (theMap, layout, RP->doorstyle, RP); 127 put_doors (theMap, layout, RP->doorstyle, RP);
128 128
129 } 129 }
130 130
131 coroapi.cede (); 131 coroapi::cede ();
132 /* create exits unless the exitstyle is "none" */ 132 /* create exits unless the exitstyle is "none" */
133 if (strcmp (RP->exitstyle, "none")) 133 if (strcmp (RP->exitstyle, "none"))
134 place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); 134 place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP);
135 135
136 coroapi.cede (); 136 coroapi::cede ();
137 place_specials_in_map (theMap, layout, RP); 137 place_specials_in_map (theMap, layout, RP);
138 138
139 coroapi.cede (); 139 coroapi::cede ();
140 /* create monsters unless the monsterstyle is "none" */ 140 /* create monsters unless the monsterstyle is "none" */
141 if (strcmp (RP->monsterstyle, "none")) 141 if (strcmp (RP->monsterstyle, "none"))
142 place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP); 142 place_monsters (theMap, RP->monsterstyle, RP->difficulty, RP);
143 143
144 coroapi.cede (); 144 coroapi::cede ();
145 /* treasures needs to have a proper difficulty set for the map. */ 145 /* treasures needs to have a proper difficulty set for the map. */
146 theMap->difficulty = theMap->estimate_difficulty (); 146 theMap->difficulty = theMap->estimate_difficulty ();
147 147
148 coroapi.cede (); 148 coroapi::cede ();
149 /* create treasure unless the treasurestyle is "none" */ 149 /* create treasure unless the treasurestyle is "none" */
150 if (strcmp (RP->treasurestyle, "none")) 150 if (strcmp (RP->treasurestyle, "none"))
151 place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); 151 place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP);
152 152
153 coroapi.cede (); 153 coroapi::cede ();
154 /* create decor unless the decorstyle is "none" */ 154 /* create decor unless the decorstyle is "none" */
155 if (strcmp (RP->decorstyle, "none")) 155 if (strcmp (RP->decorstyle, "none"))
156 put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); 156 put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP);
157 157
158 coroapi.cede (); 158 coroapi::cede ();
159 /* generate treasures, etc. */ 159 /* generate treasures, etc. */
160 theMap->fix_auto_apply (); 160 theMap->fix_auto_apply ();
161 161
162 coroapi.cede (); 162 coroapi::cede ();
163 unblock_exits (theMap, layout, RP); 163 unblock_exits (theMap, layout, RP);
164 164
165 /* free the layout */ 165 /* free the layout */
166 for (i = 0; i < RP->Xsize; i++) 166 for (i = 0; i < RP->Xsize; i++)
167 free (layout[i]); 167 free (layout[i]);
631} 631}
632 632
633void 633void
634write_map_parameters_to_string (char *buf, random_map_params *RP) 634write_map_parameters_to_string (char *buf, random_map_params *RP)
635{ 635{
636 char small_buf[2048]; 636 char small_buf[16384];
637 637
638 sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize); 638 sprintf (buf, "xsize %d\nysize %d\n", RP->Xsize, RP->Ysize);
639 639
640 if (RP->wallstyle[0]) 640 if (RP->wallstyle[0])
641 { 641 {
776 { 776 {
777 sprintf (small_buf, "origin_y %d\n", RP->origin_y); 777 sprintf (small_buf, "origin_y %d\n", RP->origin_y);
778 strcat (buf, small_buf); 778 strcat (buf, small_buf);
779 } 779 }
780 780
781 if (RP->treasureoptions)
782 {
783 sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions);
784 strcat (buf, small_buf);
785 }
786
781 if (RP->random_seed) 787 if (RP->random_seed)
782 { 788 {
783 /* Add one so that the next map is a bit different */
784 sprintf (small_buf, "random_seed %d\n", RP->random_seed + 1);
785 strcat (buf, small_buf);
786 }
787
788 if (RP->treasureoptions)
789 {
790 sprintf (small_buf, "treasureoptions %d\n", RP->treasureoptions);
791 strcat (buf, small_buf);
792 }
793
794 if (RP->random_seed)
795 {
796 sprintf (small_buf, "random_seed %d\n", RP->random_seed); 789 sprintf (small_buf, "random_seed %d\n", RP->random_seed);
790 strcat (buf, small_buf);
791 }
792
793 if (RP->custom)
794 {
795 sprintf (small_buf, "custom %s\n", RP->custom);
797 strcat (buf, small_buf); 796 strcat (buf, small_buf);
798 } 797 }
799} 798}
800 799
801void 800void
823 int difficulty_given_n, 822 int difficulty_given_n,
824 int decoroptions_n, 823 int decoroptions_n,
825 int orientation_n, 824 int orientation_n,
826 int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase) 825 int origin_x_n, int origin_y_n, int random_seed_n, int treasureoptions_n, float difficulty_increase)
827{ 826{
828 char small_buf[2048]; 827 char small_buf[16384];
829 828
830 sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n); 829 sprintf (buf, "xsize %d\nysize %d\n", xsize_n, ysize_n);
831 830
832 if (wallstyle_n && wallstyle_n[0]) 831 if (wallstyle_n && wallstyle_n[0])
833 { 832 {

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines