diff --git a/src/MaaCore/AsstCaller.cpp b/src/MaaCore/AsstCaller.cpp index cb78169fec..578d24ecfa 100644 --- a/src/MaaCore/AsstCaller.cpp +++ b/src/MaaCore/AsstCaller.cpp @@ -111,7 +111,7 @@ AsstBool AsstSetInstanceOption(AsstHandle handle, AsstInstanceOptionKey key, con AsstBool AsstConnect(AsstHandle handle, const char* adb_path, const char* address, const char* config) { if (!inited() || handle == nullptr) { - asst::Log.error(__FUNCTION__, "Cannot connect to device, asst not inited or handle is nullptr", inited(), handle); + asst::Log.error(__FUNCTION__, "Cannot connect to device, asst not inited or handle is null", inited(), handle); return AsstFalse; } diff --git a/src/MaaCore/Common/AsstConf.h b/src/MaaCore/Common/AsstConf.h index a68806c2fc..2e2c39445c 100644 --- a/src/MaaCore/Common/AsstConf.h +++ b/src/MaaCore/Common/AsstConf.h @@ -1,7 +1,7 @@ #pragma once #if !defined(ASST_USE_RANGES_STL) && !defined(ASST_USE_RANGES_RANGE_V3) && !defined(ASST_USE_RANGES_BOOST) -#if !defined (__cpp_lib_ranges) || __cpp_lib_ranges < 201911L +#if !defined(__cpp_lib_ranges) || __cpp_lib_ranges < 201911L #define ASST_USE_RANGES_RANGE_V3 #else #define ASST_USE_RANGES_STL diff --git a/src/MaaCore/Common/AsstTypes.h b/src/MaaCore/Common/AsstTypes.h index 9c30078677..517b7ab876 100644 --- a/src/MaaCore/Common/AsstTypes.h +++ b/src/MaaCore/Common/AsstTypes.h @@ -85,6 +85,7 @@ namespace asst int x = 0; int y = 0; + // clang-format off #define DEFINE_ASST_POINT_BINARY_OP_AND_ARG_ASSIGN(Op) \ friend Point operator Op(const Point& lhs, const Point& rhs) noexcept \ { \ @@ -96,6 +97,7 @@ namespace asst val.y Op## = opd.y; \ return val; \ } + // clang-format on DEFINE_ASST_POINT_BINARY_OP_AND_ARG_ASSIGN(+) DEFINE_ASST_POINT_BINARY_OP_AND_ARG_ASSIGN(-) diff --git a/src/MaaCore/Config/Miscellaneous/StageDropsConfig.h b/src/MaaCore/Config/Miscellaneous/StageDropsConfig.h index cfdfcbefb7..72e9beb12c 100644 --- a/src/MaaCore/Config/Miscellaneous/StageDropsConfig.h +++ b/src/MaaCore/Config/Miscellaneous/StageDropsConfig.h @@ -16,8 +16,7 @@ namespace asst inline std::string enum_to_string(StageDifficulty algo) { static const std::unordered_map algorithm_map = { - { StageDifficulty::Normal, "Normal" }, - { StageDifficulty::Tough, "Tough" } + { StageDifficulty::Normal, "Normal" }, { StageDifficulty::Tough, "Tough" } }; if (auto it = algorithm_map.find(algo); it != algorithm_map.end()) { return it->second; diff --git a/src/MaaCore/Config/Roguelike/RoguelikeRecruitConfig.h b/src/MaaCore/Config/Roguelike/RoguelikeRecruitConfig.h index 3a6f9777be..57f2d9f57f 100644 --- a/src/MaaCore/Config/Roguelike/RoguelikeRecruitConfig.h +++ b/src/MaaCore/Config/Roguelike/RoguelikeRecruitConfig.h @@ -35,13 +35,13 @@ namespace asst bool is_start = false; // 是否为开局干员 std::vector recruit_priority_offsets; bool is_alternate = false; // 是否后备干员 (允许重复招募、划到后备干员时不再往右划动) - int skill = 0; // 使用几技能 + int skill = 0; // 使用几技能 int alternate_skill = 0; // 当没有指定技能时使用的备选技能,一般是6星干员未精二且精二后使用3技能时才需要指定 - battle::SkillUsage skill_usage = battle::SkillUsage::Possibly; // 技能使用模式 - int skill_times = 1; // 技能使用次数 + battle::SkillUsage skill_usage = battle::SkillUsage::Possibly; // 技能使用模式 + int skill_times = 1; // 技能使用次数 battle::SkillUsage alternate_skill_usage = battle::SkillUsage::Possibly; // 备选技能使用模式 - int alternate_skill_times = 1; // 备选技能使用次数 - int auto_retreat = 0; // 部署几秒后自动撤退 + int alternate_skill_times = 1; // 备选技能使用次数 + int auto_retreat = 0; // 部署几秒后自动撤退 }; class RoguelikeRecruitConfig final : public SingletonHolder, public AbstractConfig diff --git a/src/MaaCore/Config/TaskData.cpp b/src/MaaCore/Config/TaskData.cpp index 2b4add0383..5fb3d114ee 100644 --- a/src/MaaCore/Config/TaskData.cpp +++ b/src/MaaCore/Config/TaskData.cpp @@ -717,8 +717,7 @@ asst::TaskData::taskptr_t asst::TaskData::generate_task_info(std::string_view na return task_info_ptr; } -asst::TaskData::taskptr_t asst::TaskData::generate_match_task_info(std::string_view name, - const json::value& task_json, +asst::TaskData::taskptr_t asst::TaskData::generate_match_task_info(std::string_view name, const json::value& task_json, std::shared_ptr default_ptr) { if (default_ptr == nullptr) { @@ -809,9 +808,8 @@ asst::TaskData::taskptr_t asst::TaskData::generate_hash_task_info([[maybe_unused return hash_task_info_ptr; } -bool asst::TaskData::append_base_task_info(taskptr_t task_info_ptr, std::string_view name, - const json::value& task_json, taskptr_t default_ptr, - std::string_view task_prefix) +bool asst::TaskData::append_base_task_info(taskptr_t task_info_ptr, std::string_view name, const json::value& task_json, + taskptr_t default_ptr, std::string_view task_prefix) { if (default_ptr == nullptr) { default_ptr = default_task_info_ptr; diff --git a/src/MaaCore/Task/AbstractTask.cpp b/src/MaaCore/Task/AbstractTask.cpp index cbb6a06006..16e8b28f3e 100644 --- a/src/MaaCore/Task/AbstractTask.cpp +++ b/src/MaaCore/Task/AbstractTask.cpp @@ -169,7 +169,7 @@ bool asst::AbstractTask::save_img(const std::filesystem::path& relative_dir, boo m_save_file_cnt[relative_dir] = (m_save_file_cnt[relative_dir] + 1) % Config.get_options().debug.clean_files_freq; } - + auto relative_path = relative_dir / (stem + "_raw.png"); Log.trace("Save image", relative_path); return asst::imwrite(relative_path, image); diff --git a/src/MaaCore/Task/BattleHelper.cpp b/src/MaaCore/Task/BattleHelper.cpp index eed9c00927..692f557573 100644 --- a/src/MaaCore/Task/BattleHelper.cpp +++ b/src/MaaCore/Task/BattleHelper.cpp @@ -465,7 +465,7 @@ bool asst::BattleHelper::use_all_ready_skill(const cv::Mat& reusable) } used = true; retry = 0; - + if (usage == SkillUsage::Times) { times--; if (times == 0) usage = SkillUsage::TimesUsed; diff --git a/src/MaaCore/Task/Fight/SideStoryReopenTask.h b/src/MaaCore/Task/Fight/SideStoryReopenTask.h index 29bf197b7d..65e37aee5e 100644 --- a/src/MaaCore/Task/Fight/SideStoryReopenTask.h +++ b/src/MaaCore/Task/Fight/SideStoryReopenTask.h @@ -7,7 +7,7 @@ namespace asst { public: using AbstractTask::AbstractTask; - //SideStoryReopenTask(const AsstCallback& callback, Assistant* inst, std::string_view task_chain); + // SideStoryReopenTask(const AsstCallback& callback, Assistant* inst, std::string_view task_chain); virtual ~SideStoryReopenTask() noexcept override = default; void set_sidestory_name(std::string sidestory_name); diff --git a/src/MaaCore/Task/Infrast/InfrastProcessingTask.cpp b/src/MaaCore/Task/Infrast/InfrastProcessingTask.cpp index e2a4264d6b..61ec51b43f 100644 --- a/src/MaaCore/Task/Infrast/InfrastProcessingTask.cpp +++ b/src/MaaCore/Task/Infrast/InfrastProcessingTask.cpp @@ -1,9 +1,9 @@ #include "InfrastProcessingTask.h" #include "Controller/Controller.h" +#include "Task/ProcessTask.h" #include "Utils/Logger.hpp" #include "Utils/Ranges.hpp" -#include "Task/ProcessTask.h" bool asst::InfrastProcessingTask::_run() { @@ -25,7 +25,7 @@ bool asst::InfrastProcessingTask::_run() enter_facility(); click_bottom_left_tab(); - ProcessTask(*this, {"InfrastProcessingEnterOperList"}).run(); + ProcessTask(*this, { "InfrastProcessingEnterOperList" }).run(); for (int i = 0; i <= OperSelectRetryTimes; ++i) { if (need_exit()) { diff --git a/src/MaaCore/Task/Interface/AwardTask.cpp b/src/MaaCore/Task/Interface/AwardTask.cpp index 9557430c32..5f2eb8651c 100644 --- a/src/MaaCore/Task/Interface/AwardTask.cpp +++ b/src/MaaCore/Task/Interface/AwardTask.cpp @@ -6,10 +6,10 @@ #include "Utils/Logger.hpp" -asst::AwardTask::AwardTask(const AsstCallback& callback, Assistant* inst) : - InterfaceTask(callback, inst, TaskType), - award_task_ptr(std::make_shared(m_callback, m_inst, TaskType)), - mail_task_ptr(std::make_shared(m_callback, m_inst, TaskType)) +asst::AwardTask::AwardTask(const AsstCallback& callback, Assistant* inst) + : InterfaceTask(callback, inst, TaskType), + award_task_ptr(std::make_shared(m_callback, m_inst, TaskType)), + mail_task_ptr(std::make_shared(m_callback, m_inst, TaskType)) { LogTraceFunction; diff --git a/src/MaaCore/Task/Interface/CopilotTask.cpp b/src/MaaCore/Task/Interface/CopilotTask.cpp index e3e07c7f47..4110cdd309 100644 --- a/src/MaaCore/Task/Interface/CopilotTask.cpp +++ b/src/MaaCore/Task/Interface/CopilotTask.cpp @@ -43,7 +43,7 @@ asst::CopilotTask::CopilotTask(const AsstCallback& callback, Assistant* inst) m_copilot_list_notification_ptr = start_2_tp->register_plugin(); m_subtasks.emplace_back(start_2_tp); - //跳过“以下干员出战后将被禁用,是否继续?”对话框 + // 跳过“以下干员出战后将被禁用,是否继续?”对话框 auto start_3_tp = std::make_shared(callback, inst, TaskType); start_3_tp->set_tasks({ "SkipForbiddenOperConfirm", "Stop" }).set_ignore_error(false); m_subtasks.emplace_back(start_3_tp); diff --git a/src/MaaCore/Task/Interface/DebugTask.cpp b/src/MaaCore/Task/Interface/DebugTask.cpp index 747a5ee717..ef208f1889 100644 --- a/src/MaaCore/Task/Interface/DebugTask.cpp +++ b/src/MaaCore/Task/Interface/DebugTask.cpp @@ -4,14 +4,14 @@ #include "Utils/NoWarningCV.h" +#include "Config/TaskData.h" #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" #include "Vision/Battle/BattlefieldClassifier.h" #include "Vision/Battle/BattlefieldMatcher.h" +#include "Vision/Matcher.h" #include "Vision/Miscellaneous/DepotImageAnalyzer.h" #include "Vision/Miscellaneous/StageDropsImageAnalyzer.h" -#include "Vision/Matcher.h" -#include "Config/TaskData.h" asst::DebugTask::DebugTask(const AsstCallback& callback, Assistant* inst) : InterfaceTask(callback, inst, TaskType) {} diff --git a/src/MaaCore/Task/Interface/InfrastTask.cpp b/src/MaaCore/Task/Interface/InfrastTask.cpp index d30873914f..df2230e1a7 100644 --- a/src/MaaCore/Task/Interface/InfrastTask.cpp +++ b/src/MaaCore/Task/Interface/InfrastTask.cpp @@ -9,9 +9,9 @@ #include "Task/Infrast/InfrastMfgTask.h" #include "Task/Infrast/InfrastOfficeTask.h" #include "Task/Infrast/InfrastPowerTask.h" +#include "Task/Infrast/InfrastProcessingTask.h" #include "Task/Infrast/InfrastReceptionTask.h" #include "Task/Infrast/InfrastTradeTask.h" -#include "Task/Infrast/InfrastProcessingTask.h" #include "Task/Infrast/ReplenishOriginiumShardTaskPlugin.h" #include "Task/ProcessTask.h" diff --git a/src/MaaCore/Task/Interface/StartUpTask.cpp b/src/MaaCore/Task/Interface/StartUpTask.cpp index b62ce143a1..bd068881f7 100644 --- a/src/MaaCore/Task/Interface/StartUpTask.cpp +++ b/src/MaaCore/Task/Interface/StartUpTask.cpp @@ -3,8 +3,8 @@ #include #include "Config/GeneralConfig.h" -#include "Task/Miscellaneous/StartGameTaskPlugin.h" #include "Task/Miscellaneous/AccountSwitchTask.h" +#include "Task/Miscellaneous/StartGameTaskPlugin.h" #include "Task/ProcessTask.h" #include "Utils/Logger.hpp" diff --git a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp index be2e032776..9eb544abfa 100644 --- a/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp +++ b/src/MaaCore/Task/Miscellaneous/BattleProcessTask.cpp @@ -191,8 +191,7 @@ bool asst::BattleProcessTask::do_action(const battle::copilot::Action& action, s case ActionType::SkillUsage: m_skill_usage[action.name] = action.modify_usage; - if (action.modify_usage == SkillUsage::Times) - m_skill_times[action.name] = action.modify_times; + if (action.modify_usage == SkillUsage::Times) m_skill_times[action.name] = action.modify_times; ret = true; break; diff --git a/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.h b/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.h index 9aa4bd357f..602010fb67 100644 --- a/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.h +++ b/src/MaaCore/Task/Roguelike/RoguelikeBattleTaskPlugin.h @@ -31,8 +31,8 @@ namespace asst bool do_once(); struct DeployPlanInfo { - std::string oper_name; // 干员名称 // int oper_priority; // 干员招募优先级 + std::string oper_name; // 干员名称 int oper_order_in_group; // 干员在干员组中排名 int rank; // 干员组在部署指令扁平化后的排名 Point placed; // 指令坐标 diff --git a/src/MaaCore/Task/Roguelike/RoguelikeFormationTaskPlugin.cpp b/src/MaaCore/Task/Roguelike/RoguelikeFormationTaskPlugin.cpp index d9b593b61e..3b545ac538 100644 --- a/src/MaaCore/Task/Roguelike/RoguelikeFormationTaskPlugin.cpp +++ b/src/MaaCore/Task/Roguelike/RoguelikeFormationTaskPlugin.cpp @@ -112,15 +112,15 @@ void asst::RoguelikeFormationTaskPlugin::clear_and_reselect() int require = condition.threshold; for (const std::string& group_name : condition.groups) { for (const auto& oper : oper_list) { - std::vector group_ids = RoguelikeRecruit.get_group_id(rogue_theme, oper.name); + std::vector group_ids = RoguelikeRecruit.get_group_id(rogue_theme, oper.name); for (const auto& group_id : group_ids) { std::string oper_group = group_list[group_id]; if (oper_group == group_name) { sorted_oper_list.emplace_back(oper); count++; - break;//每个干员只能选一次 + break; // 每个干员只能选一次 } - } + } if (count == require) break; } if (count == require) break; diff --git a/src/MaaCore/Utils/File.hpp b/src/MaaCore/Utils/File.hpp index b311d3a781..3c6c1a1a13 100644 --- a/src/MaaCore/Utils/File.hpp +++ b/src/MaaCore/Utils/File.hpp @@ -9,17 +9,16 @@ namespace asst::utils concept ByteValueType = std::is_integral_v && sizeof(ValueType) == 1; template - concept AppendableBytesContainer = - requires(ContainerType a) { - requires ranges::contiguous_range; - requires ByteValueType; - requires std::is_constructible_v; - requires std::is_constructible_v; // std::string(count, ch), - // std::vector(count, value) - a.insert(a.end(), a.begin(), a.begin() + (size_t)1); - a.resize(a.size()); - }; + concept AppendableBytesContainer = requires(ContainerType a) { + requires ranges::contiguous_range; + requires ByteValueType; + requires std::is_constructible_v; + requires std::is_constructible_v; // std::string(count, ch), + // std::vector(count, value) + a.insert(a.end(), a.begin(), a.begin() + (size_t)1); + a.resize(a.size()); + }; template ContainerType read_file(const std::filesystem::path& path) diff --git a/src/MaaCore/Vision/BestMatcher.h b/src/MaaCore/Vision/BestMatcher.h index 9b32a43168..ef7f52c339 100644 --- a/src/MaaCore/Vision/BestMatcher.h +++ b/src/MaaCore/Vision/BestMatcher.h @@ -1,7 +1,7 @@ #pragma once -#include "VisionHelper.h" #include "Vision/Config/MatcherConfig.h" +#include "VisionHelper.h" namespace asst { diff --git a/src/MaaCore/Vision/Matcher.cpp b/src/MaaCore/Vision/Matcher.cpp index 802cf2c970..147f30e555 100644 --- a/src/MaaCore/Vision/Matcher.cpp +++ b/src/MaaCore/Vision/Matcher.cpp @@ -39,8 +39,7 @@ Matcher::ResultOpt Matcher::analyze() const return m_result; } -Matcher::RawResult Matcher::preproc_and_match(const cv::Mat& image, - const MatcherConfig::Params& params) +Matcher::RawResult Matcher::preproc_and_match(const cv::Mat& image, const MatcherConfig::Params& params) { cv::Mat templ; std::string templ_name; diff --git a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp index e085c16649..de970f4fba 100644 --- a/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Miscellaneous/StageDropsImageAnalyzer.cpp @@ -11,8 +11,8 @@ #include "Utils/ImageIo.hpp" #include "Utils/Logger.hpp" #include "Vision/Matcher.h" -#include "Vision/TemplDetOCRer.h" #include "Vision/RegionOCRer.h" +#include "Vision/TemplDetOCRer.h" #include diff --git a/src/MaaCore/Vision/MultiMatcher.cpp b/src/MaaCore/Vision/MultiMatcher.cpp index 7f15c29837..558d6b0271 100644 --- a/src/MaaCore/Vision/MultiMatcher.cpp +++ b/src/MaaCore/Vision/MultiMatcher.cpp @@ -14,8 +14,7 @@ using namespace asst; MultiMatcher::ResultsVecOpt MultiMatcher::analyze() const { - const auto& [matched, templ, templ_name] = - Matcher::preproc_and_match(make_roi(m_image, m_roi), m_params); + const auto& [matched, templ, templ_name] = Matcher::preproc_and_match(make_roi(m_image, m_roi), m_params); if (matched.empty()) { return std::nullopt; diff --git a/src/MaaCore/Vision/MultiMatcher.h b/src/MaaCore/Vision/MultiMatcher.h index 2c8edc272a..1e0f5a1f14 100644 --- a/src/MaaCore/Vision/MultiMatcher.h +++ b/src/MaaCore/Vision/MultiMatcher.h @@ -1,6 +1,6 @@ #pragma once -#include "VisionHelper.h" #include "Vision/Config/MatcherConfig.h" +#include "VisionHelper.h" namespace asst { diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp index e121e7c5e4..a0a8059918 100644 --- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp +++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitImageAnalyzer.cpp @@ -4,8 +4,8 @@ #include "Utils/Logger.hpp" #include "Utils/NoWarningCV.h" #include "Vision/Matcher.h" -#include "Vision/TemplDetOCRer.h" #include "Vision/RegionOCRer.h" +#include "Vision/TemplDetOCRer.h" bool asst::RoguelikeRecruitImageAnalyzer::analyze() { diff --git a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp index 7163d78035..e61fc067a3 100644 --- a/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp +++ b/src/MaaCore/Vision/Roguelike/RoguelikeRecruitSupportAnalyzer.cpp @@ -10,8 +10,8 @@ #include "Utils/NoWarningCV.h" #include "Vision/Matcher.h" #include "Vision/OCRer.h" -#include "Vision/TemplDetOCRer.h" #include "Vision/RegionOCRer.h" +#include "Vision/TemplDetOCRer.h" bool asst::RoguelikeRecruitSupportAnalyzer::analyze() {