Advertisement
fastman92

createListOfFilesFromImgArchive

Feb 7th, 2012
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.57 KB | None | 0 0
  1. void __cdecl createListOfFilesFromImgArchive(const char *filepath, int ImgDescriptorNum)
  2. {
  3.   FILE *file1; // eax@1
  4.   signed int v3; // ebp@1
  5.   FILE *file2; // esi@1
  6.   char *v5; // edi@5
  7.   int v6; // eax@11
  8.   int v7; // eax@13
  9.   int v8; // eax@15
  10.   int v9; // eax@19
  11.   int v10; // eax@33
  12.   WORD v11; // cx@33
  13.   char v12; // zf@33
  14.   int v13; // eax@35
  15.   int pIndex; // [sp+0h] [bp-3Ch]@8
  16.   int AmountOfFiles; // [sp+4h] [bp-38h]@2
  17.   FILE *file3; // [sp+8h] [bp-34h]@1
  18.   int p_Size; // [sp+Ch] [bp-30h]@32
  19.   int p_Position; // [sp+10h] [bp-2Ch]@32
  20.   char Version; // [sp+14h] [bp-28h]@2
  21.   int v20; // [sp+15h] [bp-27h]@2
  22.   CDirectoryEntry Entry; // [sp+1Ch] [bp-20h]@3
  23.  
  24.   v3 = -1;
  25.   file1 = CFileMgr__Open(filepath, "rb");
  26.   file2 = file1;
  27.   file3 = file1;
  28.   if ( (signed int)file1 > 0 )
  29.   {
  30.     Version = 0;
  31.     v20 = 0;
  32.     CFileMgr__Read(file1, &Version, 4u);
  33.     CFileMgr__Read(file2, &AmountOfFiles, 4u);
  34.     for ( ; AmountOfFiles; file2 = file3 )
  35.     {
  36.       --AmountOfFiles;
  37.       CFileMgr__Read(file2, &Entry, 32u);
  38.       if ( Entry.SizeSecondPriority > dword_8E4CA8 )
  39.         dword_8E4CA8 = Entry.SizeSecondPriority;
  40.       Entry.Name[23] = 0;
  41.       v5 = strchr(Entry.Name, '.');
  42.       if ( !v5 || (signed int)(v5 - Entry.Name) > 20 )
  43.       {
  44.         Entry.Name[23] = 0;
  45.         goto LABEL_39;
  46.       }
  47.       *v5 = 0;
  48.       if ( memicmp(v5 + 1, "DFF", 3) )
  49.       {
  50.         if ( memicmp(v5 + 1, "TXD", 3) )
  51.         {
  52.           if ( memicmp(v5 + 1, "COL", 3) )
  53.           {
  54.             if ( memicmp(v5 + 1, "IPL", 3) )
  55.             {
  56.               if ( memicmp(v5 + 1, "DAT", 3) )
  57.               {
  58.                 if ( memicmp(v5 + 1, "IFP", 3) )
  59.                 {
  60.                   if ( memicmp(v5 + 1, "RRR", 3) )
  61.                   {
  62.                     if ( memicmp(v5 + 1, "SCM", 3) )
  63.                     {
  64.                       *v5 = '.';
  65.                       goto LABEL_39;
  66.                     }
  67.                     v7 = CExternalScripts__allocate(&externalScripts, Entry.Name) + 26230;
  68.                     pIndex = v7;
  69.                   }
  70.                   else
  71.                   {
  72.                     v7 = addPath(Entry.Name) + 25755;
  73.                     pIndex = v7;
  74.                   }
  75.                 }
  76.                 else
  77.                 {
  78.                   v7 = CAnimMgr__getIfpIndexByNameAlways(Entry.Name) + 25575;
  79.                   pIndex = v7;
  80.                 }
  81.               }
  82.               else
  83.               {
  84.                 sscanf(&Entry.Name[5], "%d", &pIndex);
  85.                 v7 = pIndex + 25511;
  86.                 pIndex += 25511;
  87.               }
  88.             }
  89.             else
  90.             {
  91.               v9 = IplFilePool__locate(Entry.Name);
  92.               pIndex = v9;
  93.               if ( v9 == -1 )
  94.                 v9 = allocIplFile(Entry.Name);
  95.               v7 = v9 + 25255;
  96.               pIndex = v7;
  97.             }
  98.           }
  99.           else
  100.           {
  101.             v8 = dummy_410390();
  102.             pIndex = v8;
  103.             if ( v8 == -1 )
  104.               v8 = allocateCollisionFile(Entry.Name);
  105.             v7 = v8 + 25000;
  106.             pIndex = v7;
  107.           }
  108.         }
  109.         else
  110.         {
  111.           v6 = txdIndexByName(Entry.Name);
  112.           pIndex = v6;
  113.           if ( v6 == -1 )
  114.           {
  115.             pIndex = CTxdStore__AddRef(Entry.Name);
  116.             assignPaintjobToVehicle(Entry.Name, pIndex);
  117.             v6 = pIndex;
  118.           }
  119.           v7 = v6 + 20000;
  120.           pIndex = v7;
  121.         }
  122.       }
  123.       else
  124.       {
  125.         if ( !getModelIndexByName(Entry.Name, &pIndex) )
  126.         {
  127.           Entry.Position |= ImgDescriptorNum << 24;
  128.           CImgFile__addHeader(pDirectory, &Entry);
  129.           goto LABEL_39;
  130.         }
  131.         v7 = pIndex;
  132.       }
  133.       if ( !GetLoadedObjectPositionAndSize(&loadedObjectInfo + v7, &p_Position, &p_Size) )
  134.       {
  135.         v11 = Entry.SizeFirstPriority;
  136.         v10 = 20 * pIndex;
  137.         v12 = Entry.SizeFirstPriority == 0;
  138.         *(&loadedObjectInfo.ImgOffset + 20 * pIndex) = ImgDescriptorNum;
  139.         if ( !v12 )
  140.           Entry.SizeSecondPriority = v11;
  141.         SetLoadedObjectInfoPositionAndFileSize(
  142.           (LoadedObjectInfo *)((char *)&loadedObjectInfo + v10),
  143.           Entry.Position,
  144.           Entry.SizeSecondPriority);
  145.         v13 = pIndex;
  146.         *(&loadedObjectInfo.NumOfImgDescriptor + 20 * pIndex) = 0;
  147.         if ( v3 != -1 )
  148.           *(&loadedObjectInfo.NextFileIdInImg + 10 * v3) = v13;
  149.         v3 = v13;
  150.         continue;
  151.       }
  152. LABEL_39:
  153.       v3 = -1;
  154.     }
  155.     --AmountOfFiles;
  156.     CFileMgr__CloseFile(file2);
  157.   }
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement