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

Comparing deliantra/server/random_maps/treasure.c (file contents):
Revision 1.1.1.2 by elmex, Wed Mar 15 14:05:34 2006 UTC vs.
Revision 1.2 by root, Sat Feb 25 23:03:47 2006 UTC

1/* 1/*
2 * static char *rcsid_treasure_c = 2 * static char *rcsid_treasure_c =
3 * "$Id: treasure.c,v 1.1.1.2 2006/03/15 14:05:34 elmex Exp $"; 3 * "$Id: treasure.c,v 1.2 2006/02/25 23:03:47 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
145 tries++; 145 tries++;
146 } 146 }
147 chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures,RP); 147 chest=place_chest(treasureoptions,i,j,map,style_map,num_treasures,RP);
148 if(!chest) return; 148 if(!chest) return;
149 i = chest->x; j = chest->y; 149 i = chest->x; j = chest->y;
150 if(treasureoptions &( DOORED|HIDDEN)) { 150 if(treasureoptions & (DOORED|HIDDEN)) {
151 doorlist=surround_by_doors(map,layout,i,j,treasureoptions); 151 doorlist=surround_by_doors(map,layout,i,j,treasureoptions);
152 lock_and_hide_doors(doorlist,map,treasureoptions,RP); 152 lock_and_hide_doors(doorlist,map,treasureoptions,RP);
153 free(doorlist); 153 free(doorlist);
154 } 154 }
155 } 155 }
250 250
251/* finds the closest monster and returns him, regardless of doors 251/* finds the closest monster and returns him, regardless of doors
252 or walls */ 252 or walls */
253object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) { 253object *find_closest_monster(mapstruct *map,int x,int y,RMParms *RP) {
254 int i; 254 int i;
255 for(i=0;i<SIZEOFFREE;i++) { 255 for(i=0;i<SIZEOFFREE1;i++) {
256 int lx,ly; 256 int lx,ly;
257 lx=x+freearr_x[i]; 257 lx=x+freearr_x[i];
258 ly=y+freearr_y[i]; 258 ly=y+freearr_y[i];
259 /* boundscheck */ 259 /* boundscheck */
260 if(lx >= 0 && ly >= 0 && lx < RP->Xsize && ly < RP->Ysize) 260 if(lx > 0 && ly > 0 && lx < RP->Xsize && ly < RP->Ysize)
261 /* don't bother searching this square unless the map says life exists.*/ 261 /* don't bother searching this square unless the map says life exists.*/
262 if(GET_MAP_FLAGS(map,lx,ly) & P_IS_ALIVE) { 262 if(GET_MAP_FLAGS(map,lx,ly) & P_IS_ALIVE) {
263 object *the_monster=get_map_ob(map,lx,ly); 263 object *the_monster=get_map_ob(map,lx,ly);
264 for(;the_monster!=NULL&&(!QUERY_FLAG(the_monster,FLAG_MONSTER));the_monster=the_monster->above); 264 for(;the_monster!=NULL&&(!QUERY_FLAG(the_monster,FLAG_MONSTER));the_monster=the_monster->above);
265 if(the_monster && QUERY_FLAG(the_monster,FLAG_MONSTER)) 265 if(the_monster && QUERY_FLAG(the_monster,FLAG_MONSTER))
502void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) { 502void find_enclosed_spot(mapstruct *map, int *cx, int *cy,RMParms *RP) {
503 int x,y; 503 int x,y;
504 int i; 504 int i;
505 x = *cx;y=*cy; 505 x = *cx;y=*cy;
506 506
507 for(i=0;i<=SIZEOFFREE1;i++) { 507 for(i=0;i<SIZEOFFREE1;i++) {
508 int lx,ly,sindex; 508 int lx,ly,sindex;
509 lx = x +freearr_x[i]; 509 lx = x +freearr_x[i];
510 ly = y +freearr_y[i]; 510 ly = y +freearr_y[i];
511 sindex = surround_flag3(map,lx,ly,RP); 511 sindex = surround_flag3(map,lx,ly,RP);
512 /* if it's blocked on 3 sides, it's enclosed */ 512 /* if it's blocked on 3 sides, it's enclosed */
516 } 516 }
517 } 517 }
518 518
519 /* OK, if we got here, we're obviously someplace where there's no enclosed 519 /* OK, if we got here, we're obviously someplace where there's no enclosed
520 spots--try to find someplace which is 2x enclosed. */ 520 spots--try to find someplace which is 2x enclosed. */
521 for(i=0;i<=SIZEOFFREE1;i++) { 521 for(i=0;i<SIZEOFFREE1;i++) {
522 int lx,ly,sindex; 522 int lx,ly,sindex;
523 lx = x +freearr_x[i]; 523 lx = x +freearr_x[i];
524 ly = y +freearr_y[i]; 524 ly = y +freearr_y[i];
525 sindex = surround_flag3(map,lx,ly,RP); 525 sindex = surround_flag3(map,lx,ly,RP);
526 /* if it's blocked on 3 sides, it's enclosed */ 526 /* if it's blocked on 3 sides, it's enclosed */
529 return; 529 return;
530 } 530 }
531 } 531 }
532 532
533 /* settle for one surround point */ 533 /* settle for one surround point */
534 for(i=0;i<=SIZEOFFREE1;i++) { 534 for(i=0;i<SIZEOFFREE1;i++) {
535 int lx,ly,sindex; 535 int lx,ly,sindex;
536 lx = x +freearr_x[i]; 536 lx = x +freearr_x[i];
537 ly = y +freearr_y[i]; 537 ly = y +freearr_y[i];
538 sindex = surround_flag3(map,lx,ly,RP); 538 sindex = surround_flag3(map,lx,ly,RP);
539 /* if it's blocked on 3 sides, it's enclosed */ 539 /* if it's blocked on 3 sides, it's enclosed */
542 return; 542 return;
543 } 543 }
544 } 544 }
545 /* give up and return the closest free spot. */ 545 /* give up and return the closest free spot. */
546 i = find_first_free_spot(&find_archetype("chest")->clone,map,x,y); 546 i = find_first_free_spot(&find_archetype("chest")->clone,map,x,y);
547 if(i!=-1&&i<=SIZEOFFREE1) { 547 if(i!=-1&&i<SIZEOFFREE1) {
548 *cx = x +freearr_x[i]; 548 *cx = x +freearr_x[i];
549 *cy = y +freearr_y[i]; 549 *cy = y +freearr_y[i];
550 return;
551 } 550 }
552 /* indicate failure */ 551 /* indicate failure */
553 *cx=*cy=-1; 552 *cx=*cy=-1;
554} 553}
555 554

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines