| 1302 | } |
| 1303 | |
| 1304 | staticfn void |
| 1305 | drop_weapon(int alone) |
| 1306 | { |
| 1307 | struct obj *otmp; |
| 1308 | const char *what, *which, *whichtoo; |
| 1309 | boolean candropwep, candropswapwep, updateinv = TRUE; |
| 1310 | |
| 1311 | if (uwep) { |
| 1312 | /* !alone check below is currently superfluous but in the |
| 1313 | * future it might not be so if there are monsters which cannot |
| 1314 | * wear gloves but can wield weapons |
| 1315 | */ |
| 1316 | if (!alone || cantwield(gy.youmonst.data)) { |
| 1317 | candropwep = canletgo(uwep, ""); |
| 1318 | candropswapwep = !u.twoweap || canletgo(uswapwep, ""); |
| 1319 | if (alone) { |
| 1320 | what = (candropwep && candropswapwep) ? "drop" : "release"; |
| 1321 | which = is_sword(uwep) ? "sword" : weapon_descr(uwep); |
| 1322 | if (u.twoweap) { |
| 1323 | whichtoo = |
| 1324 | is_sword(uswapwep) ? "sword" : weapon_descr(uswapwep); |
| 1325 | if (strcmp(which, whichtoo)) |
| 1326 | which = "weapon"; |
| 1327 | } |
| 1328 | if (uwep->quan != 1L || u.twoweap) |
| 1329 | which = makeplural(which); |
| 1330 | |
| 1331 | You("find you must %s %s %s!", what, |
| 1332 | the_your[!!strncmp(which, "corpse", 6)], which); |
| 1333 | } |
| 1334 | /* if either uwep or wielded uswapwep is flagged as 'in_use' |
| 1335 | then don't drop it or explicitly update inventory; leave |
| 1336 | those actions to caller (or caller's caller, &c) */ |
| 1337 | if (u.twoweap) { |
| 1338 | otmp = uswapwep; |
| 1339 | uswapwepgone(); |
| 1340 | if (otmp->in_use) |
| 1341 | updateinv = FALSE; |
| 1342 | else if (candropswapwep) |
| 1343 | dropx(otmp); |
| 1344 | } |
| 1345 | otmp = uwep; |
| 1346 | uwepgone(); |
| 1347 | if (otmp->in_use) |
| 1348 | updateinv = FALSE; |
| 1349 | else if (candropwep) |
| 1350 | dropx(otmp); |
| 1351 | /* [note: dropp vs dropx -- if heart of ahriman is wielded, we |
| 1352 | might be losing levitation by dropping it; but that won't |
| 1353 | happen until the drop, unlike Boots_off() dumping hero into |
| 1354 | water and triggering emergency_disrobe() before dropx()] */ |
| 1355 | |
| 1356 | if (updateinv) |
| 1357 | update_inventory(); |
| 1358 | } else if (!could_twoweap(gy.youmonst.data)) { |
| 1359 | untwoweapon(); |
| 1360 | } |
| 1361 | } |
no test coverage detected