Skip to content

Commit afe40ba

Browse files
committed
Polished auto config reloading a bit more.
1 parent 1059566 commit afe40ba

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

Core/Configuration/ConfigSystem.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ public static void SaveConfig(string? oldJson = null)
145145
string newJson = SaveConfigInner();
146146

147147
if (newJson != oldJson || oldJson == null) {
148+
lastConfigWatcherWriteTime = DateTime.Now.AddSeconds(0.5d); // Really ensure that this doesn't trigger an automatic config reload.
149+
148150
File.WriteAllText(ConfigPath, newJson);
149151
}
150152
}
@@ -272,7 +274,7 @@ private static void OnConfigDirectoryFileUpdateChanged(object sender, FileSystem
272274
DateTime lastWriteTime = File.GetLastWriteTime(e.FullPath);
273275

274276
if (lastWriteTime > lastConfigWatcherWriteTime) {
275-
lastConfigWatcherWriteTime = lastWriteTime.AddSeconds(1d);
277+
lastConfigWatcherWriteTime = lastWriteTime.AddSeconds(0.1d);
276278

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

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

286-
SoundEngine.PlaySound(sound with { Volume = 0.33f });
288+
try {
289+
SoundEngine.PlaySound(sound with { Volume = 0.33f });
290+
}
291+
catch { }
287292
}
288293
}
289294
}

0 commit comments

Comments
 (0)