From c0acd84e0fe7b44c9afd3faaea07e0b3de408a4f Mon Sep 17 00:00:00 2001 From: Paul Hazen Date: Tue, 16 Apr 2024 13:01:18 -0700 Subject: [PATCH] release 3.1.1 --- .gitattributes | 19 -------- CHANGELOG.md | 9 +++- Editor/Configs/EditorConfig.cs | 5 +++ Editor/Utility/BuildUtility.cs | 1 - Runtime/Core/EOSCreateOptions.cs | 2 +- Runtime/Core/EOSInitializeOptions.cs | 14 ++---- Runtime/Core/EOSPackageInfo.cs | 2 +- Runtime/Core/PlatformSpecifics.cs | 11 ++++- .../Scripts/Networking/EOSTransport.cs | 9 +--- .../Scripts/Networking/EOSTransportManager.cs | 43 ++++++++++++------- package.json | 4 +- 11 files changed, 58 insertions(+), 61 deletions(-) delete mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index b95d21cf..00000000 --- a/.gitattributes +++ /dev/null @@ -1,19 +0,0 @@ -*.cs diff=csharp text eol=lf -*.cginc text -*.shader text -*.mat merge=unityyamlmerge eol=lf -*.anim merge=unityyamlmerge eol=lf -*.unity merge=unityyamlmerge eol=lf -*.prefab merge=unityyamlmerge eol=lf -*.physicsMaterial2D merge=unityyamlmerge eol=lf -*.physicMaterial merge=unityyamlmerge eol=lf -*.asset merge=unityyamlmerge eol=lf -*.meta merge=unityyamlmerge eol=lf -*.controller merge=unityyamlmerge eol=lf -*.dll filter=lfs diff=lfs merge=lfs -text -*.lib filter=lfs diff=lfs merge=lfs -text -*.jpeg filter=lfs diff=lfs merge=lfs -text -*.png filter=lfs diff=lfs merge=lfs -text -Runtime/iOS/EOSSDK.framework/EOSSDK filter=lfs diff=lfs merge=lfs -text -*.dylib filter=lfs diff=lfs merge=lfs -text -*.exe filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index e38dc910..1866c4a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -# [3.1.0] - 2023-03-25 +# [3.1.1] - 2024-04-15 + +### Fixed +- Fix file access to be compiler-conditional for Android. +- Make compile-time conditional surrounding interface property match the compile-time conditional surrounding the implementation. +- Add compile-time conditional around WriteAsync override implementation. + +# [3.1.0] - 2024-04-11 ### Added - feat: Added extension methods to be used by sample scripts. - feat: Moved checks for input to `InputUtility` class for better abstraction. diff --git a/Editor/Configs/EditorConfig.cs b/Editor/Configs/EditorConfig.cs index 3fe44888..69066d54 100644 --- a/Editor/Configs/EditorConfig.cs +++ b/Editor/Configs/EditorConfig.cs @@ -38,6 +38,9 @@ public abstract class EditorConfig : Config { protected EditorConfig(string filename) : base(filename, Path.Combine(FileUtility.GetProjectPath(), "etc/config/")) { } + // NOTE: This compiler block is here because the base class "Config" has + // the WriteAsync function surrounded by the same conditional. +#if UNITY_EDITOR // Overridden functionality changes the default parameter value for updateAssetDatabase, because EditorConfig // should not be anywhere within Assets. public override async Task WriteAsync(bool prettyPrint = true, bool updateAssetDatabase = false) @@ -45,5 +48,7 @@ public override async Task WriteAsync(bool prettyPrint = true, bool updateAssetD // Override the base function await base.WriteAsync(prettyPrint, updateAssetDatabase); } +#endif } + } \ No newline at end of file diff --git a/Editor/Utility/BuildUtility.cs b/Editor/Utility/BuildUtility.cs index 89db9306..a6e8faac 100644 --- a/Editor/Utility/BuildUtility.cs +++ b/Editor/Utility/BuildUtility.cs @@ -26,7 +26,6 @@ namespace PlayEveryWare.EpicOnlineServices.Build { - using Codice.Client.IssueTracker; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PlayEveryWare.EpicOnlineServices.Utility; diff --git a/Runtime/Core/EOSCreateOptions.cs b/Runtime/Core/EOSCreateOptions.cs index 0b48dd88..0424a540 100644 --- a/Runtime/Core/EOSCreateOptions.cs +++ b/Runtime/Core/EOSCreateOptions.cs @@ -44,7 +44,7 @@ public class EOSCreateOptions : IEOSCreateOptions #region Platform-Specific properties -#if UNITY_PS5 || UNITY_GAMECORE || UNITY_SWITCH || UNITY_ANDROID || UNITY_IOS +#if !(UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN || UNITY_STANDALONE_LINUX || UNITY_EDITOR_LINUX || UNITY_STANDALONE_OSX || UNITY_EDITOR_OSX) public IntegratedPlatformOptionsContainer IntegratedPlatformOptionsContainerHandle { get => options.IntegratedPlatformOptionsContainerHandle; set => options.IntegratedPlatformOptionsContainerHandle = value; } #endif diff --git a/Runtime/Core/EOSInitializeOptions.cs b/Runtime/Core/EOSInitializeOptions.cs index 0858fedd..76ec5756 100644 --- a/Runtime/Core/EOSInitializeOptions.cs +++ b/Runtime/Core/EOSInitializeOptions.cs @@ -32,20 +32,14 @@ public class EOSInitializeOptions : IEOSInitializeOptions #region Platform-specific stuff public -#if !UNITY_EDITOR - Epic.OnlineServices.Platform.InitializeOptions +#if UNITY_ANDROID + AndroidInitializeOptions #else -#if UNITY_STANDALONE_WIN || UNITY_IOS || UNITY_STANDALONE_OSX || UNITY_STANDALONE_LINUX - Epic.OnlineServices.Platform.InitializeOptions -#elif UNITY_ANDROID - Epic.OnlineServices.Platform.AndroidInitializeOptions -#else - // Leaving "else" open so that if a new platform comes along we'll catch it. -#endif + InitializeOptions #endif options; - #endregion +#endregion public IntPtr AllocateMemoryFunction { get => options.AllocateMemoryFunction; set => options.AllocateMemoryFunction = value; } public IntPtr ReallocateMemoryFunction { get => options.ReallocateMemoryFunction; set => options.ReallocateMemoryFunction = value; } diff --git a/Runtime/Core/EOSPackageInfo.cs b/Runtime/Core/EOSPackageInfo.cs index df7e70ad..42f09952 100644 --- a/Runtime/Core/EOSPackageInfo.cs +++ b/Runtime/Core/EOSPackageInfo.cs @@ -35,7 +35,7 @@ public static class EOSPackageInfo * not involve editing source code files. */ - public const string Version = "3.1.0"; + public const string Version = "3.1.1"; public const string PackageName = "com.playeveryware.eos"; } diff --git a/Runtime/Core/PlatformSpecifics.cs b/Runtime/Core/PlatformSpecifics.cs index c454dba9..ce25d881 100644 --- a/Runtime/Core/PlatformSpecifics.cs +++ b/Runtime/Core/PlatformSpecifics.cs @@ -101,7 +101,14 @@ public virtual void ConfigureSystemInitOptions(ref IEOSInitializeOptions initial } string configPath = PlatformManager.GetConfigFilePath(Platform); - string configJson = File.ReadAllText(configPath); + + string configJson = +#if UNITY_ANDROID && !UNITY_EDITOR + AndroidFileIOHelper.ReadAllText(configPath); +#else + File.ReadAllText(configPath); +#endif + T config = JsonUtility.FromJson(configJson); if (config != null && initializeOptions.OverrideThreadAffinity.HasValue) @@ -129,7 +136,7 @@ public virtual Int32 IsReadyForNetworkActivity() return 1; } - #endregion +#endregion } } #endif //!EOS_DISABLE \ No newline at end of file diff --git a/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransport.cs b/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransport.cs index 3f019501..97dc0e6f 100644 --- a/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransport.cs +++ b/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransport.cs @@ -155,14 +155,7 @@ public override void Send(ulong clientId, ArraySegment payload, NetworkDel } } - // Construct our packet to be sent (ie. the payload array segment) - byte[] packet = new byte[payload.Count]; - Array.Copy(payload.Array, payload.Offset, // Source - packet, 0, // Destination - payload.Count); // Length to copy - - - P2PManager.SendPacket(userId, P2PSocketName, packet, 0, false, reliability); + P2PManager.SendPacket(userId, P2PSocketName, payload, 0, false, reliability); } /// diff --git a/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransportManager.cs b/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransportManager.cs index 3ba1e1bd..a14fbf0b 100644 --- a/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransportManager.cs +++ b/Samples~/Samples/P2PNetcodeSample/Scripts/Networking/EOSTransportManager.cs @@ -982,6 +982,21 @@ private void TryHandleConnectionClosed(ProductUserId remoteUserId, string socket /// If false and there is not an existing connection to the peer, the data will be dropped. /// Which level of reliability the packet should be sent with. public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = PacketReliability.ReliableOrdered) + { + var packetAsArraySegment = new ArraySegment(packet); + SendPacket(remoteUserId, socketName, packetAsArraySegment, channel, allowDelayedDelivery, reliability); + } + + /// + /// Sends a packet to a given remote user on an open connection using the specified reliability. + /// + /// The id of the remote user to send a packet to. + /// The name of the socket the connection is open on. + /// The packet to be sent. + /// Which channel the packet should be sent on. + /// If false and there is not an existing connection to the peer, the data will be dropped. + /// Which level of reliability the packet should be sent with. + public void SendPacket(ProductUserId remoteUserId, string socketName, ArraySegment packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = PacketReliability.ReliableOrdered) { if (remoteUserId.IsValid() == false) { @@ -989,14 +1004,14 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac return; } - if (packet.Length <= 0) + if (packet.Count <= 0) { printError("EOSTransportManager.SendPacket: Invalid parameters, packet is empty."); return; } - if (packet.Length > (MaxPacketSize - FragmentHeaderSize) * MaxFragments) + if (packet.Count > (MaxPacketSize - FragmentHeaderSize) * MaxFragments) { - printError($"EOSTransportManager.SendPacket: Fragmenting packet of size {packet.Length} would require more than {MaxFragments} fragments and cannot be sent."); + printError($"EOSTransportManager.SendPacket: Fragmenting packet of size {packet.Count} would require more than {MaxFragments} fragments and cannot be sent."); return; } @@ -1015,9 +1030,9 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac } // Split the data into fragments if necessary. One extra is added to account for the remainder after filling as many packets as possible. - int numFragments = (packet.Length / (MaxPacketSize - FragmentHeaderSize)) + 1; + int numFragments = (packet.Count / (MaxPacketSize - FragmentHeaderSize)) + 1; // The size of the remainder packet added to the count above - int lastPacketSize = packet.Length - ((numFragments - 1) * (MaxPacketSize - FragmentHeaderSize)); + int lastPacketSize = packet.Count - ((numFragments - 1) * (MaxPacketSize - FragmentHeaderSize)); // If there is no remainder (data was evenly split into full packets), we don't need the extra packet if(lastPacketSize == 0) @@ -1027,12 +1042,12 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac } int currentOffset = 0; - List messages = new List(); ushort OutgoingFragmentedIndex = connection.GetNextMessageIndex(); + byte[] fragmentBuffer = new byte[MaxPacketSize]; for (ushort i = 0; i < numFragments; ++i) { - byte[] fragment = new byte[Mathf.Min( (packet.Length - currentOffset) + FragmentHeaderSize, MaxPacketSize)]; + var fragment = new ArraySegment(fragmentBuffer, 0, Mathf.Min((packet.Count - currentOffset) + FragmentHeaderSize, MaxPacketSize)); // 4 Packet header: Bytes 1 and 2 hold the packed id, while 3 and 4 hold the fragment number, with the last bit used as a flag to mark the final fragment. fragment[0] = (byte)(OutgoingFragmentedIndex >> 8); fragment[1] = (byte)OutgoingFragmentedIndex; @@ -1040,16 +1055,12 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac fragment[3] = (byte)(i & short.MaxValue); int length = i == numFragments - 1 ? lastPacketSize : MaxPacketSize - FragmentHeaderSize; - Array.Copy(packet, currentOffset, - fragment, FragmentHeaderSize, length); - messages.Add(fragment); - currentOffset += fragment.Length-FragmentHeaderSize; - } + ArraySegment packetSegment = packet.Slice(currentOffset, length); + packetSegment.CopyTo(fragment.Slice(FragmentHeaderSize)); - for (int i = 0; i < numFragments; ++i) - { - byte[] fragment = messages[i]; + + currentOffset += fragment.Count - FragmentHeaderSize; // Send Packet SocketId socketId = new SocketId() @@ -1065,7 +1076,7 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac AllowDelayedDelivery = allowDelayedDelivery, Channel = channel, Reliability = reliability, - Data = new ArraySegment(fragment), + Data = fragment, }; Result result = P2PHandle.SendPacket(ref options); diff --git a/package.json b/package.json index 6a5db01d..707a7a43 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "com.playeveryware.eos", - "version": "3.1.0", + "version": "3.1.1", "unity": "2020.1", "unityRelease": "11f1", "displayName": "Epic Online Services Plugin for Unity", @@ -31,6 +31,6 @@ } ], "com_playeveryware": { - "git_build_sha": "50a3cf2a9664441b76afdf5473132c69497e8015" + "git_build_sha": "31b5540304ff074d7ef01f9377dafcd8fc5b1dc4" } }