| 2085 | } |
| 2086 | |
| 2087 | staticfn int |
| 2088 | do_loot_cont( |
| 2089 | struct obj **cobjp, |
| 2090 | int cindex, /* index of this container (1..N)... */ |
| 2091 | int ccount) /* ...number of them (N) */ |
| 2092 | { |
| 2093 | struct obj *cobj = *cobjp; |
| 2094 | |
| 2095 | if (!cobj) |
| 2096 | return ECMD_OK; |
| 2097 | if (cobj->olocked) { |
| 2098 | int res = ECMD_OK; |
| 2099 | |
| 2100 | #if 0 |
| 2101 | if (ccount < 2 && (svl.level.objects[cobj->ox][cobj->oy] == cobj)) |
| 2102 | pline("%s locked.", |
| 2103 | cobj->lknown ? "It is" : "Hmmm, it turns out to be"); |
| 2104 | else |
| 2105 | #endif |
| 2106 | if (cobj->lknown) |
| 2107 | pline("%s is locked.", The(xname(cobj))); |
| 2108 | else |
| 2109 | pline("Hmmm, %s turns out to be locked.", the(xname(cobj))); |
| 2110 | cobj->lknown = 1; |
| 2111 | |
| 2112 | if (flags.autounlock) { |
| 2113 | struct obj *otmp, *unlocktool = 0; |
| 2114 | coordxy ox = cobj->ox, oy = cobj->oy; |
| 2115 | |
| 2116 | u.dz = 0; /* might be non-zero from previous command since |
| 2117 | * #loot isn't a move command; pick_lock() cares */ |
| 2118 | /* if both the untrap and apply_key bits are set, untrap |
| 2119 | attempt will be performed first but we need to set up |
| 2120 | unlocktool in case "check for trap?" is declined */ |
| 2121 | if (((flags.autounlock & AUTOUNLOCK_APPLY_KEY) != 0 |
| 2122 | && (unlocktool = autokey(TRUE)) != 0) |
| 2123 | || (flags.autounlock & AUTOUNLOCK_UNTRAP) != 0) { |
| 2124 | /* pass ox and oy to avoid direction prompt */ |
| 2125 | if (pick_lock(unlocktool, ox, oy, cobj)) |
| 2126 | res = ECMD_TIME; |
| 2127 | /* attempting to untrap or unlock might trigger a trap |
| 2128 | which destroys 'cobj'; inform caller if that happens */ |
| 2129 | for (otmp = svl.level.objects[ox][oy]; otmp; |
| 2130 | otmp = otmp->nexthere) |
| 2131 | if (otmp == cobj) |
| 2132 | break; |
| 2133 | if (!otmp) |
| 2134 | *cobjp = (struct obj *) 0; |
| 2135 | return res; |
| 2136 | } |
| 2137 | if ((flags.autounlock & AUTOUNLOCK_FORCE) != 0 |
| 2138 | && res != ECMD_TIME |
| 2139 | && ccount == 1 && u_have_forceable_weapon()) { |
| 2140 | /* single container, and we could #force it open... */ |
| 2141 | /* note: doforce asks for confirmation */ |
| 2142 | cmdq_add_ec(CQ_CANNED, doforce); |
| 2143 | ga.abort_looting = TRUE; |
| 2144 | } |
no test coverage detected