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

Function RepairItem

Source/items.cpp:2543–2572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2541}
2542
2543void RepairItem(ItemStruct *i, int lvl)
2544{
2545 int rep, d;
2546
2547 if (i->_iDurability == i->_iMaxDur) {
2548 return;
2549 }
2550
2551 if (i->_iMaxDur <= 0) {
2552 i->_itype = ITYPE_NONE;
2553 return;
2554 }
2555
2556 rep = 0;
2557 do {
2558 rep += lvl + random_(37, lvl);
2559 d = i->_iMaxDur / (lvl + 9);
2560 if (d < 1)
2561 d = 1;
2562 i->_iMaxDur = i->_iMaxDur - d;
2563 if (!i->_iMaxDur) {
2564 i->_itype = ITYPE_NONE;
2565 return;
2566 }
2567 } while (rep + i->_iDurability < i->_iMaxDur);
2568
2569 i->_iDurability += rep;
2570 if (i->_iDurability > i->_iMaxDur)
2571 i->_iDurability = i->_iMaxDur;
2572}
2573
2574void DoRecharge(int pnum, int cii)
2575{

Callers 1

DoRepairFunction · 0.85

Calls 1

random_Function · 0.85

Tested by

no test coverage detected