From 1e19f9aedf7a04a2a72c5144290fd91382df19e0 Mon Sep 17 00:00:00 2001 From: John Gross Date: Thu, 22 Aug 2019 20:38:35 -0700 Subject: [PATCH] Fix save tracking desync --- Torch/TorchBase.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Torch/TorchBase.cs b/Torch/TorchBase.cs index 063d34c..8128711 100644 --- a/Torch/TorchBase.cs +++ b/Torch/TorchBase.cs @@ -383,12 +383,14 @@ namespace Torch { if (exclusive) { - if (MyAsyncSaving.InProgress || Interlocked.Increment(ref _inProgressSaves) != 1) + if (MyAsyncSaving.InProgress || _inProgressSaves >= 0) { Log.Error("Failed to save game, game is already saving"); return null; } } + + Interlocked.Increment(ref _inProgressSaves); return TorchAsyncSaving.Save(this, timeoutMs).ContinueWith((task, torchO) => { var torch = (TorchBase) torchO;