Skip to content

Commit 67bd005

Browse files
committed
fix more issues
1 parent 93a0163 commit 67bd005

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

NetcodePatcher/CodeGen/ILPostProcessorFromFile.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,12 @@ public static void ILPostProcessFile(string assemblyPath, string[] references, A
107107
ICompiledAssembly assembly = initialAssembly;
108108

109109
var result = NetworkBehaviourProcess(assembly, OnWarning, OnError);
110-
111-
if (result != null)
110+
111+
/*if (result != null)
112112
{
113113
assembly = new CompiledAssemblyFromInMemoryAssembly(result.InMemoryAssembly, assembly.Name);
114114
}
115-
/*
115+
116116
result = INetworkMessageProcess(assembly, OnWarning, OnError);
117117
118118

NetcodePatcher/CodeGen/NetworkBehaviourILPP.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ namespace Unity.Netcode.Editor.CodeGen
1717
{
1818
internal sealed class NetworkBehaviourILPP : ILPPInterface
1919
{
20-
public const string IgnoreDefine = "ILPP_IGNORE";
2120
private const string k_ReadValueMethodName = nameof(FastBufferReader.ReadValueSafe);
2221
private const string k_ReadValueInPlaceMethodName = nameof(FastBufferReader.ReadValueSafeInPlace);
2322
private const string k_ReadValueTempMethodName = nameof(FastBufferReader.ReadValueSafeTemp);
@@ -1114,8 +1113,7 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
11141113
var rpcHandlers = new List<(uint RpcMethodId, MethodDefinition RpcHandler)>();
11151114
var rpcNames = new List<(uint RpcMethodId, string RpcMethodName)>();
11161115

1117-
bool isEditorOrDevelopment = true;
1118-
1116+
bool isEditorOrDevelopment = false;
11191117

11201118
foreach (var methodDefinition in typeDefinition.Methods)
11211119
{
@@ -1153,7 +1151,7 @@ private void ProcessNetworkBehaviour(TypeDefinition typeDefinition, string[] ass
11531151
}
11541152

11551153
GenerateVariableInitialization(typeDefinition);
1156-
1154+
11571155
if (!typeDefinition.HasGenericParameters && !typeDefinition.IsGenericInstance)
11581156
{
11591157
var fieldTypes = new List<TypeReference>();
@@ -1623,12 +1621,10 @@ private MethodReference GetFastBufferReaderReadMethod(string name, TypeReference
16231621
var meetsConstraints = true;
16241622
foreach (var constraint in method.GenericParameters[0].Constraints)
16251623
{
1626-
16271624
var resolvedConstraint = constraint.Resolve();
16281625
var constraintTypeRef = constraint;
16291626

16301627

1631-
16321628
var resolvedConstraintName = resolvedConstraint.FullNameWithGenericParameters(new[] { method.GenericParameters[0] }, new[] { checkType });
16331629
if (constraintTypeRef.IsGenericInstance)
16341630
{

NetcodePatcher/Main.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace NetcodePatcher
1717
public static class Patcher
1818
{
1919
// when ran from command line
20+
2021
public static void Main(string[] args)
2122
{
2223
// if not enough args
@@ -31,7 +32,7 @@ public static void Main(string[] args)
3132
var pluginPath = args[0];
3233
var managedPath = args[1];
3334
// initialize
34-
Patcher.Initialize(pluginPath, managedPath);
35+
Patch(pluginPath, managedPath);
3536
}
3637

3738
public static IEnumerable<string> TargetDLLs
@@ -42,7 +43,12 @@ public static IEnumerable<string> TargetDLLs
4243
}
4344
}
4445

45-
public static void Initialize(string pluginPath, string managedPath)
46+
public static void Initialize()
47+
{
48+
Patch();
49+
}
50+
51+
public static void Patch(string pluginPath = null, string managedPath = null)
4652
{
4753
Patcher.Logger.LogMessage("Initializing NetcodePatcher");
4854
HashSet<string> hashSet = new HashSet<string>();
@@ -66,14 +72,14 @@ public static void Initialize(string pluginPath, string managedPath)
6672
{
6773
foreach (TypeDefinition typeDefinition in AssemblyDefinition.ReadAssembly(text3).MainModule.Types)
6874
{
69-
75+
7076

7177
if (typeDefinition.BaseType != null)
7278
{
73-
; // check if subclass of NetworkBehaviour
79+
; // check if subclass of NetworkBehaviour
7480
if (typeDefinition.IsSubclassOf(typeof(NetworkBehaviour).FullName) || typeDefinition.HasInterface(typeof(INetworkMessage).FullName) || typeDefinition.HasInterface(typeof(INetworkSerializable).FullName))
7581
{
76-
82+
7783
hashSet.Add(text3);
7884
break;
7985
}
@@ -92,13 +98,13 @@ public static void Initialize(string pluginPath, string managedPath)
9298
// replace || with new line
9399
warning = warning.Replace("|| ", "\r\n").Replace("||", " ");
94100
Patcher.Logger.LogWarning($"Warning when patching ({Path.GetFileName(text4)}): {warning}");
95-
},
101+
},
96102
(error) =>
97103
{
98104
error = error.Replace("|| ", "\r\n").Replace("||", " ");
99105
Patcher.Logger.LogError($"Error when patching ({Path.GetFileName(text4)}): {error}");
100106
});
101-
107+
102108
}
103109
catch (Exception exception)
104110
{

0 commit comments

Comments
 (0)