Adjust naming conventions and general refactoring in HLE Project (#490)
* Rename enum fields
* Naming conventions
* Remove unneeded ".this"
* Remove unneeded semicolons
* Remove unused Usings
* Don't use var
* Remove unneeded enum underlying types
* Explicitly label class visibility
* Remove unneeded @ prefixes
* Remove unneeded commas
* Remove unneeded if expressions
* Method doesn't use unsafe code
* Remove unneeded casts
* Initialized objects don't need an empty constructor
* Remove settings from DotSettings
* Revert "Explicitly label class visibility"
This reverts commit ad5eb5787c
.
* Small changes
* Revert external enum renaming
* Changes from feedback
* Remove unneeded property setters
This commit is contained in:
parent
c86aacde76
commit
85dbb9559a
299 changed files with 12268 additions and 12276 deletions
|
@ -2,16 +2,16 @@
|
|||
{
|
||||
static class EndianSwap
|
||||
{
|
||||
public static ushort Swap16(ushort Value) => (ushort)(((Value >> 8) & 0xff) | (Value << 8));
|
||||
public static ushort Swap16(ushort value) => (ushort)(((value >> 8) & 0xff) | (value << 8));
|
||||
|
||||
public static int Swap32(int Value)
|
||||
public static int Swap32(int value)
|
||||
{
|
||||
uint UintVal = (uint)Value;
|
||||
uint uintVal = (uint)value;
|
||||
|
||||
return (int)(((UintVal >> 24) & 0x000000ff) |
|
||||
((UintVal >> 8) & 0x0000ff00) |
|
||||
((UintVal << 8) & 0x00ff0000) |
|
||||
((UintVal << 24) & 0xff000000));
|
||||
return (int)(((uintVal >> 24) & 0x000000ff) |
|
||||
((uintVal >> 8) & 0x0000ff00) |
|
||||
((uintVal << 8) & 0x00ff0000) |
|
||||
((uintVal << 24) & 0xff000000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,29 +6,29 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
private static readonly uint FontKey = 0x06186249;
|
||||
|
||||
public static byte[] DecryptFont(Stream BFTTFStream)
|
||||
public static byte[] DecryptFont(Stream bfttfStream)
|
||||
{
|
||||
uint KXor(uint In) => In ^ 0x06186249;
|
||||
|
||||
using (BinaryReader Reader = new BinaryReader(BFTTFStream))
|
||||
using (BinaryReader reader = new BinaryReader(bfttfStream))
|
||||
{
|
||||
using (MemoryStream TTFStream = new MemoryStream())
|
||||
using (MemoryStream ttfStream = new MemoryStream())
|
||||
{
|
||||
using (BinaryWriter Output = new BinaryWriter(TTFStream))
|
||||
using (BinaryWriter output = new BinaryWriter(ttfStream))
|
||||
{
|
||||
if (KXor(Reader.ReadUInt32()) != 0x18029a7f)
|
||||
if (KXor(reader.ReadUInt32()) != 0x18029a7f)
|
||||
{
|
||||
throw new InvalidDataException("Error: Input file is not in BFTTF format!");
|
||||
}
|
||||
|
||||
BFTTFStream.Position += 4;
|
||||
bfttfStream.Position += 4;
|
||||
|
||||
for (int i = 0; i < (BFTTFStream.Length - 8) / 4; i++)
|
||||
for (int i = 0; i < (bfttfStream.Length - 8) / 4; i++)
|
||||
{
|
||||
Output.Write(KXor(Reader.ReadUInt32()));
|
||||
output.Write(KXor(reader.ReadUInt32()));
|
||||
}
|
||||
|
||||
return TTFStream.ToArray();
|
||||
return ttfStream.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,24 +2,24 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
static class IntUtils
|
||||
{
|
||||
public static int AlignUp(int Value, int Size)
|
||||
public static int AlignUp(int value, int size)
|
||||
{
|
||||
return (Value + (Size - 1)) & ~(Size - 1);
|
||||
return (value + (size - 1)) & ~(size - 1);
|
||||
}
|
||||
|
||||
public static long AlignUp(long Value, int Size)
|
||||
public static long AlignUp(long value, int size)
|
||||
{
|
||||
return (Value + (Size - 1)) & ~((long)Size - 1);
|
||||
return (value + (size - 1)) & ~((long)size - 1);
|
||||
}
|
||||
|
||||
public static int AlignDown(int Value, int Size)
|
||||
public static int AlignDown(int value, int size)
|
||||
{
|
||||
return Value & ~(Size - 1);
|
||||
return value & ~(size - 1);
|
||||
}
|
||||
|
||||
public static long AlignDown(long Value, int Size)
|
||||
public static long AlignDown(long value, int size)
|
||||
{
|
||||
return Value & ~((long)Size - 1);
|
||||
return value & ~((long)size - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.Utilities
|
||||
{
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
enum LinuxError
|
||||
{
|
||||
SUCCESS = 0,
|
||||
|
@ -147,6 +150,6 @@ namespace Ryujinx.HLE.Utilities
|
|||
|
||||
ERFKILL = 132 /* Operation not possible due to RF-kill */,
|
||||
|
||||
EHWPOISON = 133 /* Memory page has hardware error */,
|
||||
EHWPOISON = 133 /* Memory page has hardware error */
|
||||
}
|
||||
}
|
|
@ -9,67 +9,67 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
static class StringUtils
|
||||
{
|
||||
public static byte[] GetFixedLengthBytes(string InputString, int Size, Encoding Encoding)
|
||||
public static byte[] GetFixedLengthBytes(string inputString, int size, Encoding encoding)
|
||||
{
|
||||
InputString = InputString + "\0";
|
||||
inputString = inputString + "\0";
|
||||
|
||||
int BytesCount = Encoding.GetByteCount(InputString);
|
||||
int bytesCount = encoding.GetByteCount(inputString);
|
||||
|
||||
byte[] Output = new byte[Size];
|
||||
byte[] output = new byte[size];
|
||||
|
||||
if (BytesCount < Size)
|
||||
if (bytesCount < size)
|
||||
{
|
||||
Encoding.GetBytes(InputString, 0, InputString.Length, Output, 0);
|
||||
encoding.GetBytes(inputString, 0, inputString.Length, output, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
int NullSize = Encoding.GetByteCount("\0");
|
||||
int nullSize = encoding.GetByteCount("\0");
|
||||
|
||||
Output = Encoding.GetBytes(InputString);
|
||||
output = encoding.GetBytes(inputString);
|
||||
|
||||
Array.Resize(ref Output, Size - NullSize);
|
||||
Array.Resize(ref output, size - nullSize);
|
||||
|
||||
Output = Output.Concat(Encoding.GetBytes("\0")).ToArray();
|
||||
output = output.Concat(encoding.GetBytes("\0")).ToArray();
|
||||
}
|
||||
|
||||
return Output;
|
||||
return output;
|
||||
}
|
||||
|
||||
public static byte[] HexToBytes(string HexString)
|
||||
public static byte[] HexToBytes(string hexString)
|
||||
{
|
||||
//Ignore last charactor if HexLength % 2 != 0.
|
||||
int BytesInHex = HexString.Length / 2;
|
||||
int bytesInHex = hexString.Length / 2;
|
||||
|
||||
byte[] Output = new byte[BytesInHex];
|
||||
byte[] output = new byte[bytesInHex];
|
||||
|
||||
for (int Index = 0; Index < BytesInHex; Index++)
|
||||
for (int index = 0; index < bytesInHex; index++)
|
||||
{
|
||||
Output[Index] = byte.Parse(HexString.Substring(Index * 2, 2), NumberStyles.HexNumber);
|
||||
output[index] = byte.Parse(hexString.Substring(index * 2, 2), NumberStyles.HexNumber);
|
||||
}
|
||||
|
||||
return Output;
|
||||
return output;
|
||||
}
|
||||
|
||||
public static string ReadUtf8String(ServiceCtx Context, int Index = 0)
|
||||
public static string ReadUtf8String(ServiceCtx context, int index = 0)
|
||||
{
|
||||
long Position = Context.Request.PtrBuff[Index].Position;
|
||||
long Size = Context.Request.PtrBuff[Index].Size;
|
||||
long position = context.Request.PtrBuff[index].Position;
|
||||
long size = context.Request.PtrBuff[index].Size;
|
||||
|
||||
using (MemoryStream MS = new MemoryStream())
|
||||
using (MemoryStream ms = new MemoryStream())
|
||||
{
|
||||
while (Size-- > 0)
|
||||
while (size-- > 0)
|
||||
{
|
||||
byte Value = Context.Memory.ReadByte(Position++);
|
||||
byte value = context.Memory.ReadByte(position++);
|
||||
|
||||
if (Value == 0)
|
||||
if (value == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
MS.WriteByte(Value);
|
||||
ms.WriteByte(value);
|
||||
}
|
||||
|
||||
return Encoding.UTF8.GetString(MS.ToArray());
|
||||
return Encoding.UTF8.GetString(ms.ToArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,41 +5,41 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
class StructReader
|
||||
{
|
||||
private MemoryManager Memory;
|
||||
private MemoryManager _memory;
|
||||
|
||||
public long Position { get; private set; }
|
||||
|
||||
public StructReader(MemoryManager Memory, long Position)
|
||||
public StructReader(MemoryManager memory, long position)
|
||||
{
|
||||
this.Memory = Memory;
|
||||
this.Position = Position;
|
||||
_memory = memory;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public T Read<T>() where T : struct
|
||||
{
|
||||
T Value = MemoryHelper.Read<T>(Memory, Position);
|
||||
T value = MemoryHelper.Read<T>(_memory, Position);
|
||||
|
||||
Position += Marshal.SizeOf<T>();
|
||||
|
||||
return Value;
|
||||
return value;
|
||||
}
|
||||
|
||||
public T[] Read<T>(int Size) where T : struct
|
||||
public T[] Read<T>(int size) where T : struct
|
||||
{
|
||||
int StructSize = Marshal.SizeOf<T>();
|
||||
int structSize = Marshal.SizeOf<T>();
|
||||
|
||||
int Count = Size / StructSize;
|
||||
int count = size / structSize;
|
||||
|
||||
T[] Output = new T[Count];
|
||||
T[] output = new T[count];
|
||||
|
||||
for (int Index = 0; Index < Count; Index++)
|
||||
for (int index = 0; index < count; index++)
|
||||
{
|
||||
Output[Index] = MemoryHelper.Read<T>(Memory, Position);
|
||||
output[index] = MemoryHelper.Read<T>(_memory, Position);
|
||||
|
||||
Position += StructSize;
|
||||
Position += structSize;
|
||||
}
|
||||
|
||||
return Output;
|
||||
return output;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,19 +5,19 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
class StructWriter
|
||||
{
|
||||
private MemoryManager Memory;
|
||||
private MemoryManager _memory;
|
||||
|
||||
public long Position { get; private set; }
|
||||
|
||||
public StructWriter(MemoryManager Memory, long Position)
|
||||
public StructWriter(MemoryManager memory, long position)
|
||||
{
|
||||
this.Memory = Memory;
|
||||
this.Position = Position;
|
||||
_memory = memory;
|
||||
Position = position;
|
||||
}
|
||||
|
||||
public void Write<T>(T Value) where T : struct
|
||||
public void Write<T>(T value) where T : struct
|
||||
{
|
||||
MemoryHelper.Write(Memory, Position, Value);
|
||||
MemoryHelper.Write(_memory, Position, value);
|
||||
|
||||
Position += Marshal.SizeOf<T>();
|
||||
}
|
||||
|
|
|
@ -6,30 +6,30 @@ namespace Ryujinx.HLE.Utilities
|
|||
{
|
||||
public struct UInt128
|
||||
{
|
||||
public long High { get; private set; }
|
||||
public long Low { get; private set; }
|
||||
public long High { get; }
|
||||
public long Low { get; }
|
||||
|
||||
public UInt128(long Low, long High)
|
||||
public UInt128(long low, long high)
|
||||
{
|
||||
this.Low = Low;
|
||||
this.High = High;
|
||||
Low = low;
|
||||
High = high;
|
||||
}
|
||||
|
||||
public UInt128(string UInt128Hex)
|
||||
public UInt128(string hex)
|
||||
{
|
||||
if (UInt128Hex == null || UInt128Hex.Length != 32 || !UInt128Hex.All("0123456789abcdefABCDEF".Contains))
|
||||
if (hex == null || hex.Length != 32 || !hex.All("0123456789abcdefABCDEF".Contains))
|
||||
{
|
||||
throw new ArgumentException("Invalid Hex value!", nameof(UInt128Hex));
|
||||
throw new ArgumentException("Invalid Hex value!", nameof(hex));
|
||||
}
|
||||
|
||||
Low = Convert.ToInt64(UInt128Hex.Substring(16), 16);
|
||||
High = Convert.ToInt64(UInt128Hex.Substring(0, 16), 16);
|
||||
Low = Convert.ToInt64(hex.Substring(16), 16);
|
||||
High = Convert.ToInt64(hex.Substring(0, 16), 16);
|
||||
}
|
||||
|
||||
public void Write(BinaryWriter BinaryWriter)
|
||||
public void Write(BinaryWriter binaryWriter)
|
||||
{
|
||||
BinaryWriter.Write(Low);
|
||||
BinaryWriter.Write(High);
|
||||
binaryWriter.Write(Low);
|
||||
binaryWriter.Write(High);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
namespace Ryujinx.HLE.Utilities
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace Ryujinx.HLE.Utilities
|
||||
{
|
||||
enum WSAError
|
||||
[SuppressMessage("ReSharper", "InconsistentNaming")]
|
||||
enum WsaError
|
||||
{
|
||||
/*
|
||||
* All Windows Sockets error constants are biased by WSABASEERR from
|
||||
|
@ -21,43 +24,43 @@
|
|||
/*
|
||||
* Windows Sockets definitions of regular Berkeley error constants
|
||||
*/
|
||||
WSAEWOULDBLOCK = (WSABASEERR + 35),
|
||||
WSAEINPROGRESS = (WSABASEERR + 36),
|
||||
WSAEALREADY = (WSABASEERR + 37),
|
||||
WSAENOTSOCK = (WSABASEERR + 38),
|
||||
WSAEDESTADDRREQ = (WSABASEERR + 39),
|
||||
WSAEMSGSIZE = (WSABASEERR + 40),
|
||||
WSAEPROTOTYPE = (WSABASEERR + 41),
|
||||
WSAENOPROTOOPT = (WSABASEERR + 42),
|
||||
WSAEPROTONOSUPPORT = (WSABASEERR + 43),
|
||||
WSAESOCKTNOSUPPORT = (WSABASEERR + 44),
|
||||
WSAEOPNOTSUPP = (WSABASEERR + 45),
|
||||
WSAEPFNOSUPPORT = (WSABASEERR + 46),
|
||||
WSAEAFNOSUPPORT = (WSABASEERR + 47),
|
||||
WSAEADDRINUSE = (WSABASEERR + 48),
|
||||
WSAEADDRNOTAVAIL = (WSABASEERR + 49),
|
||||
WSAENETDOWN = (WSABASEERR + 50),
|
||||
WSAENETUNREACH = (WSABASEERR + 51),
|
||||
WSAENETRESET = (WSABASEERR + 52),
|
||||
WSAECONNABORTED = (WSABASEERR + 53),
|
||||
WSAECONNRESET = (WSABASEERR + 54),
|
||||
WSAENOBUFS = (WSABASEERR + 55),
|
||||
WSAEISCONN = (WSABASEERR + 56),
|
||||
WSAENOTCONN = (WSABASEERR + 57),
|
||||
WSAESHUTDOWN = (WSABASEERR + 58),
|
||||
WSAETOOMANYREFS = (WSABASEERR + 59),
|
||||
WSAETIMEDOUT = (WSABASEERR + 60),
|
||||
WSAECONNREFUSED = (WSABASEERR + 61),
|
||||
WSAELOOP = (WSABASEERR + 62),
|
||||
WSAENAMETOOLONG = (WSABASEERR + 63),
|
||||
WSAEHOSTDOWN = (WSABASEERR + 64),
|
||||
WSAEHOSTUNREACH = (WSABASEERR + 65),
|
||||
WSAENOTEMPTY = (WSABASEERR + 66),
|
||||
WSAEPROCLIM = (WSABASEERR + 67),
|
||||
WSAEUSERS = (WSABASEERR + 68),
|
||||
WSAEDQUOT = (WSABASEERR + 69),
|
||||
WSAESTALE = (WSABASEERR + 70),
|
||||
WSAEREMOTE = (WSABASEERR + 71),
|
||||
WSAEWOULDBLOCK = (WSABASEERR + 35),
|
||||
WSAEINPROGRESS = (WSABASEERR + 36),
|
||||
WSAEALREADY = (WSABASEERR + 37),
|
||||
WSAENOTSOCK = (WSABASEERR + 38),
|
||||
WSAEDESTADDRREQ = (WSABASEERR + 39),
|
||||
WSAEMSGSIZE = (WSABASEERR + 40),
|
||||
WSAEPROTOTYPE = (WSABASEERR + 41),
|
||||
WSAENOPROTOOPT = (WSABASEERR + 42),
|
||||
WSAEPROTONOSUPPORT = (WSABASEERR + 43),
|
||||
WSAESOCKTNOSUPPORT = (WSABASEERR + 44),
|
||||
WSAEOPNOTSUPP = (WSABASEERR + 45),
|
||||
WSAEPFNOSUPPORT = (WSABASEERR + 46),
|
||||
WSAEAFNOSUPPORT = (WSABASEERR + 47),
|
||||
WSAEADDRINUSE = (WSABASEERR + 48),
|
||||
WSAEADDRNOTAVAIL = (WSABASEERR + 49),
|
||||
WSAENETDOWN = (WSABASEERR + 50),
|
||||
WSAENETUNREACH = (WSABASEERR + 51),
|
||||
WSAENETRESET = (WSABASEERR + 52),
|
||||
WSAECONNABORTED = (WSABASEERR + 53),
|
||||
WSAECONNRESET = (WSABASEERR + 54),
|
||||
WSAENOBUFS = (WSABASEERR + 55),
|
||||
WSAEISCONN = (WSABASEERR + 56),
|
||||
WSAENOTCONN = (WSABASEERR + 57),
|
||||
WSAESHUTDOWN = (WSABASEERR + 58),
|
||||
WSAETOOMANYREFS = (WSABASEERR + 59),
|
||||
WSAETIMEDOUT = (WSABASEERR + 60),
|
||||
WSAECONNREFUSED = (WSABASEERR + 61),
|
||||
WSAELOOP = (WSABASEERR + 62),
|
||||
WSAENAMETOOLONG = (WSABASEERR + 63),
|
||||
WSAEHOSTDOWN = (WSABASEERR + 64),
|
||||
WSAEHOSTUNREACH = (WSABASEERR + 65),
|
||||
WSAENOTEMPTY = (WSABASEERR + 66),
|
||||
WSAEPROCLIM = (WSABASEERR + 67),
|
||||
WSAEUSERS = (WSABASEERR + 68),
|
||||
WSAEDQUOT = (WSABASEERR + 69),
|
||||
WSAESTALE = (WSABASEERR + 70),
|
||||
WSAEREMOTE = (WSABASEERR + 71),
|
||||
|
||||
/*
|
||||
* Extended Windows Sockets error constant definitions
|
||||
|
@ -126,6 +129,6 @@
|
|||
* buffer in general */
|
||||
WSA_QOS_TRAFFIC_CTRL_ERROR = (WSABASEERR + 1014),
|
||||
/* problem with some part of the flowspec */
|
||||
WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015),
|
||||
WSA_QOS_GENERIC_ERROR = (WSABASEERR + 1015)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue