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:
Alex Barney 2018-12-04 14:23:37 -06:00 committed by gdkchan
parent c86aacde76
commit 85dbb9559a
299 changed files with 12268 additions and 12276 deletions

View file

@ -10,13 +10,13 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{
class IAccountService : IpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
public IAccountService()
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, GetUserCount },
{ 1, GetUserExistence },
@ -32,131 +32,131 @@ namespace Ryujinx.HLE.HOS.Services.Acc
}
// GetUserCount() -> i32
public long GetUserCount(ServiceCtx Context)
public long GetUserCount(ServiceCtx context)
{
Context.ResponseData.Write(Context.Device.System.State.GetUserCount());
context.ResponseData.Write(context.Device.System.State.GetUserCount());
return 0;
}
// GetUserExistence(nn::account::Uid) -> bool
public long GetUserExistence(ServiceCtx Context)
public long GetUserExistence(ServiceCtx context)
{
UInt128 Uuid = new UInt128(
Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64());
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
Context.ResponseData.Write(Context.Device.System.State.TryGetUser(Uuid, out _));
context.ResponseData.Write(context.Device.System.State.TryGetUser(uuid, out _));
return 0;
}
// ListAllUsers() -> array<nn::account::Uid, 0xa>
public long ListAllUsers(ServiceCtx Context)
public long ListAllUsers(ServiceCtx context)
{
return WriteUserList(Context, Context.Device.System.State.GetAllUsers());
return WriteUserList(context, context.Device.System.State.GetAllUsers());
}
// ListOpenUsers() -> array<nn::account::Uid, 0xa>
public long ListOpenUsers(ServiceCtx Context)
public long ListOpenUsers(ServiceCtx context)
{
return WriteUserList(Context, Context.Device.System.State.GetOpenUsers());
return WriteUserList(context, context.Device.System.State.GetOpenUsers());
}
private long WriteUserList(ServiceCtx Context, IEnumerable<UserProfile> Profiles)
private long WriteUserList(ServiceCtx context, IEnumerable<UserProfile> profiles)
{
long OutputPosition = Context.Request.RecvListBuff[0].Position;
long OutputSize = Context.Request.RecvListBuff[0].Size;
long outputPosition = context.Request.RecvListBuff[0].Position;
long outputSize = context.Request.RecvListBuff[0].Size;
long Offset = 0;
long offset = 0;
foreach (UserProfile Profile in Profiles)
foreach (UserProfile profile in profiles)
{
if ((ulong)Offset + 16 > (ulong)OutputSize)
if ((ulong)offset + 16 > (ulong)outputSize)
{
break;
}
Context.Memory.WriteInt64(OutputPosition, Profile.Uuid.Low);
Context.Memory.WriteInt64(OutputPosition + 8, Profile.Uuid.High);
context.Memory.WriteInt64(outputPosition, profile.Uuid.Low);
context.Memory.WriteInt64(outputPosition + 8, profile.Uuid.High);
}
return 0;
}
// GetLastOpenedUser() -> nn::account::Uid
public long GetLastOpenedUser(ServiceCtx Context)
public long GetLastOpenedUser(ServiceCtx context)
{
UserProfile LastOpened = Context.Device.System.State.LastOpenUser;
UserProfile lastOpened = context.Device.System.State.LastOpenUser;
LastOpened.Uuid.Write(Context.ResponseData);
lastOpened.Uuid.Write(context.ResponseData);
return 0;
}
// GetProfile(nn::account::Uid) -> object<nn::account::profile::IProfile>
public long GetProfile(ServiceCtx Context)
public long GetProfile(ServiceCtx context)
{
UInt128 Uuid = new UInt128(
Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64());
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
if (!Context.Device.System.State.TryGetUser(Uuid, out UserProfile Profile))
if (!context.Device.System.State.TryGetUser(uuid, out UserProfile profile))
{
Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{Uuid} not found!");
Logger.PrintWarning(LogClass.ServiceAcc, $"User 0x{uuid} not found!");
return MakeError(ErrorModule.Account, AccErr.UserNotFound);
}
MakeObject(Context, new IProfile(Profile));
MakeObject(context, new IProfile(profile));
return 0;
}
// IsUserRegistrationRequestPermitted(u64, pid) -> bool
public long IsUserRegistrationRequestPermitted(ServiceCtx Context)
public long IsUserRegistrationRequestPermitted(ServiceCtx context)
{
long Unknown = Context.RequestData.ReadInt64();
long unknown = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}");
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}");
Context.ResponseData.Write(false);
context.ResponseData.Write(false);
return 0;
}
// TrySelectUserWithoutInteraction(bool) -> nn::account::Uid
public long TrySelectUserWithoutInteraction(ServiceCtx Context)
public long TrySelectUserWithoutInteraction(ServiceCtx context)
{
bool Unknown = Context.RequestData.ReadBoolean();
bool unknown = context.RequestData.ReadBoolean();
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}");
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}");
UserProfile Profile = Context.Device.System.State.LastOpenUser;
UserProfile profile = context.Device.System.State.LastOpenUser;
Profile.Uuid.Write(Context.ResponseData);
profile.Uuid.Write(context.ResponseData);
return 0;
}
// InitializeApplicationInfo(u64, pid)
public long InitializeApplicationInfo(ServiceCtx Context)
public long InitializeApplicationInfo(ServiceCtx context)
{
long Unknown = Context.RequestData.ReadInt64();
long unknown = context.RequestData.ReadInt64();
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {Unknown}");
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. Unknown: {unknown}");
return 0;
}
// GetBaasAccountManagerForApplication(nn::account::Uid) -> object<nn::account::baas::IManagerForApplication>
public long GetBaasAccountManagerForApplication(ServiceCtx Context)
public long GetBaasAccountManagerForApplication(ServiceCtx context)
{
UInt128 Uuid = new UInt128(
Context.RequestData.ReadInt64(),
Context.RequestData.ReadInt64());
UInt128 uuid = new UInt128(
context.RequestData.ReadInt64(),
context.RequestData.ReadInt64());
MakeObject(Context, new IManagerForApplication(Uuid));
MakeObject(context, new IManagerForApplication(uuid));
return 0;
}

View file

@ -7,25 +7,25 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{
class IManagerForApplication : IpcService
{
private UInt128 Uuid;
private UInt128 _uuid;
private Dictionary<int, ServiceProcessRequest> m_Commands;
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
public IManagerForApplication(UInt128 Uuid)
public IManagerForApplication(UInt128 uuid)
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, CheckAvailability },
{ 1, GetAccountId }
};
this.Uuid = Uuid;
_uuid = uuid;
}
// CheckAvailability()
public long CheckAvailability(ServiceCtx Context)
public long CheckAvailability(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAcc, "Stubbed.");
@ -33,13 +33,13 @@ namespace Ryujinx.HLE.HOS.Services.Acc
}
// GetAccountId() -> nn::account::NetworkServiceAccountId
public long GetAccountId(ServiceCtx Context)
public long GetAccountId(ServiceCtx context)
{
long NetworkServiceAccountId = 0xcafe;
long networkServiceAccountId = 0xcafe;
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. NetworkServiceAccountId: {NetworkServiceAccountId}");
Logger.PrintStub(LogClass.ServiceAcc, $"Stubbed. NetworkServiceAccountId: {networkServiceAccountId}");
Context.ResponseData.Write(NetworkServiceAccountId);
context.ResponseData.Write(networkServiceAccountId);
return 0;
}

View file

@ -12,76 +12,76 @@ namespace Ryujinx.HLE.HOS.Services.Acc
{
class IProfile : IpcService
{
private Dictionary<int, ServiceProcessRequest> m_Commands;
private Dictionary<int, ServiceProcessRequest> _commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => _commands;
private UserProfile Profile;
private UserProfile _profile;
private Stream ProfilePictureStream;
private Stream _profilePictureStream;
public IProfile(UserProfile Profile)
public IProfile(UserProfile profile)
{
m_Commands = new Dictionary<int, ServiceProcessRequest>()
_commands = new Dictionary<int, ServiceProcessRequest>
{
{ 0, Get },
{ 1, GetBase },
{ 10, GetImageSize },
{ 11, LoadImage },
{ 11, LoadImage }
};
this.Profile = Profile;
_profile = profile;
ProfilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg");
_profilePictureStream = Assembly.GetCallingAssembly().GetManifestResourceStream("Ryujinx.HLE.RyujinxProfileImage.jpg");
}
public long Get(ServiceCtx Context)
public long Get(ServiceCtx context)
{
Logger.PrintStub(LogClass.ServiceAcc, "Stubbed.");
long Position = Context.Request.ReceiveBuff[0].Position;
long position = context.Request.ReceiveBuff[0].Position;
MemoryHelper.FillWithZeros(Context.Memory, Position, 0x80);
MemoryHelper.FillWithZeros(context.Memory, position, 0x80);
Context.Memory.WriteInt32(Position, 0);
Context.Memory.WriteInt32(Position + 4, 1);
Context.Memory.WriteInt64(Position + 8, 1);
context.Memory.WriteInt32(position, 0);
context.Memory.WriteInt32(position + 4, 1);
context.Memory.WriteInt64(position + 8, 1);
return GetBase(Context);
return GetBase(context);
}
public long GetBase(ServiceCtx Context)
public long GetBase(ServiceCtx context)
{
Profile.Uuid.Write(Context.ResponseData);
_profile.Uuid.Write(context.ResponseData);
Context.ResponseData.Write(Profile.LastModifiedTimestamp);
context.ResponseData.Write(_profile.LastModifiedTimestamp);
byte[] Username = StringUtils.GetFixedLengthBytes(Profile.Name, 0x20, Encoding.UTF8);
byte[] username = StringUtils.GetFixedLengthBytes(_profile.Name, 0x20, Encoding.UTF8);
Context.ResponseData.Write(Username);
context.ResponseData.Write(username);
return 0;
}
private long LoadImage(ServiceCtx Context)
private long LoadImage(ServiceCtx context)
{
long BufferPosition = Context.Request.ReceiveBuff[0].Position;
long BufferLen = Context.Request.ReceiveBuff[0].Size;
long bufferPosition = context.Request.ReceiveBuff[0].Position;
long bufferLen = context.Request.ReceiveBuff[0].Size;
byte[] ProfilePictureData = new byte[BufferLen];
byte[] profilePictureData = new byte[bufferLen];
ProfilePictureStream.Read(ProfilePictureData, 0, ProfilePictureData.Length);
_profilePictureStream.Read(profilePictureData, 0, profilePictureData.Length);
Context.Memory.WriteBytes(BufferPosition, ProfilePictureData);
context.Memory.WriteBytes(bufferPosition, profilePictureData);
Context.ResponseData.Write(ProfilePictureStream.Length);
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
}
private long GetImageSize(ServiceCtx Context)
private long GetImageSize(ServiceCtx context)
{
Context.ResponseData.Write(ProfilePictureStream.Length);
context.ResponseData.Write(_profilePictureStream.Length);
return 0;
}