From e0e85343954ed337eaa94192c4c49390b298be11 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 8 Mar 2025 02:17:47 +0100 Subject: [PATCH] Add debug function to dump unlock links --- Questionable/Controller/CommandHandler.cs | 8 ++++++++ Questionable/Functions/GameFunctions.cs | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/Questionable/Controller/CommandHandler.cs b/Questionable/Controller/CommandHandler.cs index 6a4e36e0..de7b06b8 100644 --- a/Questionable/Controller/CommandHandler.cs +++ b/Questionable/Controller/CommandHandler.cs @@ -161,6 +161,14 @@ internal sealed class CommandHandler : IDisposable case "abandon-duty": _gameFunctions.AbandonDuty(); break; + + case "unlock-links": + int foundUnlockLinks = _gameFunctions.DumpUnlockLinks(); + if (foundUnlockLinks >= 0) + _chatGui.Print($"Saved {foundUnlockLinks} unlock links to log.", MessageTag, TagColor); + else + _chatGui.PrintError("Could not query unlock links.", MessageTag, TagColor); + break; } } diff --git a/Questionable/Functions/GameFunctions.cs b/Questionable/Functions/GameFunctions.cs index 50c0c442..65891373 100644 --- a/Questionable/Functions/GameFunctions.cs +++ b/Questionable/Functions/GameFunctions.cs @@ -516,6 +516,26 @@ internal sealed unsafe class GameFunctions /// public void AbandonDuty() => _abandonDuty(false); + public int DumpUnlockLinks() + { + UIState* uiState = UIState.Instance(); + if (uiState == null) + { + _logger.LogError("Could not query unlock links"); + return -1; + } + + List unlockedUnlockLinks = []; + for (uint unlockLink = 0; unlockLink < uiState->UnlockLinkBitmask.Length * 8; ++unlockLink) + { + if (uiState->IsUnlockLinkUnlocked(unlockLink)) + unlockedUnlockLinks.Add(unlockLink); + } + + _logger.LogInformation("Unlocked unlock links: {UnlockedUnlockLinks}", string.Join(", ", unlockedUnlockLinks)); + return unlockedUnlockLinks.Count; + } + #if false private byte ExecuteCommand(int id, int a, int b, int c, int d) { -- 2.30.2