… | |
… | |
497 | /* sets up some data structures: the _recursive form does the |
497 | /* sets up some data structures: the _recursive form does the |
498 | real work. */ |
498 | real work. */ |
499 | static object * |
499 | static object * |
500 | find_monster_in_room (maptile *map, int x, int y, random_map_params *RP) |
500 | find_monster_in_room (maptile *map, int x, int y, random_map_params *RP) |
501 | { |
501 | { |
502 | Layout layout2 (RP); |
502 | Layout layout2 (map->width, map->height); |
503 | |
503 | |
504 | layout2->clear (); |
504 | // find walls |
505 | |
|
|
506 | /* allocate and copy the layout, converting C to 0. */ |
|
|
507 | for (int i = 0; i < layout2->w; i++) |
505 | for (int i = 0; i < layout2.w; i++) |
508 | for (int j = 0; j < layout2->h; j++) |
506 | for (int j = 0; j < layout2.h; j++) |
509 | if (wall_blocked (map, i, j)) |
507 | layout2[i][j] = wall_blocked (map, i, j) ? '#' : 0; |
510 | layout2[i][j] = '#'; |
|
|
511 | |
508 | |
512 | theMonsterToFind = 0; |
509 | theMonsterToFind = 0; |
513 | theMonsterToFind = find_monster_in_room_recursive (layout2, map, x, y, RP); |
510 | theMonsterToFind = find_monster_in_room_recursive (layout2, map, x, y, RP); |
514 | |
|
|
515 | layout2.free (); |
|
|
516 | |
511 | |
517 | return theMonsterToFind; |
512 | return theMonsterToFind; |
518 | } |
513 | } |
519 | |
514 | |
520 | /* a datastructure needed by find_spot_in_room and find_spot_in_room_recursive */ |
515 | /* a datastructure needed by find_spot_in_room and find_spot_in_room_recursive */ |
… | |
… | |
609 | { |
604 | { |
610 | int lx, ly, sindex; |
605 | int lx, ly, sindex; |
611 | |
606 | |
612 | lx = x + freearr_x[i]; |
607 | lx = x + freearr_x[i]; |
613 | ly = y + freearr_y[i]; |
608 | ly = y + freearr_y[i]; |
614 | sindex = surround_flag3 (map, lx, ly, RP); |
609 | sindex = surround_flag3 (map, lx, ly); |
615 | /* if it's blocked on 3 sides, it's enclosed */ |
610 | /* if it's blocked on 3 sides, it's enclosed */ |
616 | if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14) |
611 | if (sindex == 7 || sindex == 11 || sindex == 13 || sindex == 14) |
617 | { |
612 | { |
618 | *cx = lx; |
613 | *cx = lx; |
619 | *cy = ly; |
614 | *cy = ly; |
… | |
… | |
627 | { |
622 | { |
628 | int lx, ly, sindex; |
623 | int lx, ly, sindex; |
629 | |
624 | |
630 | lx = x + freearr_x[i]; |
625 | lx = x + freearr_x[i]; |
631 | ly = y + freearr_y[i]; |
626 | ly = y + freearr_y[i]; |
632 | sindex = surround_flag3 (map, lx, ly, RP); |
627 | sindex = surround_flag3 (map, lx, ly); |
633 | /* if it's blocked on 3 sides, it's enclosed */ |
628 | /* if it's blocked on 3 sides, it's enclosed */ |
634 | if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12) |
629 | if (sindex == 3 || sindex == 5 || sindex == 9 || sindex == 6 || sindex == 10 || sindex == 12) |
635 | { |
630 | { |
636 | *cx = lx; |
631 | *cx = lx; |
637 | *cy = ly; |
632 | *cy = ly; |
… | |
… | |
644 | { |
639 | { |
645 | int lx, ly, sindex; |
640 | int lx, ly, sindex; |
646 | |
641 | |
647 | lx = x + freearr_x[i]; |
642 | lx = x + freearr_x[i]; |
648 | ly = y + freearr_y[i]; |
643 | ly = y + freearr_y[i]; |
649 | sindex = surround_flag3 (map, lx, ly, RP); |
644 | sindex = surround_flag3 (map, lx, ly); |
650 | /* if it's blocked on 3 sides, it's enclosed */ |
645 | /* if it's blocked on 3 sides, it's enclosed */ |
651 | if (sindex) |
646 | if (sindex) |
652 | { |
647 | { |
653 | *cx = lx; |
648 | *cx = lx; |
654 | *cy = ly; |
649 | *cy = ly; |
… | |
… | |
791 | int i, j; |
786 | int i, j; |
792 | int ndoors = 0; |
787 | int ndoors = 0; |
793 | |
788 | |
794 | object **doorlist = (object **)calloc (sizeof (int), 1024); |
789 | object **doorlist = (object **)calloc (sizeof (int), 1024); |
795 | |
790 | |
796 | LayoutData layout2 (RP->Xsize, RP->Ysize); |
791 | Layout layout2 (RP->Xsize, RP->Ysize); |
797 | layout2.clear (); |
792 | layout2.clear (); |
798 | |
793 | |
799 | /* allocate and copy the layout, converting C to 0. */ |
794 | /* allocate and copy the layout, converting C to 0. */ |
800 | for (i = 0; i < RP->Xsize; i++) |
795 | for (i = 0; i < RP->Xsize; i++) |
801 | for (j = 0; j < RP->Ysize; j++) |
796 | for (j = 0; j < RP->Ysize; j++) |