Fix hot reload init ordering: move after core objects are created
InitializeForHotReload() was called at the top of Startup() before _killTracker, _chatEventRouter, and _inventoryMonitor were created, causing NullReferenceException. Move the hot reload block to after all core objects are initialized. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
1fff36e3f7
commit
361c2012da
2 changed files with 18 additions and 23 deletions
|
|
@ -154,29 +154,9 @@ namespace MosswartMassacre
|
|||
MyHost = null;
|
||||
}
|
||||
|
||||
// Check if this is a hot reload
|
||||
// Check if this is a hot reload (flag for post-init handling)
|
||||
var isCharacterLoaded = CoreManager.Current.CharacterFilter.LoginStatus == 3;
|
||||
if (IsHotReload || isCharacterLoaded)
|
||||
{
|
||||
// Hot reload detected - reinitialize connections and state
|
||||
WriteToChat("[INFO] Hot reload detected - reinitializing plugin");
|
||||
|
||||
// Reload settings if character is already logged in
|
||||
if (isCharacterLoaded)
|
||||
{
|
||||
try
|
||||
{
|
||||
WriteToChat("Hot reload - reinitializing character-dependent systems");
|
||||
// Don't call LoginComplete - create hot reload specific initialization
|
||||
InitializeForHotReload();
|
||||
WriteToChat("[INFO] Hot reload initialization complete");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToChat($"[ERROR] Hot reload initialization failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
}
|
||||
var needsHotReload = IsHotReload || isCharacterLoaded;
|
||||
|
||||
// Initialize kill tracker (owns the 1-sec stats timer)
|
||||
_killTracker = new KillTracker(
|
||||
|
|
@ -260,6 +240,21 @@ namespace MosswartMassacre
|
|||
// Note: DECAL Harmony patches will be initialized in LoginComplete event
|
||||
// where the chat system is available for error messages
|
||||
|
||||
// Hot reload: run after all core objects are initialized
|
||||
if (needsHotReload && isCharacterLoaded)
|
||||
{
|
||||
try
|
||||
{
|
||||
WriteToChat("[INFO] Hot reload detected - reinitializing plugin");
|
||||
InitializeForHotReload();
|
||||
WriteToChat("[INFO] Hot reload initialization complete");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
WriteToChat($"[ERROR] Hot reload initialization failed: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue