From 634f1b70c87004ba3eab900719eb99208c6dd29e Mon Sep 17 00:00:00 2001 From: Lacyway <20912169+Lacyway@users.noreply.github.com> Date: Thu, 23 May 2024 11:26:54 +0200 Subject: [PATCH] More checks to save --- Fika.Core/Coop/GameMode/CoopGame.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs index 212fac93..3343d109 100644 --- a/Fika.Core/Coop/GameMode/CoopGame.cs +++ b/Fika.Core/Coop/GameMode/CoopGame.cs @@ -73,6 +73,7 @@ internal sealed class CoopGame : BaseLocalGame, IBotGame, IFika private WavesSpawnScenario wavesSpawnScenario_0; private NonWavesSpawnScenario nonWavesSpawnScenario_0; private Func func_1; + private bool hasSaved = false; public FikaDynamicAI DynamicAI { get; private set; } public RaidSettings RaidSettings { get; private set; } @@ -1721,6 +1722,11 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath) { + if (hasSaved) + { + return; + } + if (fromDeath) { //Since we're bypassing saving on exiting, run this now. @@ -1734,7 +1740,7 @@ private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam JsonConverter[] Converters = Traverse.Create(converterClass).Field("Converters").Value; - SaveProfileRequest SaveRequest = new SaveProfileRequest + SaveProfileRequest SaveRequest = new() { Exit = exitStatus.ToString().ToLowerInvariant(), Profile = player.Profile, @@ -1744,6 +1750,8 @@ private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam }; RequestHandler.PutJson("/raid/profile/save", SaveRequest.ToJson(Converters.AddItem(new NotesJsonConverter()).ToArray())); + + hasSaved = true; } private void StopFromError(string profileId, ExitStatus exitStatus)