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.9 by root, Wed Dec 20 09:14:22 2006 UTC vs.
Revision 1.10 by root, Mon Dec 25 14:43:23 2006 UTC

78 int i, j; 78 int i, j;
79 object *tmp; 79 object *tmp;
80 object *new_ob; 80 object *new_ob;
81 81
82 /* First, splatter everything in the dest map at the location */ 82 /* First, splatter everything in the dest map at the location */
83 nuke_map_region (dest_map, x, y, MAP_WIDTH (in_map), MAP_HEIGHT (in_map)); 83 nuke_map_region (dest_map, x, y, in_map->width, in_map->height);
84 84
85 for (i = 0; i < MAP_WIDTH (in_map); i++) 85 for (i = 0; i < in_map->width; i++)
86 for (j = 0; j < MAP_HEIGHT (in_map); j++) 86 for (j = 0; j < in_map->height; j++)
87 { 87 {
88 for (tmp = GET_MAP_OB (in_map, i, j); tmp != NULL; tmp = tmp->above) 88 for (tmp = GET_MAP_OB (in_map, i, j); tmp != NULL; tmp = tmp->above)
89 { 89 {
90 /* don't copy things with multiple squares: must be dealt with 90 /* don't copy things with multiple squares: must be dealt with
91 specially. */ 91 specially. */
110 int is_occupied = 0; 110 int is_occupied = 0;
111 int l, m; 111 int l, m;
112 112
113 /* don't even try to place a submap into a map if the big map isn't 113 /* don't even try to place a submap into a map if the big map isn't
114 sufficiently large. */ 114 sufficiently large. */
115 if (2 * xsize > MAP_WIDTH (map) || 2 * ysize > MAP_HEIGHT (map)) 115 if (2 * xsize > map->width || 2 * ysize > map->height)
116 return 0; 116 return 0;
117 117
118 /* search a bit for a completely free spot. */ 118 /* search a bit for a completely free spot. */
119 for (tries = 0; tries < 20; tries++) 119 for (tries = 0; tries < 20; tries++)
120 { 120 {
121 /* pick a random location in the layout */ 121 /* pick a random location in the layout */
122 i = RANDOM () % (MAP_WIDTH (map) - xsize - 2) + 1; 122 i = RANDOM () % (map->width - xsize - 2) + 1;
123 j = RANDOM () % (MAP_HEIGHT (map) - ysize - 2) + 1; 123 j = RANDOM () % (map->height - ysize - 2) + 1;
124 is_occupied = 0; 124 is_occupied = 0;
125 for (l = i; l < i + xsize; l++) 125 for (l = i; l < i + xsize; l++)
126 for (m = j; m < j + ysize; m++) 126 for (m = j; m < j + ysize; m++)
127 is_occupied |= layout[l][m]; 127 is_occupied |= layout[l][m];
128 if (!is_occupied) 128 if (!is_occupied)
135 if (is_occupied) 135 if (is_occupied)
136 { /* failure, try a relaxed placer. */ 136 { /* failure, try a relaxed placer. */
137 /* pick a random location in the layout */ 137 /* pick a random location in the layout */
138 for (tries = 0; tries < 10; tries++) 138 for (tries = 0; tries < 10; tries++)
139 { 139 {
140 i = RANDOM () % (MAP_WIDTH (map) - xsize - 2) + 1; 140 i = RANDOM () % (map->width - xsize - 2) + 1;
141 j = RANDOM () % (MAP_HEIGHT (map) - ysize - 2) + 1; 141 j = RANDOM () % (map->height - ysize - 2) + 1;
142 is_occupied = 0; 142 is_occupied = 0;
143 for (l = i; l < i + xsize; l++) 143 for (l = i; l < i + xsize; l++)
144 for (m = j; m < j + ysize; m++) 144 for (m = j; m < j + ysize; m++)
145 if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<') 145 if (layout[l][m] == 'C' || layout[l][m] == '>' || layout[l][m] == '<')
146 is_occupied |= 1; 146 is_occupied |= 1;
164 164
165 pick_random_object (fountain_style)->copy_to (potion); 165 pick_random_object (fountain_style)->copy_to (potion);
166 166
167 while (i < 0 && tries < 10) 167 while (i < 0 && tries < 10)
168 { 168 {
169 ix = RANDOM () % (MAP_WIDTH (map) - 2) + 1; 169 ix = RANDOM () % (map->width - 2) + 1;
170 iy = RANDOM () % (MAP_HEIGHT (map) - 2) + 1; 170 iy = RANDOM () % (map->height - 2) + 1;
171 i = find_first_free_spot (fountain, map, ix, iy); 171 i = find_first_free_spot (fountain, map, ix, iy);
172 tries++; 172 tries++;
173 } 173 }
174 174
175 if (i == -1) 175 if (i == -1)
210 210
211 pick_random_object (exit_style)->copy_to (the_exit); 211 pick_random_object (exit_style)->copy_to (the_exit);
212 212
213 while (i < 0) 213 while (i < 0)
214 { 214 {
215 ix = RANDOM () % (MAP_WIDTH (map) - 2) + 1; 215 ix = RANDOM () % (map->width - 2) + 1;
216 iy = RANDOM () % (MAP_HEIGHT (map) - 2) + 1; 216 iy = RANDOM () % (map->height - 2) + 1;
217 i = find_first_free_spot (the_exit, map, ix, iy); 217 i = find_first_free_spot (the_exit, map, ix, iy);
218 } 218 }
219 219
220 ix += freearr_x[i]; 220 ix += freearr_x[i];
221 iy += freearr_y[i]; 221 iy += freearr_y[i];
299 { 299 {
300 special_map = find_style ("/styles/specialmaps", 0, RP->difficulty); 300 special_map = find_style ("/styles/specialmaps", 0, RP->difficulty);
301 if (special_map == NULL) 301 if (special_map == NULL)
302 return; 302 return;
303 303
304 if (find_spot_for_submap (map, layout, &ix, &iy, MAP_WIDTH (special_map), MAP_HEIGHT (special_map))) 304 if (find_spot_for_submap (map, layout, &ix, &iy, special_map->width, special_map->height))
305 include_map_in_map (map, special_map, ix, iy); 305 include_map_in_map (map, special_map, ix, iy);
306 break; 306 break;
307 } 307 }
308 308
309 /* Make a special fountain: an unpickable potion disguised as 309 /* Make a special fountain: an unpickable potion disguised as

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines