Weaver: NetworkBehaviourProcessor.GenerateConstants: reuse RemoveFinalRetInstruction

This commit is contained in:
vis2k 2021-09-28 15:26:20 +08:00
parent 073c87e8d1
commit 280756e0a2

View File

@ -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;