Advertisement
Guest User

mdldmp

a guest
Mar 4th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.33 KB | None | 0 0
  1. bool FinalCleanup(string szGameName)
  2. {
  3.     std::cout << "Polishing CLN's till they shine like a FIN" << std::endl;
  4.     int NumEntries = 0;
  5.     char tmp[32] = { 0 };
  6.     FinalList = new cModel[250];
  7.     int NumItems = 0;//in FinalList
  8.     for (int j = 0; j < sInfo->iNumDumps; ++j)
  9.     {
  10.         for (int i = 0;; ++i)
  11.         {
  12.             strTmp.clear();
  13.             strTmp = sInfo->szGameName;
  14.             strTmp += itoa(j, tmp, 10);
  15.             strTmp += "-";
  16.             strTmp += itoa(i, tmp, 10);
  17.             strTmp += ".cln";
  18.             DumpFileIn.open(strTmp);
  19.             if (!DumpFileIn)
  20.             {
  21.                 if (i == 0 && j == 0)
  22.                 {
  23.                     std::cout << "Could not open initial CLN " << strTmp << std::endl;
  24.                     return false;
  25.                 }
  26.                 break;
  27.             }
  28.             else
  29.             {
  30.                 DumpFileIn >> NumEntries;
  31.                 cModel tmpModel;
  32.                 bool bAlreadyExists = false;
  33.                 for (int k = 0; k < NumEntries; ++k)
  34.                 {
  35.                     DumpFileIn >> tmpModel.primCount;
  36.                     DumpFileIn >> tmpModel.NumVertices;
  37.                     DumpFileIn >> tmpModel.stride;
  38.                     if (NumItems == 0)
  39.                     {
  40.                         memcpy(&FinalList[0], &DumpFile.cEntries[0], sizeof(cModel));
  41.                         NumItems++;
  42.                         continue;
  43.                     }
  44.                     else
  45.                     {
  46.                         for (int l = 0; l < NumItems; ++l)
  47.                         {
  48.                             if (FinalList[l].NumVertices == tmpModel.NumVertices &&
  49.                                 FinalList[l].primCount == tmpModel.primCount &&
  50.                                 FinalList[l].stride == tmpModel.stride)
  51.                             {
  52.                                 bAlreadyExists = true;
  53.                                 break;
  54.                             }
  55.                         }
  56.                         if (!bAlreadyExists)
  57.                         {
  58.                             //std::cout << "Found new entry!" << std::endl;
  59.                             memcpy(&FinalList[NumItems], &tmpModel, sizeof(cModel));
  60.                             NumItems++;
  61.                             continue;
  62.                         }
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     }
  68.     DumpFileIn.close();
  69.     std::cout << "After all that we have " << NumItems << " unique items" << std::endl;
  70.     std::cout << "Writing them to FIN" << std::endl;
  71.     if (DumpFileOut.is_open())
  72.     {
  73.         std::cout << "DumpFileOut was left open somewhere!" << std::endl;
  74.         DumpFileOut.close();
  75.     }
  76.     strTmp.clear();
  77.     strTmp = sInfo->szGameName;
  78.     strTmp += ".fin";
  79.     DumpFileOut.open(strTmp);
  80.  
  81.     if (!DumpFileOut)
  82.     {
  83.         std::cout << "Could not create FIN" << std::endl;
  84.         return false;
  85.     }
  86.     else
  87.     {
  88.         DumpFileOut << NumItems;
  89.         for (int i = 0; i < NumItems; ++i)
  90.         {
  91.             DumpFileOut << FinalList->primCount << std::endl;
  92.             DumpFileOut << FinalList->NumVertices << std::endl;
  93.             DumpFileOut << FinalList->stride << std::endl;
  94.         }
  95.     }
  96.     return true;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement