From 280756e0a224402f688aa0729c7f7ba63f65cf9c Mon Sep 17 00:00:00 2001 From: vis2k Date: Tue, 28 Sep 2021 15:26:20 +0800 Subject: [PATCH] Weaver: NetworkBehaviourProcessor.GenerateConstants: reuse RemoveFinalRetInstruction --- .../Editor/Weaver/Processors/NetworkBehaviourProcessor.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs b/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs index 1bb6d3c7c..7a216e773 100644 --- a/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs +++ b/Assets/Mirror/Editor/Weaver/Processors/NetworkBehaviourProcessor.cs @@ -294,12 +294,8 @@ void GenerateConstants(ref bool WeavingFailed) return; } - Instruction ret = ctor.Body.Instructions[ctor.Body.Instructions.Count - 1]; - if (ret.OpCode == OpCodes.Ret) - { - ctor.Body.Instructions.RemoveAt(ctor.Body.Instructions.Count - 1); - } - else + // remove the return opcode from end of function. will add our own later. + if (!RemoveFinalRetInstruction(ctor)) { Log.Error($"{netBehaviourSubclass.Name} has invalid constructor", ctor); WeavingFailed = true;