diff --git a/CHANGELOG.md b/CHANGELOG.md index 995b1dc3c8..0d15f6f0e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +## v4.10.7-beta.1 + +- 优化 界面关卡选择及提示支持外服 @liuyifan-eric @ABA2396 +- 修复 Unix 的 socket 连接错误 @HerrCai0907 +- 修复 IssueBot 文档链接错误 @Rbqwow + ## v4.10.6 - 新增 `生息演算` 流程支持,修复大量错误,优化界面支持等 @WLLEGit @hguandl @MistEO diff --git a/docs/2.3-IssueBot使用方法.md b/docs/2.3-IssueBot使用方法.md index ce239be5c8..567835daec 100644 --- a/docs/2.3-IssueBot使用方法.md +++ b/docs/2.3-IssueBot使用方法.md @@ -1,6 +1,6 @@ # Issue Bot 使用方法 -Issue Bot 使用的 action 为 [issue-checker](https://github.com/zzyyyl/issue-checker),配置文件为 [issue-checker.yml](.github/issue-checker.yml)。 +Issue Bot 使用的 action 为 [issue-checker](https://github.com/zzyyyl/issue-checker),配置文件为 [issue-checker.yml](../.github/issue-checker.yml)。 **注意:拉取请求被增加 `ambiguous` 标签是因为没有按照 commitizen 规范提交。** @@ -10,7 +10,7 @@ Issue Bot 使用的 action 为 [issue-checker](https://github.com/zzyyyl/issue-c - 给 议题 和 拉取请求 增加标签,包括 `module` 系列,`Client` 系列,`ambiguous`,`translation required` 等。 Issue Bot 会根据关键词自动增加分类标签。 - 具体关键词可以参考[配置文件](.github/issue-checker.yml)。 + 具体关键词可以参考[配置文件](../.github/issue-checker.yml)。 - 给作者是可见性设置为 public 的 MAA 成员的 议题 和 拉取请求 增加 `MAA Team` 标签。 #### 议题(Issue)及其评论 diff --git a/src/MaaCore/Controller.cpp b/src/MaaCore/Controller.cpp index 7b42d28338..8ed32ac335 100644 --- a/src/MaaCore/Controller.cpp +++ b/src/MaaCore/Controller.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #ifndef __APPLE__ #include #endif @@ -1361,7 +1362,7 @@ std::optional asst::Controller::call_command_win32(const std::string& cmd, asst::platform::single_page_buffer pipe_buffer; asst::platform::single_page_buffer sock_buffer; - + HANDLE pipe_parent_read = INVALID_HANDLE_VALUE, pipe_child_write = INVALID_HANDLE_VALUE; SECURITY_ATTRIBUTES sa_inherit { .nLength = sizeof(SECURITY_ATTRIBUTES), .bInheritHandle = TRUE }; if (!asst::win32::CreateOverlappablePipe(&pipe_parent_read, &pipe_child_write, nullptr, &sa_inherit, @@ -1590,36 +1591,37 @@ std::optional asst::Controller::call_command_posix(const std::string& cmd, } else if (m_child > 0) { // parent process - do { - if (recv_by_socket) { - sockaddr addr {}; - socklen_t len = sizeof(addr); - sock_buffer = asst::platform::single_page_buffer(); + if (recv_by_socket) { + sockaddr addr {}; + socklen_t len = sizeof(addr); + sock_buffer = asst::platform::single_page_buffer(); - int client_socket = ::accept(m_server_sock, &addr, &len); - if (client_socket < 0) { - Log.error("accept failed:", strerror(errno)); - return std::nullopt; - } - - ssize_t read_num = ::read(client_socket, sock_buffer.get(), sock_buffer.size()); - - while (read_num > 0) { - sock_data.insert(sock_data.end(), sock_buffer.get(), sock_buffer.get() + read_num); - read_num = ::read(client_socket, sock_buffer.get(), sock_buffer.size()); - } - - ::close(client_socket); - break; + int client_socket = ::accept(m_server_sock, &addr, &len); + if (client_socket < 0) { + Log.error("accept failed:", strerror(errno)); + ::kill(m_child, SIGKILL); + ::waitpid(m_child, &exit_ret, 0); + return std::nullopt; } - ssize_t read_num = ::read(m_pipe_out[PIPE_READ], pipe_buffer.get(), pipe_buffer.size()); - + ssize_t read_num = ::read(client_socket, sock_buffer.get(), sock_buffer.size()); while (read_num > 0) { - pipe_data.insert(pipe_data.end(), pipe_buffer.get(), pipe_buffer.get() + read_num); - read_num = ::read(m_pipe_out[PIPE_READ], pipe_buffer.get(), pipe_buffer.size()); + sock_data.insert(sock_data.end(), sock_buffer.get(), sock_buffer.get() + read_num); + read_num = ::read(client_socket, sock_buffer.get(), sock_buffer.size()); } - } while (::waitpid(m_child, &exit_ret, WNOHANG) == 0 && !check_timeout()); + ::shutdown(client_socket, SHUT_RDWR); + ::close(client_socket); + } + else { + do { + ssize_t read_num = ::read(m_pipe_out[PIPE_READ], pipe_buffer.get(), pipe_buffer.size()); + while (read_num > 0) { + pipe_data.insert(pipe_data.end(), pipe_buffer.get(), pipe_buffer.get() + read_num); + read_num = ::read(m_pipe_out[PIPE_READ], pipe_buffer.get(), pipe_buffer.size()); + } + } while (::waitpid(m_child, &exit_ret, WNOHANG) == 0 && !check_timeout()); + } + ::waitpid(m_child, &exit_ret, 0); // if ::waitpid(m_child, &exit_ret, WNOHANG) == 0, repeat it will cause ECHILD, so not check the return value } else { // failed to create child process diff --git a/src/MaaWpfGui/Helper/StageManager.cs b/src/MaaWpfGui/Helper/StageManager.cs index 8a4c9d8791..67f112779d 100644 --- a/src/MaaWpfGui/Helper/StageManager.cs +++ b/src/MaaWpfGui/Helper/StageManager.cs @@ -19,6 +19,7 @@ using System.Reflection; using System.Runtime.InteropServices; using System.Text; using System.Threading.Tasks; +using System.Windows.Documents; using MaaWpfGui.Helper; using Newtonsoft.Json.Linq; using Semver; @@ -85,18 +86,30 @@ namespace MaaWpfGui "yyyy/MM/dd HH:mm:ss", CultureInfo.InvariantCulture).AddHours(-Convert.ToInt32(keyValuePairs?["TimeZone"].ToString() ?? "0")); - if (activity != null) + var settingsModel = _container.Get(); + var clientType = settingsModel.ClientType; + + // 官服和B服使用同样的资源 + if (clientType == "Bilibili" || clientType == string.Empty) + { + clientType = "Official"; + } + + if (activity?[clientType] != null) { try { // 资源全开放活动 - var resource = activity["Official"]["resourceCollection"]; - resourceCollection.Tip = resource?["Tip"]?.ToString(); - resourceCollection.UtcStartTime = GetDateTime(resource, "UtcStartTime"); - resourceCollection.UtcExpireTime = GetDateTime(resource, "UtcExpireTime"); + var resource = activity[clientType]["resourceCollection"]; + if (resource != null) + { + resourceCollection.Tip = resource["Tip"]?.ToString(); + resourceCollection.UtcStartTime = GetDateTime(resource, "UtcStartTime"); + resourceCollection.UtcExpireTime = GetDateTime(resource, "UtcExpireTime"); + } // 活动关卡 - foreach (var stageObj in activity["Official"]["sideStoryStage"]) + foreach (var stageObj in activity[clientType]["sideStoryStage"] ?? Enumerable.Empty()) { bool isDebugVersion = Marshal.PtrToStringAnsi(AsstGetVersion()) == "DEBUG VERSION"; bool curParsed = !isDebugVersion ? diff --git a/src/MaaWpfGui/Helper/Utils.cs b/src/MaaWpfGui/Helper/Utils.cs index 3f3bf858fd..845313c68e 100644 --- a/src/MaaWpfGui/Helper/Utils.cs +++ b/src/MaaWpfGui/Helper/Utils.cs @@ -58,13 +58,31 @@ namespace MaaWpfGui } } + private static string _clientType = ViewStatusStorage.Get("Start.ClientType", string.Empty); + + public static string ClientType { get => _clientType; set => _clientType = value; } + + // YJ历每一天从4点开始,计算日期的时候第二天4点前仍然算作前一天 + private static readonly int YJDayStartHour = 4; + + private static readonly Dictionary _clientTypeTimezone = new Dictionary + { + { string.Empty, 8 }, + { "Official", 8 }, + { "Bilibili", 8 }, + { "txwy", 8 }, + { "YoStarEN", -7 }, + { "YoStarJP", 9 }, + { "YoStarKR", 9 }, + }; + /// /// 获取yj历时间 /// /// yj历时间 public static DateTime GetYJTimeNow() { - return DateTime.UtcNow.AddHours(4); + return ToYJTime(DateTime.UtcNow); } /// @@ -101,7 +119,7 @@ namespace MaaWpfGui /// yj历格式的时间 public static DateTime ToYJTime(DateTime dt) { - return dt.AddHours(4); + return dt.AddHours(_clientTypeTimezone[ClientType] - YJDayStartHour); } private static readonly JObject _itemList = new JObject(); diff --git a/src/MaaWpfGui/Main/AsstProxy.cs b/src/MaaWpfGui/Main/AsstProxy.cs index 3c389971fa..f079d81f77 100644 --- a/src/MaaWpfGui/Main/AsstProxy.cs +++ b/src/MaaWpfGui/Main/AsstProxy.cs @@ -476,6 +476,11 @@ namespace MaaWpfGui copilotModel.AddLog(Localization.GetString("CombatError"), UILogColor.Error); } + if (taskChain == "Fight" && (mainModel.Stage == "Annihilation")) + { + mainModel.AddLog(Localization.GetString("AnnihilationTaskFailed"), UILogColor.Warning); + } + break; case AsstMsg.TaskChainStart: diff --git a/src/MaaWpfGui/Main/SettingsViewModel.cs b/src/MaaWpfGui/Main/SettingsViewModel.cs index 8b91246ca8..1f66c85e5a 100644 --- a/src/MaaWpfGui/Main/SettingsViewModel.cs +++ b/src/MaaWpfGui/Main/SettingsViewModel.cs @@ -548,8 +548,11 @@ namespace MaaWpfGui set { SetAndNotify(ref _clientType, value); + Utils.ClientType = value; ViewStatusStorage.Set("Start.ClientType", value); UpdateWindowTitle(); /* 每次修改客户端时更新WindowTitle */ + _container.Get().UpdateStageList(true); + _container.Get().UpdateDatePrompt(); } } diff --git a/src/MaaWpfGui/Main/TaskQueueViewModel.cs b/src/MaaWpfGui/Main/TaskQueueViewModel.cs index 4854f3ff92..89f40b7c17 100644 --- a/src/MaaWpfGui/Main/TaskQueueViewModel.cs +++ b/src/MaaWpfGui/Main/TaskQueueViewModel.cs @@ -782,6 +782,17 @@ namespace MaaWpfGui var asstProxy = _container.Get(); bool mainFightRet = asstProxy.AsstAppendFight(Stage, medicine, stone, times, DropsItemId, drops_quantity); + if (mainFightRet && (Stage == "Annihilation") && _container.Get().UseAlternateStage) + { + foreach (var stage in new[] { Stage1, Stage2, Stage3 }) + { + if (IsStageOpen(stage) && (stage != Stage)) + { + mainFightRet = asstProxy.AsstAppendFight(stage, medicine, 0, int.MaxValue, string.Empty, 0); + } + } + } + if (mainFightRet && UseRemainingSanityStage && (RemainingSanityStage != string.Empty)) { return asstProxy.AsstAppendFight(RemainingSanityStage, 0, 0, int.MaxValue, string.Empty, 0, false); diff --git a/src/MaaWpfGui/Res/Localizations/en-us.xaml b/src/MaaWpfGui/Res/Localizations/en-us.xaml index 997398bd03..8754c3100e 100644 --- a/src/MaaWpfGui/Res/Localizations/en-us.xaml +++ b/src/MaaWpfGui/Res/Localizations/en-us.xaml @@ -74,7 +74,7 @@ Starting Roles Starting Oper (single, CN name only) Only supports the CN name of a single oper, default if not filled. - Select "Starting Oper" from support unit list + Select "Starting Oper" from support unit list Enable nonfirend support Deployment with Pause, Works for IS, Copilot and SSS, Beta function, Not recommended yet Use Adb Lite (Experimental) @@ -100,6 +100,10 @@ Overcoming Your Weaknesses As Your Heart Desires + Algorithm Finish + Algorithm Badge + Algorithm Construction Point + Not selected Official (CN) Bilibili @@ -242,6 +246,7 @@ Credit Store Collect mission rewards Auto I.S. + Reclamation Algorithm Select All Inverse @@ -324,6 +329,7 @@ All tasks are completed shutting down. Do you want to cancel? Tip Task(s) completed, about to hibernate + Annihilation task failed, will try to use alternate stage, some combat settings will not be effective diff --git a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml index a31d0096a8..f0b6de2821 100644 --- a/src/MaaWpfGui/Res/Localizations/zh-cn.xaml +++ b/src/MaaWpfGui/Res/Localizations/zh-cn.xaml @@ -329,6 +329,7 @@ 已刷完,即将关机,是否取消? 提示 已刷完,即将休眠 + 剿灭任务失败,将尝试使用剩余备选关卡,部分战斗设置将不生效