| 670 | } |
| 671 | |
| 672 | RESTORE_WARNING_FORMAT_NONLITERAL |
| 673 | |
| 674 | /* the #force command - try to force a chest with your weapon */ |
| 675 | int |
| 676 | doforce(void) |
| 677 | { |
| 678 | struct obj *otmp; |
| 679 | int c, picktyp; |
| 680 | char qbuf[QBUFSZ]; |
| 681 | |
| 682 | /* |
| 683 | * TODO? |
| 684 | * allow force with edged weapon to be performed on doors. |
| 685 | */ |
| 686 | |
| 687 | if (u.uswallow) { |
| 688 | You_cant("force anything from inside here."); |
| 689 | return ECMD_OK; |
| 690 | } |
| 691 | if (!u_have_forceable_weapon()) { |
| 692 | boolean use_plural = uwep && uwep->quan > 1; |
| 693 | |
| 694 | You_cant("force anything %s weapon%s.", |
| 695 | !uwep ? "when not wielding a" |
| 696 | : (uwep->oclass != WEAPON_CLASS && !is_weptool(uwep)) |
| 697 | ? (use_plural ? "without proper" : "without a proper") |
| 698 | : (use_plural ? "with those" : "with that"), |
| 699 | use_plural ? "s" : ""); |
| 700 | return ECMD_OK; |
| 701 | } |
| 702 | if (!can_reach_floor(TRUE)) { |
| 703 | cant_reach_floor(u.ux, u.uy, FALSE, TRUE, FALSE); |
| 704 | return ECMD_OK; |
| 705 | } |
| 706 | |
| 707 | picktyp = is_blade(uwep) && !is_pick(uwep); |
| 708 | if (gx.xlock.usedtime && gx.xlock.box && picktyp == gx.xlock.picktyp) { |
| 709 | You("resume your attempt to force the lock."); |
| 710 | set_occupation(forcelock, "forcing the lock", 0); |
| 711 | return ECMD_TIME; |
| 712 | } |
| 713 | |
| 714 | /* A lock is made only for the honest man, the thief will break it. */ |
| 715 | gx.xlock.box = (struct obj *) 0; |
| 716 | for (otmp = svl.level.objects[u.ux][u.uy]; otmp; otmp = otmp->nexthere) |
| 717 | if (Is_box(otmp)) { |
| 718 | if (otmp->obroken || !otmp->olocked) { |
| 719 | /* force doname() to omit known "broken" or "unlocked" |
| 720 | prefix so that the message isn't worded redundantly; |
| 721 | since we're about to set lknown, there's no need to |
| 722 | remember and then reset its current value */ |
| 723 | otmp->lknown = 0; |
| 724 | There("is %s here, but its lock is already %s.", |
| 725 | doname(otmp), otmp->obroken ? "broken" : "unlocked"); |
| 726 | otmp->lknown = 1; |
| 727 | continue; |
| 728 | } |
| 729 | (void) safe_qbuf(qbuf, "There is ", " here; force its lock?", |
nothing calls this directly
no test coverage detected