Skip to content

Commit 02da3fe

Browse files
committed
Merge branch 'upcoming' of https://github.com/SignatureBeef/Open-Terraria-API into upcoming
2 parents bb194d1 + 257cac8 commit 02da3fe

File tree

11 files changed

+68
-66
lines changed

11 files changed

+68
-66
lines changed

.config/dotnet-tools.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"dotnet-ilverify": {
6-
"version": "5.0.0",
6+
"version": "9.0.0",
77
"commands": [
88
"ilverify"
99
]

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
runs-on: ubuntu-latest,
2929
},
3030
{
31-
name: macOS,
31+
name: MacOS,
3232
runs-on: macos-latest,
3333
}
3434
]

OTAPI.Client.Launcher/MainWindow.axaml.cs

-48
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,11 @@ You should have received a copy of the GNU General Public License
2020
using Avalonia.Controls;
2121
using Avalonia.Interactivity;
2222
using Avalonia.Markup.Xaml;
23-
using Mono.Cecil;
24-
using Mono.Cecil.Cil;
2523
using OTAPI.Client.Launcher.Targets;
2624
using OTAPI.Common;
2725
using OTAPI.Patcher.Targets;
2826
using System;
2927
using System.IO;
30-
using System.Linq;
3128
using System.Runtime.InteropServices;
3229
using System.Threading.Tasks;
3330

@@ -82,8 +79,6 @@ public MainWindow()
8279

8380
if (Program.ConsoleWriter is not null)
8481
Program.ConsoleWriter.LineReceived += OnConsoleLineReceived;
85-
86-
PatchMonoMod();
8782
}
8883

8984
private void OnConsoleLineReceived(string line)
@@ -246,47 +241,4 @@ public void OnInstall(object sender, RoutedEventArgs e)
246241
}
247242
});
248243
}
249-
250-
/// <summary>
251-
/// Current MonoMod is outdated, and the new reorg is not ready yet, however we need v25 RD for NET9, yet Patcher v22 is the latest, and is not compatible with v25.
252-
/// Ultimately the problem is OTAPI Client using both at once, unlike the server setup which doesnt.
253-
/// For now, the intention is to replace the entire both with "return new string[0];" to prevent the GAC IL from being used (which it isn't anyway)
254-
/// </summary>
255-
void PatchMonoMod()
256-
{
257-
var bin = File.ReadAllBytes("MonoMod.dll");
258-
using MemoryStream ms = new(bin);
259-
var asm = AssemblyDefinition.ReadAssembly(ms);
260-
var modder = asm.MainModule.Types.Single(x => x.FullName == "MonoMod.MonoModder");
261-
var gacPaths = modder.Methods.Single(m => m.Name == "get_GACPaths");
262-
var il = gacPaths.Body.GetILProcessor();
263-
if (il.Body.Instructions.Count != 3)
264-
{
265-
il.Body.Instructions.Clear();
266-
il.Emit(OpCodes.Ldc_I4_0);
267-
il.Emit(OpCodes.Newarr, asm.MainModule.ImportReference(typeof(string)));
268-
il.Emit(OpCodes.Ret);
269-
270-
// clear MonoModder.MatchingConditionals(cap, asmName), with "return false;"
271-
var mc = modder.Methods.Single(m => m.Name == "MatchingConditionals" && m.Parameters.Count == 2 && m.Parameters[1].ParameterType.Name == "AssemblyNameReference");
272-
il = mc.Body.GetILProcessor();
273-
mc.Body.Instructions.Clear();
274-
mc.Body.Variables.Clear();
275-
mc.Body.ExceptionHandlers.Clear();
276-
il.Emit(OpCodes.Ldc_I4_1);
277-
il.Emit(OpCodes.Ret);
278-
279-
var writerParams = modder.Methods.Single(m => m.Name == "get_WriterParameters");
280-
il = writerParams.Body.GetILProcessor();
281-
var get_Current = writerParams.Body.Instructions.Single(x => x.Operand is MethodReference mref && mref.Name == "get_Current");
282-
// replace get_Current with a number, and remove the bitwise checks
283-
il.Remove(get_Current.Next);
284-
il.Remove(get_Current.Next);
285-
il.Replace(get_Current, Instruction.Create(
286-
OpCodes.Ldc_I4, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 37 : 0
287-
));
288-
289-
asm.Write("MonoMod.dll");
290-
}
291-
}
292244
}

OTAPI.Client.Launcher/OTAPI.Client.Launcher.csproj

+3-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@
5353
</ItemGroup>
5454
<ItemGroup>
5555
<PackageReference Include="ImGui.NET" Version="1.91.0.1" GeneratePathProperty="true" />
56-
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.12" GeneratePathProperty="true" />
57-
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.12" GeneratePathProperty="true" />
58-
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.12" GeneratePathProperty="true" />
56+
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.13" GeneratePathProperty="true" />
57+
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.13" GeneratePathProperty="true" />
58+
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.13" GeneratePathProperty="true" />
5959
<PackageReference Include="SharpZipLib" Version="1.4.2" />
6060
<PackageReference Include="System.Drawing.Common" Version="9.0.0" />
6161
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />

OTAPI.Patcher/NugetPackageBuilder.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void Build(ModFwModder modder)
5959
{
6060
(typeof(ModFwModder).Assembly.GetName().Name, Version: GetNugetVersionFromAssembly<ModFwModder>()),
6161
(typeof(MonoMod.MonoModder).Assembly.GetName().Name, Version: typeof(MonoMod.MonoModder).Assembly.GetName().Version.ToString()),
62-
(typeof(MonoMod.RuntimeDetour.Detour).Assembly.GetName().Name, Version: typeof(MonoMod.RuntimeDetour.Detour).Assembly.GetName().Version.ToString()),
62+
(typeof(MonoMod.RuntimeDetour.DetourBase).Assembly.GetName().Name, Version: typeof(MonoMod.RuntimeDetour.DetourBase).Assembly.GetName().Version.ToString()),
6363
(steamworks.Name, Version: steamworks.Version.ToString()),
6464
(newtonsoft.Name, Version: GetNugetVersionFromAssembly<Newtonsoft.Json.JsonConverter>().Split('+')[0] ),
6565
};

OTAPI.Patcher/OTAPI.Patcher.csproj

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,19 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net9.0</TargetFramework>
6-
<Version>3.2.1</Version>
6+
<Version>3.2.3</Version>
77
<PreserveCompilationContext>true</PreserveCompilationContext>
88
<RuntimeIdentifiers>win;osx;linux;</RuntimeIdentifiers>
99
<Nullable>enable</Nullable>
1010
<PackageReleaseNotes>Terraria 1.4.4.9 on .NET9</PackageReleaseNotes>
1111
</PropertyGroup>
1212
<ItemGroup>
13-
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.12" />
14-
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.12" />
15-
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.12" />
13+
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.13" />
14+
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.13" />
15+
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.13" />
1616
<PackageReference Include="Steamworks.NET" Version="2024.8.0" />
1717
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />
18+
<PackageReference Include="MonoMod.RuntimeDetour" Version="25.2.2" />
1819
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1920
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
2021
<PackageReference Include="System.Security.Permissions" Version="9.0.0" />

OTAPI.Patcher/Targets/PatchTargets.cs

+49
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ You should have received a copy of the GNU General Public License
1818
*/
1919
using System;
2020
using System.Collections.Generic;
21+
using System.IO;
22+
using System.Linq;
23+
using System.Runtime.InteropServices;
24+
using Mono.Cecil;
25+
using Mono.Cecil.Cil;
2126

2227
namespace OTAPI.Patcher.Targets;
2328

@@ -68,4 +73,48 @@ public static IPatchTarget DeterminePatchTarget()
6873

6974
return new PCServerTarget();
7075
}
76+
77+
static PatchTargets() => PatchMonoMod();
78+
/// <summary>
79+
/// Current MonoMod is outdated, and the new reorg is not ready yet, however we need v25 RD for NET9, yet Patcher v22 is the latest, and is not compatible with v25.
80+
/// Ultimately the problem is OTAPI using both relinker+rd at once.
81+
/// For now, the intention is to replace the entire both with "return new string[0];" to prevent the GAC IL from being used (which it isn't anyway)
82+
/// </summary>
83+
public static void PatchMonoMod()
84+
{
85+
var bin = File.ReadAllBytes("MonoMod.dll");
86+
using MemoryStream ms = new(bin);
87+
var asm = AssemblyDefinition.ReadAssembly(ms);
88+
var modder = asm.MainModule.Types.Single(x => x.FullName == "MonoMod.MonoModder");
89+
var gacPaths = modder.Methods.Single(m => m.Name == "get_GACPaths");
90+
var il = gacPaths.Body.GetILProcessor();
91+
if (il.Body.Instructions.Count != 3)
92+
{
93+
il.Body.Instructions.Clear();
94+
il.Emit(OpCodes.Ldc_I4_0);
95+
il.Emit(OpCodes.Newarr, asm.MainModule.ImportReference(typeof(string)));
96+
il.Emit(OpCodes.Ret);
97+
98+
// clear MonoModder.MatchingConditionals(cap, asmName), with "return false;"
99+
var mc = modder.Methods.Single(m => m.Name == "MatchingConditionals" && m.Parameters.Count == 2 && m.Parameters[1].ParameterType.Name == "AssemblyNameReference");
100+
il = mc.Body.GetILProcessor();
101+
mc.Body.Instructions.Clear();
102+
mc.Body.Variables.Clear();
103+
mc.Body.ExceptionHandlers.Clear();
104+
il.Emit(OpCodes.Ldc_I4_1);
105+
il.Emit(OpCodes.Ret);
106+
107+
var writerParams = modder.Methods.Single(m => m.Name == "get_WriterParameters");
108+
il = writerParams.Body.GetILProcessor();
109+
var get_Current = writerParams.Body.Instructions.Single(x => x.Operand is MethodReference mref && mref.Name == "get_Current");
110+
// replace get_Current with a number, and remove the bitwise checks
111+
il.Remove(get_Current.Next);
112+
il.Remove(get_Current.Next);
113+
il.Replace(get_Current, Instruction.Create(
114+
OpCodes.Ldc_I4, RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? 37 : 0
115+
));
116+
117+
asm.Write("MonoMod.dll");
118+
}
119+
}
71120
}

OTAPI.Scripts/OTAPI.Scripts.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<ItemGroup>
3333
<ProjectReference Include="..\FNA\FNA.Core.csproj" />
3434
<PackageReference Include="Steamworks.NET" Version="2024.8.0" />
35-
<PackageReference Include="ModFramework" Version="1.1.12" />
35+
<PackageReference Include="ModFramework" Version="1.1.13" />
3636
<PackageReference Include="MonoMod" Version="22.7.31.1" />
3737
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
3838
</ItemGroup>

OTAPI.Server.Launcher/OTAPI.Server.Launcher.csproj

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@
1212
</ItemGroup>
1313

1414
<ItemGroup>
15-
<PackageReference Include="ModFramework" Version="1.1.12">
15+
<PackageReference Include="ModFramework" Version="1.1.13">
1616
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
1717
</PackageReference>
18-
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.12" />
19-
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.12" />
20-
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.12" />
18+
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.13" />
19+
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.13" />
20+
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.13" />
2121
<PackageReference Include="Steamworks.NET" Version="2024.8.0" />
2222
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
2323
<PackageReference Include="System.Configuration.ConfigurationManager" Version="9.0.0" />

examples/RuntimeExample.Client/RuntimeExample.Client.csproj

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
1212
</PropertyGroup>
1313
<ItemGroup>
14-
<PackageReference Include="ModFramework" Version="1.1.12" />
14+
<PackageReference Include="ModFramework" Version="1.1.13" />
1515
</ItemGroup>
1616
<ItemGroup>
1717
<Reference Include="OTAPI.Runtime">
@@ -25,6 +25,6 @@
2525
</Reference>
2626
</ItemGroup>
2727
<ItemGroup>
28-
<PackageReference Include="ImGui.NET" Version="1.78.0" />
28+
<PackageReference Include="ImGui.NET" Version="1.91.0.1" />
2929
</ItemGroup>
3030
</Project>

examples/RuntimeExample.Server/RuntimeExample.Server.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="ModFramework" Version="1.1.12" />
10+
<PackageReference Include="ModFramework" Version="1.1.13" />
1111
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
1212
</ItemGroup>
1313

0 commit comments

Comments
 (0)