From 8c93f31b802eb9f45ff67f42b049b5a139635382 Mon Sep 17 00:00:00 2001 From: Paul Pacheco Date: Mon, 25 Mar 2019 23:13:52 -0500 Subject: [PATCH] refactor: Load parameters right before function call --- .../Weaver/Processors/SyncVarProcessor.cs | 27 ++++++++++--------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs index 744e4f48b..6f9e47aee 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/SyncVarProcessor.cs @@ -110,19 +110,6 @@ public static MethodDefinition ProcessSyncVarSet(TypeDefinition td, FieldDefinit ILProcessor setWorker = set.Body.GetILProcessor(); - // this - setWorker.Append(setWorker.Create(OpCodes.Ldarg_0)); - - // new value to set - setWorker.Append(setWorker.Create(OpCodes.Ldarg_1)); - - // reference to field to set - setWorker.Append(setWorker.Create(OpCodes.Ldarg_0)); - setWorker.Append(setWorker.Create(OpCodes.Ldflda, fd)); - - // dirty bit - setWorker.Append(setWorker.Create(OpCodes.Ldc_I8, dirtyBit)); // 8 byte integer aka long - MethodDefinition hookFunctionMethod; CheckForHookFunction(td, fd, out hookFunctionMethod); @@ -154,6 +141,20 @@ public static MethodDefinition ProcessSyncVarSet(TypeDefinition td, FieldDefinit setWorker.Append(label); } + // this + setWorker.Append(setWorker.Create(OpCodes.Ldarg_0)); + + // new value to set + setWorker.Append(setWorker.Create(OpCodes.Ldarg_1)); + + // reference to field to set + setWorker.Append(setWorker.Create(OpCodes.Ldarg_0)); + setWorker.Append(setWorker.Create(OpCodes.Ldflda, fd)); + + // dirty bit + setWorker.Append(setWorker.Create(OpCodes.Ldc_I8, dirtyBit)); // 8 byte integer aka long + + if (fd.FieldType.FullName == Weaver.gameObjectType.FullName) { // reference to netId Field to set