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; return;
} }
Instruction ret = ctor.Body.Instructions[ctor.Body.Instructions.Count - 1]; // remove the return opcode from end of function. will add our own later.
if (ret.OpCode == OpCodes.Ret) if (!RemoveFinalRetInstruction(ctor))
{
ctor.Body.Instructions.RemoveAt(ctor.Body.Instructions.Count - 1);
}
else
{ {
Log.Error($"{netBehaviourSubclass.Name} has invalid constructor", ctor); Log.Error($"{netBehaviourSubclass.Name} has invalid constructor", ctor);
WeavingFailed = true; WeavingFailed = true;