Replace AchievementInitializer MM IL with static hook
This commit is contained in:
parent
337f15c0ef
commit
90f1d49887
1 changed files with 4 additions and 6 deletions
|
|
@ -447,7 +447,7 @@ namespace TShockAPI
|
||||||
// Initialize the AchievementManager, which is normally only done on clients.
|
// Initialize the AchievementManager, which is normally only done on clients.
|
||||||
Game._achievements = new AchievementManager();
|
Game._achievements = new AchievementManager();
|
||||||
|
|
||||||
IL.Terraria.Initializers.AchievementInitializer.Load += OnAchievementInitializerLoad;
|
OTAPI.Hooks.Initializers.AchievementInitializerLoad += OnAchievementInitializerLoad;
|
||||||
|
|
||||||
// Actually call AchievementInitializer.Load, which is also normally only done on clients.
|
// Actually call AchievementInitializer.Load, which is also normally only done on clients.
|
||||||
AchievementInitializer.Load();
|
AchievementInitializer.Load();
|
||||||
|
|
@ -496,11 +496,9 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void OnAchievementInitializerLoad(ILContext il)
|
private static void OnAchievementInitializerLoad(object sender, OTAPI.Hooks.Initializers.AchievementInitializerLoadEventArgs args)
|
||||||
{
|
{
|
||||||
// Modify AchievementInitializer.Load to remove the Main.netMode == 2 check (occupies the first 4 IL instructions)
|
args.ShouldLoad = true;
|
||||||
for (var i = 0; i < 4; i++)
|
|
||||||
il.Body.Instructions.RemoveAt(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void CrashReporter_HeapshotRequesting(object sender, EventArgs e)
|
protected void CrashReporter_HeapshotRequesting(object sender, EventArgs e)
|
||||||
|
|
@ -524,7 +522,7 @@ namespace TShockAPI
|
||||||
}
|
}
|
||||||
SaveManager.Instance.Dispose();
|
SaveManager.Instance.Dispose();
|
||||||
|
|
||||||
IL.Terraria.Initializers.AchievementInitializer.Load -= OnAchievementInitializerLoad;
|
OTAPI.Hooks.Initializers.AchievementInitializerLoad -= OnAchievementInitializerLoad;
|
||||||
|
|
||||||
ModuleManager.Dispose();
|
ModuleManager.Dispose();
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue