Skip to content

Commit

Permalink
Polished auto config reloading a bit more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mirsario committed Jun 6, 2022
1 parent 1059566 commit afe40ba
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions Core/Configuration/ConfigSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ public static void SaveConfig(string? oldJson = null)
string newJson = SaveConfigInner();

if (newJson != oldJson || oldJson == null) {
lastConfigWatcherWriteTime = DateTime.Now.AddSeconds(0.5d); // Really ensure that this doesn't trigger an automatic config reload.

File.WriteAllText(ConfigPath, newJson);
}
}
Expand Down Expand Up @@ -272,7 +274,7 @@ private static void OnConfigDirectoryFileUpdateChanged(object sender, FileSystem
DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);

if (lastWriteTime > lastConfigWatcherWriteTime) {
lastConfigWatcherWriteTime = lastWriteTime.AddSeconds(1d);
lastConfigWatcherWriteTime = lastWriteTime.AddSeconds(0.1d);

Thread.Sleep(50); // Wait a bit, because the file is frequently still being written to here.

Expand All @@ -283,7 +285,10 @@ private static void OnConfigDirectoryFileUpdateChanged(object sender, FileSystem
if (!Main.dedServ) {
var sound = Common.Magic.MagicWeapon.MagicBlastSound;

SoundEngine.PlaySound(sound with { Volume = 0.33f });
try {
SoundEngine.PlaySound(sound with { Volume = 0.33f });
}
catch { }
}
}
}
Expand Down

0 comments on commit afe40ba

Please sign in to comment.