| 1744 | } |
| 1745 | |
| 1746 | int InvPutItem(int pnum, int x, int y) |
| 1747 | { |
| 1748 | BOOL done; |
| 1749 | int d, ii; |
| 1750 | int i, j, l; |
| 1751 | int xx, yy; |
| 1752 | int xp, yp; |
| 1753 | |
| 1754 | if (numitems >= 127) |
| 1755 | return -1; |
| 1756 | |
| 1757 | if (FindGetItem(plr[pnum].HoldItem.IDidx, plr[pnum].HoldItem._iCreateInfo, plr[pnum].HoldItem._iSeed) != -1) { |
| 1758 | DrawInvMsg("A duplicate item has been detected. Destroying duplicate..."); |
| 1759 | SyncGetItem(x, y, plr[pnum].HoldItem.IDidx, plr[pnum].HoldItem._iCreateInfo, plr[pnum].HoldItem._iSeed); |
| 1760 | } |
| 1761 | |
| 1762 | d = GetDirection(plr[pnum].WorldX, plr[pnum].WorldY, x, y); |
| 1763 | xx = x - plr[pnum].WorldX; |
| 1764 | yy = y - plr[pnum].WorldY; |
| 1765 | if (abs(xx) > 1 || abs(yy) > 1) { |
| 1766 | x = plr[pnum].WorldX + offset_x[d]; |
| 1767 | y = plr[pnum].WorldY + offset_y[d]; |
| 1768 | } |
| 1769 | if (!CanPut(x, y)) { |
| 1770 | d = (d - 1) & 7; |
| 1771 | x = plr[pnum].WorldX + offset_x[d]; |
| 1772 | y = plr[pnum].WorldY + offset_y[d]; |
| 1773 | if (!CanPut(x, y)) { |
| 1774 | d = (d + 2) & 7; |
| 1775 | x = plr[pnum].WorldX + offset_x[d]; |
| 1776 | y = plr[pnum].WorldY + offset_y[d]; |
| 1777 | if (!CanPut(x, y)) { |
| 1778 | done = FALSE; |
| 1779 | for (l = 1; l < 50 && !done; l++) { |
| 1780 | for (j = -l; j <= l && !done; j++) { |
| 1781 | yp = j + plr[pnum].WorldY; |
| 1782 | for (i = -l; i <= l && !done; i++) { |
| 1783 | xp = i + plr[pnum].WorldX; |
| 1784 | if (CanPut(xp, yp)) { |
| 1785 | done = TRUE; |
| 1786 | x = xp; |
| 1787 | y = yp; |
| 1788 | } |
| 1789 | } |
| 1790 | } |
| 1791 | } |
| 1792 | if (!done) |
| 1793 | return -1; |
| 1794 | } |
| 1795 | } |
| 1796 | } |
| 1797 | |
| 1798 | CanPut(x, y); //if (!CanPut(x, y)) { |
| 1799 | // assertion_failed(__LINE__, __FILE__, "CanPut(x,y)"); |
| 1800 | //} |
| 1801 | |
| 1802 | ii = itemavail[0]; |
| 1803 | dItem[x][y] = ii + 1; |
no test coverage detected