diff --git a/BetterGenshinImpact/BetterGenshinImpact.csproj b/BetterGenshinImpact/BetterGenshinImpact.csproj index f1b030aa..8204fac4 100644 --- a/BetterGenshinImpact/BetterGenshinImpact.csproj +++ b/BetterGenshinImpact/BetterGenshinImpact.csproj @@ -2,7 +2,7 @@ BetterGI - 0.54.2-alpha.3 + 0.54.2-alpha.4 false WinExe net8.0-windows10.0.22621.0 diff --git a/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs index 99f29ed7..d6496a19 100644 --- a/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs +++ b/BetterGenshinImpact/Core/Script/ScriptRepoUpdater.cs @@ -168,40 +168,17 @@ public class ScriptRepoUpdater : Singleton return; } - // 获取远程分支信息并拉取最新数据 - var remote = repo.Network.Remotes["origin"]; + // 直接获取远程分支的 Commit SHA + var remoteReferences = repo.Network.ListReferences(repoUrl, CreateCredentialsHandler()); + var remoteBranch = remoteReferences.FirstOrDefault(r => r.CanonicalName == "refs/heads/release"); - var fetchOptions = new FetchOptions - { - ProxyOptions = { ProxyType = ProxyType.None }, - Depth = 1, // 浅拉取,只获取最新的提交 - CredentialsProvider = CreateCredentialsHandler(), // 添加凭据处理器 - OnTransferProgress = progress => - { - onCheckoutProgress?.Invoke($"拉取对象 {progress.ReceivedObjects}/{progress.TotalObjects}", progress.ReceivedObjects, progress.TotalObjects); - return true; - } - }; - - // 拉取到远程追踪分支 - string refSpec = $"+refs/heads/release:refs/remotes/origin/release"; - Commands.Fetch(repo, remote.Name, new[] { refSpec }, fetchOptions, "拉取最新更新"); - - // 获取本地和远程commit - var localBranch = repo.Branches["release"]; - if (localBranch == null) - { - throw new Exception("未找到本地release分支"); - } - - var remoteBranch = repo.Branches["origin/release"]; if (remoteBranch == null) { throw new Exception("未找到远程release分支"); } - var currentCommitSha = localBranch.Tip?.Sha; - var remoteCommitSha = remoteBranch.Tip.Sha; + var remoteCommitSha = remoteBranch.TargetIdentifier; + var currentCommitSha = repo.Branches["release"]?.Tip?.Sha; // 比较本地和远程commit if (currentCommitSha == remoteCommitSha) diff --git a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs index 3f3a62fe..40c589c8 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/Model/Avatar.cs @@ -128,28 +128,37 @@ public class Avatar } Logger.LogInformation("游泳检测:尝试回到战斗地点"); - var pathExecutor = new PathExecutor(ct); + var cts = new CancellationTokenSource(); + var pathExecutor = new PathExecutor(cts.Token); + try { - pathExecutor.FaceTo(AutoFightTask.FightWaypoint).Wait(2000, ct); - AutoFightTask.FightWaypoint.MoveMode = MoveModeEnum.Fly.Code;//改为跳飞 + pathExecutor.FaceTo(AutoFightTask.FightWaypoint).Wait(2000,cts.Token); + AutoFightTask.FightWaypoint.MoveMode = MoveModeEnum.Fly.Code; // 改为跳飞 Simulation.SendInput.Mouse.RightButtonDown(); - pathExecutor.MoveTo(AutoFightTask.FightWaypoint).Wait(15000, ct); - AutoFightTask.FightWaypoint = null;//执行后清空,即每次战斗只执行一次,第二次直接去七天神像 + pathExecutor.MoveTo(AutoFightTask.FightWaypoint).Wait(15000,cts.Token); + cts.Cancel(); + AutoFightTask.FightWaypoint = null; Simulation.SendInput.Mouse.RightButtonUp(); } + catch (TaskCanceledException) + { + Logger.LogError("游泳检测:回到战斗地点任务被取消"); + } catch (Exception ex) { - Logger.LogWarning(ex, "游泳检测:回到战斗地点异常"); + Logger.LogError(ex, "游泳检测:回到战斗地点异常"); + } + finally + { + Simulation.ReleaseAllKey(); } - Simulation.ReleaseAllKey(); - - using var ra2 = CaptureToRectArea(); - if (!SwimmingConfirm(ra2)) + using var bitmap2 = CaptureToRectArea(); + if (!SwimmingConfirm(bitmap2)) { Logger.LogInformation("游泳检测:游泳脱困成功"); - return; + return; } Logger.LogWarning("游泳检测:回到战斗地点失败");