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

Function CheckUnique

Source/items.cpp:1942–1977  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1940}
1941
1942int CheckUnique(int i, int lvl, int uper, BOOL recreate)
1943{
1944 int j, idata, numu;
1945 BOOLEAN uok[128];
1946
1947 if (random_(28, 100) > uper)
1948 return -1;
1949
1950 numu = 0;
1951 memset(uok, 0, sizeof(uok));
1952 for (j = 0; UniqueItemList[j].UIItemId != UITYPE_INVALID; j++) {
1953 if (UniqueItemList[j].UIItemId == AllItemsList[item[i].IDidx].iItemId
1954 && lvl >= UniqueItemList[j].UIMinLvl
1955 && (recreate || !UniqueItemFlag[j] || gbMaxPlayers != 1)) {
1956 uok[j] = TRUE;
1957 numu++;
1958 }
1959 }
1960
1961 if (!numu)
1962 return -1;
1963
1964 random_(29, 10);
1965 idata = 0;
1966 while (numu > 0) {
1967 if (uok[idata])
1968 numu--;
1969 if (numu > 0) {
1970 idata++;
1971 if (idata == 128)
1972 idata = 0;
1973 }
1974 }
1975
1976 return idata;
1977}
1978
1979void GetUniqueItem(int i, int uid)
1980{

Callers 1

SetupAllItemsFunction · 0.85

Calls 1

random_Function · 0.85

Tested by

no test coverage detected