| 2705 | } |
| 2706 | |
| 2707 | staticfn int |
| 2708 | count_surround_traps(coordxy x, coordxy y) |
| 2709 | { |
| 2710 | struct rm *levp; |
| 2711 | struct obj *o; |
| 2712 | coordxy dx, dy; |
| 2713 | int glyph, ret = 0; |
| 2714 | |
| 2715 | for (dx = x - 1; dx < x + 2; ++dx) |
| 2716 | for (dy = y - 1; dy < y + 2; ++dy) { |
| 2717 | if (!isok(dx, dy)) |
| 2718 | continue; |
| 2719 | /* If a trap is shown here, don't count it; the hero |
| 2720 | * should be expecting it. But if there is a trap here |
| 2721 | * that's not shown, either undiscovered or covered by |
| 2722 | * something, do count it. |
| 2723 | */ |
| 2724 | glyph = glyph_at(dx, dy); |
| 2725 | if (glyph_is_trap(glyph)) |
| 2726 | continue; |
| 2727 | if (t_at(dx, dy)) { |
| 2728 | ++ret; |
| 2729 | continue; |
| 2730 | } |
| 2731 | levp = &levl[dx][dy]; |
| 2732 | if (IS_DOOR(levp->typ) && (levp->doormask & D_TRAPPED) != 0) { |
| 2733 | ++ret; |
| 2734 | continue; |
| 2735 | } |
| 2736 | for (o = svl.level.objects[dx][dy]; o; o = o->nexthere) |
| 2737 | if (Is_container(o) && o->otrapped) { |
| 2738 | ++ret; /* we're counting locations, so just */ |
| 2739 | break; /* count the first one in a pile */ |
| 2740 | } |
| 2741 | } |
| 2742 | /* |
| 2743 | * [Shouldn't we also check inventory for a trapped container? |
| 2744 | * Even if its trap has already been found, there's no 'tknown' |
| 2745 | * flag to help hero remember that so we have nothing comparable |
| 2746 | * to a shown glyph to justify skipping it.] |
| 2747 | */ |
| 2748 | return ret; |
| 2749 | } |
| 2750 | |
| 2751 | /* sense adjacent traps if wielding MKoT without wearing gloves */ |
| 2752 | void |
no test coverage detected