| 794 | } |
| 795 | |
| 796 | bool GameEventHandler::SaveCurrentStateIfAny() |
| 797 | { |
| 798 | ZoneScopedNC("GameEventHandler::SaveCurrentStateIfAny", 0x888888); |
| 799 | |
| 800 | if (auto* levelHandler = runtime_cast<LevelHandler>(_currentHandler.get())) { |
| 801 | if (levelHandler->IsLocalSession()) { |
| 802 | auto configDir = PreferencesCache::GetDirectory(); |
| 803 | auto s = fs::Open(fs::CombinePath(configDir, StateFileName), FileAccess::Write); |
| 804 | if (*s) { |
| 805 | s->WriteValueAsLE<std::uint64_t>(0x2095A59FF0BFBBEF); // Signature |
| 806 | s->WriteValue<std::uint8_t>(ContentResolver::StateFile); |
| 807 | s->WriteValueAsLE<std::uint16_t>(StateVersion); |
| 808 | |
| 809 | DeflateWriter co(*s); |
| 810 | if (!levelHandler->SerializeResumableToStream(co)) { |
| 811 | LOGE("Failed to save current state"); |
| 812 | } |
| 813 | return true; |
| 814 | } |
| 815 | } |
| 816 | } |
| 817 | |
| 818 | return false; |
| 819 | } |
| 820 | |
| 821 | void GameEventHandler::RemoveResumableStateIfAny() |
| 822 | { |
no test coverage detected