Skip to content

Instantly share code, notes, and snippets.

@jaenster
Created May 14, 2020 09:16
Show Gist options
  • Save jaenster/b6c42daba546674611860cd84189946e to your computer and use it in GitHub Desktop.
Save jaenster/b6c42daba546674611860cd84189946e to your computer and use it in GitHub Desktop.
char __stdcall LoadItemDesc(int a1, int a2)
{
int v2; // edx@1
int v3; // ecx@1
int v4; // edx@2
int v5; // ecx@2
signed int v6; // eax@4
int v7; // edi@6
int v8; // esi@6
int v9; // ebx@6
int v10; // eax@6
int v11; // ST0C_4@10
int v12; // esi@10
_WORD *v13; // eax@10
int v14; // edi@17
int v15; // esi@17
int v16; // ebx@17
int v17; // eax@17
int v18; // ST0C_4@21
int v19; // esi@21
_WORD *v20; // eax@21
int v21; // edi@22
int v22; // esi@22
int v23; // ebx@22
int v24; // eax@22
signed int v25; // ecx@27
int v26; // ST0C_4@31
int v27; // esi@31
_WORD *v28; // eax@31
int v29; // ecx@34
int v30; // eax@34
int v31; // ecx@34
_WORD *v32; // eax@35
_WORD *v33; // eax@36
int v34; // ecx@37
_WORD *v35; // eax@38
_WORD *v36; // eax@39
signed int v37; // esi@40
int v38; // esi@48
_WORD *v39; // eax@56
_WORD *v40; // esi@56
signed int v41; // ecx@57
_WORD *v42; // eax@64
int v43; // ecx@65
int v44; // eax@65
int v45; // esi@67
int v46; // eax@74
int v47; // esi@74
_WORD *v48; // eax@75
int v49; // eax@76
signed int v50; // eax@81
int v51; // esi@83
char v52; // al@84
int v53; // esi@89
signed int v54; // eax@90
_WORD *v55; // esi@99
_WORD *v56; // eax@99
int v57; // ebx@102
int v58; // edi@102
__int64 v59; // rax@102
__int64 v60; // rax@103
int v61; // esi@106
_WORD *v62; // eax@151
_WORD *v63; // eax@152
int v64; // eax@152
_WORD *v65; // eax@165
_WORD *v66; // eax@165
_WORD *v67; // eax@165
_WORD *v68; // eax@165
_WORD *v69; // eax@165
_WORD *v70; // eax@165
_WORD *v71; // eax@165
_WORD *v72; // eax@165
_WORD *v73; // eax@165
_WORD *v74; // eax@165
_WORD *v75; // eax@165
_WORD *v76; // eax@165
_WORD *v77; // eax@165
_WORD *v78; // eax@165
_WORD *v79; // eax@165
_WORD *v80; // eax@165
_WORD *v81; // eax@167
int v82; // ecx@172
signed int v83; // ecx@177
_WORD *v84; // eax@180
signed int v85; // esi@181
int v87; // [sp-8h] [bp-6448h]@65
char v88; // [sp+Ch] [bp-6434h]@1
char v89; // [sp+200Ch] [bp-4434h]@1
char v90; // [sp+280Ch] [bp-3C34h]@1
char v91; // [sp+300Ch] [bp-3434h]@1
char v92; // [sp+340Ch] [bp-3034h]@1
char v93; // [sp+360Ch] [bp-2E34h]@1
char v94; // [sp+380Ch] [bp-2C34h]@1
char v95; // [sp+3A0Ch] [bp-2A34h]@1
char v96; // [sp+3C0Ch] [bp-2834h]@1
char v97; // [sp+3E0Ch] [bp-2634h]@1
char v98; // [sp+400Ch] [bp-2434h]@1
char v99; // [sp+420Ch] [bp-2234h]@1
char v100; // [sp+440Ch] [bp-2034h]@1
char v101; // [sp+460Ch] [bp-1E34h]@35
char v102; // [sp+4A0Ch] [bp-1A34h]@1
char v103; // [sp+4C0Ch] [bp-1834h]@1
char v104; // [sp+4E0Ch] [bp-1634h]@1
char v105; // [sp+500Ch] [bp-1434h]@1
char v106; // [sp+520Ch] [bp-1234h]@1
__int16 v107; // [sp+5A0Ah] [bp-A36h]@184
char v108; // [sp+5A0Ch] [bp-A34h]@1
char v109; // [sp+5C0Ch] [bp-834h]@1
int v110; // [sp+640Ch] [bp-34h]@89
int v111; // [sp+6410h] [bp-30h]@1
int v112; // [sp+6414h] [bp-2Ch]@89
int v113; // [sp+641Ch] [bp-24h]@67
int v114; // [sp+6420h] [bp-20h]@1
int v115; // [sp+6424h] [bp-1Ch]@1
int v116; // [sp+6428h] [bp-18h]@1
int v117; // [sp+642Ch] [bp-14h]@1
int v118; // [sp+6430h] [bp-10h]@65
_WORD *v119; // [sp+6434h] [bp-Ch]@1
int v120; // [sp+6438h] [bp-8h]@1
int v121; // [sp+643Ch] [bp-4h]@1
int v122; // [sp+6448h] [bp+8h]@83
memset(&v109, 0, 0x800u);
memset(&v106, 0, 0x800u);
memset(&v91, 0, 0x400u);
memset(&v103, 0, 0x200u);
memset(&v98, 0, 0x200u);
memset(&v96, 0, 0x200u);
memset(&v99, 0, 0x200u);
memset(&v92, 0, 0x200u);
memset(&v97, 0, 0x200u);
memset(&v94, 0, 0x200u);
memset(&v93, 0, 0x200u);
memset(&v104, 0, 0x200u);
memset(&v100, 0, 0x200u);
memset(&v108, 0, 0x200u);
memset(&v102, 0, 0x200u);
memset(&v95, 0, 0x200u);
memset(&v105, 0, 0x200u);
memset(&v89, 0, 0x800u);
memset(&v90, 0, 0x800u);
memset(&v88, 0, 0x2000u);
v111 = 0;
v121 = 0;
v115 = 0;
v114 = 0;
v116 = 0;
v117 = 0;
v119 = (_WORD *)GetLocaleText(3998); // -
v120 = a1;
if ( a2 && GetPlayerUnit(v3, v2) )
v120 = GetPlayerUnit(v5, v4);
LOBYTE(v6) = __uncaught_exception();
if ( !v6 )
{
if ( GetUiVar_I(0x24u) )
{
v7 = yExtraOffset + SomeYCoord - 63;
v8 = xExtraOffset + 272;
v9 = sub_468730(yExtraOffset);
v10 = sub_468740();
if ( v9 >= v8 && v9 <= v8 + 32 && v10 >= v7 - 32 && v10 <= v7 )
{
v11 = yExtraOffset + SomeYCoord - 98;
v12 = xExtraOffset + 287;
v13 = (_WORD *)GetLocaleText(4144); // Close
sub_502280(v13, v12, v11, 0, 1);
}
}
if ( GetUiVar_I(1u)
|| GetUiVar_I(0x17u)
|| GetUiVar_I(0x19u)
|| GetUiVar_I(0xCu)
|| GetUiVar_I(0xEu)
|| (v6 = GetUiVar_I(0x1Au)) != 0 )
{ // Inventory / trade / shop / cube / stash
v14 = yExtraOffset + SomeYCoord - 64;
v15 = UnknownFlagRelatedUI - xExtraOffset - 302;
v16 = sub_468730(SomeYCoord);
v17 = sub_468740();
if ( v16 >= v15 && v16 <= v15 + 32 && v17 >= v14 - 32 && v17 <= v14 )
{
v18 = yExtraOffset + SomeYCoord - 99;
v19 = UnknownFlagRelatedUI - xExtraOffset - 287;
v20 = (_WORD *)GetLocaleText(4144);
sub_502280(v20, v19, v18, 0, 1);
}
v21 = yExtraOffset + SomeYCoord - 69;
v22 = UnknownFlagRelatedUI - xExtraOffset - 237;
v23 = sub_468730(yExtraOffset);
v24 = sub_468740();
if ( v23 >= v22 && v23 <= v22 + 20 && v24 >= v21 - 18 && v24 <= v21 && !sub_4B34A0() )
{
v25 = 4125; // Drop Gold
switch ( dword_7BCBF0 )
{
case 1:
v25 = 4099; // Gold
break;
case 12:
case 13:
case 15:
v25 = 4126; // Deposit
break;
case 11:
v25 = 4129; // Trade Gold
break;
default:
break;
}
v26 = yExtraOffset + SomeYCoord - 89;
v27 = UnknownFlagRelatedUI - xExtraOffset - 222;
v28 = (_WORD *)GetLocaleText(v25);
sub_502280(v28, v27, v26, 0, 1);
}
v6 = LoadExpansionAndIsIt();
if ( v6 )
{
v6 = SomethingWhenItIsExpac();
if ( v6 )
{
sub_468740();
v30 = sub_468730(v29);
v6 = sub_486860(v31, v30);
if ( v6 )
{
sub_403040((int)&v101, 2, 512, (int (__thiscall *)(int))sub_42F530);
v32 = (_WORD *)GetLocaleText(22726);// Swap weapons
CopyFieldOverOrSomething(&v101, v32);
if ( (unsigned __int16)sub_469AA0(44) == -1 )
{
if ( (unsigned __int16)sub_469AA0(44) == -1 )
{
LABEL_40:
v37 = 368;
if ( sub_468730(v34) > xExtraOffset + 500 )
v37 = 600;
LOBYTE(v6) = sub_502280(&v101, v37 + xExtraOffset, 21 - yExtraOffset, 0, 1);
goto LABEL_43;
}
v35 = (_WORD *)GetLocaleText(3997);// :
StringRelatedConvertingThing(&v101, v35);
}
else
{
v33 = (_WORD *)GetLocaleText(3997);
StringRelatedConvertingThing(&v101, v33);
}
v36 = (_WORD *)sub_46A530(44);
StringRelatedConvertingThing(&v101, v36);
goto LABEL_40;
}
}
}
}
}
LABEL_43:
if ( SomethingItemRelated || SomethingItemRelated_0 )
{
if ( SelectedItem )
{
v6 = *(_DWORD *)(a1 + 96);
if ( v6 )
{
v6 = GetInventoryIdMaybe(*(_DWORD *)(a1 + 96));
if ( !v6 )
{
v38 = *(_DWORD *)(a1 + 96);
if ( GetUiVar_I(0x17u) || !v38 || !SelectedItem || (v6 = sub_63AD50(v38, SelectedItem)) != 0 )
{
if ( SomethingItemRelated_0 && !dword_721E38 && sub_4B3500() && (unsigned int)(dword_7BCBF0 - 1) <= 8 )
{
GetItemName(128);
v39 = (_WORD *)GetLocaleText(3455);// Unidentified
CopyFieldOverOrSomething(&v108, v39);
v40 = v119;
StringRelatedConvertingThing(&v108, v119);
StringRelatedConvertingThing(&v109, &v108);
switch ( GetItemType(SelectedItem) )
{
case 0x3C:
case 0x55:
case 0x56:
case 0x57:
v41 = 10917; // Assasin Onl,y
goto LABEL_64;
case 0x3D:
case 0x47:
v41 = 10921; // Barb Only
goto LABEL_64;
case 0x3E:
case 0x45:
v41 = 10919; // Necro only
goto LABEL_64;
case 0x3F:
case 0x46:
v41 = 10920; // Pala only
goto LABEL_64;
case 0x40:
case 0x44:
v41 = 10918; // Sorrcess only
goto LABEL_64;
case 0x41:
case 0x43:
case 0x58:
v41 = 10923; // Assasin only
goto LABEL_64;
case 0x42:
case 0x48:
case 0x49:
v41 = 10922; // Druid only
LABEL_64:
v42 = (_WORD *)GetLocaleText(v41);
StringRelatedConvertingThing(&v109, v42);
StringRelatedConvertingThing(&v109, v40);
break;
default:
break;
}
StringRelatedConvertingThing(&v109, &v90);
sub_4521C0(&v109, 0);
ItemTradeImpossible(&v106, (int)&v109);
GetTextWidthFileNo(&v118);
v43 = dword_721E40;
v44 = v118;
v87 = 0;
if ( dword_721E40 - v118 <= 0 )
{
LABEL_66:
LOBYTE(v6) = sub_502280(&v106, dword_721E44, dword_721E48 + v44, v87, 1);
return v6;
}
LABEL_186:
LOBYTE(v6) = sub_502280(&v106, dword_721E3C, v43, v87, 1);
return v6;
}
v45 = sub_627E70(SelectedItem);
v113 = v45;
if ( sub_468830() == 8 || sub_62A0A0((char *)SelectedItem) )
{
LOBYTE(v6) = sub_48DB80();
return v6;
}
if ( v45 == 5 && TestItemWithSomething(SelectedItem, 16, 3999, ".\\UI\\inv.cpp") )
{
LOBYTE(v6) = sub_48D1D0((void *)a1);
return v6;
}
if ( GetItemType(SelectedItem) == 18 )
{
LOBYTE(v6) = sub_48CFF0();
return v6;
}
v46 = IsClassSpecificOnly(SelectedItem);
v47 = v46;
if ( v46 != 7 )
{
v48 = (_WORD *)GetLocaleText(v46 + 10917);// (x only) // Amazon/sorc/whatever
StringRelatedConvertingThing(&v102, v48);
StringRelatedConvertingThing(&v102, v119);
v49 = v120 ? *(_DWORD *)(v120 + 4) : -1;
if ( v49 != v47 )
v117 = 1;
}
if ( SelectedItem )
v50 = *(_DWORD *)(SelectedItem + 4);
else
v50 = -1;
v51 = GetItemText(v50);
v122 = v51;
if ( !v51 )
{
v52 = (unsigned int)InternalErrorHandlerRelated();
InternalErrorHandler(7129143, v52, 4034);
exit(-1);
}
if ( sub_62E740(SelectedItem) )
sub_484DB0(v51);
else
sub_484E90();
v53 = v120;
sub_62EAF0(SelectedItem, v120, 0, &v112, &v110, &a2);
if ( TestItemWithSomething(SelectedItem, 16, 4054, 7183296) )
{
v54 = GetItemLevelRequirement(SelectedItem, v53);
if ( v54 > 1 )
{
if ( !a2 )
v115 = 1;
sub_484FF0(v54);
}
}
if ( GetItemFlagsOrProperty(SelectedItem, 53) )
sub_4865D0();
if ( sub_629900(SelectedItem) )
sub_486670(&v98);
if ( GetItemFlagsOrProperty(SelectedItem, 13) )
{
v55 = (_WORD *)GetLocaleText(3998);
v56 = (_WORD *)GetLocaleText(20438);// Keep in Inventory to Gain Bonus
StringRelatedConvertingThing(&v103, v56);
StringRelatedConvertingThing(&v103, v55);
}
if ( GetItemFlagsOrProperty(SelectedItem, 45) || GetItemFlagsOrProperty(SelectedItem, 50) )
{
sub_484B10(SelectedItem);
v57 = 0;
v58 = 0;
LODWORD(v59) = sub_625500(SelectedItem, 91, 0);
if ( (_DWORD)v59 )
{
v60 = __PAIR__(v59, sub_483360(v59, *(_WORD *)(v122 + 266), 100));
v58 = v60;
v57 = sub_483360(v60, *(_WORD *)(v122 + 268), 100);
}
if ( TestItemWithSomething(SelectedItem, 0x400000, 4090, 7183296) )
{
v58 -= 10;
v57 -= 10;
}
v61 = v122;
if ( *(_WORD *)(v122 + 268) )
{
if ( !v110 )
v116 = 1;
sub_485170(v122, v57);
}
if ( *(_WORD *)(v122 + 266) )
{
if ( !v112 )
v114 = 1;
sub_4850A0(v122, v58);
}
if ( GetItemFlagsOrProperty(SelectedItem, 45) )
{
if ( sub_625EF0(SelectedItem, 0) >= 0 && sub_625E60(SelectedItem, 0) >= 0 )
sub_485410(SelectedItem, &v94);
sub_4861D0(&v89);
}
if ( GetItemFlagsOrProperty(SelectedItem, 51) )
{
if ( v120
&& *(_DWORD *)((char *)&loc_48E4DC + v120 - 4777176) == 3
&& (!sub_62C060(SelectedItem) || IsClassSpecificOnly(SelectedItem) == 3) )
{
sub_485D40(SelectedItem, v122);
v61 = v122;
}
sub_485BE0(&v93, v61);
}
else if ( GetItemFlagsOrProperty(SelectedItem, 15)
&& v120
&& *(_DWORD *)((char *)&loc_48E4DC + v120 - 4777176) == 6 )
{
sub_485D40(SelectedItem, v122);
}
if ( GetItemFlagsOrProperty(SelectedItem, 50) && sub_626020(SelectedItem) > 0 )
sub_485EE0(v120, SelectedItem, &v100);
}
switch ( v113 )
{
case 7:
v121 = 4;
break;
case 4:
v121 = 3;
break;
case 6:
v121 = 9;
break;
case 8:
v121 = 8;
break;
case 9:
v121 = 10;
break;
case 5:
v121 = 2;
break;
default:
if ( TestItemWithSomething(SelectedItem, 2048, 4176, 7183296)
|| TestItemWithSomething(SelectedItem, 0x400000, 4180, 7183296) )
{
v121 = 5;
}
break;
}
if ( !TestItemWithSomething(SelectedItem, 16, 4189, 7183296)
&& (unsigned int)(dword_7BCBF0 - 1) <= 8
&& !dword_721E38 )
{
v121 = 0;
}
if ( TestItemWithSomething(SelectedItem, 16, 4201, 7183296) )
{
if ( !TestItemWithSomething(SelectedItem, 2048, 4204, 7183296) )
sub_486100();
sub_4E6410(4096, 1, 0);
}
else
{
v62 = (_WORD *)GetLocaleText(3455);// Identified
CopyFieldOverOrSomething(&v108, v62);
StringRelatedConvertingThing(&v108, v119);
}
sub_486370(SelectedItem);
GetItemName(256);
v63 = (_WORD *)sub_4521C0(&v95, 3);
CopyFieldOverOrSomething(&v109, v63);
v64 = *(_DWORD *)(v122 + 128);
if ( v64 == 543712611
|| v64 == 544499042
|| v64 == 544433524
|| v64 == 543450470
|| v64 == 543256436
|| v64 == 544106596
|| v64 == 544826722
|| v64 == 544367213
|| v64 == 540109680
|| v64 == 540175216
|| v64 == 540240752
|| GetItemFlagsOrProperty(SelectedItem, 74) )
{
v121 = 8;
}
v65 = (_WORD *)sub_4521C0(&v88, 3);
StringRelatedConvertingThing(&v109, v65);
v66 = (_WORD *)sub_4521C0(&v108, 1);
StringRelatedConvertingThing(&v109, v66);
v67 = (_WORD *)sub_4521C0(&v89, 0);
StringRelatedConvertingThing(&v109, v67);
v68 = (_WORD *)sub_4521C0(&v99, v115);
StringRelatedConvertingThing(&v109, v68);
v69 = (_WORD *)sub_4521C0(&v92, v114);
StringRelatedConvertingThing(&v109, v69);
v70 = (_WORD *)sub_4521C0(&v97, v116);
StringRelatedConvertingThing(&v109, v70);
v71 = (_WORD *)sub_4521C0(&v102, v117);
StringRelatedConvertingThing(&v109, v71);
v72 = (_WORD *)sub_4521C0(&v96, 0);
StringRelatedConvertingThing(&v109, v72);
v73 = (_WORD *)sub_4521C0(&v91, 0);
StringRelatedConvertingThing(&v109, v73);
v74 = (_WORD *)sub_4521C0(&v103, 0);
StringRelatedConvertingThing(&v109, v74);
v75 = (_WORD *)sub_4521C0(&v105, 0);
StringRelatedConvertingThing(&v109, v75);
v76 = (_WORD *)sub_4521C0(&v94, 0);
StringRelatedConvertingThing(&v109, v76);
v77 = (_WORD *)sub_4521C0(&v104, 0);
StringRelatedConvertingThing(&v109, v77);
v78 = (_WORD *)sub_4521C0(&v93, 0);
StringRelatedConvertingThing(&v109, v78);
v79 = (_WORD *)sub_4521C0(&v100, 0);
StringRelatedConvertingThing(&v109, v79);
v80 = (_WORD *)sub_4521C0(&v98, 4);
StringRelatedConvertingThing(&v109, v80);
if ( TestItemWithSomething(SelectedItem, 256, 4263, 7183296) )
v121 = 1;
v81 = (_WORD *)sub_4521C0(&v90, v121);
StringRelatedConvertingThing(&v109, v81);
if ( dword_7BCBF0 && (unsigned int)(dword_7BCBF0 - 1) <= 8 )
ItemTradeImpossible(&v106, (int)&v109);
else
CopyFieldOverOrSomething(&v106, &v109);
if ( !*(_BYTE *)(v122 + 298) || (v82 = *(_DWORD *)(v122 + 128), v82 == 543647084) )
{
v85 = v111;
LABEL_183:
sub_452170(&v106);
if ( (unsigned int)Say_IIOrDraw(&v106) >= 0x3FF )
v107 = 0;
GetTextWidthFileNo(&v118);
v43 = dword_721E40;
v44 = v118;
v87 = v85;
if ( dword_721E40 - v118 <= 0 )
goto LABEL_66;
goto LABEL_186;
}
if ( !dword_7BCBF0 && (!SelectedItem || !*(_DWORD *)((char *)&loc_48E4EB + SelectedItem - 4777179)) )
{
if ( v82 == 543452002 )
{
CopyFieldOverOrSomething(&v109, &v106);
v83 = 2205;
LABEL_180:
v84 = (_WORD *)GetLocaleText(v83);
CopyFieldOverOrSomething(&v106, v84);
StringRelatedConvertingThing(&v106, v119);
StringRelatedConvertingThing(&v106, &v109);
goto LABEL_181;
}
if ( v82 == 544763746 )
{
CopyFieldOverOrSomething(&v109, &v106);
v83 = 2204;
goto LABEL_180;
}
}
LABEL_181:
v85 = 4;
sub_4521C0(&v106, 4);
goto LABEL_183;
}
}
}
}
}
return v6;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment