MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / SaveCurrentStateIfAny

Method SaveCurrentStateIfAny

Sources/Main.cpp:796–819  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

794}
795
796bool 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
821void GameEventHandler::RemoveResumableStateIfAny()
822{

Callers 1

GoToMainMenuMethod · 0.80

Calls 3

getMethod · 0.45
IsLocalSessionMethod · 0.45

Tested by

no test coverage detected