diff --git a/Fika.Core/Coop/GameMode/CoopGame.cs b/Fika.Core/Coop/GameMode/CoopGame.cs
index e47f809c..24da8448 100644
--- a/Fika.Core/Coop/GameMode/CoopGame.cs
+++ b/Fika.Core/Coop/GameMode/CoopGame.cs
@@ -1757,16 +1757,7 @@ private void HealthController_DiedEvent(EDamageType obj)
if (FikaPlugin.Instance.ForceSaveOnDeath)
{
- StartCoroutine(SaveOnDeathRoutine());
- }
- }
-
- private IEnumerator SaveOnDeathRoutine()
- {
- Task saveTask = SavePlayer((CoopPlayer)gparam_0.Player, MyExitStatus, null, true);
- while (!saveTask.IsCompleted)
- {
- yield return null;
+ Task.Run(() => SavePlayer((CoopPlayer)gparam_0.Player, MyExitStatus, null, true));
}
}
@@ -1900,11 +1891,11 @@ public override void Stop(string profileId, ExitStatus exitStatus, string exitNa
///
///
///
- private Task SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath)
+ private async Task SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitName, bool fromDeath)
{
if (hasSaved)
{
- return Task.CompletedTask;
+ return;
}
if (fromDeath)
@@ -1918,9 +1909,10 @@ private Task SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam
//Method taken directly from SPT, can be found in the aki-singleplayer assembly as OfflineSaveProfilePatch
Type converterClass = typeof(AbstractGame).Assembly.GetTypes().First(t => t.GetField("Converters", BindingFlags.Static | BindingFlags.Public) != null);
- JsonConverter[] Converters = Traverse.Create(converterClass).Field("Converters").Value;
+ JsonConverter[] converters = Traverse.Create(converterClass).Field("Converters").Value;
+ converters = [.. converters, new NotesJsonConverter()];
- SaveProfileRequest SaveRequest = new()
+ SaveProfileRequest saveRequest = new()
{
Exit = exitStatus.ToString().ToLowerInvariant(),
Profile = player.Profile,
@@ -1929,10 +1921,8 @@ private Task SavePlayer(CoopPlayer player, ExitStatus exitStatus, string exitNam
IsPlayerScav = player.Side is EPlayerSide.Savage
};
- RequestHandler.PutJson("/raid/profile/save", SaveRequest.ToJson(Converters.AddItem(new NotesJsonConverter()).ToArray()));
-
+ await RequestHandler.PutJsonAsync("/raid/profile/save", saveRequest.ToJson(converters));
hasSaved = true;
- return Task.CompletedTask;
}
///
@@ -2179,7 +2169,7 @@ private void FireCallback()
{
Callback endCallback = Traverse.Create(localGame).Field>("callback_0").Value;
- localGame.SavePlayer(localPlayer, exitStatus, exitName, false);
+ Task.Run(() => localGame.SavePlayer(localPlayer, exitStatus, exitName, false));
endCallback(new Result(exitStatus, GClass1304.Now - localGame.dateTime_0, new MetricsClass()));
UIEventSystem.Instance.Enable();