Skip to content

Commit 5a794ec

Browse files
committed
chore: Bound context for method Main.YouCanSleepNow()
1 parent e7ac417 commit 5a794ec

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using ModFramework;
2+
using Mono.Cecil;
3+
using OTAPI.UnifiedServerProcess.Core.Analysis.MethodCallAnalysis;
4+
using OTAPI.UnifiedServerProcess.Core.FunctionalFeatures;
5+
using OTAPI.UnifiedServerProcess.Core.Patching.Framework;
6+
using OTAPI.UnifiedServerProcess.Loggers;
7+
using System;
8+
using System.Collections.Generic;
9+
using System.Linq;
10+
using System.Text;
11+
using System.Threading.Tasks;
12+
13+
namespace OTAPI.UnifiedServerProcess.Core.Patching.SimplePatching
14+
{
15+
public class SetThreadStatePatcher(ILogger logger, ModuleDefinition module, MethodCallGraph callGraph) : Patcher(logger), IMethodCheckCacheFeature
16+
{
17+
public MethodCallGraph MethodCallGraph => callGraph;
18+
public override string Name => nameof(SetThreadStatePatcher);
19+
20+
public override void Patch() {
21+
this.ForceOverrideContextBoundCheck(module.GetType("Terraria.Main").Method("mfwh_NeverSleep"), true);
22+
this.ForceOverrideContextBoundCheck(module.GetType("Terraria.Main").Method("mfwh_YouCanSleepNow"), true);
23+
}
24+
}
25+
}

src/OTAPI.UnifiedServerProcess/Core/PatchingLogic.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public static void Patch(ILogger logger, ModuleDefinition module) {
3636
.Then(new SimplifyMacrosPatcher(logger, module))
3737
.Then(new RemoveUnusedCodePatcherAtBegin(logger, module))
3838
.Then(new LangManagerPrePatcher(logger, module, analyzers.MethodCallGraph))
39+
.Then(new SetThreadStatePatcher(logger, module, analyzers.MethodCallGraph))
3940

4041
.DefineArgument(new FilterArgumentSource(module, initialMethods))
4142
.RegisterProcessor(new AddModifiedFieldsProcessor(rawModifiedStaticFields, initialStaticFields))

0 commit comments

Comments
 (0)