From: Liza Carvelli Date: Tue, 12 Aug 2025 22:25:43 +0000 (+0200) Subject: Update /qst@ unlock-links X-Git-Tag: v6.1~7 X-Git-Url: https://git.jacobcasper.com/?a=commitdiff_plain;h=ebe72901b9787375f25cc82ac45be99957b0d88d;p=Questionable.git Update /qst@ unlock-links --- diff --git a/Questionable/Controller/CommandHandler.cs b/Questionable/Controller/CommandHandler.cs index abfcfbab..391e727a 100644 --- a/Questionable/Controller/CommandHandler.cs +++ b/Questionable/Controller/CommandHandler.cs @@ -34,8 +34,11 @@ internal sealed class CommandHandler : IDisposable private readonly QuestFunctions _questFunctions; private readonly GameFunctions _gameFunctions; private readonly IDataManager _dataManager; + private readonly IClientState _clientState; private readonly Configuration _configuration; + private IReadOnlyList _previouslyUnlockedUnlockLinks = []; + public CommandHandler( ICommandManager commandManager, IChatGui chatGui, @@ -52,6 +55,7 @@ internal sealed class CommandHandler : IDisposable QuestFunctions questFunctions, GameFunctions gameFunctions, IDataManager dataManager, + IClientState clientState, Configuration configuration) { _commandManager = commandManager; @@ -69,8 +73,10 @@ internal sealed class CommandHandler : IDisposable _questFunctions = questFunctions; _gameFunctions = gameFunctions; _dataManager = dataManager; + _clientState = clientState; _configuration = configuration; + _clientState.Logout += OnLogout; _commandManager.AddHandler("/qst", new CommandInfo(ProcessCommand) { HelpMessage = string.Join($"{Environment.NewLine}\t", @@ -174,11 +180,19 @@ internal sealed class CommandHandler : IDisposable break; case "unlock-links": - int foundUnlockLinks = _gameFunctions.DumpUnlockLinks(); - if (foundUnlockLinks >= 0) - _chatGui.Print($"Saved {foundUnlockLinks} unlock links to log.", MessageTag, TagColor); + IReadOnlyList unlockedUnlockLinks = _gameFunctions.GetUnlockLinks(); + if (unlockedUnlockLinks.Count >= 0) + { + _chatGui.Print($"Saved {unlockedUnlockLinks.Count} unlock links to log.", MessageTag, TagColor); + + var newUnlockLinks = unlockedUnlockLinks.Except(_previouslyUnlockedUnlockLinks).ToList(); + if (_previouslyUnlockedUnlockLinks.Count > 0 && newUnlockLinks.Count > 0) + _chatGui.Print($"New unlock links: {string.Join(", ", newUnlockLinks)}", MessageTag, TagColor); + } else _chatGui.PrintError("Could not query unlock links.", MessageTag, TagColor); + + _previouslyUnlockedUnlockLinks = unlockedUnlockLinks; break; case "taxi": @@ -330,11 +344,17 @@ internal sealed class CommandHandler : IDisposable _chatGui.Print("You are not mounted.", MessageTag, TagColor); } + private void OnLogout(int type, int code) + { + _previouslyUnlockedUnlockLinks = []; + } + public void Dispose() { #if DEBUG _commandManager.RemoveHandler("/qst@"); #endif _commandManager.RemoveHandler("/qst"); + _clientState.Logout -= OnLogout; } } diff --git a/Questionable/Functions/GameFunctions.cs b/Questionable/Functions/GameFunctions.cs index f2030993..2724e3a6 100644 --- a/Questionable/Functions/GameFunctions.cs +++ b/Questionable/Functions/GameFunctions.cs @@ -528,13 +528,13 @@ internal sealed unsafe class GameFunctions /// public void AbandonDuty() => _abandonDuty(false); - public int DumpUnlockLinks() + public IReadOnlyList GetUnlockLinks() { UIState* uiState = UIState.Instance(); if (uiState == null) { _logger.LogError("Could not query unlock links"); - return -1; + return []; } List unlockedUnlockLinks = []; @@ -545,7 +545,7 @@ internal sealed unsafe class GameFunctions } _logger.LogInformation("Unlocked unlock links: {UnlockedUnlockLinks}", string.Join(", ", unlockedUnlockLinks)); - return unlockedUnlockLinks.Count; + return unlockedUnlockLinks; } #if false