From 149ea6100888fbb30b26a13027b0ac9412607b52 Mon Sep 17 00:00:00 2001 From: wcko87 Date: Sat, 15 Apr 2017 02:50:31 +0800 Subject: [PATCH] Simplify blackness code --- rabi_splitter_WPF/MainContext.cs | 2 +- rabi_splitter_WPF/MainWindow.xaml.cs | 31 +++++++--------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/rabi_splitter_WPF/MainContext.cs b/rabi_splitter_WPF/MainContext.cs index c19c3b6..cc91b16 100644 --- a/rabi_splitter_WPF/MainContext.cs +++ b/rabi_splitter_WPF/MainContext.cs @@ -336,7 +336,7 @@ namespace rabi_splitter_WPF } } - public bool readyToStartGame = false; + public int previousBlackness = -1; public string oldtitle; public int veridx; public int lastmoney; diff --git a/rabi_splitter_WPF/MainWindow.xaml.cs b/rabi_splitter_WPF/MainWindow.xaml.cs index ab0ce7b..09fc12a 100644 --- a/rabi_splitter_WPF/MainWindow.xaml.cs +++ b/rabi_splitter_WPF/MainWindow.xaml.cs @@ -98,32 +98,15 @@ namespace rabi_splitter_WPF #region Detect Start Game { - int blackness = MemoryHelper.GetMemoryValue(process, StaticData.BlacknessAddr[mainContext.veridx]); // blackness - if (blackness == 0) + int blackness = MemoryHelper.GetMemoryValue(process, StaticData.BlacknessAddr[mainContext.veridx]); + if (mainContext.previousBlackness == 0 && blackness >= 100000) { - if (!mainContext.readyToStartGame) - { - mainContext.readyToStartGame = true; - } - } - else if (blackness >= 100000) - { - if (mainContext.readyToStartGame) - { - // suddent jump to 100000. - mainContext.readyToStartGame = false; - if (mainContext.AutoStart) sendstarttimer(); - DebugLog("Start Game!"); - } - } - else // 0 < blackness < 100000 - { - if (mainContext.readyToStartGame) - { - // disarm ready trigger. - mainContext.readyToStartGame = false; - } + // Sudden increase by 100000 + // Have to be careful, though. I don't know whether anything else causes blackness to increase by 100000 + if (mainContext.AutoStart) sendstarttimer(); + DebugLog("Start Game!"); } + mainContext.previousBlackness = blackness; } #endregion