From 8442a5917f39b9d1e338234d4f300671ce295141 Mon Sep 17 00:00:00 2001 From: Starlet Date: Tue, 12 Jun 2018 14:28:45 -0400 Subject: [PATCH 1/2] [PCTL] Add CreateServiceWithoutInitialize and Initialize --- .../Services/Pctl/IParentalControlService.cs | 15 ++++++++++++++- .../Pctl/IParentalControlServiceFactory.cs | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs index eb363ade1c..c88545c654 100644 --- a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs +++ b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs @@ -1,3 +1,4 @@ +using Ryujinx.HLE.Logging; using Ryujinx.HLE.OsHle.Ipc; using System.Collections.Generic; @@ -9,12 +10,24 @@ namespace Ryujinx.HLE.OsHle.Services.Pctl public override IReadOnlyDictionary Commands => m_Commands; + public bool Initialized = false; + public IParentalControlService() { m_Commands = new Dictionary() { - //... + { 1, Initialize } }; } + + public long Initialize(ServiceCtx Context) + { + if (!Initialized) + Initialized = true; + else + Context.Ns.Log.PrintWarning(LogClass.ServicePctl, "Service is already initialized!"); + + return 0; + } } } \ No newline at end of file diff --git a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs index 094245f6b7..5a7b2c29f0 100644 --- a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs +++ b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs @@ -13,15 +13,27 @@ namespace Ryujinx.HLE.OsHle.Services.Pctl { m_Commands = new Dictionary() { - { 0, CreateService } + { 0, CreateService }, + { 1, CreateServiceWithoutInitialize } }; } - public static long CreateService(ServiceCtx Context) + public long CreateService(ServiceCtx Context) { MakeObject(Context, new IParentalControlService()); return 0; } + + public long CreateServiceWithoutInitialize(ServiceCtx Context) + { + IParentalControlService Service = new IParentalControlService(); + + Service.Initialized = true; + + MakeObject(Context, Service); + + return 0; + } } } \ No newline at end of file From c646a009188252bb30785992f7e19155e1bf70a7 Mon Sep 17 00:00:00 2001 From: Starlet Date: Tue, 12 Jun 2018 20:51:59 -0400 Subject: [PATCH 2/2] Compliant with review. --- .../OsHle/Services/Pctl/IParentalControlService.cs | 14 +++++++++++--- .../Pctl/IParentalControlServiceFactory.cs | 6 +----- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs index c88545c654..60a69f58c9 100644 --- a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs +++ b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlService.cs @@ -10,22 +10,30 @@ namespace Ryujinx.HLE.OsHle.Services.Pctl public override IReadOnlyDictionary Commands => m_Commands; - public bool Initialized = false; + private bool Initialized = false; - public IParentalControlService() + private bool NeedInitialize; + + public IParentalControlService(bool NeedInitialize = true) { m_Commands = new Dictionary() { { 1, Initialize } }; + + this.NeedInitialize = NeedInitialize; } public long Initialize(ServiceCtx Context) { - if (!Initialized) + if (NeedInitialize && !Initialized) + { Initialized = true; + } else + { Context.Ns.Log.PrintWarning(LogClass.ServicePctl, "Service is already initialized!"); + } return 0; } diff --git a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs index 5a7b2c29f0..7ef91d7fb6 100644 --- a/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs +++ b/Ryujinx.HLE/OsHle/Services/Pctl/IParentalControlServiceFactory.cs @@ -27,11 +27,7 @@ namespace Ryujinx.HLE.OsHle.Services.Pctl public long CreateServiceWithoutInitialize(ServiceCtx Context) { - IParentalControlService Service = new IParentalControlService(); - - Service.Initialized = true; - - MakeObject(Context, Service); + MakeObject(Context, new IParentalControlService(false)); return 0; }