Browse Source

items.cpp - SpawnQuestItem bin exact (#797)

pull/78/head
qndel 7 years ago committed by Anders Jenbo
parent
commit
ea8167582e
  1. 62
      Source/items.cpp

62
Source/items.cpp

@ -3022,58 +3022,42 @@ void __fastcall RecreateEar(int ii, unsigned short ic, int iseed, int Id, int du
void __fastcall SpawnQuestItem(int itemid, int x, int y, int randarea, int selflag)
{
int i; // ebx
BOOL failed; // eax
int j; // esi
int v12; // ebx
int v13; // esi
int tries; // [esp+10h] [ebp-4h]
BOOL failed;
int i, j, tries;
if (randarea) {
tries = 0;
while (1) {
LABEL_3:
if (++tries > 1000 && randarea > 1)
--randarea;
tries++;
if (tries > 1000 && randarea > 1)
randarea--;
x = random(0, MAXDUNX);
y = random(0, MAXDUNY);
i = 0;
failed = 0;
if (randarea <= 0)
break;
while (!failed) {
for (j = 0; j < randarea; j++) {
if (failed)
break;
failed = ItemSpaceOk(i + x, j + y) == 0;
}
if (++i >= randarea) {
if (failed)
goto LABEL_3;
goto LABEL_13;
failed = FALSE;
for (i = 0; i < randarea && !failed; i++) {
for (j = 0; j < randarea && !failed; j++) {
failed = !ItemSpaceOk(i + x, j + y);
}
}
if (!failed)
break;
}
}
LABEL_13:
if (numitems < MAXITEMS) {
v12 = itemavail[0];
v13 = itemavail[0];
item[v13]._ix = x;
itemactive[numitems] = v12;
item[v13]._iy = y;
i = itemavail[0];
itemavail[0] = itemavail[MAXITEMS - numitems - 1];
dItem[x][y] = v12 + 1;
GetItemAttrs(v12, itemid, currlevel);
SetupItem(v12);
item[v13]._iPostDraw = TRUE;
itemactive[numitems] = i;
item[i]._ix = x;
item[i]._iy = y;
dItem[x][y] = i + 1;
GetItemAttrs(i, itemid, currlevel);
SetupItem(i);
item[i]._iPostDraw = TRUE;
if (selflag) {
item[v13]._iAnimFlag = FALSE;
item[v13]._iSelFlag = selflag;
item[v13]._iAnimFrame = item[v13]._iAnimLen;
item[i]._iAnimFlag = FALSE;
item[i]._iSelFlag = selflag;
item[i]._iAnimFrame = item[i]._iAnimLen;
}
++numitems;
}

Loading…
Cancel
Save