Skip to content

Instantly share code, notes, and snippets.

@ezdiy
Created September 12, 2017 08:09
Show Gist options
  • Save ezdiy/b63709c02ddacc471cecab91f5369c11 to your computer and use it in GitHub Desktop.
Save ezdiy/b63709c02ddacc471cecab91f5369c11 to your computer and use it in GitHub Desktop.
int __thiscall apply_chara_light(void *this, unsigned __int8 light)
{
void *chara_struct; // edi@1
int v3; // ebp@1
int v4; // eax@2
int v5; // esi@3
int v6; // eax@4
int v7; // esi@5
int v8; // eax@6
int v9; // eax@8
int v10; // ebx@10
int v11; // ecx@10
int v12; // ebx@10
bool v13; // zf@10
int v14; // edx@11
int v15; // esi@11
int v16; // edx@19
int v17; // edi@20
int v18; // edx@21
int v19; // eax@21
int v20; // edi@21
bool v21; // sf@21
int v22; // eax@22
int v23; // esi@23
int v24; // ecx@24
char v26; // [sp+0h] [bp-448h]@0
int v27; // [sp+18h] [bp-430h]@10
int v28; // [sp+1Ch] [bp-42Ch]@6
int v29; // [sp+20h] [bp-428h]@6
__int16 Src; // [sp+24h] [bp-424h]@1
char v31; // [sp+26h] [bp-422h]@1
__int16 v32; // [sp+22Ch] [bp-21Ch]@1
char v33; // [sp+22Eh] [bp-21Ah]@1
int v34; // [sp+444h] [bp-4h]@6
chara_struct = this;
v3 = 0;
v32 = 0;
memset(&v33, 0, 0x206u);
Src = 0;
memset(&v31, 0, 0x206u);
if ( *((_DWORD *)chara_struct + 25) )
{
v4 = *((_DWORD *)chara_struct + 5);
sub_603B30(*((_DWORD *)chara_struct + 25));
*((_BYTE *)chara_struct + 69) = light;
if ( light ) // // This builds up filename according to 'light' value
{
v6 = *((_DWORD *)chara_struct + 7);
if ( v6 )
{
sub_597E00(v6, 260, L"data/jg2p01_00_00.pp", v26);
v7 = *((_DWORD *)chara_struct + 7);
sub_598140(260, (const char *)&off_72CAA4, &Str, light);
}
}
else
{
sub_597E00(*((_DWORD *)chara_struct + 8), 260, L"data/jg2e01_00_00.pp", v26);
v5 = *((_DWORD *)chara_struct + 8);
sub_598140(260, (const char *)&off_72CA80, &Str);
}
sub_402770(&Src, (int)&v29);
v34 = 0;
sub_402770(&v32, (int)&v28);
LOBYTE(v34) = 1;
load_xl_file(
(int)&v28,
*((_DWORD *)chara_struct + 5),
*((_DWORD *)chara_struct + 25),
*((_DWORD *)chara_struct + 4) + 28,
&v29);
LOBYTE(v34) = 0;
v8 = v28 - 16;
if ( _InterlockedDecrement((volatile signed __int32 *)(v28 - 16 + 12)) <= 0 )
(*(void (__stdcall **)(int))(**(_DWORD **)v8 + 4))(v8);
v34 = -1;
v9 = v29 - 16;
if ( _InterlockedDecrement((volatile signed __int32 *)(v29 - 16 + 12)) <= 0 )
(*(void (__stdcall **)(int))(**(_DWORD **)v9 + 4))(v9);
v10 = *((_DWORD *)chara_struct + 14);
v11 = *((_DWORD *)chara_struct + 25);
*((_DWORD *)chara_struct + 111) = 0;
*((_DWORD *)chara_struct + 112) = 0;
v12 = v10 + 2;
v13 = *(_BYTE *)(v11 + 748) == 0;
v27 = 0;
if ( !v13 )
{
do
{
v14 = *(_DWORD *)(*((_DWORD *)chara_struct + 25) + 752);
v15 = v14 + v3;
if ( *(_BYTE *)(v14 + v3 + 8) != 15 && *(_BYTE *)(v14 + v3 + 8) != 14 )
*(_BYTE *)(v15 + 8) = v12;
if ( v15 )
{
if ( !strncmp("cam", *(const char **)(v15 + 4), 3u) )
*((_DWORD *)chara_struct + 111) = v15;
if ( !strncmp("rim", *(const char **)(v15 + 4), 3u) )
*((_DWORD *)chara_struct + 112) = v15;
}
v16 = *(_BYTE *)(*((_DWORD *)chara_struct + 25) + 748);
v3 += 0x18C;
++v27;
}
while ( v27 < v16 );
}
v17 = *((_DWORD *)chara_struct + 25);
if ( v17 )
{
v18 = *(_DWORD *)(v17 + 0x218);
v19 = *(_DWORD *)(v18 + 12);
v20 = 0;
v13 = *(_DWORD *)(v18 + 8) == 0;
v21 = *(_DWORD *)(v18 + 8) < 0;
*(_BYTE *)(v18 + 445) = v12;
if ( !v21 && !v13 )
{
v22 = v19 + 8;
do
{
v23 = *(_DWORD *)(v22 + 4);
v13 = *(_DWORD *)v22 == 0;
v21 = *(_DWORD *)v22 < 0;
*(_BYTE *)(v22 + 437) = v12;
if ( !v21 && !v13 )
{
do
{
v22 = apply_value_to_frame(v23, v12);
v23 += 0x42F4;
}
while ( v24 + 1 < *(_DWORD *)v22 );
}
++v20;
v22 += 0x42F4;
}
while ( v20 < *(_DWORD *)(v18 + 8) );
}
}
}
return sub_689A59();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment