for magic unlocking; returns true if targeted monster (which might be hero) gets untrapped; the trap remains intact */
| 6098 | /* for magic unlocking; returns true if targeted monster (which might |
| 6099 | be hero) gets untrapped; the trap remains intact */ |
| 6100 | boolean |
| 6101 | openholdingtrap( |
| 6102 | struct monst *mon, |
| 6103 | boolean *noticed) /* set to true iff hero notices the effect; |
| 6104 | * otherwise left with its previous value intact */ |
| 6105 | { |
| 6106 | struct trap *t, tdummy; |
| 6107 | char buf[BUFSZ], whichbuf[20]; |
| 6108 | const char *trapdescr = 0, *which = 0; |
| 6109 | boolean ishero = (mon == &gy.youmonst); |
| 6110 | |
| 6111 | if (!mon) |
| 6112 | return FALSE; |
| 6113 | if (mon == u.usteed) |
| 6114 | ishero = TRUE; |
| 6115 | |
| 6116 | t = t_at(ishero ? u.ux : mon->mx, ishero ? u.uy : mon->my); |
| 6117 | |
| 6118 | if (ishero && u.utrap) { /* all u.utraptype values are holding traps */ |
| 6119 | /* there might not be any trap at hero's spot for tt_buriedball; |
| 6120 | conversely, there might be an unrelated trap at that spot */ |
| 6121 | if (!t) { |
| 6122 | t = &tdummy; |
| 6123 | (void) memset(t, 0, sizeof *t), t->ntrap = NULL; |
| 6124 | /* fallback 't' is now nonNull, t->tseen and t->madeby_u are 0 */ |
| 6125 | } |
| 6126 | which = the_your[(!t || !t->tseen || !t->madeby_u) ? 0 : 1]; |
| 6127 | |
| 6128 | switch (u.utraptype) { |
| 6129 | case TT_LAVA: |
| 6130 | trapdescr = "molten lava"; |
| 6131 | break; |
| 6132 | case TT_INFLOOR: |
| 6133 | /* solidified lava, so not "floor" even if within a room */ |
| 6134 | trapdescr = "ground"; |
| 6135 | break; |
| 6136 | case TT_BURIEDBALL: |
| 6137 | trapdescr = "your anchor"; |
| 6138 | which = ""; |
| 6139 | break; |
| 6140 | case TT_BEARTRAP: |
| 6141 | case TT_PIT: |
| 6142 | case TT_WEB: |
| 6143 | trapdescr = defsyms[(u.utraptype == TT_WEB) ? S_web |
| 6144 | : (u.utraptype == TT_PIT) ? S_pit |
| 6145 | : S_bear_trap].explanation; |
| 6146 | break; |
| 6147 | default: |
| 6148 | /* lint suppression in case 't' is unexpectedly Null |
| 6149 | or u.utraptype has new value we don't know about yet */ |
| 6150 | trapdescr = "trap"; |
| 6151 | break; |
| 6152 | } |
| 6153 | } else { |
| 6154 | /* if no trap here or it's not a holding trap, we're done */ |
| 6155 | if (!t || (t->ttyp != BEAR_TRAP && t->ttyp != WEB)) |
| 6156 | return FALSE; |
| 6157 | trapdescr = trapname(t->ttyp, FALSE); |
no test coverage detected