mirror of
https://git.ryujinx.app/ryubing/ryujinx.git
synced 2025-07-05 01:16:27 +02:00
misc: chore: Use collection expressions in HLE project
This commit is contained in:
parent
3c2f283ec7
commit
70b767ef60
72 changed files with 312 additions and 299 deletions
|
@ -84,7 +84,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
|||
NetworkConfig = networkConfig,
|
||||
};
|
||||
|
||||
bool success = _parent.NetworkClient.CreateNetwork(request, _advertiseData ?? Array.Empty<byte>());
|
||||
bool success = _parent.NetworkClient.CreateNetwork(request, _advertiseData ?? []);
|
||||
|
||||
return success ? ResultCode.Success : ResultCode.InvalidState;
|
||||
}
|
||||
|
|
|
@ -163,7 +163,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
|||
}
|
||||
else
|
||||
{
|
||||
return Array.Empty<NodeLatestUpdate>();
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator
|
|||
public NetworkInfo[] Scan(ushort channel, ScanFilter scanFilter)
|
||||
{
|
||||
Logger.Warning?.PrintMsg(LogClass.ServiceLdn, "Attempted to scan for networks, but Multiplayer is disabled!");
|
||||
return Array.Empty<NetworkInfo>();
|
||||
return [];
|
||||
}
|
||||
|
||||
public void SetAdvertiseData(byte[] data) { }
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
private readonly Ssid _fakeSsid;
|
||||
private ILdnTcpSocket _tcp;
|
||||
private LdnProxyUdpServer _udp, _udp2;
|
||||
private readonly List<LdnProxyTcpSession> _stations = new();
|
||||
private readonly List<LdnProxyTcpSession> _stations = [];
|
||||
private readonly Lock _lock = new();
|
||||
|
||||
private readonly AutoResetEvent _apConnected = new(false);
|
||||
|
@ -340,10 +340,10 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
|
||||
if (_protocol.SendBroadcast(_udp, LanPacketType.Scan, DefaultPort) < 0)
|
||||
{
|
||||
return Array.Empty<NetworkInfo>();
|
||||
return [];
|
||||
}
|
||||
|
||||
List<NetworkInfo> outNetworkInfo = new();
|
||||
List<NetworkInfo> outNetworkInfo = [];
|
||||
|
||||
foreach (KeyValuePair<ulong, NetworkInfo> item in _udp.GetScanResults())
|
||||
{
|
||||
|
|
|
@ -162,7 +162,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
|
||||
public int SendBroadcast(ILdnSocket s, LanPacketType type, int port)
|
||||
{
|
||||
return SendPacket(s, type, Array.Empty<byte>(), new IPEndPoint(_discovery.LocalBroadcastAddr, port));
|
||||
return SendPacket(s, type, [], new IPEndPoint(_discovery.LocalBroadcastAddr, port));
|
||||
}
|
||||
|
||||
public int SendPacket(ILdnSocket s, LanPacketType type, byte[] data, EndPoint endPoint = null)
|
||||
|
@ -231,7 +231,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
|
||||
private int Compress(byte[] input, out byte[] output)
|
||||
{
|
||||
List<byte> outputList = new();
|
||||
List<byte> outputList = [];
|
||||
int i = 0;
|
||||
int maxCount = 0xFF;
|
||||
|
||||
|
@ -275,7 +275,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnMitm
|
|||
|
||||
private int Decompress(byte[] input, out byte[] output)
|
||||
{
|
||||
List<byte> outputList = new();
|
||||
List<byte> outputList = [];
|
||||
int i = 0;
|
||||
|
||||
while (i < input.Length && outputList.Count < BufferSize)
|
||||
|
|
|
@ -40,7 +40,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
private readonly RyuLdnProtocol _protocol;
|
||||
private readonly NetworkTimeout _timeout;
|
||||
|
||||
private readonly List<NetworkInfo> _availableGames = new();
|
||||
private readonly List<NetworkInfo> _availableGames = [];
|
||||
private DisconnectReason _disconnectReason;
|
||||
|
||||
private P2pProxyServer _hostedProxy;
|
||||
|
@ -109,7 +109,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
|
||||
ConnectAsync();
|
||||
|
||||
int index = WaitHandle.WaitAny(new WaitHandle[] { _connected, _error }, FailureTimeout);
|
||||
int index = WaitHandle.WaitAny([_connected, _error], FailureTimeout);
|
||||
|
||||
if (IsConnected)
|
||||
{
|
||||
|
@ -326,7 +326,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
|
||||
SendAsync(_protocol.Encode(PacketId.Reject, new RejectRequest(disconnectReason, nodeId)));
|
||||
|
||||
int index = WaitHandle.WaitAny(new WaitHandle[] { _reject, _error }, InactiveTimeout);
|
||||
int index = WaitHandle.WaitAny([_reject, _error], InactiveTimeout);
|
||||
|
||||
if (index == 0)
|
||||
{
|
||||
|
@ -566,13 +566,13 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu
|
|||
|
||||
SendAsync(_protocol.Encode(PacketId.Scan, scanFilter));
|
||||
|
||||
index = WaitHandle.WaitAny(new WaitHandle[] { _scan, _error }, ScanTimeout);
|
||||
index = WaitHandle.WaitAny([_scan, _error], ScanTimeout);
|
||||
}
|
||||
|
||||
if (index != 0)
|
||||
{
|
||||
// An error occurred or timeout. Write 0 games.
|
||||
return Array.Empty<NetworkInfo>();
|
||||
return [];
|
||||
}
|
||||
|
||||
return _availableGames.ToArray();
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
{
|
||||
private const ushort EphemeralBase = 49152;
|
||||
|
||||
private readonly List<ushort> _ephemeralPorts = new();
|
||||
private readonly List<ushort> _ephemeralPorts = [];
|
||||
|
||||
private readonly Lock _lock = new();
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
public EndPoint LocalEndpoint { get; }
|
||||
public IPAddress LocalAddress { get; }
|
||||
|
||||
private readonly List<LdnProxySocket> _sockets = new();
|
||||
private readonly List<LdnProxySocket> _sockets = [];
|
||||
private readonly Dictionary<ProtocolType, EphemeralPortPool> _ephemeralPorts = new();
|
||||
|
||||
private readonly IProxyClient _parent;
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
private readonly LdnProxy _proxy;
|
||||
|
||||
private bool _isListening;
|
||||
private readonly List<LdnProxySocket> _listenSockets = new();
|
||||
private readonly List<LdnProxySocket> _listenSockets = [];
|
||||
|
||||
private readonly Queue<ProxyConnectRequest> _connectRequests = new();
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ namespace Ryujinx.HLE.HOS.Services.Ldn.UserServiceCreator.LdnRyu.Proxy
|
|||
private NatDevice _natDevice;
|
||||
private Mapping _portMapping;
|
||||
|
||||
private readonly List<P2pProxySession> _players = new();
|
||||
private readonly List<P2pProxySession> _players = [];
|
||||
|
||||
private readonly List<ExternalProxyToken> _waitingTokens = new();
|
||||
private readonly List<ExternalProxyToken> _waitingTokens = [];
|
||||
private readonly AutoResetEvent _tokenEvent = new(false);
|
||||
|
||||
private uint _broadcastAddress;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue