return a coord c inside mkroom croom, but not in a subroom. returns TRUE if any such space found. can return a non-accessible location, eg. inside a wall if a themed room is not irregular, but has some non-room terrain */
| 691 | can return a non-accessible location, eg. inside a wall |
| 692 | if a themed room is not irregular, but has some non-room terrain */ |
| 693 | boolean |
| 694 | somexy(struct mkroom *croom, coord *c) |
| 695 | { |
| 696 | int try_cnt = 0; |
| 697 | int i; |
| 698 | |
| 699 | if (croom->irregular) { |
| 700 | i = (int) ((croom - svr.rooms) + ROOMOFFSET); |
| 701 | |
| 702 | while (try_cnt++ < 100) { |
| 703 | c->x = somex(croom); |
| 704 | c->y = somey(croom); |
| 705 | if (!levl[c->x][c->y].edge && (int) levl[c->x][c->y].roomno == i) |
| 706 | return TRUE; |
| 707 | } |
| 708 | /* try harder; exhaustively search until one is found */ |
| 709 | for (c->x = croom->lx; c->x <= croom->hx; c->x++) |
| 710 | for (c->y = croom->ly; c->y <= croom->hy; c->y++) |
| 711 | if (!levl[c->x][c->y].edge |
| 712 | && (int) levl[c->x][c->y].roomno == i) |
| 713 | return TRUE; |
| 714 | return FALSE; |
| 715 | } |
| 716 | |
| 717 | if (!croom->nsubrooms) { |
| 718 | c->x = somex(croom); |
| 719 | c->y = somey(croom); |
| 720 | return TRUE; |
| 721 | } |
| 722 | |
| 723 | /* Check that coords doesn't fall into a subroom or into a wall */ |
| 724 | |
| 725 | while (try_cnt++ < 100) { |
| 726 | c->x = somex(croom); |
| 727 | c->y = somey(croom); |
| 728 | if (IS_WALL(levl[c->x][c->y].typ)) |
| 729 | continue; |
| 730 | for (i = 0; i < croom->nsubrooms; i++) |
| 731 | if (inside_room(croom->sbrooms[i], c->x, c->y)) |
| 732 | goto you_lose; |
| 733 | break; |
| 734 | you_lose: |
| 735 | ; |
| 736 | } |
| 737 | if (try_cnt >= 100) |
| 738 | return FALSE; |
| 739 | return TRUE; |
| 740 | } |
| 741 | |
| 742 | /* like somexy(), but returns an accessible location */ |
| 743 | boolean |
no test coverage detected