Browse Source

🐛 Fix uninitialized values for items generated in a loop

Fixes #1121
xad
Anders Jenbo 5 years ago
parent
commit
2e3bb9206d
  1. 8
      Source/items.cpp

8
Source/items.cpp

@ -1765,7 +1765,7 @@ void GetStaffSpell(int i, int lvl, BOOL onlygood)
lvl = 10;
int s = SPL_FIREBOLT;
enum spell_id bs = SPL_NULL;
enum spell_id bs = SPL_NULL;
while (rv > 0) {
int sLevel = GetSpellStaffLevel(s);
if (sLevel != -1 && l >= sLevel) {
@ -5328,13 +5328,14 @@ void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta)
return;
int ii = AllocateItem();
GetSuperItemSpace(x, y, ii);
while (true) {
memset(&item[ii], 0, sizeof(*item));
SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta);
if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell)
break;
}
GetSuperItemSpace(x, y, ii);
if (sendmsg)
NetSendCmdDItem(FALSE, ii);
@ -5348,16 +5349,17 @@ static void CreateMagicItem(int x, int y, int lvl, int imisc, int imid, int icur
return;
int ii = AllocateItem();
GetSuperItemSpace(x, y, ii);
int idx = RndTypeItems(imisc, imid, lvl);
while (true) {
memset(&item[ii], 0, sizeof(*item));
SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta);
if (item[ii]._iCurs == icurs)
break;
idx = RndTypeItems(imisc, imid, lvl);
}
GetSuperItemSpace(x, y, ii);
if (sendmsg)
NetSendCmdDItem(FALSE, ii);

Loading…
Cancel
Save