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.51 by root, Wed Jun 30 01:32:57 2010 UTC vs.
Revision 1.55 by root, Sun Jul 4 00:58:18 2010 UTC

43/* clear map completely of all !floor objects: 43/* clear map completely of all !floor objects:
44 * a rectangular area of xsize, ysize 44 * a rectangular area of xsize, ysize
45 * is cleared with the top left corner at xstart, ystart 45 * is cleared with the top left corner at xstart, ystart
46 */ 46 */
47static void 47static void
48nuke_map_region (maptile *map, char **layout, int xstart, int ystart, int xsize, int ysize) 48nuke_map_region (maptile *map, char **maze, int xstart, int ystart, int xsize, int ysize)
49{ 49{
50 for (int i = xstart; i < xstart + xsize; i++) 50 for (int i = xstart; i < xstart + xsize; i++)
51 for (int j = ystart; j < ystart + ysize; j++) 51 for (int j = ystart; j < ystart + ysize; j++)
52 { 52 {
53 layout[i][j] = 'S'; 53 maze[i][j] = 'S';
54 54
55 for (object *tmp = map->at (i, j).bot; tmp; ) 55 for (object *tmp = map->at (i, j).bot; tmp; )
56 if (tmp->flag [FLAG_IS_FLOOR]) 56 if (tmp->flag [FLAG_IS_FLOOR])
57 tmp = tmp->above; 57 tmp = tmp->above;
58 else 58 else
84 dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON); 84 dest_map->insert (new_ob, x + i, y + j, 0, INS_NO_MERGE | INS_NO_WALK_ON);
85 } 85 }
86} 86}
87 87
88static int 88static int
89find_spot_for_submap (maptile *map, char **layout, int *ix, int *iy, int xsize, int ysize) 89find_spot_for_submap (maptile *map, char **maze, int *ix, int *iy, int xsize, int ysize)
90{ 90{
91 int blocked, i, j; 91 int blocked, i, j;
92 92
93 /* don't even try to place a submap into a map if the big map isn't 93 /* don't even try to place a submap into a map if the big map isn't
94 sufficiently large. */ 94 sufficiently large. */
98 /* search a bit for a completely free spot. */ 98 /* search a bit for a completely free spot. */
99 for (int tries = 0; tries < 20; tries++) 99 for (int tries = 0; tries < 20; tries++)
100 { 100 {
101 blocked = 0; 101 blocked = 0;
102 102
103 /* pick a random location in the layout */ 103 /* pick a random location in the maze */
104 i = rmg_rndm (1, map->width - xsize - 2); 104 i = rmg_rndm (1, map->width - xsize - 2);
105 j = rmg_rndm (1, map->height - ysize - 2); 105 j = rmg_rndm (1, map->height - ysize - 2);
106 106
107 for (int l = i; l < i + xsize; l++) 107 for (int l = i; l < i + xsize; l++)
108 for (int m = j; m < j + ysize; m++) 108 for (int m = j; m < j + ysize; m++)
116 } 116 }
117 117
118 /* if we failed, relax the restrictions */ 118 /* if we failed, relax the restrictions */
119 if (blocked) 119 if (blocked)
120 { /* failure, try a relaxed placer. */ 120 { /* failure, try a relaxed placer. */
121 /* pick a random location in the layout */ 121 /* pick a random location in the maze */
122 for (int tries = 0; tries < 10; tries++) 122 for (int tries = 0; tries < 10; tries++)
123 { 123 {
124 i = rmg_rndm (1, map->width - xsize - 2); 124 i = rmg_rndm (1, map->width - xsize - 2);
125 j = rmg_rndm (1, map->height - ysize - 2); 125 j = rmg_rndm (1, map->height - ysize - 2);
126 126
127 blocked = 0; 127 blocked = 0;
128 128
129 for (int l = i; l < i + xsize; l++) 129 for (int l = i; l < i + xsize; l++)
130 for (int m = j; m < j + ysize; m++) 130 for (int m = j; m < j + ysize; m++)
131 if (layout[l][m] != '#' && layout[l][m] != 'D' && layout[l][m] != 0) 131 if (maze[l][m] != '#' && maze[l][m] != 'D' && maze[l][m] != 0)
132 { 132 {
133 blocked = 1; 133 blocked = 1;
134 break; 134 break;
135 } 135 }
136 } 136 }
272 dynbuf_text buf; 272 dynbuf_text buf;
273 273
274 { 274 {
275 random_map_params &rp = *new random_map_params; // for zero_intiialised to work... 275 random_map_params &rp = *new random_map_params; // for zero_intiialised to work...
276 276
277 rp.hv = (HV *)SvREFCNT_inc_NN ((SV *)RP->hv); 277 rp.hv = (HV *)newHV ();
278 rp.hv_clone ();
279 278
280 rp.xsize = g_xsize; 279 rp.xsize = g_xsize;
281 rp.ysize = g_ysize; 280 rp.ysize = g_ysize;
282 281
282 rp.set ("wallstyle" , RP->get_str ("wallstyle" , 0));
283 rp.set ("floorstyle" , RP->get_str ("floorstyle", 0));
284 rp.set ("exitstyle" , RP->get_str ("exitstyle" , 0));
285 rp.set ("region" , RP->get_str ("region" , 0));
286 rp.set ("monsterstyle" , mon);
283 rp.set ("treasurestyle", "none"); 287 rp.set ("treasurestyle", "none");
288 rp.set ("layoutstyle" , style);
284 rp.set ("decorstyle" , decor); 289 rp.set ("decorstyle" , decor);
285 rp.set ("decoroptions" , (IV)-1); 290 rp.set ("decoroptions" , (IV)-1);
286 291 rp.set ("symmetry" , (IV)SYMMETRY_NONE);
287 assign (rp.monsterstyle, mon); 292 rp.set ("orientation" , (IV)1);
288 assign (rp.layoutstyle , style);
289 293
290 rp.layoutoptions1 = RMOPT_WALLS_ONLY; 294 rp.layoutoptions1 = RMOPT_WALLS_ONLY;
291 rp.symmetry = SYMMETRY_NONE;
292 rp.dungeon_depth = RP->dungeon_level; 295 rp.dungeon_depth = RP->dungeon_level;
293 rp.dungeon_level = RP->dungeon_level; 296 rp.dungeon_level = RP->dungeon_level;
294 rp.difficulty = RP->difficulty; 297 rp.difficulty = RP->difficulty;
295 rp.difficulty_given = RP->difficulty; 298 rp.difficulty_given = RP->difficulty;
296 rp.difficulty_increase = RP->difficulty_increase; 299 rp.difficulty_increase = RP->difficulty_increase;
297 rp.orientation = 1;
298 rp.random_seed = uint32_t (RP->random_seed + 0xdeadbeef); 300 rp.random_seed = uint32_t (RP->random_seed + 0xdeadbeef);
299 rp.region = RP->region;
300 301
301 the_exit->slaying = shstr_random_map_exit; 302 the_exit->slaying = shstr_random_map_exit;
302 the_exit->msg = rp.as_shstr (); 303 the_exit->msg = rp.as_shstr ();
303 304
304 delete &rp; 305 delete &rp;
305 } 306 }
306 307
307 insert_ob_in_map (the_exit, map, NULL, 0); 308 insert_ob_in_map (the_exit, map, NULL, 0);
308} 309}
309 310
310void 311void
311place_specials_in_map (maptile *map, char **layout, random_map_params *RP) 312place_specials_in_map (maptile *map, char **maze, random_map_params *RP)
312{ 313{
313 switch (rmg_rndm (NUM_OF_SPECIAL_TYPES)) 314 switch (rmg_rndm (NUM_OF_SPECIAL_TYPES))
314 { 315 {
315 case SPECIAL_SUBMAP: 316 case SPECIAL_SUBMAP:
316 { 317 {
320 if (!special_map) 321 if (!special_map)
321 break; 322 break;
322 323
323 int ix, iy; /* map insertion locatons */ 324 int ix, iy; /* map insertion locatons */
324 325
325 if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height)) 326 if (find_spot_for_submap (map, maze, &ix, &iy, special_map->width, special_map->height))
326 { 327 {
327 /* First, splatter everything in the dest map at the location */ 328 /* First, splatter everything in the dest map at the location */
328 nuke_map_region (map, layout, ix, iy, special_map->width, special_map->height); 329 nuke_map_region (map, maze, ix, iy, special_map->width, special_map->height);
329 include_map_in_map (map, special_map, ix, iy); 330 include_map_in_map (map, special_map, ix, iy);
330 } 331 }
331 } 332 }
332 333
333 break; 334 break;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines