| 2017 | } |
| 2018 | |
| 2019 | void StoreSellItem() |
| 2020 | { |
| 2021 | int i, idx, cost; |
| 2022 | |
| 2023 | idx = stextvhold + ((stextlhold - stextup) >> 2); |
| 2024 | if (storehidx[idx] >= 0) |
| 2025 | RemoveInvItem(myplr, storehidx[idx]); |
| 2026 | else |
| 2027 | RemoveSpdBarItem(myplr, -(storehidx[idx] + 1)); |
| 2028 | cost = storehold[idx]._iIvalue; |
| 2029 | storenumh--; |
| 2030 | if (idx != storenumh) { |
| 2031 | while (idx < storenumh) { |
| 2032 | storehold[idx] = storehold[idx + 1]; |
| 2033 | storehidx[idx] = storehidx[idx + 1]; |
| 2034 | idx++; |
| 2035 | } |
| 2036 | } |
| 2037 | plr[myplr]._pGold += cost; |
| 2038 | for (i = 0; i < plr[myplr]._pNumInv && cost > 0; i++) { |
| 2039 | if (plr[myplr].InvList[i]._itype == ITYPE_GOLD && plr[myplr].InvList[i]._ivalue != GOLD_MAX_LIMIT) { |
| 2040 | if (cost + plr[myplr].InvList[i]._ivalue <= GOLD_MAX_LIMIT) { |
| 2041 | plr[myplr].InvList[i]._ivalue += cost; |
| 2042 | SetGoldCurs(myplr, i); |
| 2043 | cost = 0; |
| 2044 | } else { |
| 2045 | cost -= GOLD_MAX_LIMIT - plr[myplr].InvList[i]._ivalue; |
| 2046 | plr[myplr].InvList[i]._ivalue = GOLD_MAX_LIMIT; |
| 2047 | SetGoldCurs(myplr, i); |
| 2048 | } |
| 2049 | } |
| 2050 | } |
| 2051 | if (cost > 0) { |
| 2052 | while (cost > GOLD_MAX_LIMIT) { |
| 2053 | PlaceStoreGold(GOLD_MAX_LIMIT); |
| 2054 | cost -= GOLD_MAX_LIMIT; |
| 2055 | } |
| 2056 | PlaceStoreGold(cost); |
| 2057 | } |
| 2058 | } |
| 2059 | |
| 2060 | void S_SSellEnter() |
| 2061 | { |
no test coverage detected