Advertisement
Zgragselus

Copilot bug

Jul 5th, 2024
814
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1.     // At start ensure that all data records are loaded
  2.     for (size_t i = 0; i < mHeaderRecords.size(); i++)
  3.     {
  4.         if (mHeaderRecords[i].GetFilename() != nullptr && mHeaderRecords[i].GetFilename()[0] != '\0' && mHeaderRecords[i].GetOffset() != 0)
  5.         {
  6.             if (mDataRecords[i] == nullptr)
  7.             {
  8.                 ReadRecord(i);
  9.             }
  10.         }
  11.     }
  12.  
  13.     // Prior to saving, offsets have to be re-calculated, skipping the files that are not supposed
  14.     // to be saved (i.e. those with empty names)
  15.     size_t offset = mHeader.GetSize();
  16.     size_t count = 0;
  17.  
  18.     for (size_t i = 0; i < mHeaderRecords.size(); i++)
  19.     {
  20.         if (mHeaderRecords[i].GetFilename() == nullptr || mHeaderRecords[i].GetFilename()[0] == '\0')
  21.         {
  22.             offset += 0;
  23.         }
  24.         else
  25.         {
  26.             offset += mDataRecords[i]->GetSize();
  27.             count++;
  28.         }
  29.     }
  30.  
  31.     // Update record count in header
  32.     mHeader.mRecordCount = count;
  33.  
  34.     offset += mBody.GetSize();
  35.  
  36.     for (size_t i = 0; i < mHeaderRecords.size(); i++)
  37.     {
  38.         if (mHeaderRecords[i].GetFilename() == nullptr || mHeaderRecords[i].GetFilename()[0] == '\0')
  39.         {
  40.             mHeaderRecords[i].mOffset = 0;
  41.         }
  42.         else
  43.         {
  44.             mHeaderRecords[i].mOffset = offset;
  45.             offset += mDataRecords[i]->GetSize();
  46.         }
  47.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement