bool CSavestateWriter::Initialize(const CGameClient* gameClient, uint64_t frameHistoryCount) { m_savestate.Reset(); m_fps = 0.0; m_fps = gameClient->Timing().GetFrameRate(); CDateTime now = CDateTime::GetCurrentDateTime(); std::string label = now.GetAsLocalizedDateTime(); m_savestate.SetType(SAVETYPE::MANUAL); m_savestate.SetLabel(label); m_savestate.SetGameClient(gameClient->ID()); m_savestate.SetGamePath(gameClient->GetGamePath()); m_savestate.SetTimestamp(now); m_savestate.SetPlaytimeFrames(frameHistoryCount); m_savestate.SetPlaytimeWallClock(frameHistoryCount / m_fps); //! @todo Accumulate playtime instead of deriving it //! @todo Get CRC from game data instead of filename Crc32 crc; crc.Compute(gameClient->GetGamePath()); m_savestate.SetGameCRC(StringUtils::Format("%08x", (unsigned __int32)crc)); m_savestate.SetPath(CSavestateUtils::MakePath(m_savestate)); if (m_savestate.Path().empty()) CLog::Log(LOGDEBUG, "Failed to calculate savestate path"); if (m_fps == 0.0) return false; // Sanity check return !m_savestate.Path().empty(); }
TEST(TestCrc32, Compute_1) { Crc32 a; uint32_t varcrc; a.Compute(refdata, sizeof(refdata) - 1); varcrc = a; EXPECT_EQ(0xa4eb60e3, varcrc); }
TEST(TestCrc32, Compute_2) { Crc32 a; uint32_t varcrc; CStdString s = refdata; a.Compute(s); varcrc = a; EXPECT_EQ(0xa4eb60e3, varcrc); }