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.1 by elmex, Sun Aug 13 17:16:03 2006 UTC vs.
Revision 1.2 by root, Tue Aug 29 08:01:36 2006 UTC

1/* 1/*
2 * static char *rcsid_special_c = 2 * static char *rcsid_special_c =
3 * "$Id: special.C,v 1.1 2006/08/13 17:16:03 elmex Exp $"; 3 * "$Id: special.C,v 1.2 2006/08/29 08:01:36 root Exp $";
4 */ 4 */
5 5
6/* 6/*
7 CrossFire, A Multiplayer game for X-windows 7 CrossFire, A Multiplayer game for X-windows
8 8
25 25
26 The authors can be reached via e-mail at crossfire-devel@real-time.com 26 The authors can be reached via e-mail at crossfire-devel@real-time.com
27*/ 27*/
28 28
29/* Specials in this file: 29/* Specials in this file:
30 included maps */ 30 included maps */
31 31
32#include <global.h> 32#include <global.h>
33#include <random_map.h> 33#include <random_map.h>
34#include <rproto.h> 34#include <rproto.h>
35 35
74 object *tmp; 74 object *tmp;
75 object *new_ob; 75 object *new_ob;
76 76
77 /* First, splatter everything in the dest map at the location */ 77 /* First, splatter everything in the dest map at the location */
78 nuke_map_region(dest_map,x,y,MAP_WIDTH(in_map),MAP_HEIGHT(in_map)); 78 nuke_map_region(dest_map,x,y,MAP_WIDTH(in_map),MAP_HEIGHT(in_map));
79 79
80 for(i=0;i<MAP_WIDTH(in_map);i++) 80 for(i=0;i<MAP_WIDTH(in_map);i++)
81 for(j=0;j<MAP_HEIGHT(in_map);j++) { 81 for(j=0;j<MAP_HEIGHT(in_map);j++) {
82 for(tmp=get_map_ob(in_map,i,j);tmp!=NULL;tmp=tmp->above) { 82 for(tmp=get_map_ob(in_map,i,j);tmp!=NULL;tmp=tmp->above) {
83 /* don't copy things with multiple squares: must be dealt with 83 /* don't copy things with multiple squares: must be dealt with
84 specially. */ 84 specially. */
113 for(m=j;m<j + ysize;m++) 113 for(m=j;m<j + ysize;m++)
114 is_occupied|=layout[l][m]; 114 is_occupied|=layout[l][m];
115 if(!is_occupied) break; 115 if(!is_occupied) break;
116 } 116 }
117 117
118 118
119 /* if we failed, relax the restrictions */ 119 /* if we failed, relax the restrictions */
120 120
121 if(is_occupied) { /* failure, try a relaxed placer. */ 121 if(is_occupied) { /* failure, try a relaxed placer. */
122 /* pick a random location in the layout */ 122 /* pick a random location in the layout */
123 for(tries=0;tries<10;tries++) { 123 for(tries=0;tries<10;tries++) {
181 if(!exit_style) return; 181 if(!exit_style) return;
182 182
183 copy_object(pick_random_object(exit_style),the_exit); 183 copy_object(pick_random_object(exit_style),the_exit);
184 184
185 while(i<0) { 185 while(i<0) {
186 ix = RANDOM() % (MAP_WIDTH(map) -2) +1; 186 ix = RANDOM() % (MAP_WIDTH(map) -2) +1;
187 iy = RANDOM() % (MAP_HEIGHT(map) -2) +1; 187 iy = RANDOM() % (MAP_HEIGHT(map) -2) +1;
188 i = find_first_free_spot(the_exit,map,ix,iy); 188 i = find_first_free_spot(the_exit,map,ix,iy);
189 } 189 }
190 190
191 ix += freearr_x[i]; 191 ix += freearr_x[i];
192 iy += freearr_y[i]; 192 iy += freearr_y[i];
193 the_exit->x = ix; 193 the_exit->x = ix;
194 the_exit->y = iy; 194 the_exit->y = iy;
195 195
196 if(!hole_type) hole_type = RANDOM() % NR_OF_HOLE_TYPES + 1 ; 196 if(!hole_type) hole_type = RANDOM() % NR_OF_HOLE_TYPES + 1 ;
197 197
198 switch(hole_type) { 198 switch(hole_type) {
199 case GLORY_HOLE: /* treasures */ 199 case GLORY_HOLE: /* treasures */
200 { 200 {
201 g_xsize = RANDOM() %3 + 4 + RP->difficulty/4; 201 g_xsize = RANDOM() %3 + 4 + RP->difficulty/4;
202 g_ysize = RANDOM() %3 + 4 + RP->difficulty/4; 202 g_ysize = RANDOM() %3 + 4 + RP->difficulty/4;
203 style = "onion"; 203 style = "onion";
204 decor = "wealth2"; 204 decor = "wealth2";
205 mon = "none"; 205 mon = "none";
206 break; 206 break;
207 } 207 }
208 208
209 case ORC_ZONE: /* hole with orcs in it. */ 209 case ORC_ZONE: /* hole with orcs in it. */
210 { 210 {
211 g_xsize = RANDOM() %3 + 4 + RP->difficulty/4; 211 g_xsize = RANDOM() %3 + 4 + RP->difficulty/4;
212 g_ysize = RANDOM() %3 + 4 + RP->difficulty/4; 212 g_ysize = RANDOM() %3 + 4 + RP->difficulty/4;
213 style = "onion"; 213 style = "onion";
214 decor = "wealth2"; 214 decor = "wealth2";
215 mon = "orc"; 215 mon = "orc";
216 break; 216 break;
217 } 217 }
218 218
219 case MINING_ZONE: /* hole with orcs in it. */ 219 case MINING_ZONE: /* hole with orcs in it. */
220 { 220 {
221 g_xsize = RANDOM() %9 + 4 + RP->difficulty/4; 221 g_xsize = RANDOM() %9 + 4 + RP->difficulty/4;
222 g_ysize = RANDOM() %9 + 4 + RP->difficulty/4; 222 g_ysize = RANDOM() %9 + 4 + RP->difficulty/4;
223 style = "maze"; 223 style = "maze";
224 decor = "minerals2"; 224 decor = "minerals2";
225 mon = "none"; 225 mon = "none";
226 break; 226 break;
227 } 227 }
228 228
229 default: /* undefined */ 229 default: /* undefined */
230 LOG(llevError, "place_special_exit: undefined hole type %d\n", hole_type); 230 LOG(llevError, "place_special_exit: undefined hole type %d\n", hole_type);
231 return; 231 return;
232 break; 232 break;
233 } 233 }
234 234
235 /* Need to be at least this size, otherwise the load 235 /* Need to be at least this size, otherwise the load
236 * code will generate new size values which are too large. 236 * code will generate new size values which are too large.
237 */ 237 */
246 the_exit->msg = add_string(buf); 246 the_exit->msg = add_string(buf);
247 247
248 insert_ob_in_map(the_exit,map,NULL,0); 248 insert_ob_in_map(the_exit,map,NULL,0);
249} 249}
250 250
251 251
252void place_specials_in_map(mapstruct *map, char **layout,RMParms *RP) { 252void place_specials_in_map(mapstruct *map, char **layout,RMParms *RP) {
253 mapstruct *special_map; 253 mapstruct *special_map;
254 int ix,iy; /* map insertion locatons */ 254 int ix,iy; /* map insertion locatons */
255 int special_type; /* type of special to make */ 255 int special_type; /* type of special to make */
256 256
260 260
261 /* includes a special map into the random map being made. */ 261 /* includes a special map into the random map being made. */
262 case SPECIAL_SUBMAP: { 262 case SPECIAL_SUBMAP: {
263 special_map = find_style("/styles/specialmaps",0,RP->difficulty); 263 special_map = find_style("/styles/specialmaps",0,RP->difficulty);
264 if(special_map==NULL) return; 264 if(special_map==NULL) return;
265 265
266 if(find_spot_for_submap(map,layout,&ix,&iy,MAP_WIDTH(special_map),MAP_HEIGHT(special_map))) 266 if(find_spot_for_submap(map,layout,&ix,&iy,MAP_WIDTH(special_map),MAP_HEIGHT(special_map)))
267 include_map_in_map(map,special_map,ix,iy); 267 include_map_in_map(map,special_map,ix,iy);
268 break; 268 break;
269 } 269 }
270 270

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines