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; lvl = 10;
int s = SPL_FIREBOLT; int s = SPL_FIREBOLT;
enum spell_id bs = SPL_NULL; enum spell_id bs = SPL_NULL;
while (rv > 0) { while (rv > 0) {
int sLevel = GetSpellStaffLevel(s); int sLevel = GetSpellStaffLevel(s);
if (sLevel != -1 && l >= sLevel) { if (sLevel != -1 && l >= sLevel) {
@ -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