Skip to content

Commit

Permalink
4.1.2
Browse files Browse the repository at this point in the history
- Improved missing Newtsonsoft dependency for Edgegap will warn less frequently now.
- Changed revert ReadPermission values due to some experiencing a Unity serialization bug.
- Improved client and server now check for duplicate sceneIds at runtime when a scene is loaded.
- Fixed a critical TimeManager error where timing updates were not sending to clients.
- Fixed regression where server would kick client for sending an invalid LOD while client owned multiple objects.
- Added ColliderExtensions utility.
- Fixed detection accuracy on NetworkCollision/Trigger components.
  • Loading branch information
FirstGearGames committed Feb 23, 2024
1 parent 56e4d76 commit 600063f
Show file tree
Hide file tree
Showing 16 changed files with 501 additions and 94 deletions.
Original file line number Diff line number Diff line change
@@ -1,63 +1,63 @@
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace IO.Swagger.Model {

/// <summary>
///
/// </summary>
[DataContract]
public class ApiModelContainercrashdata {
/// <summary>
/// Auto Generated Field for exit_code
/// </summary>
/// <value>Auto Generated Field for exit_code</value>
[DataMember(Name="exit_code", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "exit_code")]
public int? ExitCode { get; set; }

/// <summary>
/// Auto Generated Field for message
/// </summary>
/// <value>Auto Generated Field for message</value>
[DataMember(Name="message", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }

/// <summary>
/// Auto Generated Field for restart_count
/// </summary>
/// <value>Auto Generated Field for restart_count</value>
[DataMember(Name="restart_count", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "restart_count")]
public int? RestartCount { get; set; }


/// <summary>
/// Get the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString() {
StringBuilder sb = new StringBuilder();
sb.Append("class ApiModelContainercrashdata {\n");
sb.Append(" ExitCode: ").Append(ExitCode).Append("\n");
sb.Append(" Message: ").Append(Message).Append("\n");
sb.Append(" RestartCount: ").Append(RestartCount).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson() {
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

}
}
using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;

namespace IO.Swagger.Model {

/// <summary>
///
/// </summary>
[DataContract]
public class ApiModelContainercrashdata {
/// <summary>
/// Auto Generated Field for exit_code
/// </summary>
/// <value>Auto Generated Field for exit_code</value>
[DataMember(Name="exit_code", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "exit_code")]
public int? ExitCode { get; set; }

/// <summary>
/// Auto Generated Field for message
/// </summary>
/// <value>Auto Generated Field for message</value>
[DataMember(Name="message", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }

/// <summary>
/// Auto Generated Field for restart_count
/// </summary>
/// <value>Auto Generated Field for restart_count</value>
[DataMember(Name="restart_count", EmitDefaultValue=false)]
[JsonProperty(PropertyName = "restart_count")]
public int? RestartCount { get; set; }


/// <summary>
/// Get the string presentation of the object
/// </summary>
/// <returns>String presentation of the object</returns>
public override string ToString() {
StringBuilder sb = new StringBuilder();
sb.Append("class ApiModelContainercrashdata {\n");
sb.Append(" ExitCode: ").Append(ExitCode).Append("\n");
sb.Append(" Message: ").Append(Message).Append("\n");
sb.Append(" RestartCount: ").Append(RestartCount).Append("\n");
sb.Append("}\n");
return sb.ToString();
}

/// <summary>
/// Get the JSON string presentation of the object
/// </summary>
/// <returns>JSON string presentation of the object</returns>
public string ToJson() {
return JsonConvert.SerializeObject(this, Formatting.Indented);
}

}
}
38 changes: 34 additions & 4 deletions Assets/FishNet/Plugins/Edgegap/Newtonsoft_Package_Patch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,47 @@

#if UNITY_EDITOR
using UnityEditor;

namespace Newtonsoft.Json
{
{
public static class FallbackDisplayer
{
private const string WARN_TIME_NAME = "EdgegapWarnTime";

internal static void ResetWarnTime()
{
EditorPrefs.SetString(WARN_TIME_NAME, DateTime.Now.ToBinary().ToString());
}


[InitializeOnLoadMethod]
private static void Initialize()
{
UnityEngine.Debug.LogWarning($"Edgegap requires Json.NET to be imported to function. To import Json.NET navigate to Window -> Package Manager -> Click the + symbol and choose 'Add package by name' -> com.unity.nuget.newtonsoft-json -> Leave version blank and click Add.");
{
string dtStr = EditorPrefs.GetString(WARN_TIME_NAME, string.Empty);
//Somehow got cleared. Reset.
if (string.IsNullOrWhiteSpace(dtStr))
{
ResetWarnTime();
}
else
{
long binary;
//Failed to parse.
if (!long.TryParse(dtStr, out binary))
{
ResetWarnTime();
}
else
{
//Not enough time passed.
DateTime dt = DateTime.FromBinary(binary);
if ((DateTime.Now - dt).TotalMinutes < 30)
return;
}

}

UnityEngine.Debug.LogWarning($"Edgegap requires Json.NET to be imported to function. To import Json.NET navigate to Window -> Package Manager -> Click the + symbol and choose 'Add package by name' -> com.unity.nuget.newtonsoft-json -> Leave version blank and click Add. If you are not currently using Edgegap you may ignore this message.");
}
}
}
Expand Down
10 changes: 8 additions & 2 deletions Assets/FishNet/Runtime/Editor/Configuring/ConfigurationEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,12 @@ public static void RebuildSceneIds()
return;
}
#endif
if (ApplicationState.IsPlaying())
{
Debug.Log($"SceneIds cannot be rebuilt while in play mode.");
return;
}

int generatedCount = 0;
int processedScenes = 0;
for (int i = 0; i < SceneManager.sceneCount; i++)
Expand All @@ -153,7 +159,7 @@ public static void RebuildSceneIds()

processedScenes++;
List<NetworkObject> nobs = CollectionCaches<NetworkObject>.RetrieveList();
Scenes.GetSceneNetworkObjects(s, false, ref nobs);
Scenes.GetSceneNetworkObjects(s, false, false, ref nobs);
int nobCount = nobs.Count;
for (int z = 0; z < nobCount; z++)
{
Expand Down Expand Up @@ -225,7 +231,7 @@ public static void RemoveDuplicateNetworkObjects()
Scene s = SceneManager.GetSceneAt(i);

List<NetworkObject> nobs = CollectionCaches<NetworkObject>.RetrieveList();
Scenes.GetSceneNetworkObjects(s, false, ref nobs);
Scenes.GetSceneNetworkObjects(s, false, false, ref nobs);
int nobsCount = nobs.Count;
for (int z = 0; z < nobsCount; z++)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private void Rigidbodies_OnOwnershipClient(NetworkConnection prevOwner)
if (_graphicalAnimators.Length > 0)
{
for (int i = 0; i < _graphicalAnimators.Length; i++)
_graphicalAnimators[i].keepAnimatorControllerStateOnDisable = true;
_graphicalAnimators[i].keepAnimatorStateOnDisable = true;

/* True if at least one animator is on the graphical root.
* Unity gets components in order so it's safe to assume
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,8 +408,8 @@ int GetHistoryIndex(uint lTick, bool getClosest)
/// <returns>Number of colliders hit.</returns>
private int GetSphereColliderHits(SphereCollider sphereCollider, int layerMask)
{
float scaledRadius = (sphereCollider.radius * transform.lossyScale.magnitude);
return Physics.OverlapSphereNonAlloc(sphereCollider.bounds.center, scaledRadius, _hits, layerMask);
sphereCollider.GetSphereCastParams(out Vector3 center, out float radius);
return Physics.OverlapSphereNonAlloc(center, radius, _hits, layerMask);
}

/// <summary>
Expand Down Expand Up @@ -441,10 +441,8 @@ private int GetCapsuleColliderHits(CapsuleCollider capsuleCollider, int layerMas
return 0;
}

Vector3 start = (center + offset);
Vector3 end = (center - offset);
float scaledRadius = (capsuleCollider.radius * transform.lossyScale.magnitude);
return Physics.OverlapCapsuleNonAlloc(start, end, scaledRadius, _hits, layerMask);
capsuleCollider.GetCapsuleCastParams(out Vector3 start, out Vector3 end, out float radius);
return Physics.OverlapCapsuleNonAlloc(start, end, radius, _hits, layerMask);
}

/// <summary>
Expand All @@ -453,8 +451,8 @@ private int GetCapsuleColliderHits(CapsuleCollider capsuleCollider, int layerMas
/// <returns>Number of colliders hit.</returns>
private int GetBoxColliderHits(BoxCollider boxCollider, Quaternion rotation, int layerMask)
{
Bounds bounds = boxCollider.bounds;
return Physics.OverlapBoxNonAlloc(bounds.center, bounds.extents, _hits, rotation, layerMask);
boxCollider.GetBoxCastParams(out Vector3 center, out Vector3 halfExtents);
return Physics.OverlapBoxNonAlloc(center, halfExtents, _hits, rotation, layerMask);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ internal void OnClientConnectionState(ClientConnectionStateArgs args)
else
{
foreach (NetworkObject n in Spawned.Values)
{
{
n.InvokeStopCallbacks(false);
n.SetInitializedStatus(false, false);
}
Expand Down Expand Up @@ -263,7 +263,7 @@ internal void RegisterAndDespawnSceneObjects()
private void RegisterAndDespawnSceneObjects(Scene s)
{
List<NetworkObject> nobs = CollectionCaches<NetworkObject>.RetrieveList();
Scenes.GetSceneNetworkObjects(s, false, ref nobs);
Scenes.GetSceneNetworkObjects(s, false, true, ref nobs);

int nobsCount = nobs.Count;
for (int i = 0; i < nobsCount; i++)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ private void SetupSceneObjects(Scene s)
return;

List<NetworkObject> sceneNobs = CollectionCaches<NetworkObject>.RetrieveList();
Scenes.GetSceneNetworkObjects(s, false, ref sceneNobs);
Scenes.GetSceneNetworkObjects(s, false, true, ref sceneNobs);

//Sort the nobs based on initialization order.
bool initializationOrderChanged = false;
Expand Down
1 change: 0 additions & 1 deletion Assets/FishNet/Runtime/Managing/Timing/TimeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,6 @@ private void TryIterateData(bool incoming)
/// </summary>
private void SendTimingAdjustment()
{
return;
//Send every second.
if (LocalTick % _tickRate == 0)
{
Expand Down
Loading

0 comments on commit 600063f

Please sign in to comment.