Code
481/// Helper function to read in an array of data entries and remap them to new locations482/// Note: This assumes the array in the stream does NOT have a lead count value.483template<typename TType>484bool ReadAndRemapDataArray(FDataStream& kStream, int iSrcCount, TType* pvDest, int iDestCount, const int* piaRemap)485{486 TType* pvBuffer = (TType*)_malloca(iSrcCount * sizeof(TType));487 kStream.ReadIt(iSrcCount * sizeof(TType), (void*)pvBuffer);488489 bool bRemapSuccess = true;490 for(int i = 0; i < iSrcCount; ++i)491 {492 int iDestIndex = piaRemap[i]; // The new index493 if(iDestIndex >= 0 && iDestIndex < iDestCount)494 {495 pvDest[iDestIndex] = pvBuffer[i];496 }497 else498 bRemapSuccess = false;499 }500 _freea(pvBuffer);501 return bRemapSuccess;502}