Skip to content

Commit

Permalink
4.4.5 Pre-release 03
Browse files Browse the repository at this point in the history
- Added Logging option RPC attributes.
- Fixed HashGrid demo scene allowing clients to locally teleport server authoritative objects.
- Fixed timed observers not rebuilding when the maximum rebuild time was set to 0f.
- Fixed NetworkTransform field deinitializing without re-initializing on clientHost.
- Fixed NetworkTransform not resetting all datas properly on clientHost disconnect and reconnect.
- Fixed SyncVar not resetting 'values set' field after deinitializing when pooling.
- Changed NetworkObject.NetworkBehaviours is now a List rather than Array.
- Changed renamed NetworkObject.SerializedNestedNetworkObjects to InitializedNestedNetworkObjects.
- Changed renamed NetworkObject.SerializedRootNetworkBehaviour to InitializedParentNetworkBehaviour.
- Fixed nested NetworkObjects spawning under their parent NetworkObject rather than the object they were under on the prefab.
  • Loading branch information
FirstGearGames committed Sep 4, 2024
1 parent dc44a6d commit 2dacadd
Show file tree
Hide file tree
Showing 202 changed files with 1,430 additions and 1,488 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static FieldReference TryMakeGenericInstance(this FieldReference fr)
if (declaringTr.HasGenericParameters)
{
GenericInstanceType git = declaringTr.MakeGenericInstanceType();
FieldReference result = new FieldReference(fr.Name, fr.FieldType, git);
FieldReference result = new(fr.Name, fr.FieldType, git);
return result;
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ internal static ParameterDefinition GetEndParameter(this MethodDefinition md, in
/// </summary>
internal static VariableDefinition CreateVariable(this MethodDefinition methodDef, TypeReference variableTypeRef)
{
VariableDefinition variableDef = new VariableDefinition(variableTypeRef);
VariableDefinition variableDef = new(variableTypeRef);
methodDef.Body.Variables.Add(variableDef);
return variableDef;
}
Expand Down Expand Up @@ -99,7 +99,7 @@ public static MonoFN.Cecil.Cil.OpCode GetCallOpCode(this MethodReference mr, Cod
public static ParameterDefinition CreateParameter(this MethodDefinition thisMd, CodegenSession session, ParameterAttributes attr, System.Type type)
{
TypeReference parameterTypeRef = session.ImportReference(type);
ParameterDefinition pd = new ParameterDefinition($"p{thisMd.Parameters.Count}", attr, parameterTypeRef);
ParameterDefinition pd = new($"p{thisMd.Parameters.Count}", attr, parameterTypeRef);
thisMd.Parameters.Add(pd);
return pd;
}
Expand All @@ -109,14 +109,14 @@ public static ParameterDefinition CreateParameter(this MethodDefinition thisMd,
/// </summary>
public static List<ParameterDefinition> CreateParameters(this MethodDefinition thisMd, CodegenSession session, MethodDefinition otherMd)
{
List<ParameterDefinition> results = new List<ParameterDefinition>();
List<ParameterDefinition> results = new();

foreach (ParameterDefinition pd in otherMd.Parameters)
{
session.ImportReference(pd.ParameterType.CachedResolve(session));
int currentCount = thisMd.Parameters.Count;
string name = (pd.Name + currentCount);
ParameterDefinition parameterDef = new ParameterDefinition(name, pd.Attributes, pd.ParameterType);
ParameterDefinition parameterDef = new(name, pd.Attributes, pd.ParameterType);
//Set any default values.
parameterDef.Constant = pd.Constant;
parameterDef.IsReturnValue = pd.IsReturnValue;
Expand Down Expand Up @@ -151,7 +151,7 @@ public static MethodReference GetMethodReference(this MethodDefinition md, Codeg
if (md.DeclaringType.HasGenericParameters)
{
GenericInstanceType git = methodRef.DeclaringType.MakeGenericInstanceType();
MethodReference result = new MethodReference(md.Name, md.ReturnType)
MethodReference result = new(md.Name, md.ReturnType)
{
HasThis = md.HasThis,
ExplicitThis = md.ExplicitThis,
Expand Down Expand Up @@ -214,7 +214,7 @@ public static MethodDefinition CreateCopy(this MethodDefinition copiedMd, Codege

MethodAttributes attr = (attributesOverride.HasValue) ? attributesOverride.Value : copiedMd.Attributes;
string name = (nameOverride == null) ? copiedMd.Name : nameOverride;
MethodDefinition result = new MethodDefinition(name, attr, copiedMd.ReturnType);
MethodDefinition result = new(name, attr, copiedMd.ReturnType);
foreach (GenericParameter item in copiedMd.GenericParameters)
result.GenericParameters.Add(item);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static MethodReference GetMethodReferenceInBase(this TypeDefinition td, C
if (baseTr.CachedResolve(session).HasGenericParameters)
{
GenericInstanceType git = (GenericInstanceType)baseTr;
baseMr = new MethodReference(baseMd.Name, baseMd.ReturnType, git)
baseMr = new(baseMd.Name, baseMd.ReturnType, git)
{
HasThis = baseMd.HasThis,
CallingConvention = baseMd.CallingConvention,
Expand Down Expand Up @@ -106,7 +106,7 @@ public static MethodReference GetOrCreateMethodReference(this TypeDefinition td,
//Not found.
if (md == null)
{
md = new MethodDefinition(methodName, attributes, returnType);
md = new(methodName, attributes, returnType);
td.Methods.Add(md);
created = true;
}
Expand All @@ -128,7 +128,7 @@ public static MethodDefinition GetOrCreateMethodDefinition(this TypeDefinition t
//Not found.
if (md == null)
{
md = new MethodDefinition(methodName, attributes, returnType);
md = new(methodName, attributes, returnType);
td.Methods.Add(md);
created = true;
}
Expand All @@ -150,7 +150,7 @@ public static MethodDefinition GetOrCreateMethodDefinition(this TypeDefinition t
if (md == null)
{
TypeReference returnType = session.ImportReference(methodTemplate.ReturnType);
md = new MethodDefinition(methodName, methodTemplate.Attributes, returnType)
md = new(methodName, methodTemplate.Attributes, returnType)
{
ExplicitThis = methodTemplate.ExplicitThis,
AggressiveInlining = methodTemplate.AggressiveInlining,
Expand Down Expand Up @@ -255,10 +255,10 @@ public static FieldReference CreateFieldReference(this FieldDefinition fd, Codeg
//Is generic.
if (declaringType.HasGenericParameters)
{
GenericInstanceType git = new GenericInstanceType(declaringType);
GenericInstanceType git = new(declaringType);
foreach (GenericParameter item in declaringType.GenericParameters)
git.GenericArguments.Add(item);
fr = new FieldReference(fd.Name, fd.FieldType, git);
fr = new(fd.Name, fd.FieldType, git);
return fr;
}
//Not generic.
Expand Down Expand Up @@ -292,7 +292,7 @@ public static FieldReference GetOrCreateFieldReference(this TypeDefinition td, C
/// </summary>
public static FieldReference CreateFieldDefinition(this TypeDefinition td, CodegenSession session, string fieldName, FieldAttributes attributes, TypeReference fieldTypeRef)
{
FieldDefinition fd = new FieldDefinition(fieldName, attributes, fieldTypeRef);
FieldDefinition fd = new(fieldName, attributes, fieldTypeRef);
td.Fields.Add(fd);
return fd.CreateFieldReference(session);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static string GetFullnameWithoutBrackets(this TypeReference tr)
/// </summary>
public static GenericInstanceType MakeGenericInstanceType(this TypeReference self)
{
GenericInstanceType instance = new GenericInstanceType(self);
GenericInstanceType instance = new(self);
foreach (GenericParameter argument in self.GenericParameters)
instance.GenericArguments.Add(argument);

Expand Down
8 changes: 4 additions & 4 deletions Assets/FishNet/CodeGenerating/Helpers/CodegenSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ internal class CodegenSession
/// <summary>
/// SyncVars that are being accessed from an assembly other than the currently being processed one.
/// </summary>
internal List<FieldDefinition> DifferentAssemblySyncVars = new List<FieldDefinition>();
internal List<FieldDefinition> DifferentAssemblySyncVars = new();


/// <summary>
Expand All @@ -38,7 +38,7 @@ internal class CodegenSession
/// <summary>
/// Quick lookup of base classes.
/// </summary>
private Dictionary<string, CodegenBase> _basesCache = new Dictionary<string, CodegenBase>();
private Dictionary<string, CodegenBase> _basesCache = new();

/// <summary>
/// Returns class of type if found within CodegenBase classes.
Expand All @@ -58,9 +58,9 @@ internal T GetClass<T>() where T : CodegenBase
internal bool Initialize(ModuleDefinition module)
{
Module = module;
Diagnostics = new List<DiagnosticMessage>();
Diagnostics = new();

_bases = new List<CodegenBase>()
_bases = new()
{
new ReaderImports(), new ReaderProcessor()
,new WriterImports(), new WriterProcessor()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal static void AddError(this List<DiagnosticMessage> diagnostics, MethodDe

internal static void AddMessage(this List<DiagnosticMessage> diagnostics, DiagnosticType diagnosticType, SequencePoint sequencePoint, string message)
{
diagnostics.Add(new DiagnosticMessage
diagnostics.Add(new()
{
DiagnosticType = diagnosticType,
File = sequencePoint?.Document.Url.Replace($"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}", ""),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static MethodDefinition GetDefaultConstructor(this TypeDefinition typeDef
/// <returns></returns>
public static List<MethodDefinition> GetConstructors(this TypeDefinition typeDef)
{
List<MethodDefinition> lst = new List<MethodDefinition>();
List<MethodDefinition> lst = new();
foreach (MethodDefinition methodDef in typeDef.Methods)
{
if (methodDef.IsConstructor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal static class ILProcessorExtensions
/// </summary>
public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSession session, string txt)
{
List<Instruction> insts = new List<Instruction>();
List<Instruction> insts = new();
insts.Add(processor.Create(OpCodes.Ldstr, txt));
insts.Add(processor.Create(OpCodes.Call, session.GetClass<GeneralHelper>().Debug_LogCommon_MethodRef));
return insts;
Expand All @@ -23,7 +23,7 @@ public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSess
/// </summary>
public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSession session, VariableDefinition vd)
{
List<Instruction> insts = new List<Instruction>();
List<Instruction> insts = new();
insts.Add(processor.Create(OpCodes.Ldloc, vd));
insts.Add(processor.Create(OpCodes.Box, vd.VariableType));
insts.Add(processor.Create(OpCodes.Call, session.GetClass<GeneralHelper>().Debug_LogCommon_MethodRef));
Expand All @@ -34,7 +34,7 @@ public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSess
/// </summary>
public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSession session, FieldDefinition fd, bool loadArg0)
{
List<Instruction> insts = new List<Instruction>();
List<Instruction> insts = new();
if (loadArg0)
insts.Add(processor.Create(OpCodes.Ldarg_0));
insts.Add(processor.Create(OpCodes.Ldfld, fd));
Expand All @@ -47,7 +47,7 @@ public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSess
/// </summary>
public static List<Instruction> DebugLog(this ILProcessor processor, CodegenSession session, ParameterDefinition pd)
{
List<Instruction> insts = new List<Instruction>();
List<Instruction> insts = new();
insts.Add(processor.Create(OpCodes.Ldloc, pd));
insts.Add(processor.Create(OpCodes.Box, pd.ParameterType));
insts.Add(processor.Create(OpCodes.Call, session.GetClass<GeneralHelper>().Debug_LogCommon_MethodRef));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static CustomAttribute GetCustomAttribute(this MethodReference mr, string
/// <returns></returns>
public static GenericInstanceMethod MakeGenericMethod(this MethodReference method, params TypeReference[] genericArguments)
{
GenericInstanceMethod result = new GenericInstanceMethod(method);
GenericInstanceMethod result = new(method);
foreach (TypeReference argument in genericArguments)
result.GenericArguments.Add(argument);
return result;
Expand All @@ -39,7 +39,7 @@ public static GenericInstanceMethod MakeGenericMethod(this MethodReference metho
/// <returns></returns>
public static GenericInstanceMethod MakeGenericMethod(this MethodReference method)
{
GenericInstanceMethod result = new GenericInstanceMethod(method);
GenericInstanceMethod result = new(method);
foreach (ParameterDefinition pd in method.Parameters)
result.GenericArguments.Add(pd.ParameterType);

Expand Down Expand Up @@ -106,18 +106,18 @@ internal static bool RemoveEndRet(this MethodReference mr, CodegenSession sessio
/// <returns></returns>
public static MethodReference MakeHostInstanceGeneric(this MethodReference self, CodegenSession session, GenericInstanceType instanceType)
{
MethodReference reference = new MethodReference(self.Name, self.ReturnType, instanceType)
MethodReference reference = new(self.Name, self.ReturnType, instanceType)
{
CallingConvention = self.CallingConvention,
HasThis = self.HasThis,
ExplicitThis = self.ExplicitThis
};

foreach (ParameterDefinition parameter in self.Parameters)
reference.Parameters.Add(new ParameterDefinition(parameter.ParameterType));
reference.Parameters.Add(new(parameter.ParameterType));

foreach (GenericParameter generic_parameter in self.GenericParameters)
reference.GenericParameters.Add(new GenericParameter(generic_parameter.Name, reference));
reference.GenericParameters.Add(new(generic_parameter.Name, reference));

return session.ImportReference(reference);
}
Expand All @@ -133,18 +133,18 @@ public static MethodReference MakeHostInstanceGeneric(this MethodReference self,
public static MethodReference MakeHostInstanceGeneric(this MethodReference self, TypeReference typeRef, params TypeReference[] args)
{
GenericInstanceType git = typeRef.MakeGenericInstanceType(args);
MethodReference reference = new MethodReference(self.Name, self.ReturnType, git)
MethodReference reference = new(self.Name, self.ReturnType, git)
{
CallingConvention = self.CallingConvention,
HasThis = self.HasThis,
ExplicitThis = self.ExplicitThis
};

foreach (ParameterDefinition parameter in self.Parameters)
reference.Parameters.Add(new ParameterDefinition(parameter.ParameterType));
reference.Parameters.Add(new(parameter.ParameterType));

foreach (GenericParameter generic_parameter in self.GenericParameters)
reference.GenericParameters.Add(new GenericParameter(generic_parameter.Name, reference));
reference.GenericParameters.Add(new(generic_parameter.Name, reference));

return reference;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal static class TypeDefinitionExtensionsOld
/// </summary>
internal static GenericInstanceType CreateGenericInstanceType(this TypeDefinition type, Collection<GenericParameter> parameters)
{
GenericInstanceType git = new GenericInstanceType(type);
GenericInstanceType git = new(type);
foreach (GenericParameter gp in parameters)
git.GenericArguments.Add(gp);

Expand Down
Loading

0 comments on commit 2dacadd

Please sign in to comment.