Skip to content

Commit

Permalink
4.4.3
Browse files Browse the repository at this point in the history
- Fixed replicates not running on server when StateForwarding was disabled.
- Fixed SyncTypes resetting incorrectly when there were no observers.
- Fixed NetworkTransform debug left in.
- Fixed ObjectCaching missing variables during compiles (#760).
  • Loading branch information
FirstGearGames committed Aug 22, 2024
1 parent 5397658 commit 732a99d
Show file tree
Hide file tree
Showing 28 changed files with 172 additions and 178 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ Documentation
*.vs/
*.vsconfig
*.csproj.meta
.idea
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ internal void CreateReplicateDelegate(MethodDefinition originalMethodDef, Method
/// <param name="rpcType"></param>
internal void CreateRpcDelegate(bool runLocally, TypeDefinition typeDef, MethodDefinition readerMethodDef, RpcType rpcType, uint methodHash, CustomAttribute rpcAttribute)
{



MethodDefinition methodDef = typeDef.GetMethod(NetworkBehaviourProcessor.NETWORKINITIALIZE_EARLY_INTERNAL_NAME);
ILProcessor processor = methodDef.Body.GetILProcessor();
Expand Down
4 changes: 2 additions & 2 deletions Assets/FishNet/CodeGenerating/ILCore/FishNetILPP.cs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ private bool CreateQOLAttributes(CodegenSession session)
bool modified = false;

bool codeStripping = false;


List<TypeDefinition> allTypeDefs = session.Module.Types.ToList();

/* First pass, potentially only pass.
Expand All @@ -351,7 +351,7 @@ private bool CreateQOLAttributes(CodegenSession session)
modified |= session.GetClass<QolAttributeProcessor>().Process(td, codeStripping);
}




return modified;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal bool ProcessLocal(TypeDefinition typeDef)
CreateNetworkInitializeMethods(td, out networkInitializeIfDisabledMd);
CallNetworkInitializesFromNetworkInitializeIfDisabled(networkInitializeIfDisabledMd);




/* Prediction. */
/* Run prediction first since prediction will modify
Expand Down Expand Up @@ -198,7 +198,7 @@ internal bool NonNetworkBehaviourHasInvalidAttributes(Collection<TypeDefinition>
return false;
}




/// <summary>
/// Calls the next awake method if the nested awake was created by codegen.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal bool Process(TypeDefinition typeDef, bool moveStrippedCalls)
bool modified = false;
List<MethodDefinition> methods = typeDef.Methods.ToList();




foreach (MethodDefinition md in methods)
{
Expand Down Expand Up @@ -152,14 +152,14 @@ private void CreateAttributeMethod(MethodDefinition methodDef, CustomAttribute q

bool StripMethod(MethodDefinition md)
{



//Fall through.
return false;
}
}



}

}
12 changes: 6 additions & 6 deletions Assets/FishNet/CodeGenerating/Processing/Rpc/RpcProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ private MethodDefinition CreateRpcWriterMethod(List<ParameterDefinition> seriali
{
intentionallyNull = false;




string methodName = $"{WRITER_PREFIX}{GetRpcMethodName(cr)}";
/* If method already exist then clear it. This
Expand Down Expand Up @@ -376,7 +376,7 @@ private bool CreateClientRpcWriterMethod(List<ParameterDefinition> serializedPar
/* Creates basic ServerRpc and ClientRpc
* conditions such as if requireOwnership ect..
* or if (!base.isClient) */


CreateClientRpcConditionsForServer(writerMd);

VariableDefinition channelVariableDef = CreateAndPopulateChannelVariable(writerMd, channelParameterDef);
Expand Down Expand Up @@ -434,7 +434,7 @@ private bool CreateServerRpcWriterMethod(List<ParameterDefinition> serializedPar
/* Creates basic ServerRpc
* conditions such as if requireOwnership ect..
* or if (!base.isClient) */


CreateServerRpcConditionsForClient(writerMd, cr.Attribute);

VariableDefinition channelVariableDef = CreateAndPopulateChannelVariable(writerMd, channelParameterDef);
Expand Down Expand Up @@ -500,7 +500,7 @@ private MethodDefinition CreateRpcReaderMethod(List<ParameterDefinition> seriali
MethodDefinition logicMd = cr.LogicMethodDef;
CustomAttribute rpcAttribute = cr.Attribute;




string methodName = $"{READER_PREFIX}{GetRpcMethodName(cr)}";
/* If method already exist then just return it. This
Expand Down Expand Up @@ -873,7 +873,7 @@ private MethodDefinition CreateRpcLogicMethod(List<AttributeData> datas, Created
TypeDefinition typeDef = cr.TypeDef;
MethodDefinition originalMd = cr.OriginalMethodDef;




//Methodname for logic methods do not use prefixes because there can be only one.
string methodName = $"{LOGIC_PREFIX}{GetMethodNameAsParameters(originalMd)}";
Expand Down Expand Up @@ -930,7 +930,7 @@ private void RedirectOriginalToWriter(List<CreatedRpc> createdRpcs)
* entry. */
MethodDefinition originalMd = createdRpcs[0].OriginalMethodDef;




ILProcessor processor = originalMd.Body.GetILProcessor();
originalMd.Body.Instructions.Clear();
Expand Down
12 changes: 6 additions & 6 deletions Assets/FishNet/Runtime/Editor/CodeStripping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace FishNet.Configuring


public class CodeStripping


{

/// <summary>
Expand All @@ -35,7 +35,7 @@ public static bool RemoveServerLogic
{
get
{



/* This is to protect non pro users from enabling this
* without the extra logic code. */
Expand All @@ -51,7 +51,7 @@ public static bool StripBuild
{
get
{



/* This is to protect non pro users from enabling this
* without the extra logic code. */
Expand All @@ -75,7 +75,7 @@ public void OnPreprocessBuild(BuildReport report)
CompilationPipeline.compilationStarted += CompilationPipelineOnCompilationStarted;
CompilationPipeline.compilationFinished += CompilationPipelineOnCompilationFinished;



}
/* Solution for builds ending with errors and not triggering OnPostprocessBuild.
* Link: https://gamedev.stackexchange.com/questions/181611/custom-build-failure-callback
Expand All @@ -100,14 +100,14 @@ private void CompilationPipelineOnCompilationFinished(object compilationContext)

private void BuildingEnded()
{



Generator.IgnorePostProcess = false;
}

public void OnPostprocessBuild(BuildReport report)
{


BuildingEnded();
}
}
Expand Down
4 changes: 2 additions & 2 deletions Assets/FishNet/Runtime/Editor/ScriptingDefines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void AddDefineSymbols()
{
"FISHNET",
thisVersion,


};
bool modified = false;
//Now add FN defines.
Expand All @@ -60,7 +60,7 @@ public static void AddDefineSymbols()
modified |= definesHs.Remove("PREDICTION_V2");
/* Remove pro define if not on pro. This might look a little
* funny because the code below varies depending on if pro or not. */


#pragma warning disable CS0162 // Unreachable code detected
modified |= definesHs.Remove(proDefine);
#pragma warning restore CS0162 // Unreachable code detected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public override void OnInspectorGUI()
EditorGUILayout.ObjectField("Script:", MonoScript.FromMonoBehaviour(na), typeof(NetworkAnimator), false);
GUI.enabled = true;



#pragma warning disable CS0162 // Unreachable code detected
EditorGUILayout.HelpBox(EditingConstants.PRO_ASSETS_LOCKED_TEXT, MessageType.Warning);
#pragma warning restore CS0162 // Unreachable code detected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ private void InitializeOnce()
foreach (AnimatorControllerParameter item in _animator.parameters)
{
bool process = !_animator.IsParameterControlledByCurve(item.name);


if (process)
{
//Over 250 parameters; who would do this!?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public override void OnInspectorGUI()
GameKitEditing.AddObjectField("Script:", MonoScript.FromMonoBehaviour((NetworkTransform)target), typeof(NetworkTransform), false, EditorLayoutEnableType.Disabled);

bool isPro = false;


if (isPro)
EditorGUILayout.HelpBox(EditingConstants.PRO_ASSETS_UNLOCKED_TEXT, MessageType.None);
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1553,7 +1553,7 @@ private void MoveToTarget(float delta)
//No more in buffer, see if can extrapolate.
else
{


/* If everything matches up then end queue.
* Otherwise let it play out until stuff
* aligns. Generally the time remaining is enough
Expand All @@ -1562,7 +1562,7 @@ private void MoveToTarget(float delta)
if (!HasChanged(td))
_currentGoalData = null;
OnInterpolationComplete?.Invoke();


}
}
}
Expand Down Expand Up @@ -2073,7 +2073,7 @@ private void SetExtrapolation(TransformData prev, TransformData next, Channel ch
//Default value.
next.ExtrapolationState = TransformData.ExtrapolateState.Disabled;



}


Expand Down Expand Up @@ -2103,7 +2103,6 @@ private void TargetUpdateTransform(NetworkConnection conn, ArraySegment<byte> da
[ObserversRpc]
private void ObserversUpdateClientAuthoritativeTransform(ArraySegment<byte> data, Channel channel)
{
Debug.Log($"Got observerRpc");
if (!_clientAuthoritative && base.IsOwner && !_sendToOwner)
return;
if (_clientAuthoritative && base.IsOwner)
Expand Down
14 changes: 2 additions & 12 deletions Assets/FishNet/Runtime/Managing/Client/Object/ObjectCaching.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
#if UNITY_EDITOR || DEVELOPMENT_BUILD
#define DEVELOPMENT
#endif
using FishNet.Connection;
using FishNet.Connection;
using FishNet.Managing.Object;
using FishNet.Object;
using FishNet.Object.Helping;
using FishNet.Serializing;
using FishNet.Utility.Extension;
using FishNet.Utility.Performance;
using GameKit.Dependencies.Utilities;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -583,10 +578,8 @@ public enum ActionType
public Quaternion? Rotation;
public Vector3? Scale;
public ulong SceneId;
#if DEVELOPMENT
public string SceneName = string.Empty;
public string ObjectName = string.Empty;
#endif

/// <summary>
/// True if spawning.
Expand Down Expand Up @@ -631,10 +624,9 @@ public void InitializeSpawn(NetworkManager manager, ushort collectionId, int obj
Rotation = rotation;
Scale = scale;
SceneId = sceneId;
#if DEVELOPMENT
SceneName = sceneName;
ObjectName = objectName;
#endif

if (payload.Count > 0)
PayloadReader = ReaderPool.Retrieve(payload, manager);
if (rpcLinks.Count > 0)
Expand All @@ -660,10 +652,8 @@ public void InitializeDespawn(int objectId, DespawnType despawnType)
/// </summary>
public void ResetState()
{
#if DEVELOPMENT
SceneName = string.Empty;
ObjectName = string.Empty;
#endif
NetworkObject = null;

ReaderPool.StoreAndDefault(ref PayloadReader);
Expand Down
2 changes: 1 addition & 1 deletion Assets/FishNet/Runtime/Managing/NetworkManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public static IReadOnlyList<NetworkManager> Instances
/// <summary>
/// Version of this release.
/// </summary>
public const string FISHNET_VERSION = "4.4.2";
public const string FISHNET_VERSION = "4.4.3";
/// <summary>
/// Maximum framerate allowed.
/// </summary>
Expand Down
18 changes: 15 additions & 3 deletions Assets/FishNet/Runtime/Object/NetworkBehaviour.Prediction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,16 @@ protected internal void Replicate_Replay_Authoritative<T>(uint replayTick, Repli
/// </summary>
protected internal void Replicate_Replay_NonAuthoritative<T>(uint replayTick, ReplicateUserLogicDelegate<T> del, List<T> replicatesHistory, Channel channel) where T : IReplicateData
{

//NOTESSTART
/* When inserting states only replay the first state after the reconcile.
* This prevents an inconsistency on running created states if other created states
* were to arrive late. Essentially the first state is considered 'current' and the rest
* are acting as a buffer against unsteady networking conditions. */

/* When appending states all created can be run. Appended states are only inserted after they've
* run at the end of the tick, which performs of it's own queue. Because of this, it's safe to assume
* if the state has been inserted into the past it has already passed it's buffer checks. */
//NOTESEND
T data;
ReplicateState state;
bool isAppendedOrder = _networkObjectCache.PredictionManager.IsAppendedStateOrder;
Expand Down Expand Up @@ -605,10 +614,13 @@ protected internal void EmptyReplicatesQueueIntoHistory<T>(BasicQueue<T> replica
[APIExclude]
protected internal void Replicate_NonAuthoritative<T>(ReplicateUserLogicDelegate<T> del, BasicQueue<T> replicatesQueue, List<T> replicatesHistory, Channel channel) where T : IReplicateData
{
bool ownerlessAndServer = (!Owner.IsValid && IsServerStarted);
bool serverStarted = _networkObjectCache.IsServerStarted;
bool ownerlessAndServer = (!Owner.IsValid && serverStarted);
if (IsOwner || ownerlessAndServer)
return;
if (!_networkObjectCache.EnableStateForwarding)
/* Still need to run inputs if server, even if forwarding
* is not enabled.*/
if (!_networkObjectCache.EnableStateForwarding && !serverStarted)
return;

TimeManager tm = _networkObjectCache.TimeManager;
Expand Down
30 changes: 20 additions & 10 deletions Assets/FishNet/Runtime/Object/NetworkBehaviour.SyncTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,19 +199,29 @@ internal void ReadSyncType(PooledReader reader, int writtenLength, bool asServer
/// <returns>True if there are no pending dirty sync types.</returns>
internal bool WriteDirtySyncTypes(SyncTypeWriteFlag flags)
{
// /* IsSpawned Can occur when a synctype is queued after
// * the object is marked for destruction. This should not
// * happen under most conditions since synctypes will be
// * pushed through when despawn is called.
// *
// * No observers can occur when the server changes a syncType
// * value but gained no observers in the same tick. We still
// * want to mark a syncType as dirty in this situation because
// * it needs to write in a despawn message in the scenario the object
// * is spawned (no observers), synctype changed, then despawned immediately
// * after.
// */
// if (!IsSpawned || _networkObjectCache.Observers.Count == 0)
// {
// ResetState_SyncTypes(asServer: true);
// return true;
// }

/* IsSpawned Can occur when a synctype is queued after
* the object is marked for destruction. This should not
* happen under most conditions since synctypes will be
* pushed through when despawn is called.
*
* No observers can occur when the server changes a syncType
* value but gained no observers in the same tick. We still
* want to mark a syncType as dirty in this situation because
* it needs to write in a despawn message in the scenario the object
* is spawned (no observers), synctype changed, then despawned immediately
* after.
*/
if (!IsSpawned || _networkObjectCache.Observers.Count == 0)
* pushed through when despawn is called. */
if (!IsSpawned)
{
ResetState_SyncTypes(asServer: true);
return true;
Expand Down
Loading

0 comments on commit 732a99d

Please sign in to comment.