Return typ of liquid to fill a hole with, or ROOM, if no liquid nearby */
| 603 | |
| 604 | /* Return typ of liquid to fill a hole with, or ROOM, if no liquid nearby */ |
| 605 | schar |
| 606 | fillholetyp(coordxy x, coordxy y, |
| 607 | boolean fill_if_any) /* force filling if it exists at all */ |
| 608 | { |
| 609 | coordxy x1, y1; |
| 610 | coordxy lo_x = max(1, x - 1), hi_x = min(x + 1, COLNO - 1), |
| 611 | lo_y = max(0, y - 1), hi_y = min(y + 1, ROWNO - 1); |
| 612 | int pool_cnt = 0, moat_cnt = 0, lava_cnt = 0; |
| 613 | |
| 614 | for (x1 = lo_x; x1 <= hi_x; x1++) |
| 615 | for (y1 = lo_y; y1 <= hi_y; y1++) |
| 616 | if (is_moat(x1, y1)) |
| 617 | moat_cnt++; |
| 618 | else if (is_pool(x1, y1)) |
| 619 | /* This must come after is_moat since moats are pools |
| 620 | * but not vice-versa. */ |
| 621 | pool_cnt++; |
| 622 | else if (is_lava(x1, y1)) |
| 623 | lava_cnt++; |
| 624 | |
| 625 | if (!fill_if_any) |
| 626 | pool_cnt /= 3; /* not as much liquid as the others */ |
| 627 | |
| 628 | if ((lava_cnt > moat_cnt + pool_cnt && rn2(lava_cnt + 1)) |
| 629 | || (lava_cnt && fill_if_any)) |
| 630 | return LAVAPOOL; |
| 631 | else if ((moat_cnt > 0 && rn2(moat_cnt + 1)) || (moat_cnt && fill_if_any)) |
| 632 | return MOAT; |
| 633 | else if ((pool_cnt > 0 && rn2(pool_cnt + 1)) || (pool_cnt && fill_if_any)) |
| 634 | return POOL; |
| 635 | else |
| 636 | return ROOM; |
| 637 | } |
| 638 | |
| 639 | void |
| 640 | digactualhole(coordxy x, coordxy y, struct monst *madeby, int ttyp) |
no test coverage detected