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

Comparing deliantra/server/random_maps/special.C (file contents):
Revision 1.18 by root, Sat Jan 27 00:50:13 2007 UTC vs.
Revision 1.19 by root, Sat Jan 27 00:56:48 2007 UTC

118 118
119 /* search a bit for a completely free spot. */ 119 /* search a bit for a completely free spot. */
120 for (tries = 0; tries < 20; tries++) 120 for (tries = 0; tries < 20; tries++)
121 { 121 {
122 /* pick a random location in the layout */ 122 /* pick a random location in the layout */
123 i = RANDOM () % (map->width - xsize - 2) + 1; 123 i = rndm (map->width - xsize - 2) + 1;
124 j = RANDOM () % (map->height - ysize - 2) + 1; 124 j = rndm (map->height - ysize - 2) + 1;
125 is_occupied = 0; 125 is_occupied = 0;
126 for (l = i; l < i + xsize; l++) 126 for (l = i; l < i + xsize; l++)
127 for (m = j; m < j + ysize; m++) 127 for (m = j; m < j + ysize; m++)
128 is_occupied |= layout[l][m]; 128 is_occupied |= layout[l][m];
129 if (!is_occupied) 129 if (!is_occupied)
136 if (is_occupied) 136 if (is_occupied)
137 { /* failure, try a relaxed placer. */ 137 { /* failure, try a relaxed placer. */
138 /* pick a random location in the layout */ 138 /* pick a random location in the layout */
139 for (tries = 0; tries < 10; tries++) 139 for (tries = 0; tries < 10; tries++)
140 { 140 {
141 i = RANDOM () % (map->width - xsize - 2) + 1; 141 i = rndm (map->width - xsize - 2) + 1;
142 j = RANDOM () % (map->height - ysize - 2) + 1; 142 j = rndm (map->height - ysize - 2) + 1;
143 is_occupied = 0; 143 is_occupied = 0;
144 for (l = i; l < i + xsize; l++) 144 for (l = i; l < i + xsize; l++)
145 for (m = j; m < j + ysize; m++) 145 for (m = j; m < j + ysize; m++)
146 if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') 146 if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<')
147 is_occupied |= 1; 147 is_occupied |= 1;
160{ 160{
161 int ix, iy, i = -1, tries = 0; 161 int ix, iy, i = -1, tries = 0;
162 maptile *fountain_style = find_style ("/styles/misc", "fountains", -1); 162 maptile *fountain_style = find_style ("/styles/misc", "fountains", -1);
163 163
164 if (!fountain_style) 164 if (!fountain_style)
165 {
165 LOG (llevError, "unabel to load stylemap /styles/misc fountains\n"), 166 LOG (llevError, "unabel to load stylemap /styles/misc fountains\n");
166 return; 167 return;
168 }
167 169
168 object *fountain = get_archetype ("fountain"); 170 object *fountain = get_archetype ("fountain");
169 object *potion = object::create (); 171 object *potion = object::create ();
170 172
171 pick_random_object (fountain_style)->copy_to (potion); 173 pick_random_object (fountain_style)->copy_to (potion);
172 174
173 while (i < 0 && tries < 10) 175 while (i < 0 && tries < 10)
174 { 176 {
175 ix = RANDOM () % (map->width - 2) + 1; 177 ix = rndm (map->width - 2) + 1;
176 iy = RANDOM () % (map->height - 2) + 1; 178 iy = rndm (map->height - 2) + 1;
177 i = find_free_spot (fountain, map, ix, iy, 1, SIZEOFFREE1 + 1); 179 i = find_free_spot (fountain, map, ix, iy, 1, SIZEOFFREE1 + 1);
178 tries++; 180 tries++;
179 } 181 }
180 182
181 if (i == -1) 183 if (i == -1)
207 char buf[16384], *style, *decor, *mon; 209 char buf[16384], *style, *decor, *mon;
208 maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1); 210 maptile *exit_style = find_style ("/styles/misc", "obscure_exits", -1);
209 int g_xsize, g_ysize; 211 int g_xsize, g_ysize;
210 212
211 if (!exit_style) 213 if (!exit_style)
214 {
212 LOG (llevError, "unabel to load stylemap /styles/misc obscure_exits\n"), 215 LOG (llevError, "unabel to load stylemap /styles/misc obscure_exits\n");
213 return 0; 216 return;
217 }
214 218
215 object *the_exit = object::create (); 219 object *the_exit = object::create ();
216 220
217 if (!exit_style) 221 if (!exit_style)
218 return; 222 return;
219 223
220 pick_random_object (exit_style)->copy_to (the_exit); 224 pick_random_object (exit_style)->copy_to (the_exit);
221 225
222 while (i < 0) 226 while (i < 0)
223 { 227 {
224 ix = RANDOM () % (map->width - 2) + 1; 228 ix = rndm (map->width - 2) + 1;
225 iy = RANDOM () % (map->height - 2) + 1; 229 iy = rndm (map->height - 2) + 1;
226 i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1); 230 i = find_free_spot (the_exit, map, ix, iy, 1, SIZEOFFREE1 + 1);
227 } 231 }
228 232
229 ix += freearr_x[i]; 233 ix += freearr_x[i];
230 iy += freearr_y[i]; 234 iy += freearr_y[i];
231 the_exit->x = ix; 235 the_exit->x = ix;
232 the_exit->y = iy; 236 the_exit->y = iy;
233 237
234 if (!hole_type) 238 if (!hole_type)
235 hole_type = RANDOM () % NR_OF_HOLE_TYPES + 1; 239 hole_type = rndm (NR_OF_HOLE_TYPES) + 1;
236 240
237 switch (hole_type) 241 switch (hole_type)
238 { 242 {
239 case GLORY_HOLE: /* treasures */ 243 case GLORY_HOLE: /* treasures */
240 { 244 {
296{ 300{
297 maptile *special_map; 301 maptile *special_map;
298 int ix, iy; /* map insertion locatons */ 302 int ix, iy; /* map insertion locatons */
299 int special_type; /* type of special to make */ 303 int special_type; /* type of special to make */
300 304
301
302 special_type = RANDOM () % NUM_OF_SPECIAL_TYPES; 305 special_type = rndm (NUM_OF_SPECIAL_TYPES);
306
303 switch (special_type) 307 switch (special_type)
304 { 308 {
305 309 case SPECIAL_SUBMAP:
306 /* includes a special map into the random map being made. */ 310 /* includes a special map into the random map being made. */
307 case SPECIAL_SUBMAP:
308 {
309 special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); 311 special_map = find_style ("/styles/specialmaps", 0, RP->difficulty);
312
310 if (!special_map) 313 if (!special_map)
311 return; 314 return;
312 315
313 if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height)) 316 if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height))
314 include_map_in_map (map, special_map, ix, iy); 317 include_map_in_map (map, special_map, ix, iy);
318
315 break; 319 break;
316 }
317 320
321 case SPECIAL_FOUNTAIN:
318 /* Make a special fountain: an unpickable potion disguised as 322 /* Make a special fountain: an unpickable potion disguised as
319 a fountain, or rather, colocated with a fountain. */ 323 a fountain, or rather, colocated with a fountain. */
320 case SPECIAL_FOUNTAIN:
321 {
322 place_fountain_with_specials (map); 324 place_fountain_with_specials (map);
323 break; 325 break;
324 }
325 326
327 case SPECIAL_EXIT:
326 /* Make an exit to another random map, e.g. a gloryhole. */ 328 /* Make an exit to another random map, e.g. a gloryhole. */
327 case SPECIAL_EXIT:
328 {
329 place_special_exit (map, 0, RP); 329 place_special_exit (map, 0, RP);
330 break; 330 break;
331 }
332 } 331 }
333 332
334} 333}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines