Browse Source

🐛 Fix uninitialized values for items generated in a loop

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

6
Source/items.cpp

@ -5328,13 +5328,14 @@ void CreateSpellBook(int x, int y, int ispell, BOOL sendmsg, BOOL delta)
return; return;
int ii = AllocateItem(); int ii = AllocateItem();
GetSuperItemSpace(x, y, ii);
while (true) { while (true) {
memset(&item[ii], 0, sizeof(*item));
SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta); SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta);
if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell) if (item[ii]._iMiscId == IMISC_BOOK && item[ii]._iSpell == ispell)
break; break;
} }
GetSuperItemSpace(x, y, ii);
if (sendmsg) if (sendmsg)
NetSendCmdDItem(FALSE, ii); NetSendCmdDItem(FALSE, ii);
@ -5348,16 +5349,17 @@ static void CreateMagicItem(int x, int y, int lvl, int imisc, int imid, int icur
return; return;
int ii = AllocateItem(); int ii = AllocateItem();
GetSuperItemSpace(x, y, ii);
int idx = RndTypeItems(imisc, imid, lvl); int idx = RndTypeItems(imisc, imid, lvl);
while (true) { while (true) {
memset(&item[ii], 0, sizeof(*item));
SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta); SetupAllItems(ii, idx, AdvanceRndSeed(), 2 * lvl, 1, TRUE, FALSE, delta);
if (item[ii]._iCurs == icurs) if (item[ii]._iCurs == icurs)
break; break;
idx = RndTypeItems(imisc, imid, lvl); idx = RndTypeItems(imisc, imid, lvl);
} }
GetSuperItemSpace(x, y, ii);
if (sendmsg) if (sendmsg)
NetSendCmdDItem(FALSE, ii); NetSendCmdDItem(FALSE, ii);

Loading…
Cancel
Save