MCPcopy Create free account
hub / github.com/doldecomp/mkdd / checkData

Method checkData

src/Osako/SystemFile.cpp:240–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238}
239
240void SystemFile::checkData()
241{
242 mValidSections = 0;
243 for (u8 i = 0; i < 2; i++)
244 {
245 mFileData[i].mSystemRecord.crypt(mFileData[i].mCheckData.mKey);
246 if (isCheckDataValid(mFileData[i]))
247 mValidSections |= 1 << i;
248 }
249
250 if (isCheckDataValid(mHeader))
251 mValidSections |= 4;
252 else
253 mValidSections &= ~4;
254
255 switch (mValidSections & 3)
256 {
257 case 0: // no sections are valid
258 mSectionCount = 0;
259 break;
260 case 1: // section 1 is valid
261 case 2: // section 2 is valid
262 mSectionCount = 1;
263 mCurrentIndex = (mValidSections & 3) - 1;
264 mBackupIndex = 1 - mCurrentIndex;
265 break;
266 case 3: // both sections are valid
267 mSectionCount = 2;
268
269 // determine which save is older
270 if (mFileData[0].mSystemRecord.mTimesFetched >= mFileData[1].mSystemRecord.mTimesFetched)
271 {
272 mCurrentIndex = 0;
273 mBackupIndex = 1;
274 }
275 else
276 {
277 mCurrentIndex = 1;
278 mBackupIndex = 0;
279 }
280 break;
281 }
282
283 mActiveSave = mCurrentIndex;
284}
285
286bool SystemFile::isSavable()
287{

Callers

nothing calls this directly

Calls 1

cryptMethod · 0.45

Tested by

no test coverage detected