Skip to content

Commit

Permalink
release 3.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhazen committed Apr 16, 2024
1 parent 024a48d commit c0acd84
Show file tree
Hide file tree
Showing 11 changed files with 58 additions and 61 deletions.
19 changes: 0 additions & 19 deletions .gitattributes

This file was deleted.

9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
5 changes: 5 additions & 0 deletions Editor/Configs/EditorConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,17 @@ 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)
{
// Override the base function
await base.WriteAsync(prettyPrint, updateAssetDatabase);
}
#endif
}

}
1 change: 0 additions & 1 deletion Editor/Utility/BuildUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

namespace PlayEveryWare.EpicOnlineServices.Build
{
using Codice.Client.IssueTracker;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using PlayEveryWare.EpicOnlineServices.Utility;
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Core/EOSCreateOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 4 additions & 10 deletions Runtime/Core/EOSInitializeOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
2 changes: 1 addition & 1 deletion Runtime/Core/EOSPackageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
11 changes: 9 additions & 2 deletions Runtime/Core/PlatformSpecifics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T>(configJson);

if (config != null && initializeOptions.OverrideThreadAffinity.HasValue)
Expand Down Expand Up @@ -129,7 +136,7 @@ public virtual Int32 IsReadyForNetworkActivity()
return 1;
}

#endregion
#endregion
}
}
#endif //!EOS_DISABLE
Original file line number Diff line number Diff line change
Expand Up @@ -155,14 +155,7 @@ public override void Send(ulong clientId, ArraySegment<byte> 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);
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -982,21 +982,36 @@ private void TryHandleConnectionClosed(ProductUserId remoteUserId, string socket
/// <param name="allowDelayedDelivery">If <c>false</c> and there is not an existing connection to the peer, the data will be dropped.</param>
/// <param name="reliability">Which level of reliability the packet should be sent with.</param>
public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = PacketReliability.ReliableOrdered)
{
var packetAsArraySegment = new ArraySegment<byte>(packet);
SendPacket(remoteUserId, socketName, packetAsArraySegment, channel, allowDelayedDelivery, reliability);
}

/// <summary>
/// Sends a packet to a given remote user on an open connection using the specified reliability.
/// </summary>
/// <param name="remoteUserId">The id of the remote user to send a packet to.</param>
/// <param name="socketName">The name of the socket the connection is open on.</param>
/// <param name="packet">The packet to be sent.</param>
/// <param name="channel">Which channel the packet should be sent on.</param>
/// <param name="allowDelayedDelivery">If <c>false</c> and there is not an existing connection to the peer, the data will be dropped.</param>
/// <param name="reliability">Which level of reliability the packet should be sent with.</param>
public void SendPacket(ProductUserId remoteUserId, string socketName, ArraySegment<byte> packet, byte channel = 0, bool allowDelayedDelivery = false, PacketReliability reliability = PacketReliability.ReliableOrdered)
{
if (remoteUserId.IsValid() == false)
{
printError($"EOSTransportManager.SendPacket: Invalid parameters, RemoteUserId '{remoteUserId}' is invalid.");
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;
}

Expand All @@ -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)
Expand All @@ -1027,29 +1042,25 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac
}

int currentOffset = 0;
List<byte[]> messages = new List<byte[]>();

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<byte>(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;
fragment[2] = (byte)(((i & short.MaxValue) >> 8) | (byte)(i == numFragments - 1 ? 128 : 0));
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<byte> 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()
Expand All @@ -1065,7 +1076,7 @@ public void SendPacket(ProductUserId remoteUserId, string socketName, byte[] pac
AllowDelayedDelivery = allowDelayedDelivery,
Channel = channel,
Reliability = reliability,
Data = new ArraySegment<byte>(fragment),
Data = fragment,
};

Result result = P2PHandle.SendPacket(ref options);
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -31,6 +31,6 @@
}
],
"com_playeveryware": {
"git_build_sha": "50a3cf2a9664441b76afdf5473132c69497e8015"
"git_build_sha": "31b5540304ff074d7ef01f9377dafcd8fc5b1dc4"
}
}

0 comments on commit c0acd84

Please sign in to comment.