Fix save tracking desync

This commit is contained in:
John Gross
2019-08-22 20:38:35 -07:00
parent 1b4c5ace61
commit 1e19f9aedf

View File

@@ -383,12 +383,14 @@ namespace Torch
{ {
if (exclusive) 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"); Log.Error("Failed to save game, game is already saving");
return null; return null;
} }
} }
Interlocked.Increment(ref _inProgressSaves);
return TorchAsyncSaving.Save(this, timeoutMs).ContinueWith((task, torchO) => return TorchAsyncSaving.Save(this, timeoutMs).ContinueWith((task, torchO) =>
{ {
var torch = (TorchBase) torchO; var torch = (TorchBase) torchO;