Browse Source

Clean up CheckInvHLight

pull/88/head
Anders Jenbo 7 years ago
parent
commit
190106c8c5
  1. 181
      Source/inv.cpp
  2. 4
      Source/inv.h

181
Source/inv.cpp

@ -518,7 +518,7 @@ BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag)
return done;
}
BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag)
BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag)
{
int i, j, xx, yy;
BOOL done;
@ -2065,123 +2065,94 @@ int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, in
return ii;
}
int CheckInvHLight()
char CheckInvHLight()
{
signed int v0; // ebx
int result; // eax
ItemStruct *v2; // edi
PlayerStruct *v3; // esi
int v4; // eax
int v5; // ebx
int v6; // edi
char *v7; // eax
char v9; // [esp+Fh] [ebp-1h]
v0 = 0;
do {
result = InvRect[v0].X;
if (MouseX >= result) {
result += 29;
if (MouseX < result) {
result = InvRect[v0].Y;
if (MouseY >= result - 29 && MouseY < result)
break;
}
int r, ii, nGold;
ItemStruct *pi;
PlayerStruct *p;
char rv;
for (r = 0; (DWORD)r < 73; r++) {
if (MouseX >= InvRect[r].X
&& MouseX < InvRect[r].X + 29
&& MouseY >= InvRect[r].Y - 29
&& MouseY < InvRect[r].Y) {
break;
}
++v0;
} while ((unsigned int)v0 < 0x49);
if ((unsigned int)v0 >= 0x49)
goto LABEL_37;
v9 = -1;
}
if ((DWORD)r >= 73)
return -1;
rv = -1;
infoclr = COL_WHITE;
v2 = 0;
v3 = &plr[myplr];
pi = NULL;
p = &plr[myplr];
ClearPanel();
if (v0 >= 0 && v0 <= 3) {
v9 = 0;
v2 = v3->InvBody;
goto LABEL_36;
}
switch (v0) {
case 4:
v9 = 1;
v2 = &v3->InvBody[INVLOC_RING_LEFT];
goto LABEL_36;
case 5:
v9 = 2;
v2 = &v3->InvBody[INVLOC_RING_RIGHT];
goto LABEL_36;
case 6:
v9 = 3;
v2 = &v3->InvBody[INVLOC_AMULET];
goto LABEL_36;
}
if (v0 >= 7 && v0 <= 12) {
v9 = 4;
v2 = &v3->InvBody[INVLOC_HAND_LEFT];
goto LABEL_36;
}
if (v0 < 13 || v0 > 18) {
if (v0 >= 19 && v0 <= 24) {
v9 = 6;
v2 = &v3->InvBody[INVLOC_CHEST];
goto LABEL_36;
}
if (v0 < 25 || v0 > 64) {
if (v0 < 65)
goto LABEL_36;
v5 = v0 - 65;
drawsbarflag = TRUE;
result = 368 * v5;
v2 = &v3->SpdList[v5];
if (v3->SpdList[v5]._itype != ITYPE_NONE) {
v9 = v5 + 47;
goto LABEL_36;
}
if (r >= 0 && r <= 3) {
rv = INVLOC_HEAD;
pi = &p->InvBody[rv];
} else if (r == 4) {
rv = INVLOC_RING_LEFT;
pi = &p->InvBody[rv];
} else if (r == 5) {
rv = INVLOC_RING_RIGHT;
pi = &p->InvBody[rv];
} else if (r == 6) {
rv = INVLOC_AMULET;
pi = &p->InvBody[rv];
} else if (r >= 7 && r <= 12) {
rv = INVLOC_HAND_LEFT;
pi = &p->InvBody[rv];
} else if (r >= 13 && r <= 18) {
pi = &p->InvBody[INVLOC_HAND_LEFT];
if (pi->_itype == ITYPE_NONE || pi->_iLoc != ILOC_TWOHAND) {
rv = INVLOC_HAND_RIGHT;
pi = &p->InvBody[rv];
} else {
result = abs(v3->InvGrid[v0 - 25]); // abs(*((char *)&v3->InvList[39]._iVAdd2 + v0 + 3)); /* find right address */
if (result) {
v4 = result - 1;
v9 = v4 + 7;
v2 = &v3->InvList[v4];
goto LABEL_36;
}
}
LABEL_37:
_LOBYTE(result) = -1;
return result;
rv = INVLOC_HAND_LEFT;
}
} else if (r >= 19 && r <= 24) {
rv = INVLOC_CHEST;
pi = &p->InvBody[rv];
} else if (r >= 25 && r <= 64) {
r = abs(p->InvGrid[r - 25]);
if (!r)
return -1;
ii = r - 1;
rv = ii + 7;
pi = &p->InvList[ii];
} else if (r >= 65) {
r -= 65;
drawsbarflag = TRUE;
pi = &p->SpdList[r];
if (pi->_itype == ITYPE_NONE)
return -1;
rv = r + 47;
}
v2 = &v3->InvBody[INVLOC_HAND_LEFT];
if (v3->InvBody[INVLOC_HAND_LEFT]._itype == ITYPE_NONE || v3->InvBody[INVLOC_HAND_LEFT]._iLoc != 2) {
v9 = 5;
v2 = &v3->InvBody[INVLOC_HAND_RIGHT];
} else {
v9 = 4;
}
LABEL_36:
result = v2->_itype;
if (result == ITYPE_NONE)
goto LABEL_37;
if (result == ITYPE_GOLD) {
v6 = v2->_ivalue;
v7 = get_pieces_str(v6);
result = sprintf(infostr, "%i gold %s", v6, v7);
if (pi->_itype == ITYPE_NONE)
return -1;
if (pi->_itype == ITYPE_GOLD) {
nGold = pi->_ivalue;
sprintf(infostr, "%i gold %s", nGold, get_pieces_str(nGold));
} else {
if (v2->_iMagical == ITEM_QUALITY_MAGIC) {
if (pi->_iMagical == ITEM_QUALITY_MAGIC) {
infoclr = COL_BLUE;
} else if (v2->_iMagical == ITEM_QUALITY_UNIQUE) {
} else if (pi->_iMagical == ITEM_QUALITY_UNIQUE) {
infoclr = COL_GOLD;
}
strcpy(infostr, v2->_iName);
if (v2->_iIdentified) {
strcpy(infostr, v2->_iIName);
PrintItemDetails(v2);
strcpy(infostr, pi->_iName);
if (pi->_iIdentified) {
strcpy(infostr, pi->_iIName);
PrintItemDetails(pi);
} else {
PrintItemDur(v2);
PrintItemDur(pi);
}
}
_LOBYTE(result) = v9;
return result;
return rv;
}
// 4B883C: using guessed type int infoclr;

4
Source/inv.h

@ -11,7 +11,7 @@ void InvDrawSlotBack(int X, int Y, int W, int H);
void DrawInv();
void DrawInvBelt();
BOOL AutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag);
BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, int saveflag);
BOOL SpecialAutoPlace(int pnum, int ii, int sx, int sy, BOOL saveflag);
BOOL GoldAutoPlace(int pnum);
int WeaponAutoPlace(int pnum);
int SwapItem(ItemStruct *a, ItemStruct *b);
@ -35,7 +35,7 @@ BOOL TryInvPut();
void DrawInvMsg(char *msg);
int InvPutItem(int pnum, int x, int y);
int SyncPutItem(int pnum, int x, int y, int idx, WORD icreateinfo, int iseed, int Id, int dur, int mdur, int ch, int mch, int ivalue, unsigned int ibuff);
int CheckInvHLight();
char CheckInvHLight();
void RemoveScroll(int pnum);
BOOL UseScroll();
void UseStaffCharge(int pnum);

Loading…
Cancel
Save