again, special stuff should only apply to qsb messages, goofus.

This commit is contained in:
JohnCorby 2022-01-14 01:21:23 -08:00
parent 992db18851
commit fd6519f104

View File

@ -315,13 +315,19 @@ namespace Mirror.Weaver
MethodDefinition ctor = Resolvers.ResolveDefaultPublicCtor(variable);
if (ctor == null)
{
// Log.Error($"{variable.Name} can't be deserialized because it has no default constructor. Don't use {variable.Name} in [SyncVar]s, Rpcs, Cmds, etc.", variable);
// WeavingFailed = true;
// return;
var anyCtor = td.Methods.First(m => m.IsConstructor);
ctor = new MethodDefinition(anyCtor.Name, anyCtor.Attributes, anyCtor.ReturnType);
ctor.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
td.Methods.Add(ctor);
if (td.IsQSBMessageType())
{
var anyCtor = td.Methods.First(m => m.IsConstructor);
ctor = new MethodDefinition(anyCtor.Name, anyCtor.Attributes, anyCtor.ReturnType);
ctor.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
td.Methods.Add(ctor);
}
else
{
Log.Error($"{variable.Name} can't be deserialized because it has no default constructor. Don't use {variable.Name} in [SyncVar]s, Rpcs, Cmds, etc.", variable);
WeavingFailed = true;
return;
}
}
MethodReference ctorRef = assembly.MainModule.ImportReference(ctor);