| 2082 | } |
| 2083 | |
| 2084 | void GameEventHandler::SaveEpisodeContinue(const LevelInitialization& levelInit) |
| 2085 | { |
| 2086 | if (levelInit.LevelName.empty()) { |
| 2087 | return; |
| 2088 | } |
| 2089 | |
| 2090 | auto p = levelInit.LevelName.partition('/'); |
| 2091 | if (!levelInit.IsLocalSession || p[0] == "unknown"_s || levelInit.LevelName == "prince/trainer"_s) { |
| 2092 | return; |
| 2093 | } |
| 2094 | |
| 2095 | std::optional<Episode> currentEpisode = ContentResolver::Get().GetEpisode(p[0]); |
| 2096 | if (!currentEpisode || currentEpisode->FirstLevel == p[2]) { |
| 2097 | return; |
| 2098 | } |
| 2099 | |
| 2100 | const PlayerCarryOver* firstPlayer; |
| 2101 | std::size_t playerCount = levelInit.GetPlayerCount(&firstPlayer); |
| 2102 | |
| 2103 | // Don't save continue in multiplayer |
| 2104 | if (playerCount == 1) { |
| 2105 | auto* episodeContinue = PreferencesCache::GetEpisodeContinue(p[0], true); |
| 2106 | episodeContinue->LevelName = p[2]; |
| 2107 | episodeContinue->State.Flags = EpisodeContinuationFlags::None; |
| 2108 | if (levelInit.CheatsUsed) { |
| 2109 | episodeContinue->State.Flags |= EpisodeContinuationFlags::CheatsUsed; |
| 2110 | } |
| 2111 | |
| 2112 | episodeContinue->State.DifficultyAndPlayerType = ((std::int32_t)levelInit.Difficulty & 0x0f) | (((std::int32_t)firstPlayer->Type & 0x0f) << 4); |
| 2113 | episodeContinue->State.Lives = firstPlayer->Lives; |
| 2114 | episodeContinue->State.Score = firstPlayer->Score; |
| 2115 | episodeContinue->State.ElapsedMilliseconds = levelInit.ElapsedMilliseconds; |
| 2116 | std::memcpy(episodeContinue->State.Gems, firstPlayer->Gems, sizeof(firstPlayer->Gems)); |
| 2117 | std::memcpy(episodeContinue->State.Ammo, firstPlayer->Ammo, sizeof(firstPlayer->Ammo)); |
| 2118 | std::memcpy(episodeContinue->State.WeaponUpgrades, firstPlayer->WeaponUpgrades, sizeof(firstPlayer->WeaponUpgrades)); |
| 2119 | |
| 2120 | PreferencesCache::TutorialCompleted = true; |
| 2121 | PreferencesCache::Save(); |
| 2122 | } else if (!PreferencesCache::TutorialCompleted) { |
| 2123 | PreferencesCache::TutorialCompleted = true; |
| 2124 | PreferencesCache::Save(); |
| 2125 | } |
| 2126 | } |
| 2127 | |
| 2128 | void GameEventHandler::ExtractPakFile(StringView pakFile, StringView targetPath) |
| 2129 | { |
nothing calls this directly
no test coverage detected