Skip to content

Commit 231a5af

Browse files
authored
Hot reload fixes (#819)
* Avoid log duplication from paket plugin source. * Reset time values on reload.
1 parent 0849504 commit 231a5af

File tree

5 files changed

+13
-1
lines changed

5 files changed

+13
-1
lines changed

NWN.Anvil/src/main/API/Time/Time.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ internal sealed class Service : IUpdateable
3333

3434
public Service()
3535
{
36+
TimeSinceStartup = TimeSpan.Zero;
37+
DeltaTime = TimeSpan.Zero;
3638
Log.Debug(Stopwatch.IsHighResolution ? "Using high resolution loop timer for loop operations..." : "Using system time for loop operations...");
3739
}
3840

NWN.Anvil/src/main/Plugins/IPluginSource.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
using System;
12
using System.Collections.Generic;
23

34
namespace Anvil.Plugins
45
{
5-
internal interface IPluginSource
6+
internal interface IPluginSource : IDisposable
67
{
78
IEnumerable<Plugin> Bootstrap();
89
}

NWN.Anvil/src/main/Plugins/LocalPluginSource.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,7 @@ private IEnumerable<Plugin> CreatePluginsFromPaths(IEnumerable<string> pluginPat
5353

5454
return plugins;
5555
}
56+
57+
public void Dispose() {}
5658
}
5759
}

NWN.Anvil/src/main/Plugins/Paket/PaketPluginSource.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,10 @@ private void OnLogEvent(object sender, Logging.Trace args)
155155
break;
156156
}
157157
}
158+
159+
public void Dispose()
160+
{
161+
Logging.@event.Publish.RemoveHandler(OnLogEvent);
162+
}
158163
}
159164
}

NWN.Anvil/src/main/Plugins/PluginManager.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,8 @@ private void BootstrapPlugins()
252252
throw new Exception("No plugins are available to load, and ANVIL_PREVENT_START_NO_PLUGIN is enabled.\n" +
253253
$"Check your plugins are available at {HomeStorage.Plugins}, or add valid plugins paths using the ANVIL_ADD_PLUGIN_PATHS variable.");
254254
}
255+
256+
pluginSources.DisposeAll();
255257
}
256258

257259
private bool IsUnloadComplete(Dictionary<WeakReference, string> pendingUnloads, int attempt)

0 commit comments

Comments
 (0)