Skip to content

Commit fef9e5c

Browse files
author
FirstGearGames
committed
4.3.0
- Improved NetworkCollider/2D now use current physics scene rather than global. - Fixed hotpath allocation in PredictionRigidbody. - Added ReadUnallocatedAttribute which makes generated readers pull from caches for classes. - Fixed prediction replaying 1 additional tick. - Fixed typo in a SceneManager warn message causing it to not display complete information. - Changed AllowPredictedSpawning and ReservedObjectIds moved from PredictionManager to ServerManager for future proofing. - Changed PredictionManager.Interpolation renamed to ClientInterpolation. - Added PredictionManager.ServerInterpolation(not yet functional). - Added ClientManager.IsServerDevelopment. This is true if the server notified client it's on a development build. - Fixed NetworkBehaviour start/stop callbacks firing out of order or not at all under certain conditions as clientHost (#652). - Fixed instantiated nested NetworkObject transform properties being wrong under certain conditions (#660). - Added NetworkAnimator.SynchronizeWhenDisbaled. - Added more Multipass methods to update transport settings. - Improved PredictionRigidbody now also writes the RigidbodyState. - Added NetworkObject.DetachGraphicalObject for prediction. - Fixed RigidbodyPauser causing physics casts to fail on paused objects. - Obsoleted several RollbackManager methods in favor of simplified versions. - Improved RollbackManager XML. - Improved Added Unity.Mathmatics to excluded codegen assemblies. - Added NetworkObject.AdaptiveInterpolation. - Added NetworkObject.SpectatorInterpolation, seen when adaptive interpolation is off. - Added NetworkObject.SmoothedProperties. - Added NetworkObject.PredictionSmoother. - Added several API for AdaptiveLocalTransformTickSmoother (PredictionSmoother). - Added MoveRates.Move methods which utilize TransformPropertyFlag. - Changed BasicQueue moved from FishNet utilities to GameKit utiltiies. - Added IncludeSerialization attribute types not explicitly used in networking code, but need generated serializers - Added TimeManager.Get/SetPhysicsTimeScale. - Improved fixed LiteNetLib not re-using peerIds. - Improved updated Tugboat to the latest LiteNetLib. - Improved NetworkManager now automatically sets spawnable prefabs to DefaultPrefabObjects if not already specified. - Fixed prediction 1 codegen failing to find reconcile method. - Removed VERSION.txt file. - Added server now validates clients FishNet version; this is intended for development, not security.
1 parent 507e4e8 commit fef9e5c

File tree

136 files changed

+5918
-4783
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+5918
-4783
lines changed

Assets/FishNet/CodeGenerating/Helpers/GeneralHelper.cs

+24-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
using FishNet.Serializing;
99
using FishNet.Serializing.Helping;
1010
using FishNet.Utility.Performance;
11+
using GameKit.Dependencies.Utilities;
1112
using MonoFN.Cecil;
1213
using MonoFN.Cecil.Cil;
1314
using MonoFN.Cecil.Rocks;
1415
using System;
1516
using System.Collections.Generic;
17+
using System.Runtime.InteropServices.ComTypes;
1618
using UnityEngine;
1719
using SR = System.Reflection;
1820

@@ -63,13 +65,15 @@ internal class GeneralHelper : CodegenBase
6365
public TypeReference ActionT3_TypeRef;
6466
public MethodReference ActionT2Constructor_MethodRef;
6567
public MethodReference ActionT3Constructor_MethodRef;
68+
public TypeReference ObjectCaches_TypeRef;
6669

6770
private Dictionary<Type, TypeReference> _importedTypeReferences = new Dictionary<Type, TypeReference>();
6871
private Dictionary<FieldDefinition, FieldReference> _importedFieldReferences = new Dictionary<FieldDefinition, FieldReference>();
6972
private Dictionary<MethodReference, MethodDefinition> _methodReferenceResolves = new Dictionary<MethodReference, MethodDefinition>();
7073
private Dictionary<TypeReference, TypeDefinition> _typeReferenceResolves = new Dictionary<TypeReference, TypeDefinition>();
7174
private Dictionary<FieldReference, FieldDefinition> _fieldReferenceResolves = new Dictionary<FieldReference, FieldDefinition>();
7275
private Dictionary<string, MethodDefinition> _comparerDelegates = new Dictionary<string, MethodDefinition>();
76+
private MethodReference _objectCaches_Retrieve_MethodRef;
7377
#endregion
7478

7579
#region Const.
@@ -93,6 +97,9 @@ public override bool ImportReferences()
9397
ExcludeSerializationAttribute_FullName = typeof(ExcludeSerializationAttribute).FullName;
9498
NotSerializerAttribute_FullName = typeof(NotSerializerAttribute).FullName;
9599

100+
TypeReference _objectCaches_TypeRef = base.ImportReference(typeof(ObjectCaches<>));
101+
_objectCaches_Retrieve_MethodRef = _objectCaches_TypeRef.CachedResolve(base.Session).GetMethodReference(base.Session, nameof(ObjectCaches<int>.Retrieve));
102+
96103
tmpType = typeof(BasicQueue<>);
97104
base.ImportReference(tmpType);
98105
foreach (SR.MethodInfo mi in tmpType.GetMethods())
@@ -904,7 +911,23 @@ public VariableDefinition CreateVariable(MethodDefinition methodDef, Type variab
904911

905912
#region SetVariableDef.
906913
/// <summary>
907-
/// Initializes variableDef as a new object or collection of typeDef.
914+
/// Initializes variableDef as an object or collection of typeDef using cachces.
915+
/// </summary>
916+
/// <param name="processor"></param>
917+
/// <param name="variableDef"></param>
918+
/// <param name="typeDef"></param>
919+
public void SetVariableDefinitionFromCaches(ILProcessor processor, VariableDefinition variableDef, TypeDefinition typeDef)
920+
{
921+
TypeReference dataTr = variableDef.VariableType;
922+
GenericInstanceType git = ObjectCaches_TypeRef.MakeGenericInstanceType(new TypeReference[] { dataTr });
923+
924+
MethodReference genericInstanceMethod = _objectCaches_Retrieve_MethodRef.MakeHostInstanceGeneric(base.Session, git);
925+
processor.Emit(OpCodes.Call, genericInstanceMethod);
926+
processor.Emit(OpCodes.Stloc, variableDef);
927+
}
928+
929+
/// <summary>
930+
/// Initializes variableDef as a new object or collection of typeDef using instantiation.
908931
/// </summary>
909932
/// <param name="processor"></param>
910933
/// <param name="variableDef"></param>

Assets/FishNet/CodeGenerating/ILCore/FishNetILPP.cs

+38
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ public override ILPostProcessResult Process(ICompiledAssembly compiledAssembly)
7878
modified |= CreateDeclaredSerializerDelegates(session);
7979
modified |= CreateDeclaredSerializers(session);
8080
modified |= CreateDeclaredComparerDelegates(session);
81+
modified |= CreateIncludeSerializationSerializers(session);
8182
modified |= CreateIBroadcast(session);
8283
#if !DISABLE_QOL_ATTRIBUTES
8384
modified |= CreateQOLAttributes(session);
@@ -233,6 +234,43 @@ internal bool CreateDeclaredComparerDelegates(CodegenSession session)
233234

234235
return modified;
235236
}
237+
238+
/// <summary>
239+
/// Creates serializers for types that use IncludeSerialization attribute.
240+
/// </summary>
241+
private bool CreateIncludeSerializationSerializers(CodegenSession session)
242+
{
243+
string attributeName = typeof(IncludeSerializationAttribute).FullName;
244+
WriterProcessor wp = session.GetClass<WriterProcessor>();
245+
ReaderProcessor rp = session.GetClass<ReaderProcessor>();
246+
247+
bool modified = false;
248+
List<TypeDefinition> allTypeDefs = session.Module.Types.ToList();
249+
foreach (TypeDefinition td in allTypeDefs)
250+
{
251+
if (!CanSerialize())
252+
continue;
253+
254+
TypeReference tr = session.ImportReference(td);
255+
if (wp.CreateWriter(tr) != null && rp.CreateReader(tr) != null)
256+
modified = true;
257+
else
258+
session.LogError($"Failed to create serializers for {td.FullName}.");
259+
260+
bool CanSerialize()
261+
{
262+
foreach (CustomAttribute item in td.CustomAttributes)
263+
{
264+
if (item.AttributeType.FullName == attributeName)
265+
return true;
266+
}
267+
268+
return false;
269+
}
270+
}
271+
272+
return modified;
273+
}
236274

237275

238276
/// <summary>

Assets/FishNet/CodeGenerating/Processing/Prediction/PredictionProcessor.cs

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ internal bool GetPredictionMethods(TypeDefinition typeDef, out MethodDefinition
372372
{
373373
if (!MethodIsPrivate(methodDef) || AlreadyFound(reconcileMd))
374374
error = true;
375+
else
376+
reconcileMd = methodDef;
375377
}
376378
if (error)
377379
break;

Assets/FishNet/CodeGenerating/Processing/ReaderProcessor.cs

+15-4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
using FishNet.Utility.Performance;
1212
using FishNet.Object;
1313
using FishNet.Utility;
14+
using GameKit.Dependencies.Utilities;
1415

1516
namespace FishNet.CodeGenerating.Helping
1617
{
@@ -220,7 +221,7 @@ internal void CreateInitializeDelegate(MethodReference readMr)
220221
return;
221222

222223
GeneratedReader_OnLoad_MethodDef.RemoveEndRet(base.Session);
223-
224+
224225
//Check if already exist.
225226
ILProcessor processor = GeneratedReader_OnLoad_MethodDef.Body.GetILProcessor();
226227
TypeReference dataTypeRef = readMr.ReturnType;
@@ -365,7 +366,7 @@ internal List<Instruction> CreateRead(MethodDefinition methodDef, ParameterDefin
365366
TypeReference genericTr = base.ImportReference(readTypeRef);
366367
readMr = _readUnpackedMethodRef.GetMethodReference(base.Session, genericTr);
367368
}
368-
369+
369370
insts.Add(processor.Create(OpCodes.Call, readMr));
370371
//Store into local variable.
371372
insts.Add(processor.Create(OpCodes.Stloc, createdVariableDef));
@@ -1045,8 +1046,18 @@ private MethodReference CreateClassOrStructReaderMethodReference(TypeReference o
10451046
}
10461047

10471048
/* If here then not null. */
1048-
//Make a new instance of object type and set to objectVariableDef.
1049-
base.GetClass<GeneralHelper>().SetVariableDefinitionFromObject(processor, objectVariableDef, objectTypeDef);
1049+
//See if to use non-alloc reads.
1050+
if (objectTr.CachedResolve(base.Session).HasCustomAttribute<ReadUnallocated>())
1051+
{
1052+
//Make a new instance of object type and set to objectVariableDef.
1053+
base.GetClass<GeneralHelper>().SetVariableDefinitionFromCaches(processor, objectVariableDef, objectTypeDef);
1054+
}
1055+
else
1056+
{
1057+
//Make a new instance of object type and set to objectVariableDef.
1058+
base.GetClass<GeneralHelper>().SetVariableDefinitionFromObject(processor, objectVariableDef, objectTypeDef);
1059+
}
1060+
10501061
if (!ReadFieldsAndProperties(createdReaderMd, readerParameterDef, objectVariableDef, objectTr))
10511062
return null;
10521063
/* //codegen scriptableobjects seem to climb too high up to UnityEngine.Object when

Assets/FishNet/CodeGenerating/Processing/WriterProcessor.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ internal class WriterProcessor : CodegenBase
8080
/// </summary>
8181
public static readonly string[] EXCLUDED_ASSEMBLY_PREFIXES = new string[]
8282
{
83-
"UnityEngine."
83+
"UnityEngine.",
84+
"Unity.Mathmatics",
8485
};
8586
#endregion
8687

Assets/FishNet/Demos/Authenticator/Prefabs.meta

-8
This file was deleted.

Assets/FishNet/Demos/Authenticator/Prefabs/_Authenticator_Prefabs.asset

-15
This file was deleted.

Assets/FishNet/Demos/Authenticator/Prefabs/_Authenticator_Prefabs.asset.meta

-8
This file was deleted.

Assets/FishNet/Demos/Authenticator/Scenes/Authenticator.unity

+1-1
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ MonoBehaviour:
362362
_objectPool: {fileID: 0}
363363
_persistence: 0
364364
_logging: {fileID: 0}
365-
_spawnablePrefabs: {fileID: 11400000, guid: ab6a9000f5ff83f45b6761c2a3be018d, type: 2}
365+
_spawnablePrefabs: {fileID: 11400000, guid: 68e79e63a16f2c74e81f070bd36822b8, type: 2}
366366
--- !u!1 &7443408886491481971
367367
GameObject:
368368
m_ObjectHideFlags: 0

Assets/FishNet/Demos/ColliderRollback/Prefabs/_ColliderRollback_Prefabs.asset

-16
This file was deleted.

Assets/FishNet/Demos/ColliderRollback/Prefabs/_ColliderRollback_Prefabs.asset.meta

-8
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using FishNet.Component.ColliderRollback;
2-
using FishNet.Managing.Timing;
3-
using FishNet.Object;
4-
using System.Collections.Generic;
5-
using System.Linq;
6-
using UnityEngine;
7-
8-
9-
namespace FishNet.Example.ColliderRollbacks
10-
{
11-
12-
/// <summary>
13-
/// DEMO. CODE IS NOT OPTIMIZED.
14-
/// Fires at objects.
15-
/// </summary>
16-
public class Fire : NetworkBehaviour
17-
{
18-
19-
20-
}
21-
}
22-
1+
using FishNet.Component.ColliderRollback;
2+
using FishNet.Managing.Timing;
3+
using FishNet.Object;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using UnityEngine;
7+
8+
9+
namespace FishNet.Example.ColliderRollbacks
10+
{
11+
12+
/// <summary>
13+
/// DEMO. CODE IS NOT OPTIMIZED.
14+
/// Fires at objects.
15+
/// </summary>
16+
public class Fire : NetworkBehaviour
17+
{
18+
19+
20+
}
21+
}
22+

Assets/FishNet/Demos/HashGrid/Prefabs/_HashGrid_Prefabs.asset

-17
This file was deleted.

Assets/FishNet/Demos/HashGrid/Prefabs/_HashGrid_Prefabs.asset.meta

-8
This file was deleted.

Assets/FishNet/Demos/HashGrid/Scenes/HashGrid_Demo.unity

+13-3
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,14 @@ MonoBehaviour:
290290
_initializeOrder: 0
291291
_defaultDespawnType: 0
292292
NetworkObserver: {fileID: 0}
293+
_enablePrediction: 0
294+
_predictionType: 0
295+
_graphicalObject: {fileID: 0}
296+
_enableStateForwarding: 1
297+
_networkTransform: {fileID: 0}
298+
_ownerInterpolation: 1
299+
_enableTeleport: 0
300+
_teleportThreshold: 1
293301
<PrefabId>k__BackingField: 0
294302
<SpawnableCollectionId>k__BackingField: 0
295303
_scenePathHash: 1046374546
@@ -429,6 +437,7 @@ MonoBehaviour:
429437
- 90
430438
- 100
431439
_updateHostVisibility: 1
440+
_maximumTimedObserversDuration: 10
432441
_defaultConditions:
433442
- {fileID: 11400000, guid: cc503f7541ebd424c94541e6a767efee, type: 2}
434443
--- !u!114 &1424052073952814568
@@ -854,6 +863,7 @@ Canvas:
854863
m_OverrideSorting: 0
855864
m_OverridePixelPerfect: 0
856865
m_SortingBucketNormalizedSize: 0
866+
m_VertexColorAlwaysGammaSpace: 0
857867
m_AdditionalShaderChannelsFlag: 0
858868
m_SortingLayerID: 0
859869
m_SortingOrder: 0
@@ -1002,7 +1012,7 @@ MonoBehaviour:
10021012
_objectPool: {fileID: 0}
10031013
_persistence: 0
10041014
_logging: {fileID: 0}
1005-
_spawnablePrefabs: {fileID: 11400000, guid: 2863463f6933f3f439a639f883f642f6, type: 2}
1015+
_spawnablePrefabs: {fileID: 11400000, guid: 68e79e63a16f2c74e81f070bd36822b8, type: 2}
10061016
--- !u!1 &7443408886575219563
10071017
GameObject:
10081018
m_ObjectHideFlags: 0
@@ -1090,9 +1100,9 @@ MonoBehaviour:
10901100
_ipv4BindAddress:
10911101
_enableIpv6: 1
10921102
_ipv6BindAddress:
1093-
_port: 30681
1103+
_port: 7112
10941104
_maximumClients: 4095
1095-
_clientAddress: 4d3a4e3f1ace.pr.edgegap.net
1105+
_clientAddress: localhost
10961106
--- !u!224 &9139860295505404435
10971107
RectTransform:
10981108
m_ObjectHideFlags: 0

Assets/FishNet/Demos/IntermediateLayer/Prefabs.meta

-8
This file was deleted.

0 commit comments

Comments
 (0)