Skip to content

Commit

Permalink
More checks to save
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacyway committed May 23, 2024
1 parent 8ab45ce commit 634f1b7
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Fika.Core/Coop/GameMode/CoopGame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal sealed class CoopGame : BaseLocalGame<GamePlayerOwner>, IBotGame, IFika
private WavesSpawnScenario wavesSpawnScenario_0;
private NonWavesSpawnScenario nonWavesSpawnScenario_0;
private Func<Player, GamePlayerOwner> func_1;
private bool hasSaved = false;

public FikaDynamicAI DynamicAI { get; private set; }
public RaidSettings RaidSettings { get; private set; }
Expand Down Expand Up @@ -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.
Expand All @@ -1734,7 +1740,7 @@ private void SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam

JsonConverter[] Converters = Traverse.Create(converterClass).Field<JsonConverter[]>("Converters").Value;

SaveProfileRequest SaveRequest = new SaveProfileRequest
SaveProfileRequest SaveRequest = new()
{
Exit = exitStatus.ToString().ToLowerInvariant(),
Profile = player.Profile,
Expand All @@ -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)
Expand Down

0 comments on commit 634f1b7

Please sign in to comment.