This commit is contained in:
Mister_Nebula 2021-05-03 22:35:18 +01:00
parent fcf7706b8e
commit f47ad1a8cd
6 changed files with 457 additions and 440 deletions

View File

@ -48,7 +48,7 @@ namespace QNetWeaver
{ {
return false; return false;
} }
foreach (var typeReference in Helpers.ResolveInheritanceHierarchy(typeRef)) foreach (var typeReference in ResolveInheritanceHierarchy(typeRef))
{ {
if (typeReference.IsGenericInstance) if (typeReference.IsGenericInstance)
{ {
@ -112,7 +112,7 @@ namespace QNetWeaver
var text2 = "<"; var text2 = "<";
var text3 = ", "; var text3 = ", ";
IEnumerable<TypeReference> genericArguments = genericInstanceType.GenericArguments; IEnumerable<TypeReference> genericArguments = genericInstanceType.GenericArguments;
result = text + text2 + string.Join(text3, Enumerable.ToArray<string>(Enumerable.Select<TypeReference, string>(genericArguments, new Func<TypeReference, string>(Helpers.PrettyPrintType)))) + ">"; result = text + text2 + string.Join(text3, Enumerable.ToArray<string>(Enumerable.Select<TypeReference, string>(genericArguments, new Func<TypeReference, string>(PrettyPrintType)))) + ">";
} }
else if (type.HasGenericParameters) else if (type.HasGenericParameters)
{ {
@ -134,7 +134,7 @@ namespace QNetWeaver
} }
var addSearchDirectoryHelper = new Helpers.AddSearchDirectoryHelper(assemblyResolver); var addSearchDirectoryHelper = new Helpers.AddSearchDirectoryHelper(assemblyResolver);
addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(assemblyPath)); addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(assemblyPath));
addSearchDirectoryHelper.AddSearchDirectory(Helpers.UnityEngineDLLDirectoryName()); addSearchDirectoryHelper.AddSearchDirectory(UnityEngineDLLDirectoryName());
addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(unityEngineDLLPath)); addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(unityEngineDLLPath));
addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(unityUNetDLLPath)); addSearchDirectoryHelper.AddSearchDirectory(Path.GetDirectoryName(unityUNetDLLPath));
if (extraPaths != null) if (extraPaths != null)
@ -145,7 +145,7 @@ namespace QNetWeaver
} }
} }
readerParameters.AssemblyResolver = assemblyResolver; readerParameters.AssemblyResolver = assemblyResolver;
readerParameters.SymbolReaderProvider = Helpers.GetSymbolReaderProvider(assemblyPath); readerParameters.SymbolReaderProvider = GetSymbolReaderProvider(assemblyPath);
return readerParameters; return readerParameters;
} }
@ -179,7 +179,7 @@ namespace QNetWeaver
public static MethodReference MakeHostInstanceGeneric(MethodReference self, params TypeReference[] arguments) public static MethodReference MakeHostInstanceGeneric(MethodReference self, params TypeReference[] arguments)
{ {
var methodReference = new MethodReference(self.Name, self.ReturnType, Helpers.MakeGenericType(self.DeclaringType, arguments)) var methodReference = new MethodReference(self.Name, self.ReturnType, MakeGenericType(self.DeclaringType, arguments))
{ {
HasThis = self.HasThis, HasThis = self.HasThis,
ExplicitThis = self.ExplicitThis, ExplicitThis = self.ExplicitThis,

View File

@ -204,7 +204,7 @@ namespace QNetWeaver
foreach (var methodDefinition5 in m_Cmds) foreach (var methodDefinition5 in m_Cmds)
{ {
var field = Weaver.ResolveField(m_td, "kCmd" + methodDefinition5.Name); var field = Weaver.ResolveField(m_td, "kCmd" + methodDefinition5.Name);
var hashCode = NetworkBehaviourProcessor.GetHashCode(m_td.Name + ":Cmd:" + methodDefinition5.Name); var hashCode = GetHashCode(m_td.Name + ":Cmd:" + methodDefinition5.Name);
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode));
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field));
GenerateCommandDelegate(ilprocessor2, Weaver.registerCommandDelegateReference, m_CmdInvocationFuncs[num], field); GenerateCommandDelegate(ilprocessor2, Weaver.registerCommandDelegateReference, m_CmdInvocationFuncs[num], field);
@ -214,7 +214,7 @@ namespace QNetWeaver
foreach (var methodDefinition6 in m_Rpcs) foreach (var methodDefinition6 in m_Rpcs)
{ {
var field2 = Weaver.ResolveField(m_td, "kRpc" + methodDefinition6.Name); var field2 = Weaver.ResolveField(m_td, "kRpc" + methodDefinition6.Name);
var hashCode2 = NetworkBehaviourProcessor.GetHashCode(m_td.Name + ":Rpc:" + methodDefinition6.Name); var hashCode2 = GetHashCode(m_td.Name + ":Rpc:" + methodDefinition6.Name);
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode2)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode2));
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field2)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field2));
GenerateCommandDelegate(ilprocessor2, Weaver.registerRpcDelegateReference, m_RpcInvocationFuncs[num2], field2); GenerateCommandDelegate(ilprocessor2, Weaver.registerRpcDelegateReference, m_RpcInvocationFuncs[num2], field2);
@ -224,7 +224,7 @@ namespace QNetWeaver
foreach (var methodDefinition7 in m_TargetRpcs) foreach (var methodDefinition7 in m_TargetRpcs)
{ {
var field3 = Weaver.ResolveField(m_td, "kTargetRpc" + methodDefinition7.Name); var field3 = Weaver.ResolveField(m_td, "kTargetRpc" + methodDefinition7.Name);
var hashCode3 = NetworkBehaviourProcessor.GetHashCode(m_td.Name + ":TargetRpc:" + methodDefinition7.Name); var hashCode3 = GetHashCode(m_td.Name + ":TargetRpc:" + methodDefinition7.Name);
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode3)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode3));
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field3)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field3));
GenerateCommandDelegate(ilprocessor2, Weaver.registerRpcDelegateReference, m_TargetRpcInvocationFuncs[num3], field3); GenerateCommandDelegate(ilprocessor2, Weaver.registerRpcDelegateReference, m_TargetRpcInvocationFuncs[num3], field3);
@ -234,7 +234,7 @@ namespace QNetWeaver
foreach (var eventDefinition in m_Events) foreach (var eventDefinition in m_Events)
{ {
var field4 = Weaver.ResolveField(m_td, "kEvent" + eventDefinition.Name); var field4 = Weaver.ResolveField(m_td, "kEvent" + eventDefinition.Name);
var hashCode4 = NetworkBehaviourProcessor.GetHashCode(m_td.Name + ":Event:" + eventDefinition.Name); var hashCode4 = GetHashCode(m_td.Name + ":Event:" + eventDefinition.Name);
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode4)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode4));
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field4)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field4));
GenerateCommandDelegate(ilprocessor2, Weaver.registerEventDelegateReference, m_EventInvocationFuncs[num4], field4); GenerateCommandDelegate(ilprocessor2, Weaver.registerEventDelegateReference, m_EventInvocationFuncs[num4], field4);
@ -244,7 +244,7 @@ namespace QNetWeaver
foreach (var fieldDefinition in m_SyncLists) foreach (var fieldDefinition in m_SyncLists)
{ {
var field5 = Weaver.ResolveField(m_td, "kList" + fieldDefinition.Name); var field5 = Weaver.ResolveField(m_td, "kList" + fieldDefinition.Name);
var hashCode5 = NetworkBehaviourProcessor.GetHashCode(m_td.Name + ":List:" + fieldDefinition.Name); var hashCode5 = GetHashCode(m_td.Name + ":List:" + fieldDefinition.Name);
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode5)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Ldc_I4, hashCode5));
ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field5)); ilprocessor2.Append(ilprocessor2.Create(OpCodes.Stsfld, field5));
GenerateSyncListInstanceInitializer(ilprocessor, fieldDefinition); GenerateSyncListInstanceInitializer(ilprocessor, fieldDefinition);
@ -475,7 +475,7 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.And)); ilprocessor.Append(ilprocessor.Create(OpCodes.And));
ilprocessor.Append(ilprocessor.Create(OpCodes.Brfalse, instruction2)); ilprocessor.Append(ilprocessor.Create(OpCodes.Brfalse, instruction2));
Weaver.DLog(m_td, $" writing dirtycheck", new object[0]); Weaver.DLog(m_td, $" writing dirtycheck", new object[0]);
NetworkBehaviourProcessor.WriteDirtyCheck(ilprocessor, true); WriteDirtyCheck(ilprocessor, true);
Weaver.DLog(m_td, $" done writing dirtycheck", new object[0]); Weaver.DLog(m_td, $" done writing dirtycheck", new object[0]);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_1)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_1));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
@ -501,7 +501,7 @@ namespace QNetWeaver
num++; num++;
} }
Weaver.DLog(m_td, $" Finish foreach 2", new object[0]); Weaver.DLog(m_td, $" Finish foreach 2", new object[0]);
NetworkBehaviourProcessor.WriteDirtyCheck(ilprocessor, false); WriteDirtyCheck(ilprocessor, false);
if (Weaver.generateLogErrors) if (Weaver.generateLogErrors)
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldstr, "Injected Serialize " + m_td.Name)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldstr, "Injected Serialize " + m_td.Name));
@ -898,7 +898,7 @@ namespace QNetWeaver
var methodDefinition = new MethodDefinition("InvokeCmd" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType); var methodDefinition = new MethodDefinition("InvokeCmd" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType);
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteServerActiveCheck(ilprocessor, md.Name, label, "Command"); WriteServerActiveCheck(ilprocessor, md.Name, label, "Command");
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td)); ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td));
MethodDefinition result; MethodDefinition result;
@ -910,7 +910,7 @@ namespace QNetWeaver
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
NetworkBehaviourProcessor.AddInvokeParameters(methodDefinition.Parameters); AddInvokeParameters(methodDefinition.Parameters);
result = methodDefinition; result = methodDefinition;
} }
return result; return result;
@ -931,13 +931,13 @@ namespace QNetWeaver
} }
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteSetupLocals(ilprocessor); WriteSetupLocals(ilprocessor);
if (Weaver.generateLogErrors) if (Weaver.generateLogErrors)
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldstr, "Call Command function " + md.Name)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldstr, "Call Command function " + md.Name));
ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.logErrorReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.logErrorReference));
} }
NetworkBehaviourProcessor.WriteClientActiveCheck(ilprocessor, md.Name, label, "Command function"); WriteClientActiveCheck(ilprocessor, md.Name, label, "Command function");
var instruction = ilprocessor.Create(OpCodes.Nop); var instruction = ilprocessor.Create(OpCodes.Nop);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.UBehaviourIsServer)); ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.UBehaviourIsServer));
@ -950,9 +950,9 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.Call, md)); ilprocessor.Append(ilprocessor.Create(OpCodes.Call, md));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
ilprocessor.Append(instruction); ilprocessor.Append(instruction);
NetworkBehaviourProcessor.WriteCreateWriter(ilprocessor); WriteCreateWriter(ilprocessor);
NetworkBehaviourProcessor.WriteMessageSize(ilprocessor); WriteMessageSize(ilprocessor);
NetworkBehaviourProcessor.WriteMessageId(ilprocessor, 5); WriteMessageId(ilprocessor, 5);
var fieldDefinition = new FieldDefinition("kCmd" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type); var fieldDefinition = new FieldDefinition("kCmd" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type);
m_td.Fields.Add(fieldDefinition); m_td.Fields.Add(fieldDefinition);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0));
@ -965,7 +965,7 @@ namespace QNetWeaver
var writeFunc = Weaver.GetWriteFunc(Weaver.NetworkInstanceIdType); var writeFunc = Weaver.GetWriteFunc(Weaver.NetworkInstanceIdType);
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, writeFunc)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, writeFunc));
MethodDefinition result; MethodDefinition result;
if (!NetworkBehaviourProcessor.WriteArguments(ilprocessor, md, "Command", false)) if (!WriteArguments(ilprocessor, md, "Command", false))
{ {
result = null; result = null;
} }
@ -1001,7 +1001,7 @@ namespace QNetWeaver
var methodDefinition = new MethodDefinition("InvokeRpc" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType); var methodDefinition = new MethodDefinition("InvokeRpc" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType);
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteClientActiveCheck(ilprocessor, md.Name, label, "TargetRPC"); WriteClientActiveCheck(ilprocessor, md.Name, label, "TargetRPC");
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td)); ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td));
ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.ReadyConnectionReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.ReadyConnectionReference));
@ -1014,7 +1014,7 @@ namespace QNetWeaver
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
NetworkBehaviourProcessor.AddInvokeParameters(methodDefinition.Parameters); AddInvokeParameters(methodDefinition.Parameters);
result = methodDefinition; result = methodDefinition;
} }
return result; return result;
@ -1025,7 +1025,7 @@ namespace QNetWeaver
var methodDefinition = new MethodDefinition("InvokeRpc" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType); var methodDefinition = new MethodDefinition("InvokeRpc" + md.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType);
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteClientActiveCheck(ilprocessor, md.Name, label, "RPC"); WriteClientActiveCheck(ilprocessor, md.Name, label, "RPC");
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td)); ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td));
MethodDefinition result; MethodDefinition result;
@ -1037,7 +1037,7 @@ namespace QNetWeaver
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, md));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
NetworkBehaviourProcessor.AddInvokeParameters(methodDefinition.Parameters); AddInvokeParameters(methodDefinition.Parameters);
result = methodDefinition; result = methodDefinition;
} }
return result; return result;
@ -1052,8 +1052,8 @@ namespace QNetWeaver
} }
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteSetupLocals(ilprocessor); WriteSetupLocals(ilprocessor);
NetworkBehaviourProcessor.WriteServerActiveCheck(ilprocessor, md.Name, label, "TargetRPC Function"); WriteServerActiveCheck(ilprocessor, md.Name, label, "TargetRPC Function");
var instruction = ilprocessor.Create(OpCodes.Nop); var instruction = ilprocessor.Create(OpCodes.Nop);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_1)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_1));
ilprocessor.Append(ilprocessor.Create(OpCodes.Isinst, Weaver.ULocalConnectionToServerType)); ilprocessor.Append(ilprocessor.Create(OpCodes.Isinst, Weaver.ULocalConnectionToServerType));
@ -1062,9 +1062,9 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.logErrorReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Call, Weaver.logErrorReference));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
ilprocessor.Append(instruction); ilprocessor.Append(instruction);
NetworkBehaviourProcessor.WriteCreateWriter(ilprocessor); WriteCreateWriter(ilprocessor);
NetworkBehaviourProcessor.WriteMessageSize(ilprocessor); WriteMessageSize(ilprocessor);
NetworkBehaviourProcessor.WriteMessageId(ilprocessor, 2); WriteMessageId(ilprocessor, 2);
var fieldDefinition = new FieldDefinition("kTargetRpc" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type); var fieldDefinition = new FieldDefinition("kTargetRpc" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type);
m_td.Fields.Add(fieldDefinition); m_td.Fields.Add(fieldDefinition);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0));
@ -1076,7 +1076,7 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference));
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId));
MethodDefinition result; MethodDefinition result;
if (!NetworkBehaviourProcessor.WriteArguments(ilprocessor, md, "TargetRPC", true)) if (!WriteArguments(ilprocessor, md, "TargetRPC", true))
{ {
result = null; result = null;
} }
@ -1117,11 +1117,11 @@ namespace QNetWeaver
} }
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteSetupLocals(ilprocessor); WriteSetupLocals(ilprocessor);
NetworkBehaviourProcessor.WriteServerActiveCheck(ilprocessor, md.Name, label, "RPC Function"); WriteServerActiveCheck(ilprocessor, md.Name, label, "RPC Function");
NetworkBehaviourProcessor.WriteCreateWriter(ilprocessor); WriteCreateWriter(ilprocessor);
NetworkBehaviourProcessor.WriteMessageSize(ilprocessor); WriteMessageSize(ilprocessor);
NetworkBehaviourProcessor.WriteMessageId(ilprocessor, 2); WriteMessageId(ilprocessor, 2);
var fieldDefinition = new FieldDefinition("kRpc" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type); var fieldDefinition = new FieldDefinition("kRpc" + md.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type);
m_td.Fields.Add(fieldDefinition); m_td.Fields.Add(fieldDefinition);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0));
@ -1133,7 +1133,7 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference));
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId));
MethodDefinition result; MethodDefinition result;
if (!NetworkBehaviourProcessor.WriteArguments(ilprocessor, md, "RPC", false)) if (!WriteArguments(ilprocessor, md, "RPC", false))
{ {
result = null; result = null;
} }
@ -1629,7 +1629,7 @@ namespace QNetWeaver
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
var instruction = ilprocessor.Create(OpCodes.Nop); var instruction = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteClientActiveCheck(ilprocessor, ed.Name, label, "Event"); WriteClientActiveCheck(ilprocessor, ed.Name, label, "Event");
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td)); ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, m_td));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldfld, fieldDefinition)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldfld, fieldDefinition));
@ -1648,7 +1648,7 @@ namespace QNetWeaver
{ {
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, methodReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, methodReference));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
NetworkBehaviourProcessor.AddInvokeParameters(methodDefinition.Parameters); AddInvokeParameters(methodDefinition.Parameters);
result = methodDefinition; result = methodDefinition;
} }
} }
@ -1665,11 +1665,11 @@ namespace QNetWeaver
} }
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteSetupLocals(ilprocessor); WriteSetupLocals(ilprocessor);
NetworkBehaviourProcessor.WriteServerActiveCheck(ilprocessor, ed.Name, label, "Event"); WriteServerActiveCheck(ilprocessor, ed.Name, label, "Event");
NetworkBehaviourProcessor.WriteCreateWriter(ilprocessor); WriteCreateWriter(ilprocessor);
NetworkBehaviourProcessor.WriteMessageSize(ilprocessor); WriteMessageSize(ilprocessor);
NetworkBehaviourProcessor.WriteMessageId(ilprocessor, 7); WriteMessageId(ilprocessor, 7);
var fieldDefinition = new FieldDefinition("kEvent" + ed.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type); var fieldDefinition = new FieldDefinition("kEvent" + ed.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type);
m_td.Fields.Add(fieldDefinition); m_td.Fields.Add(fieldDefinition);
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldloc_0));
@ -1681,7 +1681,7 @@ namespace QNetWeaver
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.getUNetIdReference));
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, Weaver.NetworkWriterWriteNetworkInstanceId));
MethodDefinition result; MethodDefinition result;
if (!NetworkBehaviourProcessor.WriteArguments(ilprocessor, methodReference.Resolve(), "SyncEvent", false)) if (!WriteArguments(ilprocessor, methodReference.Resolve(), "SyncEvent", false))
{ {
result = null; result = null;
} }
@ -1832,7 +1832,7 @@ namespace QNetWeaver
m_SyncVarNetIds.Add(fieldDefinition); m_SyncVarNetIds.Add(fieldDefinition);
Weaver.lists.netIdFields.Add(fieldDefinition); Weaver.lists.netIdFields.Add(fieldDefinition);
} }
var methodDefinition = NetworkBehaviourProcessor.ProcessSyncVarGet(fd, name); var methodDefinition = ProcessSyncVarGet(fd, name);
var methodDefinition2 = ProcessSyncVarSet(fd, name, dirtyBit, fieldDefinition); var methodDefinition2 = ProcessSyncVarSet(fd, name, dirtyBit, fieldDefinition);
var item = new PropertyDefinition("Network" + name, PropertyAttributes.None, fd.FieldType) var item = new PropertyDefinition("Network" + name, PropertyAttributes.None, fd.FieldType)
{ {
@ -1850,7 +1850,7 @@ namespace QNetWeaver
var methodDefinition = new MethodDefinition("InvokeSyncList" + fd.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType); var methodDefinition = new MethodDefinition("InvokeSyncList" + fd.Name, MethodAttributes.Family | MethodAttributes.Static | MethodAttributes.HideBySig, Weaver.voidType);
var ilprocessor = methodDefinition.Body.GetILProcessor(); var ilprocessor = methodDefinition.Body.GetILProcessor();
var label = ilprocessor.Create(OpCodes.Nop); var label = ilprocessor.Create(OpCodes.Nop);
NetworkBehaviourProcessor.WriteClientActiveCheck(ilprocessor, fd.Name, label, "SyncList"); WriteClientActiveCheck(ilprocessor, fd.Name, label, "SyncList");
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldarg_0));
ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, fd.DeclaringType)); ilprocessor.Append(ilprocessor.Create(OpCodes.Castclass, fd.DeclaringType));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ldfld, fd)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ldfld, fd));
@ -1864,13 +1864,13 @@ namespace QNetWeaver
}); });
ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, method)); ilprocessor.Append(ilprocessor.Create(OpCodes.Callvirt, method));
ilprocessor.Append(ilprocessor.Create(OpCodes.Ret)); ilprocessor.Append(ilprocessor.Create(OpCodes.Ret));
NetworkBehaviourProcessor.AddInvokeParameters(methodDefinition.Parameters); AddInvokeParameters(methodDefinition.Parameters);
return methodDefinition; return methodDefinition;
} }
private FieldDefinition ProcessSyncList(FieldDefinition fd, int dirtyBit) private FieldDefinition ProcessSyncList(FieldDefinition fd, int dirtyBit)
{ {
var methodDefinition = NetworkBehaviourProcessor.ProcessSyncListInvoke(fd); var methodDefinition = ProcessSyncListInvoke(fd);
m_SyncListInvocationFuncs.Add(methodDefinition); m_SyncListInvocationFuncs.Add(methodDefinition);
return new FieldDefinition("kList" + fd.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type); return new FieldDefinition("kList" + fd.Name, FieldAttributes.Private | FieldAttributes.Static, Weaver.int32Type);
} }

View File

@ -20,12 +20,12 @@ namespace QNetWeaver
var unetDLL = args[2]; var unetDLL = args[2];
var outputDirectory = args[3]; var outputDirectory = args[3];
var assembly = args[4]; var assembly = args[4];
Program.CheckDLLPath(unityEngine); CheckDLLPath(unityEngine);
Program.CheckDLLPath(qnetDLL); CheckDLLPath(qnetDLL);
Program.CheckDLLPath(unetDLL); CheckDLLPath(unetDLL);
Program.CheckOutputDirectory(outputDirectory); CheckOutputDirectory(outputDirectory);
Program.CheckAssemblyPath(assembly); CheckAssemblyPath(assembly);
Weaver.WeaveAssemblies(assembly, null, null, outputDirectory, unityEngine, qnetDLL, unetDLL); Weaver.WeaveAssemblies(assembly, null, null, outputDirectory, unityEngine, qnetDLL, unetDLL);
} }

File diff suppressed because it is too large Load Diff

View File

@ -367,7 +367,7 @@ copy /y "$(ProjectDir)\default-config.json" "$(OwmlDir)\Mods\$(ProjectName)"
copy /y "$(SolutionDir)\AssetBundles" "$(OwmlDir)\Mods\$(ProjectName)\assets copy /y "$(SolutionDir)\AssetBundles" "$(OwmlDir)\Mods\$(ProjectName)\assets
copy /y "$(ProjectDir)\manifest.json" "$(OwmlDir)\Mods\$(ProjectName)" copy /y "$(ProjectDir)\manifest.json" "$(OwmlDir)\Mods\$(ProjectName)"
"$(SolutionDir)\QNetWeaver\bin\Debug\QNetWeaver.exe" "$(GameDir)\OuterWilds_Data\Managed\UnityEngine.dll" "$(OwmlDir)\Mods\$(ProjectName)\QuantumUNET.dll" "$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll" "$(SolutionDir)\WeavedFiles" "$(TargetPath)" "$(SolutionDir)\QNetWeaver\bin\Debug\QNetWeaver.exe" "$(GameDir)\OuterWilds_Data\Managed\UnityEngine.CoreModule.dll" "$(OwmlDir)\Mods\$(ProjectName)\QuantumUNET.dll" "$(GameDir)\OuterWilds_Data\Managed\UnityEngine.Networking.dll" "$(SolutionDir)\WeavedFiles" "$(TargetPath)"
copy /y "$(SolutionDir)\WeavedFiles\QSB.dll" "$(OwmlDir)\Mods\$(ProjectName)"</PostBuildEvent> copy /y "$(SolutionDir)\WeavedFiles\QSB.dll" "$(OwmlDir)\Mods\$(ProjectName)"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>

Binary file not shown.