Skip to content

Commit

Permalink
1.2.3
Browse files Browse the repository at this point in the history
- Really fixed index issue in AddChannel.
- Updated namespaces to reflect other Fish-Networking namespaces.
  • Loading branch information
FirstGearGames committed Apr 9, 2022
1 parent 671d41f commit 859874c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 25 deletions.
3 changes: 1 addition & 2 deletions FishNet/Plugins/Bayou/Bayou.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
using FishNet.Managing;
using FishNet.Managing.Logging;
using FishNet.Managing.Transporting;
using FishNet.Transporting;
using System;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace FishNet.Bayou
namespace FishNet.Transporting.Bayou
{
[DisallowMultipleComponent]
public class Bayou : Transport
Expand Down
4 changes: 4 additions & 0 deletions FishNet/Plugins/Bayou/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
1.2.3
- Really fixed index issue in AddChannel.
- Updated namespaces to reflect other Fish-Networking namespaces.

1.2.2
- Fixed rare index out of range error in AddChannel.

Expand Down
2 changes: 1 addition & 1 deletion FishNet/Plugins/Bayou/Core/BidirectionalDictionary.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Collections;
using System.Collections.Generic;

namespace FishNet.Bayou
namespace FishNet.Transporting.Bayou
{
internal class BidirectionalDictionary<T1, T2> : IEnumerable
{
Expand Down
4 changes: 1 addition & 3 deletions FishNet/Plugins/Bayou/Core/ClientSocket.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
using FishNet.Transporting;
using JamesFrowen.SimpleWeb;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace FishNet.Bayou.Client
namespace FishNet.Transporting.Bayou.Client
{
public class ClientSocket : CommonSocket
{
Expand Down
17 changes: 5 additions & 12 deletions FishNet/Plugins/Bayou/Core/CommonSocket.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
using FishNet.Transporting;
using System;
using System;
using System.Collections.Generic;

namespace FishNet.Bayou
namespace FishNet.Transporting.Bayou
{

public abstract class CommonSocket
Expand Down Expand Up @@ -46,7 +45,6 @@ protected void SetConnectionState(LocalConnectionStates connectionState, bool as
protected Transport Transport = null;
#endregion


/// <summary>
/// Sends data to connectionId.
/// </summary>
Expand Down Expand Up @@ -80,16 +78,11 @@ internal void ClearPacketQueue(ref Queue<Packet> queue)
internal void AddChannel(ref Packet packet)
{
int writePosition = packet.Length;
byte[] array = packet.Data;
int dataLength = packet.Data.Length;
//Need to resize to fit channel write. This will virtually never happen.
if (dataLength <= writePosition)
Array.Resize(ref array, dataLength + 1);

array[writePosition] = (byte)packet.Channel;
packet.Length += 1;
packet.AddLength(1);
packet.Data[writePosition] = (byte)packet.Channel;
}


/// <summary>
/// Removes the channel, outputting it and returning a new ArraySegment.
/// </summary>
Expand Down
4 changes: 1 addition & 3 deletions FishNet/Plugins/Bayou/Core/ServerSocket.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
using FishNet.Transporting;
using FishNet.Utility.Performance;
using JamesFrowen.SimpleWeb;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;

namespace FishNet.Bayou.Server
namespace FishNet.Transporting.Bayou.Server
{
public class ServerSocket : CommonSocket
{
Expand Down
23 changes: 20 additions & 3 deletions FishNet/Plugins/Bayou/Core/Supporting.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using FishNet.Utility.Performance;
using System;

namespace FishNet.Bayou


namespace FishNet.Transporting.Bayou
{


internal struct Packet
{
public readonly int ConnectionId;
public readonly byte[] Data;
public byte[] Data;
public int Length;
public readonly byte Channel;

Expand All @@ -34,6 +36,20 @@ public ArraySegment<byte> GetArraySegment()
return new ArraySegment<byte>(Data, 0, Length);
}

/// <summary>
/// Adds on length and resizes Data if needed.
/// </summary>
/// <param name="length"></param>
public void AddLength(int length)
{
int totalNeeded = (Length + length);
if (Data.Length < totalNeeded)
Array.Resize(ref Data, totalNeeded);

Length += length;
}


public void Dispose()
{
ByteArrayPool.Store(Data);
Expand All @@ -44,7 +60,8 @@ public void Dispose()

}

namespace FishNet.Bayou.Server

namespace FishNet.Transporting.Bayou.Server
{

internal struct RemoteConnectionEvent
Expand Down
2 changes: 1 addition & 1 deletion FishNet/Plugins/Bayou/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.2.2
1.2.3

0 comments on commit 859874c

Please sign in to comment.