"Quaffing is like drinking, except you spill more." - Terry Pratchett */ the #quaff command */
| 523 | /* "Quaffing is like drinking, except you spill more." - Terry Pratchett */ |
| 524 | /* the #quaff command */ |
| 525 | int |
| 526 | dodrink(void) |
| 527 | { |
| 528 | struct obj *otmp; |
| 529 | |
| 530 | if (Strangled) { |
| 531 | pline("If you can't breathe air, how can you drink liquid?"); |
| 532 | return ECMD_OK; |
| 533 | } |
| 534 | |
| 535 | drink_ok_extra = 0; |
| 536 | /* preceding 'q'/#quaff with 'm' skips the possibility of drinking |
| 537 | from fountains, sinks, and surrounding water plus the prompting |
| 538 | which those entail; optional for interactive use, essential for |
| 539 | context-sensitive inventory item action 'quaff' */ |
| 540 | if (!iflags.menu_requested) { |
| 541 | /* Is there a fountain to drink from here? */ |
| 542 | if (IS_FOUNTAIN(levl[u.ux][u.uy].typ) |
| 543 | /* not as low as floor level but similar restrictions apply */ |
| 544 | && can_reach_floor(FALSE)) { |
| 545 | if (y_n("Drink from the fountain?") == 'y') { |
| 546 | drinkfountain(); |
| 547 | return ECMD_TIME; |
| 548 | } |
| 549 | ++drink_ok_extra; |
| 550 | } |
| 551 | /* Or a kitchen sink? */ |
| 552 | if (IS_SINK(levl[u.ux][u.uy].typ) |
| 553 | /* not as low as floor level but similar restrictions apply */ |
| 554 | && can_reach_floor(FALSE)) { |
| 555 | if (y_n("Drink from the sink?") == 'y') { |
| 556 | drinksink(); |
| 557 | return ECMD_TIME; |
| 558 | } |
| 559 | ++drink_ok_extra; |
| 560 | } |
| 561 | /* Or are you surrounded by water? */ |
| 562 | if (Underwater && !u.uswallow) { |
| 563 | if (y_n("Drink the water around you?") == 'y') { |
| 564 | pline("Do you know what lives in this water?"); |
| 565 | return ECMD_TIME; |
| 566 | } |
| 567 | ++drink_ok_extra; |
| 568 | } |
| 569 | } |
| 570 | |
| 571 | otmp = getobj("drink", drink_ok, GETOBJ_NOFLAGS); |
| 572 | if (!otmp) |
| 573 | return ECMD_CANCEL; |
| 574 | |
| 575 | /* |
| 576 | * 3.6: quan > 1 used to be left to useup(), but we need to |
| 577 | * force the current potion to be unworn, and don't want to do |
| 578 | * that for the entire stack when starting with more than 1. |
| 579 | * [Drinking a wielded potion of polymorph can trigger a shape |
| 580 | * change which causes hero's weapon to be dropped. In 3.4.x, |
| 581 | * that led to an "object lost" panic since subsequent useup() |
| 582 | * was no longer dealing with an inventory item. Unwearing |
nothing calls this directly
no test coverage detected