MCPcopy Create free account
hub / github.com/diasurgical/devilution / StoreGoldFit

Function StoreGoldFit

Source/stores.cpp:1959–1994  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1957}
1958
1959BOOL StoreGoldFit(int idx)
1960{
1961 int i, sz, cost, numsqrs;
1962
1963 cost = storehold[idx]._iIvalue;
1964 sz = cost / GOLD_MAX_LIMIT;
1965 if (cost % GOLD_MAX_LIMIT)
1966 sz++;
1967
1968 SetCursor_(storehold[idx]._iCurs + CURSOR_FIRSTITEM);
1969 numsqrs = cursW / 28 * (cursH / 28);
1970 SetCursor_(CURSOR_HAND);
1971
1972 if (numsqrs >= sz)
1973 return TRUE;
1974
1975 for (i = 0; i < 40; i++) {
1976 if (!plr[myplr].InvGrid[i])
1977 numsqrs++;
1978 }
1979
1980 for (i = 0; i < plr[myplr]._pNumInv; i++) {
1981 if (plr[myplr].InvList[i]._itype == ITYPE_GOLD && plr[myplr].InvList[i]._ivalue != GOLD_MAX_LIMIT) {
1982 if (cost + plr[myplr].InvList[i]._ivalue <= GOLD_MAX_LIMIT)
1983 cost = 0;
1984 else
1985 cost -= GOLD_MAX_LIMIT - plr[myplr].InvList[i]._ivalue;
1986 }
1987 }
1988
1989 sz = cost / GOLD_MAX_LIMIT;
1990 if (cost % GOLD_MAX_LIMIT)
1991 sz++;
1992
1993 return numsqrs >= sz;
1994}
1995
1996void PlaceStoreGold(int v)
1997{

Callers 2

S_SSellEnterFunction · 0.85
S_WSellEnterFunction · 0.85

Calls 1

SetCursor_Function · 0.85

Tested by

no test coverage detected