Skip to content

Decompiled : Decoding AID

iamkisly edited this page Dec 18, 2016 · 6 revisions
//----- (0046F8B0) --------------------------------------------------------
int __cdecl sub_46F8B0(int a1, char *a2)
{
  unsigned int v3; // eax@3
  unsigned int v4; // esi@3
  unsigned int v5; // eax@3
  int v6; // edi@19
  int v7; // ebp@20
  int v8; // eax@23
  int v9; // ebp@23
  char v10; // bl@23
  int v11; // eax@26
  int v12; // edi@26
  int v13; // eax@26
  char v14; // cl@27
  int v15; // ebx@32
  int v16; // eax@32
  int v17; // ebp@32
  int v18; // eax@34
  int v19; // edi@34
  int v20; // eax@34
  char v21; // al@36
  char v22; // bl@41
  int v23; // eax@41
  int v24; // edi@41
  int v25; // eax@41
  char v26; // al@43
  int v27; // eax@53
  int v28; // eax@62
  char v29; // [sp+13h] [bp-Dh]@20
  int v30; // [sp+14h] [bp-Ch]@24
  int v31; // [sp+18h] [bp-8h]@13
  int v32; // [sp+1Ch] [bp-4h]@14
  char v33; // [sp+24h] [bp+4h]@26
  char v34; // [sp+24h] [bp+4h]@34
  char v35; // [sp+24h] [bp+4h]@41

  if ( !dword_5AA2B8 )
    return 13;
  v3 = sub_46F2E0(a1);
  v4 = v3;
  v5 = sub_516C10(v3); // a1 >> 28
  if ( !v5 )
  {
    if ( !sub_454AB0(v4, a2) ) //GET_TILE_PATH
      return 16;
    return 0;
  }
  if ( v5 == 1 )
  {
    if ( !sub_4579A0(v4, a2) )
      return 16;
    return 0;
  }
  if ( v5 == 3 )
  {
    if ( !sub_49FC50(v4, a2) )
      return 16;
    return 0;
  }
  if ( v5 == 4 )
  {
    v31 = 1000 * sub_518810(v4);
    v31 += sub_516C20(v4);
    if ( sub_452240(dword_5AA2B4, &v31) )
    {
      sprintf(a2, aArtSceneryS, v32);
      return 0;
    }
    return 16;
  }
  if ( v5 == 7 )
  {
    v31 = 1000 * sub_518B70(v4);
    v31 += sub_516C20(v4);
    if ( sub_452240(dword_5AA29C, &v31) )
    {
      sprintf(a2, aArtContainerS, v32);
      return 0;
    }
    return 16;
  }
  if ( v5 == 2 )
  {
    v6 = sub_518540(v4);
    if ( v6 < 9 )
    {
      v7 = sub_5183B0(v4);
      v29 = byte_57DA80[sub_5184C0(v4)];
      if ( v6 == 4 || v6 == 6 )
        v29 = byte_57DA82;
      v8 = sub_518330(v4);
      v9 = (int)*(&off_57DA84 + v7);
      v10 = v8;
      if ( v8 == 24 )
      {
        v30 = (int)aXx;
        v29 = byte_57DA82;
      }
      else
      {
        v30 = (int)*(&off_57DA98 + v6);
      }
      v11 = sub_518660(v4);
      v12 = v11;
      v33 = byte_57DA7C[v11];
      v13 = sub_5185E0(v4);
      if ( v13 != 7 || (v14 = byte_57DABF, v12 != 1) )
        v14 = byte_57DABC[v13];
      sprintf(a2, aArtCritterSCSC, v9, v29, v9, v29, v30, v33, v14, (char)(v10 + 97));
      return 0;
    }
    return 16;
  }
  if ( v5 != 12 )
  {
    if ( v5 == 13 )
    {
      v31 = sub_516C20(v4);
      if ( sub_452240(dword_5AA294, &v31) )
      {
        v22 = sub_518330(v4);
        v23 = sub_518660(v4);
        v24 = v23;
        v35 = byte_57DA7C[v23];
        v25 = sub_5185E0(v4);
        if ( v25 != 7 || v24 != 1 )
          v26 = byte_57DABC[v25];
        else
          v26 = byte_57DABF;
        sprintf(a2, aArtUnique_npcS, v32, v32, v35, v26, (char)(v22 + 97));
        return 0;
      }
      return 16;
    }
    if ( v5 == 5 )
    {
      v31 = sub_516C20(v4);
      if ( sub_452240(dword_5AA2AC, &v31) )
      {
        sprintf(a2, aArtInterfaceS, v32);
        return 0;
      }
      return 16;
    }
    if ( v5 == 9 )
    {
      if ( !sub_457D40(v4, a2) )
        return 16;
      return 0;
    }
    if ( v5 == 10 )
    {
      v27 = sub_4EA600(v4, a2);
    }
    else
    {
      if ( v5 != 6 )
      {
        if ( v5 == 11 )
        {
          sub_457E60(v4, a2);
          return 0;
        }
        if ( v5 != 14 )
          return 16;
        v31 = sub_516C20(v4);
        if ( !sub_452240(dword_5AA290, &v31) )
          return 16;
        v28 = sub_5190A0(v4);
        sprintf(a2, aArtEye_candyS_, v32, byte_57DACC[v28]);
        return 0;
      }
      v27 = sub_4FAD10(v4, a2);
    }
    if ( !v27 )
      return 16;
    return 0;
  }
  v31 = sub_518430(v4);
  if ( !sub_452240(dword_5AA28C, &v31) )
    return 16;
  v15 = sub_518330(v4);
  v16 = sub_518540(v4);
  v17 = (int)aXx;
  if ( v15 != 24 )
    v17 = (int)*(&off_57DA98 + v16);
  v18 = sub_518660(v4);
  v19 = v18;
  v34 = byte_57DA7C[v18];
  v20 = sub_5185E0(v4);
  if ( v20 != 7 || v19 != 1 )
    v21 = byte_57DABC[v20];
  else
    v21 = byte_57DABF;
  sprintf(a2, aArtMonsterSSSC, v32, v32, v17, v34, v21, (char)(v15 + 97));
  return 0;
}
// 57DA82: using guessed type char byte_57DA82;
// 57DA84: using guessed type void *off_57DA84;
// 57DA98: using guessed type void *off_57DA98;
// 57DABF: using guessed type char byte_57DABF;
// 5AA2B8: using guessed type int dword_5AA2B8;