From 5636d24ac71c7945c54758bd998664e29e8093bf Mon Sep 17 00:00:00 2001 From: BoatTK Date: Sat, 18 Jul 2026 19:30:37 -0400 Subject: [PATCH] Fixed MiniMetro Updated RAM pointer for MiniMetro. Added handling/disconnection when the Process ends. Added safeguard for Passenger value changing when returning to Main Menu. --- .../Models/Games/MiniMetroConnector.cs | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/HintMachine/Models/Games/MiniMetroConnector.cs b/HintMachine/Models/Games/MiniMetroConnector.cs index fcf7d9f..7daef7f 100644 --- a/HintMachine/Models/Games/MiniMetroConnector.cs +++ b/HintMachine/Models/Games/MiniMetroConnector.cs @@ -14,6 +14,7 @@ public class MiniMetroConnector : IGameConnector }; private ProcessRamWatcher _ram = null; + private uint? _lastValidValue = null; public MiniMetroConnector() { @@ -40,13 +41,35 @@ public override void Disconnect() protected override bool Poll() { - try { - long address = _ram.ResolvePointerPath32(_ram.BaseAddress + 0x3A1574, new int[] { 0x690, 0x20, 0x8, 0x4C, 0x8, 0xC, 0x88 }); - _passengersQuest.UpdateValue(_ram.ReadUint32(address)); + try + { + long address = _ram.ResolvePointerPath32(_ram.BaseAddress + 0x0058010C, new int[] { 0x5EC, 0x24, 0x8, 0x54, 0x10 }); + uint value = _ram.ReadUint32(address); + if (address == 0) + return true; + + if (_lastValidValue.HasValue) + { + long delta = (long)value - (long)_lastValidValue.Value; + + // Returning to Menu causes Passenger Count to become -1 (255 unsigned int), which is frequently flagging the MaxIncrease warning. + // This hides this warning when the value was specifically set to 255 from far away. + bool likelyMainMenuReturn = (value == 255 && delta > _passengersQuest.MaxIncrease); + if (likelyMainMenuReturn) + return true; + } + + _passengersQuest.UpdateValue(value); + _lastValidValue = value; } - catch - { } - + catch (ProcessRamWatcherException) + { + if (_ram?.Process == null || _ram.Process.HasExited) + return false; + + return true; + } + return true; } }