Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool FinalCleanup(string szGameName)
- {
- std::cout << "Polishing CLN's till they shine like a FIN" << std::endl;
- int NumEntries = 0;
- char tmp[32] = { 0 };
- FinalList = new cModel[250];
- int NumItems = 0;//in FinalList
- for (int j = 0; j < sInfo->iNumDumps; ++j)
- {
- for (int i = 0;; ++i)
- {
- strTmp.clear();
- strTmp = sInfo->szGameName;
- strTmp += itoa(j, tmp, 10);
- strTmp += "-";
- strTmp += itoa(i, tmp, 10);
- strTmp += ".cln";
- DumpFileIn.open(strTmp);
- if (!DumpFileIn)
- {
- if (i == 0 && j == 0)
- {
- std::cout << "Could not open initial CLN " << strTmp << std::endl;
- return false;
- }
- break;
- }
- else
- {
- DumpFileIn >> NumEntries;
- cModel tmpModel;
- bool bAlreadyExists = false;
- for (int k = 0; k < NumEntries; ++k)
- {
- DumpFileIn >> tmpModel.primCount;
- DumpFileIn >> tmpModel.NumVertices;
- DumpFileIn >> tmpModel.stride;
- if (NumItems == 0)
- {
- memcpy(&FinalList[0], &DumpFile.cEntries[0], sizeof(cModel));
- NumItems++;
- continue;
- }
- else
- {
- for (int l = 0; l < NumItems; ++l)
- {
- if (FinalList[l].NumVertices == tmpModel.NumVertices &&
- FinalList[l].primCount == tmpModel.primCount &&
- FinalList[l].stride == tmpModel.stride)
- {
- bAlreadyExists = true;
- break;
- }
- }
- if (!bAlreadyExists)
- {
- //std::cout << "Found new entry!" << std::endl;
- memcpy(&FinalList[NumItems], &tmpModel, sizeof(cModel));
- NumItems++;
- continue;
- }
- }
- }
- }
- }
- }
- DumpFileIn.close();
- std::cout << "After all that we have " << NumItems << " unique items" << std::endl;
- std::cout << "Writing them to FIN" << std::endl;
- if (DumpFileOut.is_open())
- {
- std::cout << "DumpFileOut was left open somewhere!" << std::endl;
- DumpFileOut.close();
- }
- strTmp.clear();
- strTmp = sInfo->szGameName;
- strTmp += ".fin";
- DumpFileOut.open(strTmp);
- if (!DumpFileOut)
- {
- std::cout << "Could not create FIN" << std::endl;
- return false;
- }
- else
- {
- DumpFileOut << NumItems;
- for (int i = 0; i < NumItems; ++i)
- {
- DumpFileOut << FinalList->primCount << std::endl;
- DumpFileOut << FinalList->NumVertices << std::endl;
- DumpFileOut << FinalList->stride << std::endl;
- }
- }
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement