From 9ae60207c4e93388b97e10af5ead090a038f8a7c Mon Sep 17 00:00:00 2001 From: Caian Benedicto Date: Fri, 2 Apr 2021 10:42:25 -0300 Subject: [PATCH] Fix Tamper Machine crash and timings (#2159) * Add missing return * Change TamperMachine sleep to 83ms * Change constant name to PascalCase --- Ryujinx.HLE/HOS/ModLoader.cs | 2 ++ Ryujinx.HLE/HOS/TamperMachine.cs | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/Ryujinx.HLE/HOS/ModLoader.cs b/Ryujinx.HLE/HOS/ModLoader.cs index 430a05900..a2e9af18a 100644 --- a/Ryujinx.HLE/HOS/ModLoader.cs +++ b/Ryujinx.HLE/HOS/ModLoader.cs @@ -630,6 +630,8 @@ namespace Ryujinx.HLE.HOS if (tamperInfo == null || tamperInfo.BuildIds == null || tamperInfo.CodeAddresses == null) { Logger.Error?.Print(LogClass.ModLoader, "Unable to install cheat because the associated process is invalid"); + + return; } Logger.Info?.Print(LogClass.ModLoader, $"Build ids found for title {titleId:X16}:\n {String.Join("\n ", tamperInfo.BuildIds)}"); diff --git a/Ryujinx.HLE/HOS/TamperMachine.cs b/Ryujinx.HLE/HOS/TamperMachine.cs index 77e274014..9cdea94ae 100644 --- a/Ryujinx.HLE/HOS/TamperMachine.cs +++ b/Ryujinx.HLE/HOS/TamperMachine.cs @@ -13,6 +13,10 @@ namespace Ryujinx.HLE.HOS { public class TamperMachine { + // Atmosphere specifies a delay of 83 milliseconds between the execution of the last + // cheat and the re-execution of the first one. + private const int TamperMachineSleepMs = 1000 / 12; + private Thread _tamperThread = null; private ConcurrentQueue _programs = new ConcurrentQueue(); private long _pressedKeys = 0; @@ -76,7 +80,7 @@ namespace Ryujinx.HLE.HOS if (sleepCounter == 0) { sleepCounter = _programs.Count; - Thread.Sleep(1); + Thread.Sleep(TamperMachineSleepMs); } else {