void __userpurge sub_526916(int a1<ebx>, int a2<ebp>, int a3<edi>, int a4<esi>, int a5)
{
int v5; // ecx@1
int v6; // esi@1
int v7; // ecx@1
char v8; // al@1
int v9; // ecx@1
int v10; // eax@1
int v11; // ecx@3
signed __int16 v12; // ax@9
int v13; // ecx@19
int v14; // ST14_4@20
char v15; // al@22
int v16; // edi@22
int v17; // esi@23
int v18; // ecx@23
int v19; // eax@23
int v20; // ST14_4@23
const CHAR *v21; // ST08_4@23
void *v22; // esp@23
const CHAR *v23; // ST08_4@23
int v24; // eax@23
int v25; // eax@25
int v26; // eax@27
int v27; // eax@27
signed __int16 v28; // [sp-5Ch] [bp-5Ch]@10
int v29; // [sp-58h] [bp-58h]@1
int v30; // [sp-54h] [bp-54h]@1
int v31; // [sp-50h] [bp-50h]@1
sub_5F9280();
v31 = a1;
v30 = a4;
v6 = v5;
v7 = *(_DWORD *)(a2 + 8);
v29 = a3;
*(_DWORD *)(a2 - 36) = v6;
v8 = CInPacket::Decode1(v7); // reads in a byte prob storage size
v9 = *(_DWORD *)(a2 + 8);
*(_DWORD *)(v6 + 220) = (unsigned __int8)v8;
LOWORD(v10) = CInPacket::Decode2(v9); // reads in the bitfield encoding (type)
(short)
*(_DWORD *)(a2 - 40) = v10;
if ( v10 & 2 )
*(_DWORD *)(v6 + 224) = CInPacket::Decode4(*(_DWORD *)(a2 + 8));// reads in the
number of equips
*(_DWORD *)(a2 - 20) = 0;
*(_DWORD *)(a2 - 4) = 0;
sub_529A38((void *)(a2 - 20));
v11 = *(_DWORD *)(v6 + 184);
*(_DWORD *)(a2 - 20) = *(_DWORD *)(v6 + 184);
*(_DWORD *)(v6 + 184) = 0;
*(_DWORD *)(a2 - 16) = 1;
do
{
if ( *(_DWORD *)(a2 - 16) == 1 ) // if equip
{
LABEL_13:
v28 = 4;
goto LABEL_14;
}
if ( *(_DWORD *)(a2 - 16) == 2 ) // if use
{
v28 = 8;
}
else
{
if ( *(_DWORD *)(a2 - 16) == 3 ) // if setup
{
v28 = 16;
}
else
{
if ( *(_DWORD *)(a2 - 16) == 4 ) // if etc
goto LABEL_13;
if ( *(_DWORD *)(a2 - 16) != 5 ) // if cash
{
v12 = 0;
goto LABEL_15;
}
v28 = 64;
}
}
LABEL_14:
v12 = v28;
LABEL_15:
if ( *(_WORD *)(a2 - 40) & (unsigned __int16)v12 )
{
v15 = CInPacket::Decode1(*(_DWORD *)(a2 + 8));// reads 1 byte after the num items in
storage which is item type I think
v16 = 0;
*(_DWORD *)(a2 - 28) = (unsigned __int8)v15;
if ( (signed int)(unsigned __int8)v15 > 0 )
{
do // this is the loop that adds the item data probably
{
sub_526BA4(a2 - 88);
*(_BYTE *)(a2 - 4) = 1;
v17 = sub_45FA26(0, a2, v16, v6);
*(_BYTE *)(a2 - 4) = 2;
sub_4AF372(v17);
sub_40DAC2(a2 - 68);
*(_DWORD *)(a2 - 64) = *(_DWORD *)(v17 + 4);
*(_BYTE *)(a2 - 4) = 1;
sub_40DAC2(a2 - 60);
v18 = *(_DWORD *)(a2 - 64);
*(_DWORD *)(a2 - 88) = *(_DWORD *)(v18 + 12);
v19 = (*(int (__cdecl **)(int, int, int))(*(_DWORD *)v18 + 4))(v29, v30, v31);
v20 = *(_DWORD *)(a2 - 88);
*(_DWORD *)(a2 - 84) = v19;
*(_DWORD *)(a2 - 80) = v16;
v21 = *(const CHAR **)CItemInfo::GetItemName(a2, a2 - 48, v20);
*(_BYTE *)(a2 - 4) = 3;
v22 = alloca(2 * MultiByteToWideChar(0, 0, v21, -1, 0, 0));
v6 = (int)&v29;
v23 = *(const CHAR **)CItemInfo::GetItemName(a2, a2 - 44, *(_DWORD *)(a2 -
88));
*(_BYTE *)(a2 - 4) = 4;
MultiByteToWideChar(0, 0, v23, -1, (LPWSTR)&v29, 1073741823);
sub_40298A(a2, (int)&v29);
_bstr_t::operator_(a2 - 32);
sub_453530(a2 - 32);
v24 = *(_DWORD *)(a2 - 44);
*(_BYTE *)(a2 - 4) = 3;
if ( v24 )
sub_41E324((volatile LONG *)(v24 - 12));
v25 = *(_DWORD *)(a2 - 48);
*(_BYTE *)(a2 - 4) = 1;
if ( v25 )
sub_41E324((volatile LONG *)(v25 - 12));
v26 = sub_48ACF0(a2 - 52, *(_DWORD *)(a2 - 88), 1, 0);
_com_ptr_t<_com_IIID<IWzGr2DLayer____s_GUID__GUID_6dc8c7ce_8e81_4420_b4f6_4b60
b7d5fcdf>>::operator_(*(_DWORD *)v26);
v27 = *(_DWORD *)(a2 - 52);
if ( v27 )
(*(void (__stdcall **)(_DWORD))(*(_DWORD *)v27 + 8))(*(_DWORD *)(a2 - 52));
sub_529A74(-1);
sub_5299E1(a2 - 88);
*(_BYTE *)(a2 - 4) = 0;
sub_526BB2(a2 - 88);
++v16;
}
while ( v16 < *(_DWORD *)(a2 - 28) );
v6 = *(_DWORD *)(a2 - 36);
}
v11 = *(_DWORD *)(a2 - 20);
}
else
{
*(_DWORD *)(a2 - 24) = 0;
*(_DWORD *)(a2 - 28) = 0;
while ( v11 && *(_DWORD *)(a2 - 24) < *(_DWORD *)(v11 - 4) )
{
v13 = *(_DWORD *)(a2 - 28) + v11;
if ( *(_DWORD *)v13 / 1000000 == *(_DWORD *)(a2 - 16) )// probably gets the item type
{
v14 = v13;
sub_529A74(-1);
sub_5299E1(v14);
}
++*(_DWORD *)(a2 - 24);
*(_DWORD *)(a2 - 28) += 28;
v11 = *(_DWORD *)(a2 - 20);
}
}
++*(_DWORD *)(a2 - 16);
}
while ( *(_DWORD *)(a2 - 16) <= 5 );
*(_DWORD *)(v6 + 212) = -1;
*(_DWORD *)(a2 - 4) = -1;
sub_529A38((void *)(a2 - 20));
}