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.18 by root, Thu Jan 11 00:41:08 2007 UTC vs.
Revision 1.19 by root, Sat Jan 13 23:06:13 2007 UTC

51 } 51 }
52 } 52 }
53 printf ("\n"); 53 printf ("\n");
54} 54}
55 55
56maptile * 56bool
57generate_random_map (const char *OutFileName, random_map_params *RP) 57maptile::generate_random_map (random_map_params *RP)
58{ 58{
59 char **layout, buf[16384]; 59 char **layout, buf[16384];
60 maptile *theMap;
61 int i; 60 int i;
62 61
63 /* pick a random seed, or use the one from the input file */ 62 /* 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)); 63 SRANDOM (RP->random_seed ? RP->random_seed + RP->dungeon_level : time (0));
65 64
106#ifdef RMAP_DEBUG 105#ifdef RMAP_DEBUG
107 dump_layout (layout, RP); 106 dump_layout (layout, RP);
108#endif 107#endif
109 108
110 /* allocate the map and set the floor */ 109 /* allocate the map and set the floor */
111 theMap = make_map_floor (layout, RP->floorstyle, RP); 110 make_map_floor (layout, RP->floorstyle, RP);
112
113 /* set the name of the map. */
114 theMap->path = OutFileName;
115 111
116 /* set region */ 112 /* set region */
117 theMap->region = RP->region; 113 region = RP->region;
118 114
119 coroapi::cede (); 115 coroapi::cede ();
116
120 /* create walls unless the wallstyle is "none" */ 117 /* create walls unless the wallstyle is "none" */
121 if (strcmp (RP->wallstyle, "none")) 118 if (strcmp (RP->wallstyle, "none"))
122 { 119 {
123 make_map_walls (theMap, layout, RP->wallstyle, RP); 120 make_map_walls (this, layout, RP->wallstyle, RP);
124 121
125 /* place doors unless doorstyle or wallstyle is "none" */ 122 /* place doors unless doorstyle or wallstyle is "none" */
126 if (strcmp (RP->doorstyle, "none")) 123 if (strcmp (RP->doorstyle, "none"))
127 put_doors (theMap, layout, RP->doorstyle, RP); 124 put_doors (this, layout, RP->doorstyle, RP);
128 125
129 } 126 }
130 127
131 coroapi::cede (); 128 coroapi::cede ();
129
132 /* create exits unless the exitstyle is "none" */ 130 /* create exits unless the exitstyle is "none" */
133 if (strcmp (RP->exitstyle, "none")) 131 if (strcmp (RP->exitstyle, "none"))
134 place_exits (theMap, layout, RP->exitstyle, RP->orientation, RP); 132 place_exits (this, layout, RP->exitstyle, RP->orientation, RP);
135 133
136 coroapi::cede (); 134 coroapi::cede ();
135
137 place_specials_in_map (theMap, layout, RP); 136 place_specials_in_map (this, layout, RP);
138 137
139 coroapi::cede (); 138 coroapi::cede ();
139
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 (this, RP->monsterstyle, RP->difficulty, RP);
143 143
144 coroapi::cede (); 144 coroapi::cede ();
145
145 /* treasures needs to have a proper difficulty set for the map. */ 146 /* treasures needs to have a proper difficulty set for the map. */
146 theMap->difficulty = theMap->estimate_difficulty (); 147 difficulty = estimate_difficulty ();
147 148
148 coroapi::cede (); 149 coroapi::cede ();
150
149 /* create treasure unless the treasurestyle is "none" */ 151 /* create treasure unless the treasurestyle is "none" */
150 if (strcmp (RP->treasurestyle, "none")) 152 if (strcmp (RP->treasurestyle, "none"))
151 place_treasure (theMap, layout, RP->treasurestyle, RP->treasureoptions, RP); 153 place_treasure (this, layout, RP->treasurestyle, RP->treasureoptions, RP);
152 154
153 coroapi::cede (); 155 coroapi::cede ();
156
154 /* create decor unless the decorstyle is "none" */ 157 /* create decor unless the decorstyle is "none" */
155 if (strcmp (RP->decorstyle, "none")) 158 if (strcmp (RP->decorstyle, "none"))
156 put_decor (theMap, layout, RP->decorstyle, RP->decoroptions, RP); 159 put_decor (this, layout, RP->decorstyle, RP->decoroptions, RP);
157 160
158 coroapi::cede (); 161 coroapi::cede ();
162
159 /* generate treasures, etc. */ 163 /* generate treasures, etc. */
160 theMap->fix_auto_apply (); 164 fix_auto_apply ();
161 165
162 coroapi::cede (); 166 coroapi::cede ();
163 unblock_exits (theMap, layout, RP); 167 unblock_exits (this, layout, RP);
164 168
165 /* free the layout */ 169 /* free the layout */
166 for (i = 0; i < RP->Xsize; i++) 170 for (i = 0; i < RP->Xsize; i++)
167 free (layout[i]); 171 free (layout[i]);
168 172
169 free (layout); 173 free (layout);
170 174
171 theMap->msg = strdup (buf); 175 msg = strdup (buf);
172 theMap->in_memory = MAP_IN_MEMORY; 176 in_memory = MAP_IN_MEMORY;
173 177
174 return theMap; 178 return 1;
175} 179}
176 180
177/* function selects the layout function and gives it whatever 181/* function selects the layout function and gives it whatever
178 arguments it needs. */ 182 arguments it needs. */
179char ** 183char **

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines