qstcompanion v1.0.6

This commit is contained in:
alydev 2025-12-07 10:54:53 +10:00
parent 5e1e1decc5
commit ada27cf05b
30 changed files with 3403 additions and 426 deletions

View file

@ -538,6 +538,31 @@ public class QuestRotationExecutionService : IDisposable
return false;
}
public void ClearCharacterQuestData(string characterName)
{
log.Information("[QuestRotation] Clearing all quest data for " + characterName);
int questsCleared = 0;
foreach (KeyValuePair<uint, List<string>> kvp in questCompletionByCharacter.ToList())
{
if (kvp.Value.Remove(characterName))
{
questsCleared++;
}
if (kvp.Value.Count == 0)
{
questCompletionByCharacter.Remove(kvp.Key);
}
}
log.Information($"[QuestRotation] Removed {characterName} from {questsCleared} quests in rotation tracking");
if (preCheckService != null)
{
preCheckService.ClearCharacterData(characterName);
log.Information("[QuestRotation] Cleared " + characterName + " data from PreCheck service");
}
onDataChanged?.Invoke();
log.Information("[QuestRotation] Quest data reset complete for " + characterName);
}
private void ScanAndSaveAllCompletedQuests(string characterName)
{
if (string.IsNullOrEmpty(characterName))
@ -637,12 +662,19 @@ public class QuestRotationExecutionService : IDisposable
{
log.Warning("[ErrorRecovery] Disconnect detected for " + charToRelog);
log.Information("[ErrorRecovery] Automatically relogging to " + charToRelog + "...");
errorRecoveryService.Reset();
currentState.Phase = RotationPhase.WaitingForCharacterLogin;
currentState.CurrentCharacter = charToRelog;
currentState.PhaseStartTime = DateTime.Now;
autoRetainerIpc.SwitchCharacter(charToRelog);
log.Information("[ErrorRecovery] Relog initiated for " + charToRelog);
if (errorRecoveryService.RequestRelog())
{
errorRecoveryService.Reset();
currentState.Phase = RotationPhase.WaitingForCharacterLogin;
currentState.CurrentCharacter = charToRelog;
currentState.PhaseStartTime = DateTime.Now;
log.Information("[ErrorRecovery] Relog initiated for " + charToRelog);
}
else
{
log.Error("[ErrorRecovery] Failed to request relog via AutoRetainer");
errorRecoveryService.Reset();
}
return;
}
log.Warning("[ErrorRecovery] Disconnect detected but no character to relog to");
@ -652,19 +684,12 @@ public class QuestRotationExecutionService : IDisposable
{
deathHandler.Update();
}
if (dungeonAutomation != null)
if (dungeonAutomation != null && !submarineManager.IsSubmarinePaused)
{
if (submarineManager.IsSubmarinePaused)
dungeonAutomation.Update();
if (isRotationActive && configuration.EnableAutoDutyUnsynced && !dungeonAutomation.IsWaitingForParty && currentState.Phase != RotationPhase.WaitingForCharacterLogin && currentState.Phase != RotationPhase.WaitingBeforeCharacterSwitch && currentState.Phase != RotationPhase.WaitingForHomeworldReturn && currentState.Phase != RotationPhase.ScanningQuests && currentState.Phase != RotationPhase.CheckingQuestCompletion && currentState.Phase != RotationPhase.InitializingFirstCharacter)
{
log.Debug("[QuestRotation] Submarine multi-mode active - skipping dungeon validation");
}
else
{
dungeonAutomation.Update();
if (isRotationActive && configuration.EnableAutoDutyUnsynced && !dungeonAutomation.IsWaitingForParty && currentState.Phase != RotationPhase.WaitingForCharacterLogin && currentState.Phase != RotationPhase.WaitingBeforeCharacterSwitch && currentState.Phase != RotationPhase.WaitingForHomeworldReturn && currentState.Phase != RotationPhase.ScanningQuests && currentState.Phase != RotationPhase.CheckingQuestCompletion && currentState.Phase != RotationPhase.InitializingFirstCharacter)
{
_ = submarineManager.IsSubmarinePaused;
}
_ = submarineManager.IsSubmarinePaused;
}
}
if (combatDutyDetection != null)
@ -1164,7 +1189,25 @@ public class QuestRotationExecutionService : IDisposable
{
string currentQuestIdStr2 = questionableIPC.GetCurrentQuestId();
byte? currentSequence2 = questionableIPC.GetCurrentSequence();
if (!string.IsNullOrEmpty(currentQuestIdStr2) && currentSequence2.HasValue && uint.TryParse(currentQuestIdStr2, out var currentQuestId2))
uint currentQuestId2;
if (string.IsNullOrEmpty(currentQuestIdStr2) && currentState.HasQuestBeenAccepted)
{
if (QuestManager.Instance() != null)
{
byte gameQuestSeq = QuestManager.GetQuestSequence((ushort)questId);
if (gameQuestSeq >= activeStopPoint.Sequence.Value)
{
log.Information("[QuestRotation] ✓ Questionable auto-stopped at stop point!");
log.Information($"[QuestRotation] Quest {questId} Sequence {gameQuestSeq} >= {activeStopPoint.Sequence.Value}");
shouldRotate = true;
}
else
{
log.Debug($"[QuestRotation] Questionable stopped but not at stop sequence (seq {gameQuestSeq} < {activeStopPoint.Sequence.Value})");
}
}
}
else if (!string.IsNullOrEmpty(currentQuestIdStr2) && currentSequence2.HasValue && uint.TryParse(currentQuestIdStr2, out currentQuestId2))
{
if (currentQuestId2 == questId)
{
@ -1315,17 +1358,24 @@ public class QuestRotationExecutionService : IDisposable
{
return;
}
log.Information("[QuestRotation] ========================================");
log.Information("[QuestRotation] === SENDING HOMEWORLD RETURN COMMAND ===");
log.Information("[QuestRotation] ========================================");
try
if (configuration.ReturnToHomeworldOnStopQuest)
{
commandManager.ProcessCommand("/li");
log.Information("[QuestRotation] ✓ /li command sent (homeworld return)");
log.Information("[QuestRotation] ========================================");
log.Information("[QuestRotation] === SENDING HOMEWORLD RETURN COMMAND ===");
log.Information("[QuestRotation] ========================================");
try
{
commandManager.ProcessCommand("/li");
log.Information("[QuestRotation] ✓ /li command sent (homeworld return)");
}
catch (Exception ex)
{
log.Error("[QuestRotation] Failed to send /li command: " + ex.Message);
}
}
catch (Exception ex)
else
{
log.Error("[QuestRotation] Failed to send /li command: " + ex.Message);
log.Information("[QuestRotation] Skipping homeworld return (setting disabled)");
}
Task.Delay(2000).ContinueWith(delegate
{