the #pay command */
| 1740 | |
| 1741 | /* the #pay command */ |
| 1742 | int |
| 1743 | dopay(void) |
| 1744 | { |
| 1745 | struct eshk *eshkp; |
| 1746 | struct monst *shkp; |
| 1747 | struct monst *nxtm, *resident; |
| 1748 | Bill *ibill = (Bill *) NULL; |
| 1749 | long ltmp; |
| 1750 | long umoney; |
| 1751 | int sk = 0, seensk = 0, nexttosk = 0; |
| 1752 | boolean paid = FALSE, stashed_gold = (hidden_gold(TRUE) > 0L), |
| 1753 | pay_done; |
| 1754 | |
| 1755 | gm.multi = 0; |
| 1756 | |
| 1757 | /* Find how many shk's there are, how many are in |
| 1758 | * sight, and are you in a shop room with one. |
| 1759 | */ |
| 1760 | nxtm = resident = 0; |
| 1761 | for (shkp = next_shkp(fmon, FALSE); shkp; |
| 1762 | shkp = next_shkp(shkp->nmon, FALSE)) { |
| 1763 | sk++; |
| 1764 | if (m_next2u(shkp)) { |
| 1765 | /* next to an irate shopkeeper? prioritize that */ |
| 1766 | if (nxtm && ANGRY(nxtm)) |
| 1767 | continue; |
| 1768 | nexttosk++; |
| 1769 | nxtm = shkp; |
| 1770 | } |
| 1771 | if (canspotmon(shkp)) |
| 1772 | seensk++; |
| 1773 | if (inhishop(shkp) && (*u.ushops == ESHK(shkp)->shoproom)) |
| 1774 | resident = shkp; |
| 1775 | } |
| 1776 | |
| 1777 | if (nxtm && nexttosk == 1) { |
| 1778 | shkp = nxtm; |
| 1779 | goto proceed; |
| 1780 | } |
| 1781 | |
| 1782 | if ((!sk && (!Blind || Blind_telepat)) || (!Blind && !seensk)) { |
| 1783 | There("appears to be no shopkeeper here to receive your payment."); |
| 1784 | return ECMD_OK; |
| 1785 | } |
| 1786 | |
| 1787 | if (!seensk) { |
| 1788 | You_cant("see..."); |
| 1789 | return ECMD_OK; |
| 1790 | } |
| 1791 | |
| 1792 | /* The usual case. Allow paying at a distance when |
| 1793 | * inside a tended shop. Should we change that? |
| 1794 | */ |
| 1795 | if (sk == 1 && resident) { |
| 1796 | shkp = resident; |
| 1797 | goto proceed; |
| 1798 | } |
| 1799 |
no test coverage detected