From: Liza Carvelli Date: Sat, 8 Mar 2025 01:17:47 +0000 (+0100) Subject: Add debug function to dump unlock links X-Git-Tag: v4.24~3 X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=e0e85343954ed337eaa94192c4c49390b298be11;p=Questionable.git Add debug function to dump unlock links --- 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) {