Browse Source

`DrawInv` is now binary exact.

pull/4/head
Dennis Duda 8 years ago
parent
commit
e8b53791d3
  1. 2
      Source/cursor.cpp
  2. 2
      Source/engine.cpp
  3. 2
      Source/engine.h
  4. 537
      Source/inv.cpp
  5. 2
      Source/items.cpp
  6. 4
      defs.h
  7. 17
      enums.h
  8. 4
      structs.h

2
Source/cursor.cpp

@ -9,6 +9,8 @@ int pcursmonst; // idb
int icursW28; // idb
void *pCursCels;
int icursH; // weak
// inv_item value
char pcursinvitem; // weak
int icursW; // weak
char pcursitem; // weak

2
Source/engine.cpp

@ -1271,7 +1271,7 @@ LABEL_14:
}
}
void __fastcall CelDecodeClr(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction)
void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction)
{
char *v8; // ebx
int v9; // eax

2
Source/engine.h

@ -37,7 +37,7 @@ void __fastcall Cel2DecodeHdrLight(int screen_x, int screen_y, char *pCelBuff, i
void __fastcall Cel2DecodeLightTrans(char *dst_buf, char *pCelBuff, int frame, int frame_width, int a5, int direction);
void __fastcall Cel2DrawHdrLightRed(int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int always_0, int direction, char always_1);
void __fastcall CelDecodeRect(char *pBuff, int always_0, int dst_height, int dst_width, char *pCelBuff, int frame, int frame_width);
void __fastcall CelDecodeClr(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction);
void __fastcall CelDecodeClr(BYTE colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction);
void __fastcall CelDrawHdrClrHL(char colour, int screen_x, int screen_y, char *pCelBuff, int frame, int frame_width, int a7, int direction);
void __fastcall ENG_set_pixel(int screen_x, int screen_y, char pixel);
void __fastcall engine_draw_pixel(int x, int y);

537
Source/inv.cpp

@ -157,287 +157,304 @@ LABEL_9:
void __cdecl DrawInv()
{
int v0; // ecx
int v1; // eax
int v2; // esi
int v3; // ebp
char v4; // cl
int v5; // ecx
int v6; // eax
int v7; // edi
int v8; // edx
char v9; // cl
int v10; // ecx
int v11; // eax
int v12; // edi
int v13; // edx
char v14; // cl
int v15; // ecx
int v16; // eax
int v17; // esi
int v18; // edx
char v19; // cl
int v20; // ecx
int v21; // eax
int v22; // esi
int v23; // edi
int v24; // ebp
char v25; // cl
char *v26; // ecx
int v27; // ebp
int v28; // eax
int v29; // esi
int v30; // edi
char v31; // cl
int v32; // ecx
int v33; // eax
int v34; // esi
int v35; // edi
char v36; // cl
signed int v37; // esi
signed int v38; // edi
int v39; // ecx
char v40; // al
int v41; // eax
int v42; // ebp
int v43; // ecx
int v44; // esi
char v45; // al
int v46; // ecx
int v47; // edx
int screen_y; // [esp+10h] [ebp-A8h]
int screen_ya; // [esp+10h] [ebp-A8h]
int screen_yb; // [esp+10h] [ebp-A8h]
signed int screen_yc; // [esp+10h] [ebp-A8h]
signed int screen_yd; // [esp+10h] [ebp-A8h]
int screen_ye; // [esp+10h] [ebp-A8h]
signed int screen_x; // [esp+14h] [ebp-A4h]
int invtest[40]; // [esp+18h] [ebp-A0h]
BOOL invtest[40];
CelDecodeOnly(384, 511, pInvCels, 1, 320);
if ( plr[myplr].InvBody[0]._itype != -1 )
if ( plr[myplr].InvBody[INVLOC_HEAD]._itype != ITYPE_NONE )
{
InvDrawSlotBack(517, 219, 56, 56);
v0 = myplr;
v1 = myplr;
v2 = plr[myplr].InvBody[0]._iCurs + 12;
v3 = InvItemWidth[v2];
if ( !pcursinvitem )
{
v4 = -59;
if ( plr[v1].InvBody[0]._iMagical )
v4 = -75;
if ( !plr[v1].InvBody[0]._iStatFlag )
v4 = -27;
CelDecodeClr(v4, 517, 219, (char *)pCursCels, v2, v3, 0, 8);
v0 = myplr;
}
if ( plr[v0].InvBody[0]._iStatFlag )
CelDrawHdrOnly(517, 219, (char *)pCursCels, v2, v3, 0, 8);
InvDrawSlotBack(517, 219, 2 * INV_SLOT_SIZE_PX, 2 * INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_HEAD]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == INVITEM_HEAD )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_HEAD]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, 517, 219, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_HEAD]._iStatFlag )
{
CelDrawHdrOnly(517, 219, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(517, 219, (char *)pCursCels, v2, v3, 0, 8, 1);
}
if ( plr[myplr].InvBody[1]._itype != -1 )
{
InvDrawSlotBack(432, 365, 28, 28);
v5 = myplr;
v6 = myplr;
v7 = plr[myplr].InvBody[1]._iCurs + 12;
v8 = InvItemWidth[v7];
screen_y = InvItemWidth[v7];
if ( pcursinvitem == 1 )
{
v9 = -59;
if ( plr[v6].InvBody[1]._iMagical )
v9 = -75;
if ( !plr[v6].InvBody[1]._iStatFlag )
v9 = -27;
CelDecodeClr(v9, 432, 365, (char *)pCursCels, v7, v8, 0, 8);
v5 = myplr;
v8 = screen_y;
}
if ( plr[v5].InvBody[1]._iStatFlag )
CelDrawHdrOnly(432, 365, (char *)pCursCels, v7, v8, 0, 8);
{
CelDrawHdrLightRed(517, 219, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
if ( plr[myplr].InvBody[INVLOC_RING_LEFT]._itype != ITYPE_NONE )
{
InvDrawSlotBack(432, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_RING_LEFT]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == INVITEM_RING_LEFT )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_RING_LEFT]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, 432, 365, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_RING_LEFT]._iStatFlag )
{
CelDrawHdrOnly(432, 365, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(432, 365, (char *)pCursCels, v7, v8, 0, 8, 1);
}
if ( plr[myplr].InvBody[2]._itype != -1 )
{
InvDrawSlotBack(633, 365, 28, 28);
v10 = myplr;
v11 = myplr;
v12 = plr[myplr].InvBody[2]._iCurs + 12;
v13 = InvItemWidth[v12];
screen_ya = InvItemWidth[v12];
if ( pcursinvitem == 2 )
{
v14 = -59;
if ( plr[v11].InvBody[2]._iMagical )
v14 = -75;
if ( !plr[v11].InvBody[2]._iStatFlag )
v14 = -27;
CelDecodeClr(v14, 633, 365, (char *)pCursCels, v12, v13, 0, 8);
v10 = myplr;
v13 = screen_ya;
}
if ( plr[v10].InvBody[2]._iStatFlag )
CelDrawHdrOnly(633, 365, (char *)pCursCels, v12, v13, 0, 8);
{
CelDrawHdrLightRed(432, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
if ( plr[myplr].InvBody[INVLOC_RING_RIGHT]._itype != ITYPE_NONE )
{
InvDrawSlotBack(633, 365, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_RING_RIGHT]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == INVITEM_RING_RIGHT )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_RING_RIGHT]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, 633, 365, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_RING_RIGHT]._iStatFlag )
{
CelDrawHdrOnly(633, 365, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(633, 365, (char *)pCursCels, v12, v13, 0, 8, 1);
}
if ( plr[myplr].InvBody[3]._itype != -1 )
{
InvDrawSlotBack(589, 220, 28, 28);
v15 = myplr;
v16 = myplr;
v17 = plr[myplr].InvBody[3]._iCurs + 12;
v18 = InvItemWidth[v17];
screen_yb = InvItemWidth[v17];
if ( pcursinvitem == 3 )
{
v19 = -59;
if ( plr[v16].InvBody[3]._iMagical )
v19 = -75;
if ( !plr[v16].InvBody[3]._iStatFlag )
v19 = -27;
CelDecodeClr(v19, 589, 220, (char *)pCursCels, v17, v18, 0, 8);
v15 = myplr;
v18 = screen_yb;
}
if ( plr[v15].InvBody[3]._iStatFlag )
CelDrawHdrOnly(589, 220, (char *)pCursCels, v17, v18, 0, 8);
{
CelDrawHdrLightRed(633, 365, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
if ( plr[myplr].InvBody[INVLOC_AMULET]._itype != ITYPE_NONE )
{
InvDrawSlotBack(589, 220, INV_SLOT_SIZE_PX, INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_AMULET]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == INVITEM_AMULET )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_AMULET]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, 589, 220, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_AMULET]._iStatFlag )
{
CelDrawHdrOnly(589, 220, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(589, 220, (char *)pCursCels, v17, v18, 0, 8, 1);
}
if ( plr[myplr].InvBody[4]._itype != -1 )
{
InvDrawSlotBack(401, 320, 56, 84);
v20 = myplr;
v21 = myplr;
v22 = plr[myplr].InvBody[4]._iCurs + 12;
v23 = InvItemWidth[v22];
v24 = v23 != 28 ? 401 : 415;
screen_yc = InvItemHeight[v22] != 84 ? 306 : 320;
if ( pcursinvitem == 4 )
{
v25 = -59;
if ( plr[v21].InvBody[4]._iMagical )
v25 = -75;
if ( !plr[v21].InvBody[4]._iStatFlag )
v25 = -27;
CelDecodeClr(v25, v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8);
v20 = myplr;
}
if ( plr[v20].InvBody[4]._iStatFlag )
CelDrawHdrOnly(v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8);
{
CelDrawHdrLightRed(589, 220, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._itype != ITYPE_NONE )
{
InvDrawSlotBack(401, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_HAND_LEFT]._iCurs + 12;
int frame_width = InvItemWidth[frame];
// calc item offsets for weapons smaller than 2x3 slots
int screen_x = frame_width == INV_SLOT_SIZE_PX ? 415 : 401;
int screen_y = InvItemHeight[frame] == (3 * INV_SLOT_SIZE_PX) ? 320 : 306;
if ( pcursinvitem == INVITEM_HAND_LEFT )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._iStatFlag )
{
CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(v24, screen_yc, (char *)pCursCels, v22, v23, 0, 8, 1);
if ( plr[myplr].InvBody[4]._iLoc == ILOC_TWOHAND )
{
InvDrawSlotBack(631, 320, 56, 84);
CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
if ( plr[myplr].InvBody[INVLOC_HAND_LEFT]._iLoc == ILOC_TWOHAND )
{
InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
light_table_index = 0;
cel_transparency_active = 1;
v26 = &gpBuffer->row[160].pixels[581];
if ( v23 != 28 )
v26 = &gpBuffer->row[160].pixels[567];
CelDecodeHdrLightTrans(v26, (char *)pCursCels, v22, v23, 0, 8);
CelDecodeHdrLightTrans(
frame_width == INV_SLOT_SIZE_PX
? &gpBuffer->row[160].pixels[581]
: &gpBuffer->row[160].pixels[567],
(char *)pCursCels, frame, frame_width, 0, 8);
cel_transparency_active = 0;
}
}
if ( plr[myplr].InvBody[5]._itype != -1 )
if ( plr[myplr].InvBody[INVLOC_HAND_RIGHT]._itype != ITYPE_NONE )
{
InvDrawSlotBack(631, 320, 56, 84);
v27 = myplr;
v28 = myplr;
v29 = plr[myplr].InvBody[5]._iCurs + 12;
v30 = InvItemWidth[v29];
screen_yd = InvItemHeight[v29] != 84 ? 306 : 320;
if ( pcursinvitem == 5 )
InvDrawSlotBack(631, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iCurs + 12;
int frame_width = InvItemWidth[frame];
// calc item offsets for weapons smaller than 2x3 slots
int screen_x = frame_width == INV_SLOT_SIZE_PX ? 645 : 633;
int screen_y = InvItemHeight[frame] == 3 * INV_SLOT_SIZE_PX ? 320 : 306;
if ( pcursinvitem == INVITEM_HAND_RIGHT )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_HAND_RIGHT]._iStatFlag )
{
v31 = -59;
if ( plr[v28].InvBody[5]._iMagical )
v31 = -75;
if ( !plr[v28].InvBody[5]._iStatFlag )
v31 = -27;
CelDecodeClr(v31, v30 != 28 ? 633 : 645, screen_yd, (char *)pCursCels, v29, v30, 0, 8);
v27 = myplr;
CelDrawHdrOnly(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8);
}
screen_x = v30 != 28 ? 633 : 645;
if ( plr[v27].InvBody[5]._iStatFlag )
CelDrawHdrOnly(screen_x, screen_yd, (char *)pCursCels, v29, v30, 0, 8);
else
CelDrawHdrLightRed(screen_x, screen_yd, (char *)pCursCels, v29, v30, 0, 8, 1);
}
if ( plr[myplr].InvBody[6]._itype != -1 )
{
InvDrawSlotBack(517, 320, 56, 84);
v32 = myplr;
v33 = myplr;
v34 = plr[myplr].InvBody[6]._iCurs + 12;
v35 = InvItemWidth[v34];
if ( pcursinvitem == 6 )
{
v36 = -59;
if ( plr[v33].InvBody[6]._iMagical )
v36 = -75;
if ( !plr[v33].InvBody[6]._iStatFlag )
v36 = -27;
CelDecodeClr(v36, 517, 320, (char *)pCursCels, v34, v35, 0, 8);
v32 = myplr;
}
if ( plr[v32].InvBody[6]._iStatFlag )
CelDrawHdrOnly(517, 320, (char *)pCursCels, v34, v35, 0, 8);
{
CelDrawHdrLightRed(screen_x, screen_y, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
if ( plr[myplr].InvBody[INVLOC_CHEST]._itype != ITYPE_NONE )
{
InvDrawSlotBack(517, 320, 2 * INV_SLOT_SIZE_PX, 3 * INV_SLOT_SIZE_PX);
int frame = plr[myplr].InvBody[INVLOC_CHEST]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == INVITEM_CHEST )
{
int colour = 197;
if ( plr[myplr].InvBody[INVLOC_CHEST]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(colour, 517, 320, (char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvBody[INVLOC_CHEST]._iStatFlag )
{
CelDrawHdrOnly(517, 320, (char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(517, 320, (char *)pCursCels, v34, v35, 0, 8, 1);
{
CelDrawHdrLightRed(517, 320, (char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
v37 = 0;
do
for ( int i = 0; i < NUM_INV_GRID_ELEM; i++ )
{
if ( plr[myplr].InvGrid[v37] )
InvDrawSlotBack(InvRect[v37 + 25].X + 64, InvRect[v37 + 25].Y + 159, 28, 28);
++v37;
if ( plr[myplr].InvGrid[i] != 0 )
{
InvDrawSlotBack(
InvRect[i + SLOTXY_INV_FIRST].X + 64,
InvRect[i + SLOTXY_INV_FIRST].Y + 159,
INV_SLOT_SIZE_PX,
INV_SLOT_SIZE_PX);
}
}
while ( v37 < 40 );
v38 = 0;
do
for ( int j = 0; j < NUM_INV_GRID_ELEM; j++ )
{
v39 = 21720 * myplr;
v40 = plr[myplr].InvGrid[v38];
if ( v40 > 0 )
{
v41 = v40 - 1;
invtest[v38] = 1;
v42 = v41;
v43 = 368 * v41 + v39;
v44 = *(int *)((char *)&plr[0].InvList[0]._iCurs + v43) + 12;
screen_ye = InvItemWidth[v44];
if ( pcursinvitem == v41 + 7 )
{
v45 = -59;
if ( *(&plr[0].InvList[0]._iMagical + v43) )
v45 = -75;
if ( !*(int *)((char *)&plr[0].InvList[0]._iStatFlag + v43) )
v45 = -27;
if ( plr[myplr].InvGrid[j] > 0 ) // first slot of an item
{
int ii = plr[myplr].InvGrid[j] - 1;
invtest[j] = TRUE;
int frame = plr[myplr].InvList[ii]._iCurs + 12;
int frame_width = InvItemWidth[frame];
if ( pcursinvitem == ii + INVITEM_INV_FIRST )
{
int colour = 197;
if ( plr[myplr].InvList[ii]._iMagical )
{
colour = 181;
}
if ( !plr[myplr].InvList[ii]._iStatFlag )
{
colour = 229;
}
CelDecodeClr(
v45,
InvRect[v38 + 25].X + 64,
InvRect[v38 + 25].Y + 159,
(char *)pCursCels,
v44,
screen_ye,
0,
8);
}
v46 = InvRect[v38 + 25].X + 64;
v47 = InvRect[v38 + 25].Y + 159;
if ( plr[myplr].InvList[v42]._iStatFlag )
CelDrawHdrOnly(v46, v47, (char *)pCursCels, v44, screen_ye, 0, 8);
colour,
InvRect[j + SLOTXY_INV_FIRST].X + 64,
InvRect[j + SLOTXY_INV_FIRST].Y + 159,
(char *)pCursCels, frame, frame_width, 0, 8);
}
if ( plr[myplr].InvList[ii]._iStatFlag )
{
CelDrawHdrOnly(
InvRect[j + SLOTXY_INV_FIRST].X + 64,
InvRect[j + SLOTXY_INV_FIRST].Y + 159,
(char *)pCursCels, frame, frame_width, 0, 8);
}
else
CelDrawHdrLightRed(v46, v47, (char *)pCursCels, v44, screen_ye, 0, 8, 1);
{
CelDrawHdrLightRed(
InvRect[j + SLOTXY_INV_FIRST].X + 64,
InvRect[j + SLOTXY_INV_FIRST].Y + 159,
(char *)pCursCels, frame, frame_width, 0, 8, 1);
}
}
++v38;
}
while ( v38 < 40 );
}
// 4B8CB8: using guessed type char pcursinvitem;
// 69BEF8: using guessed type int light_table_index;
@ -1631,8 +1648,8 @@ void __fastcall CheckInvCut(int pnum, int mx, int my)
{
// check which inventory rectangle the mouse is in, if any
if ( mx >= InvRect[r].X
&& mx < InvRect[r].X + INV_SLOT_SIZE_PX
&& my >= InvRect[r].Y - INV_SLOT_SIZE_PX
&& mx < InvRect[r].X + (INV_SLOT_SIZE_PX + 1)
&& my >= InvRect[r].Y - (INV_SLOT_SIZE_PX + 1)
&& my < InvRect[r].Y )
{
done = TRUE;
@ -1726,7 +1743,7 @@ void __fastcall CheckInvCut(int pnum, int mx, int my)
iv = -ii;
}
for ( int i = 0; i < NUM_INVELEMS; i++ )
for ( int i = 0; i < NUM_INV_GRID_ELEM; i++ )
{
if ( plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv )
{
@ -1743,7 +1760,7 @@ void __fastcall CheckInvCut(int pnum, int mx, int my)
{
plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv];
for ( int j = 0; j < NUM_INVELEMS; j++ )
for ( int j = 0; j < NUM_INV_GRID_ELEM; j++ )
{
if ( plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1 )
{
@ -1810,7 +1827,7 @@ void __fastcall RemoveInvItem(int pnum, int iv)
{
iv++;
for ( int i = 0; i < NUM_INVELEMS; i++ )
for ( int i = 0; i < NUM_INV_GRID_ELEM; i++ )
{
if ( plr[pnum].InvGrid[i] == iv || plr[pnum].InvGrid[i] == -iv )
{
@ -1825,7 +1842,7 @@ void __fastcall RemoveInvItem(int pnum, int iv)
{
plr[pnum].InvList[iv] = plr[pnum].InvList[plr[pnum]._pNumInv];
for ( int j = 0; j < NUM_INVELEMS; j++ )
for ( int j = 0; j < NUM_INV_GRID_ELEM; j++ )
{
if ( plr[pnum].InvGrid[j] == plr[pnum]._pNumInv + 1 )
{

2
Source/items.cpp

@ -1529,7 +1529,7 @@ void __fastcall CreatePlrItems(int p)
memset(&plr[p].InvGrid, 0, sizeof(plr[p].InvGrid));
pi = plr[p].InvList;
for ( i = 0; i < NUM_INVELEMS; i++ )
for ( i = 0; i < NUM_INV_GRID_ELEM; i++ )
{
pi[i]._itype = ITYPE_NONE;
}

4
defs.h

@ -31,8 +31,8 @@
// number of inventory grid cells
#define NUM_INVELEMS 40
#define INV_SLOT_SIZE_PX 29
#define NUM_INV_GRID_ELEM 40
#define INV_SLOT_SIZE_PX 28
// todo: enums
#define NUM_SFX 858

17
enums.h

@ -2485,6 +2485,21 @@ enum inv_body_loc {
NUM_INVLOC,
};
enum inv_item {
INVITEM_HEAD = 0,
INVITEM_RING_LEFT = 1,
INVITEM_RING_RIGHT = 2,
INVITEM_AMULET = 3,
INVITEM_HAND_LEFT = 4,
INVITEM_HAND_RIGHT = 5,
INVITEM_CHEST = 6,
INVITEM_INV_FIRST = 7,
INVITEM_INV_LAST = 46,
INVITEM_BELT_FIRST = 47,
INVITEM_BELT_LAST = 54,
NUM_INVELEM
};
// identifiers for each of the inventory squares
// see https://github.com/sanctuary/graphics/blob/master/inventory.png
enum inv_xy_slot {
@ -2508,4 +2523,4 @@ enum inv_xy_slot {
SLOTXY_BELT_FIRST = 65,
SLOTXY_BELT_LAST = 72,
NUM_XY_SLOTS = 73
};
};

4
structs.h

@ -304,9 +304,9 @@ struct PlayerStruct
// TODO: Replace 7 with NUM_INVLOC, however VC6
// doesn't seem to allow enum members as array size...
ItemStruct InvBody[7];
ItemStruct InvList[NUM_INVELEMS];
ItemStruct InvList[NUM_INV_GRID_ELEM];
int _pNumInv;
char InvGrid[NUM_INVELEMS];
char InvGrid[NUM_INV_GRID_ELEM];
ItemStruct SpdList[8];
ItemStruct HoldItem;
int _pIMinDam;

Loading…
Cancel
Save