Skip to content

Commit 91d046c

Browse files
committed
2.2.0
1 parent 2e5d7fe commit 91d046c

File tree

2 files changed

+37
-6
lines changed

2 files changed

+37
-6
lines changed

NetcodePatcher/CodeGen/ILPostProcessorFromFile.cs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,22 @@ public static ILPostProcessResult INetworkSerializableProcess(ICompiledAssembly
103103

104104
public static void ILPostProcessFile(string assemblyPath, string[] references, Action<string> OnWarning, Action<string> OnError)
105105
{
106-
var initialAssembly = new CompiledAssemblyFromFile(assemblyPath);
106+
// remove files with _original.dll and _original.pdb
107+
108+
109+
var newPath = assemblyPath.Replace(".dll", "_original.dll");
110+
string pdbFileName = Path.GetFileNameWithoutExtension(assemblyPath) + ".pdb";
111+
string pdbPath = Path.Combine(Path.GetDirectoryName(assemblyPath), pdbFileName);
112+
string newPdbPath = pdbPath.Replace(".pdb", "_original.pdb");
113+
114+
File.Move(assemblyPath, newPath);
115+
File.Move(pdbPath, newPdbPath);
116+
117+
// read the original assembly from file
118+
119+
120+
121+
var initialAssembly = new CompiledAssemblyFromFile(newPath);
107122
initialAssembly.References = references;
108123

109124
ICompiledAssembly assembly = initialAssembly;
@@ -130,11 +145,15 @@ public static void ILPostProcessFile(string assemblyPath, string[] references, A
130145
}
131146

132147
result = INetworkSerializableProcess(assembly, OnWarning, OnError);
133-
134148

135149
// save the weaved assembly to file.
136150
// some tests open it and check for certain IL code.
137151
File.WriteAllBytes(assemblyPath, result.InMemoryAssembly.PeData);
152+
File.WriteAllBytes(pdbPath, result.InMemoryAssembly.PdbData);
153+
154+
// remove the _original.dll and _original.pdb files
155+
File.Delete(newPath);
156+
File.Delete(newPdbPath);
138157

139158
}
140159
}

NetcodePatcher/Main.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ namespace NetcodePatcher
1414
{
1515
public static class Patcher
1616
{
17-
17+
public const string NetcodePatcherVersion = "2.2.0";
1818
public static void Main(string[] args)
1919
{
2020
// check if enough args, otherwise print usage
@@ -111,7 +111,7 @@ public void LogInfo(string message)
111111

112112
public static void Patch(string pluginPath, string managedPath)
113113
{
114-
Patcher.Logger.LogMessage("Initializing NetcodePatcher");
114+
Patcher.Logger.LogMessage($"Initializing NetcodePatcher {NetcodePatcherVersion}");
115115
HashSet<string> hashSet = new HashSet<string>();
116116
List<string> references = new List<string>()
117117
{
@@ -127,9 +127,21 @@ public static void Patch(string pluginPath, string managedPath)
127127
"UnityEngine.CoreModule",
128128
"Unity.Netcode.Components",
129129
"Unity.Networking.Transport",
130-
"Assembly-CSharp"
130+
"Assembly-CSharp",
131+
"ClientNetworkTransform"
131132
};
132133

134+
// remove files with _original.dll and _original.pdb in pluginPath
135+
foreach (string text in Directory.GetFiles(pluginPath, "*.*", SearchOption.AllDirectories))
136+
{
137+
string fileName = Path.GetFileName(text);
138+
if (fileName.ToLower().Contains("_original"))
139+
{
140+
Patcher.Logger.LogMessage("Deleting : " + fileName);
141+
File.Delete(text);
142+
}
143+
}
144+
133145
foreach (string text3 in Directory.GetFiles(pluginPath, "*.dll", SearchOption.AllDirectories))
134146
{
135147
string fileName = Path.GetFileName(text3);
@@ -157,7 +169,7 @@ public static void Patch(string pluginPath, string managedPath)
157169
}
158170
}
159171

160-
if (skip)
172+
if (skip || hashSet.Contains(text3))
161173
{
162174
break;
163175
}

0 commit comments

Comments
 (0)