aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAc_K <Acoustik666@gmail.com>2020-11-27 18:57:20 +0100
committerGitHub <noreply@github.com>2020-11-27 18:57:20 +0100
commitb1877632cfabad9e5856c6f82430ecc851645be9 (patch)
treed6cb0455b9ad277e8fd1cf4f733cd8484f6818e7
parent632a84155b537298b65da0653435882a753f0bbe (diff)
Remove some warnings and cleaning code (#1736)
-rw-r--r--Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs2
-rw-r--r--Ryujinx.Common/SystemInfo/MacOSSysteminfo.cs2
-rw-r--r--Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs2
-rw-r--r--Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs3
-rw-r--r--Ryujinx/Motion/Client.cs127
-rw-r--r--Ryujinx/Program.cs2
-rw-r--r--Ryujinx/Ui/MainWindow.cs2
-rw-r--r--Ryujinx/Updater/UpdateDialog.cs2
-rw-r--r--Ryujinx/Updater/Updater.cs3
9 files changed, 74 insertions, 71 deletions
diff --git a/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs b/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs
index bd3ee57a..c729ab3d 100644
--- a/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs
+++ b/Ryujinx.Common/SystemInfo/LinuxSystemInfo.cs
@@ -1,8 +1,10 @@
using System.IO;
using System.Linq;
+using System.Runtime.Versioning;
namespace Ryujinx.Common.SystemInfo
{
+ [SupportedOSPlatform("linux")]
internal class LinuxSysteminfo : SystemInfo
{
public override string CpuName { get; }
diff --git a/Ryujinx.Common/SystemInfo/MacOSSysteminfo.cs b/Ryujinx.Common/SystemInfo/MacOSSysteminfo.cs
index 5ba45a68..1cf18ca0 100644
--- a/Ryujinx.Common/SystemInfo/MacOSSysteminfo.cs
+++ b/Ryujinx.Common/SystemInfo/MacOSSysteminfo.cs
@@ -1,11 +1,13 @@
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
using System.Text;
using Ryujinx.Common.Logging;
namespace Ryujinx.Common.SystemInfo
{
+ [SupportedOSPlatform("macos")]
internal class MacOSSysteminfo : SystemInfo
{
public override string CpuName { get; }
diff --git a/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs b/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs
index 2bdd6250..1b048c8e 100644
--- a/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs
+++ b/Ryujinx.Common/SystemInfo/WindowsSystemInfo.cs
@@ -2,9 +2,11 @@ using Ryujinx.Common.Logging;
using System;
using System.Management;
using System.Runtime.InteropServices;
+using System.Runtime.Versioning;
namespace Ryujinx.Common.SystemInfo
{
+ [SupportedOSPlatform("windows")]
internal class WindowsSysteminfo : SystemInfo
{
public override string CpuName { get; }
diff --git a/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs b/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs
index 96cdd574..f7fbec3d 100644
--- a/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs
+++ b/Ryujinx.Graphics.Nvdec.Vp9/DecodeMv.cs
@@ -918,9 +918,10 @@ namespace Ryujinx.Graphics.Nvdec.Vp9
if (mi.Mode != PredictionMode.ZeroMv)
{
+ Span<Mv> tmpMvs = stackalloc Mv[Constants.MaxMvRefCandidates];
+
for (refr = 0; refr < 1 + isCompound; ++refr)
{
- Span<Mv> tmpMvs = stackalloc Mv[Constants.MaxMvRefCandidates];
sbyte frame = mi.RefFrame[refr];
int refmvCount;
diff --git a/Ryujinx/Motion/Client.cs b/Ryujinx/Motion/Client.cs
index c1822bcd..8c5ad20d 100644
--- a/Ryujinx/Motion/Client.cs
+++ b/Ryujinx/Motion/Client.cs
@@ -24,8 +24,8 @@ namespace Ryujinx.Motion
private readonly Dictionary<int, Dictionary<int, MotionInput>> _motionData;
private readonly Dictionary<int, UdpClient> _clients;
- private bool[] _clientErrorStatus = new bool[Enum.GetValues(typeof(PlayerIndex)).Length];
- private long[] _clientRetryTimer = new long[Enum.GetValues(typeof(PlayerIndex)).Length];
+ private readonly bool[] _clientErrorStatus = new bool[Enum.GetValues(typeof(PlayerIndex)).Length];
+ private readonly long[] _clientRetryTimer = new long[Enum.GetValues(typeof(PlayerIndex)).Length];
public Client()
{
@@ -48,11 +48,9 @@ namespace Ryujinx.Motion
{
client.Value?.Dispose();
}
-#pragma warning disable CS0168
- catch (SocketException ex)
-#pragma warning restore CS0168
+ catch (SocketException socketException)
{
- Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to dispose motion client. Error code {ex.ErrorCode}");
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to dispose motion client. Error: {socketException.ErrorCode}");
}
}
@@ -94,20 +92,20 @@ namespace Ryujinx.Motion
ReceiveLoop(player);
});
}
- catch (FormatException fex)
+ catch (FormatException formatException)
{
if (!_clientErrorStatus[player])
{
- Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to connect to motion source at {host}:{port}. Error {fex.Message}");
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to connect to motion source at {host}:{port}. Error: {formatException.Message}");
_clientErrorStatus[player] = true;
}
}
- catch (SocketException sex)
+ catch (SocketException socketException)
{
if (!_clientErrorStatus[player])
{
- Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to connect to motion source at {host}:{port}. Error code {sex.ErrorCode}");
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to connect to motion source at {host}:{port}. Error: {socketException.ErrorCode}");
_clientErrorStatus[player] = true;
}
@@ -118,8 +116,10 @@ namespace Ryujinx.Motion
SetRetryTimer(player);
}
- catch (Exception ex)
+ catch (Exception exception)
{
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to register motion client. Error: {exception.Message}");
+
_clientErrorStatus[player] = true;
RemoveClient(player);
@@ -166,11 +166,11 @@ namespace Ryujinx.Motion
{
_client?.Send(data, data.Length);
}
- catch (SocketException ex)
+ catch (SocketException socketException)
{
if (!_clientErrorStatus[clientId])
{
- Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to send data request to motion source at {_client.Client.RemoteEndPoint}. Error code {ex.ErrorCode}");
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to send data request to motion source at {_client.Client.RemoteEndPoint}. Error: {socketException.ErrorCode}");
}
_clientErrorStatus[clientId] = true;
@@ -181,7 +181,7 @@ namespace Ryujinx.Motion
SetRetryTimer(clientId);
}
- catch (ObjectDisposedException dex)
+ catch (ObjectDisposedException)
{
_clientErrorStatus[clientId] = true;
@@ -231,7 +231,7 @@ namespace Ryujinx.Motion
private bool CanConnect(int clientId)
{
- return _clientRetryTimer[clientId] == 0 ? true : PerformanceCounter.ElapsedMilliseconds - 5000 > _clientRetryTimer[clientId];
+ return _clientRetryTimer[clientId] == 0 || PerformanceCounter.ElapsedMilliseconds - 5000 > _clientRetryTimer[clientId];
}
public void ReceiveLoop(int clientId)
@@ -251,16 +251,14 @@ namespace Ryujinx.Motion
continue;
}
-#pragma warning disable CS4014
Task.Run(() => HandleResponse(data, clientId));
-#pragma warning restore CS4014
}
}
- catch (SocketException ex)
+ catch (SocketException socketException)
{
if (!_clientErrorStatus[clientId])
{
- Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to receive data from motion source at {endPoint}. Error code {ex.ErrorCode}");
+ Logger.Warning?.PrintMsg(LogClass.Hid, $"Unable to receive data from motion source at {endPoint}. Error: {socketException.ErrorCode}");
}
_clientErrorStatus[clientId] = true;
@@ -285,19 +283,16 @@ namespace Ryujinx.Motion
}
}
-#pragma warning disable CS1998
public void HandleResponse(byte[] data, int clientId)
-#pragma warning restore CS1998
{
ResetRetryTimer(clientId);
MessageType type = (MessageType)BitConverter.ToUInt32(data.AsSpan().Slice(16, 4));
- data = data.AsSpan().Slice(16).ToArray();
-
- using MemoryStream mem = new MemoryStream(data);
+ data = data.AsSpan()[16..].ToArray();
- using BinaryReader reader = new BinaryReader(mem);
+ using MemoryStream stream = new MemoryStream(data);
+ using BinaryReader reader = new BinaryReader(stream);
switch (type)
{
@@ -335,21 +330,25 @@ namespace Ryujinx.Motion
{
if (_motionData[clientId].ContainsKey(slot))
{
- var previousData = _motionData[clientId][slot];
+ MotionInput previousData = _motionData[clientId][slot];
previousData.Update(accelerometer, gyroscrope, timestamp, config.Sensitivity, (float)config.GyroDeadzone);
}
else
{
MotionInput input = new MotionInput();
+
input.Update(accelerometer, gyroscrope, timestamp, config.Sensitivity, (float)config.GyroDeadzone);
+
_motionData[clientId].Add(slot, input);
}
}
else
{
MotionInput input = new MotionInput();
+
input.Update(accelerometer, gyroscrope, timestamp, config.Sensitivity, (float)config.GyroDeadzone);
+
_motionData.Add(clientId, new Dictionary<int, MotionInput>() { { slot, input } });
}
}
@@ -366,36 +365,34 @@ namespace Ryujinx.Motion
Header header = GenerateHeader(clientId);
- using (MemoryStream mem = new MemoryStream())
+ using (MemoryStream stream = new MemoryStream())
+ using (BinaryWriter writer = new BinaryWriter(stream))
{
- using (BinaryWriter writer = new BinaryWriter(mem))
- {
- writer.WriteStruct(header);
+ writer.WriteStruct(header);
- ControllerInfoRequest request = new ControllerInfoRequest()
- {
- Type = MessageType.Info,
- PortsCount = 4
- };
+ ControllerInfoRequest request = new ControllerInfoRequest()
+ {
+ Type = MessageType.Info,
+ PortsCount = 4
+ };
- request.PortIndices[0] = (byte)slot;
+ request.PortIndices[0] = (byte)slot;
- writer.WriteStruct(request);
+ writer.WriteStruct(request);
- header.Length = (ushort)(mem.Length - 16);
+ header.Length = (ushort)(stream.Length - 16);
- writer.Seek(6, SeekOrigin.Begin);
- writer.Write(header.Length);
+ writer.Seek(6, SeekOrigin.Begin);
+ writer.Write(header.Length);
- header.Crc32 = Crc32Algorithm.Compute(mem.ToArray());
+ header.Crc32 = Crc32Algorithm.Compute(stream.ToArray());
- writer.Seek(8, SeekOrigin.Begin);
- writer.Write(header.Crc32);
+ writer.Seek(8, SeekOrigin.Begin);
+ writer.Write(header.Crc32);
- byte[] data = mem.ToArray();
+ byte[] data = stream.ToArray();
- Send(data, clientId);
- }
+ Send(data, clientId);
}
}
@@ -408,35 +405,33 @@ namespace Ryujinx.Motion
Header header = GenerateHeader(clientId);
- using (MemoryStream mem = new MemoryStream())
+ using (MemoryStream stream = new MemoryStream())
+ using (BinaryWriter writer = new BinaryWriter(stream))
{
- using (BinaryWriter writer = new BinaryWriter(mem))
- {
- writer.WriteStruct(header);
+ writer.WriteStruct(header);
- ControllerDataRequest request = new ControllerDataRequest()
- {
- Type = MessageType.Data,
- Slot = (byte)slot,
- SubscriberType = SubscriberType.Slot
- };
+ ControllerDataRequest request = new ControllerDataRequest()
+ {
+ Type = MessageType.Data,
+ Slot = (byte)slot,
+ SubscriberType = SubscriberType.Slot
+ };
- writer.WriteStruct(request);
+ writer.WriteStruct(request);
- header.Length = (ushort)(mem.Length - 16);
+ header.Length = (ushort)(stream.Length - 16);
- writer.Seek(6, SeekOrigin.Begin);
- writer.Write(header.Length);
+ writer.Seek(6, SeekOrigin.Begin);
+ writer.Write(header.Length);
- header.Crc32 = Crc32Algorithm.Compute(mem.ToArray());
+ header.Crc32 = Crc32Algorithm.Compute(stream.ToArray());
- writer.Seek(8, SeekOrigin.Begin);
- writer.Write(header.Crc32);
+ writer.Seek(8, SeekOrigin.Begin);
+ writer.Write(header.Crc32);
- byte[] data = mem.ToArray();
+ byte[] data = stream.ToArray();
- Send(data, clientId);
- }
+ Send(data, clientId);
}
}
diff --git a/Ryujinx/Program.cs b/Ryujinx/Program.cs
index 280b5c36..927ed80a 100644
--- a/Ryujinx/Program.cs
+++ b/Ryujinx/Program.cs
@@ -128,7 +128,7 @@ namespace Ryujinx
if (ConfigurationState.Instance.CheckUpdatesOnStart.Value && Updater.CanUpdate(false))
{
- Updater.BeginParse(mainWindow, false);
+ _ = Updater.BeginParse(mainWindow, false);
}
Application.Run();
diff --git a/Ryujinx/Ui/MainWindow.cs b/Ryujinx/Ui/MainWindow.cs
index 6bcb4235..63922948 100644
--- a/Ryujinx/Ui/MainWindow.cs
+++ b/Ryujinx/Ui/MainWindow.cs
@@ -1192,7 +1192,7 @@ namespace Ryujinx.Ui
{
if (Updater.CanUpdate(true))
{
- Updater.BeginParse(this, true);
+ _ = Updater.BeginParse(this, true);
}
}
diff --git a/Ryujinx/Updater/UpdateDialog.cs b/Ryujinx/Updater/UpdateDialog.cs
index 7c2d32d6..76143181 100644
--- a/Ryujinx/Updater/UpdateDialog.cs
+++ b/Ryujinx/Updater/UpdateDialog.cs
@@ -70,7 +70,7 @@ namespace Ryujinx.Ui
SecondaryText.Text = "";
_restartQuery = true;
- Updater.UpdateRyujinx(this, _buildUrl);
+ _ = Updater.UpdateRyujinx(this, _buildUrl);
}
}
diff --git a/Ryujinx/Updater/Updater.cs b/Ryujinx/Updater/Updater.cs
index 56de31b0..42b97cc8 100644
--- a/Ryujinx/Updater/Updater.cs
+++ b/Ryujinx/Updater/Updater.cs
@@ -10,6 +10,7 @@ using System.IO;
using System.Net;
using System.Net.NetworkInformation;
using System.Runtime.InteropServices;
+using System.Text;
using System.Threading.Tasks;
namespace Ryujinx
@@ -163,7 +164,7 @@ namespace Ryujinx
{
using (Stream inStream = File.OpenRead(updateFile))
using (Stream gzipStream = new GZipInputStream(inStream))
- using (TarInputStream tarStream = new TarInputStream(gzipStream))
+ using (TarInputStream tarStream = new TarInputStream(gzipStream, Encoding.ASCII))
{
updateDialog.ProgressBar.MaxValue = inStream.Length;