Skip to content

Commit

Permalink
fix: autosave saving when off (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bronya-Rand authored Feb 17, 2025
1 parent 82cc65f commit 649ac3b
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions Brio/Game/Core/AutoSaveService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,28 @@ private void OnElapsed(object? sender, ElapsedEventArgs e)

private void AutoSave()
{
try
if (ConfigurationService.Instance.Configuration.AutoSave.AutoSaveSystemEnabled)
{
var scene = _sceneService.GenerateSceneFile();
try
{
var scene = _sceneService.GenerateSceneFile();

byte[] bytes = MessagePackSerializer.Serialize(scene);
byte[] bytes = MessagePackSerializer.Serialize(scene);

var path = Path.Combine(AutoSaveFolder, $"autosave-{DateTime.Now:yyyy-MM-dd}-{DateTime.Now:hh-mm-ss}.brioautosave");
Brio.Log.Verbose($"AutoSaving: {path}");
var path = Path.Combine(AutoSaveFolder, $"autosave-{DateTime.Now:yyyy-MM-dd}-{DateTime.Now:hh-mm-ss}.brioautosave");
Brio.Log.Verbose($"AutoSaving: {path}");

File.WriteAllBytes(path, bytes);
File.WriteAllBytes(path, bytes);

Brio.Log.Verbose($"AutoSaved!");
Brio.Log.Verbose($"AutoSaved!");

Update();
CleanOldSaves();
}
catch(Exception ex)
{
Brio.Log.Error(ex, "Exception AutoSaving!");
Update();
CleanOldSaves();
}
catch(Exception ex)
{
Brio.Log.Error(ex, "Exception AutoSaving!");
}
}
}

Expand Down

0 comments on commit 649ac3b

Please sign in to comment.