mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
fix.修复一些warning
This commit is contained in:
@@ -113,6 +113,7 @@ bool AsstCatchFake(asst::Assistant* p_asst)
|
||||
|
||||
return p_asst->catch_fake();
|
||||
#else
|
||||
(void*)p_asst;
|
||||
return false;
|
||||
#endif // LOG_TRACE
|
||||
}
|
||||
@@ -261,4 +262,4 @@ bool AsstAppendDebug(asst::Assistant* p_asst)
|
||||
#else
|
||||
return false;
|
||||
#endif // LOG_TRACE
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,8 +80,8 @@ namespace asst
|
||||
#ifdef _WIN32
|
||||
const char* src_str = gbk_str.c_str();
|
||||
int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, nullptr, 0);
|
||||
wchar_t* wstr = new wchar_t[len + 1];
|
||||
memset(wstr, 0, len + 1);
|
||||
wchar_t* wstr = new wchar_t[len + 1U];
|
||||
memset(wstr, 0, len + 1U);
|
||||
MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len);
|
||||
len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr);
|
||||
char* str = new char[len + 1];
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
#include "UserConfiger.h"
|
||||
|
||||
asst::Controller::Controller()
|
||||
: m_rand_engine(time(nullptr))
|
||||
: m_rand_engine(static_cast<unsigned int>(time(nullptr)))
|
||||
{
|
||||
LogTraceFunction;
|
||||
|
||||
#ifdef _WIN32
|
||||
// 安全属性描述符
|
||||
m_pipe_sec_attr.nLength = sizeof(SECURITY_ATTRIBUTES);
|
||||
m_pipe_sec_attr.nLength = sizeof SECURITY_ATTRIBUTES;
|
||||
m_pipe_sec_attr.lpSecurityDescriptor = nullptr;
|
||||
m_pipe_sec_attr.bInheritHandle = TRUE;
|
||||
|
||||
@@ -140,12 +140,12 @@ bool asst::Controller::connect_adb(const std::string & address)
|
||||
|
||||
if (cur_ratio >= DefaultRatio // 说明是宽屏或默认16:9,按照高度计算缩放
|
||||
|| std::fabs(cur_ratio - DefaultRatio) < DoubleDiff) {
|
||||
int scale_width = cur_ratio * WindowHeightDefault;
|
||||
int scale_width = static_cast<int>(cur_ratio * WindowHeightDefault);
|
||||
m_scale_size = std::make_pair(scale_width, WindowHeightDefault);
|
||||
m_control_scale = static_cast<double>(m_emulator_info.adb.display_height) / static_cast<double>(WindowHeightDefault);
|
||||
}
|
||||
else { // 否则可能是偏正方形的屏幕,按宽度计算
|
||||
int scale_height = WindowWidthDefault / cur_ratio;
|
||||
int scale_height = static_cast<int>(WindowWidthDefault / cur_ratio);
|
||||
m_scale_size = std::make_pair(WindowWidthDefault, scale_height);
|
||||
m_control_scale = static_cast<double>(m_emulator_info.adb.display_width) / static_cast<double>(WindowWidthDefault);
|
||||
}
|
||||
@@ -265,13 +265,13 @@ bool asst::Controller::try_capture(const EmulatorInfo & info, bool without_handl
|
||||
// 转成宽字符的
|
||||
wchar_t* class_wbuff = nullptr;
|
||||
if (!handle_info.class_name.empty()) {
|
||||
size_t class_len = (handle_info.class_name.size() + 1) * 2;
|
||||
int class_len = static_cast<int>(handle_info.class_name.size() + 1U) * 2;
|
||||
class_wbuff = new wchar_t[class_len];
|
||||
::MultiByteToWideChar(CP_UTF8, 0, handle_info.class_name.c_str(), -1, class_wbuff, class_len);
|
||||
}
|
||||
wchar_t* window_wbuff = nullptr;
|
||||
if (!handle_info.window_name.empty()) {
|
||||
size_t window_len = (handle_info.window_name.size() + 1) * 2;
|
||||
int window_len = static_cast<int>(handle_info.window_name.size() + 1U) * 2;
|
||||
window_wbuff = new wchar_t[window_len];
|
||||
memset(window_wbuff, 0, window_len);
|
||||
::MultiByteToWideChar(CP_UTF8, 0, handle_info.window_name.c_str(), -1, window_wbuff, window_len);
|
||||
@@ -528,7 +528,7 @@ void asst::Controller::random_delay() const
|
||||
auto& opt = Resrc.cfg().get_options();
|
||||
if (opt.control_delay_upper != 0) {
|
||||
LogTraceFunction;
|
||||
static std::default_random_engine rand_engine(time(nullptr));
|
||||
static std::default_random_engine rand_engine(static_cast<unsigned int>(time(nullptr)));
|
||||
static std::uniform_int_distribution<unsigned> rand_uni(
|
||||
opt.control_delay_lower,
|
||||
opt.control_delay_upper);
|
||||
@@ -599,8 +599,8 @@ bool asst::Controller::screencap()
|
||||
|
||||
int asst::Controller::click(const Point & p, bool block)
|
||||
{
|
||||
int x = p.x * m_control_scale;
|
||||
int y = p.y * m_control_scale;
|
||||
int x = static_cast<int>(p.x * m_control_scale);
|
||||
int y = static_cast<int>(p.y * m_control_scale);
|
||||
//log.trace("Click, raw:", p.x, p.y, "corr:", x, y);
|
||||
|
||||
return click_without_scale(Point(x, y), block);
|
||||
@@ -632,10 +632,10 @@ int asst::Controller::click_without_scale(const Rect & rect, bool block)
|
||||
|
||||
int asst::Controller::swipe(const Point & p1, const Point & p2, int duration, bool block, int extra_delay, bool extra_swipe)
|
||||
{
|
||||
int x1 = p1.x * m_control_scale;
|
||||
int y1 = p1.y * m_control_scale;
|
||||
int x2 = p2.x * m_control_scale;
|
||||
int y2 = p2.y * m_control_scale;
|
||||
int x1 = static_cast<int>(p1.x * m_control_scale);
|
||||
int y1 = static_cast<int>(p1.y * m_control_scale);
|
||||
int x2 = static_cast<int>(p2.x * m_control_scale);
|
||||
int y2 = static_cast<int>(p2.y * m_control_scale);
|
||||
//log.trace("Swipe, raw:", p1.x, p1.y, p2.x, p2.y, "corr:", x1, y1, x2, y2);
|
||||
|
||||
return swipe_without_scale(Point(x1, y1), Point(x2, y2), duration, block, extra_delay, extra_swipe);
|
||||
@@ -675,8 +675,8 @@ int asst::Controller::swipe_without_scale(const Point & p1, const Point & p2, in
|
||||
if (p2.x != p1.x) {
|
||||
double k = (double)(p2.y - p1.y) / (p2.x - p1.x);
|
||||
double temp = extra_swipe_dist / std::sqrt(1 + k * k);
|
||||
end_x = p2.x + (p2.x > p1.x ? -1 : 1) * temp;
|
||||
end_y = p2.y + (p2.y > p1.y ? -1 : 1) * std::fabs(k) * temp;
|
||||
end_x = p2.x + static_cast<int>((p2.x > p1.x ? -1.0 : 1.0) * temp);
|
||||
end_y = p2.y + static_cast<int>((p2.y > p1.y ? -1.0 : 1.0) * std::fabs(k) * temp);
|
||||
}
|
||||
else {
|
||||
end_x = p2.x;
|
||||
|
||||
@@ -16,12 +16,12 @@ asst::InfrastAbstractTask::InfrastAbstractTask(AsstCallback callback, void* call
|
||||
: AbstractTask(callback, callback_arg)
|
||||
{
|
||||
if (m_face_hash_thres == 0) {
|
||||
m_face_hash_thres = std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
Task.get("InfrastOperFaceHash"))->templ_threshold;
|
||||
m_face_hash_thres = static_cast<int>(std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
Task.get("InfrastOperFaceHash"))->templ_threshold);
|
||||
}
|
||||
if (m_name_hash_thres == 0) {
|
||||
m_name_hash_thres = std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
Task.get("InfrastOperNameHash"))->templ_threshold;
|
||||
m_name_hash_thres = static_cast<int>(std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
Task.get("InfrastOperNameHash"))->templ_threshold);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ bool asst::InfrastFacilityImageAnalyzer::analyze()
|
||||
mm_analyzer.sort_result();
|
||||
max_score = cur_score;
|
||||
cur_facility_result = cur_res;
|
||||
cor_suffix_index = i;
|
||||
cor_suffix_index = static_cast<int>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,8 +131,8 @@ void asst::InfrastOperImageAnalyzer::mood_analyze()
|
||||
|
||||
const auto prg_task_ptr = std::dynamic_pointer_cast<MatchTaskInfo>(
|
||||
Task.get("InfrastOperMoodProgressBar"));
|
||||
int prg_lower_limit = prg_task_ptr->templ_threshold;
|
||||
int prg_diff_thres = prg_task_ptr->special_threshold;
|
||||
uint8_t prg_lower_limit = static_cast<uint8_t>(prg_task_ptr->templ_threshold);
|
||||
int prg_diff_thres = static_cast<int>(prg_task_ptr->special_threshold);
|
||||
Rect rect_move = prg_task_ptr->rect_move;
|
||||
|
||||
for (auto&& oper : m_result) {
|
||||
|
||||
@@ -93,7 +93,7 @@ bool asst::InfrastProductionTask::shift_facility_list()
|
||||
|
||||
locked_analyzer.set_image(image);
|
||||
if (locked_analyzer.analyze()) {
|
||||
m_cur_num_of_lokced_opers = locked_analyzer.get_result().size();
|
||||
m_cur_num_of_lokced_opers = static_cast<int>(locked_analyzer.get_result().size());
|
||||
}
|
||||
else {
|
||||
m_cur_num_of_lokced_opers = 0;
|
||||
@@ -186,7 +186,7 @@ size_t asst::InfrastProductionTask::opers_detect()
|
||||
const auto& cur_all_opers = oper_analyzer.get_result();
|
||||
max_num_of_opers_per_page = (std::max)(max_num_of_opers_per_page, cur_all_opers.size());
|
||||
|
||||
int cur_available_num = cur_all_opers.size();
|
||||
int cur_available_num = static_cast<int>(cur_all_opers.size());
|
||||
for (const auto& cur_oper : cur_all_opers) {
|
||||
if (cur_oper.skills.empty()) {
|
||||
--cur_available_num;
|
||||
@@ -306,7 +306,7 @@ bool asst::InfrastProductionTask::optimal_calc()
|
||||
continue;
|
||||
}
|
||||
// TODO:这里做成除了不等于,还可计算大于、小于等不同条件的
|
||||
int cur_value = Status.get(cond);
|
||||
int cur_value = static_cast<int>(Status.get(cond));
|
||||
if (cur_value != cond_value) {
|
||||
meet_condition = false;
|
||||
break;
|
||||
@@ -586,7 +586,7 @@ asst::InfrastProductionTask::efficient_regex_calc(
|
||||
// TODO 报错!
|
||||
}
|
||||
std::string status_key = cur_formula.substr(pos + 1, rp_pos - pos - 1);
|
||||
int status_value = Status.get(status_key);
|
||||
int64_t status_value = Status.get(status_key);
|
||||
cur_formula.replace(pos, rp_pos - pos + 1, std::to_string(status_value));
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ void asst::ProcessTask::exec_stage_drops()
|
||||
if (start_times > 0) {
|
||||
int64_t duration = time(nullptr) - start_times;
|
||||
int64_t delay = duration * 1000 - m_cur_task_ptr->rear_delay;
|
||||
m_rear_delay["StartButton2"] = delay;
|
||||
m_rear_delay["StartButton2"] = static_cast<int>(delay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,15 +213,17 @@ void asst::ProcessTask::exec_swipe_task(ProcessTaskAction action)
|
||||
{
|
||||
const auto&& [width, height] = Ctrler.get_scale_size();
|
||||
|
||||
const static Rect right_rect(width * 0.8,
|
||||
height * 0.4,
|
||||
width * 0.1,
|
||||
height * 0.2);
|
||||
const static Rect right_rect(
|
||||
static_cast<int>(width * 0.8),
|
||||
static_cast<int>(height * 0.4),
|
||||
static_cast<int>(width * 0.1),
|
||||
static_cast<int>(height * 0.2));
|
||||
|
||||
const static Rect left_rect(width * 0.1,
|
||||
height * 0.4,
|
||||
width * 0.1,
|
||||
height * 0.2);
|
||||
const static Rect left_rect(
|
||||
static_cast<int>(width * 0.1),
|
||||
static_cast<int>(height * 0.4),
|
||||
static_cast<int>(width * 0.1),
|
||||
static_cast<int>(height * 0.2));
|
||||
|
||||
switch (action) {
|
||||
case asst::ProcessTaskAction::SwipeToTheLeft:
|
||||
|
||||
@@ -77,7 +77,7 @@ bool RecruitTask::_run()
|
||||
// 识别到的5个Tags,全组合排列
|
||||
std::vector<std::vector<std::string>> all_combs;
|
||||
size_t len = all_tags.size();
|
||||
int count = (std::pow)(2, len);
|
||||
int count = static_cast<int>(std::pow(2, len));
|
||||
for (int i = 0; i < count; ++i) {
|
||||
std::vector<std::string> temp;
|
||||
for (int j = 0, mask = 1; j < len; ++j) {
|
||||
|
||||
@@ -38,9 +38,12 @@ void asst::TaskData::clear_cache() noexcept
|
||||
|
||||
bool asst::TaskData::parse(const json::value& json)
|
||||
{
|
||||
auto to_lower = [](char c) -> char {
|
||||
return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
|
||||
};
|
||||
for (const auto& [name, task_json] : json.as_object()) {
|
||||
std::string algorithm_str = task_json.get("algorithm", "matchtemplate");
|
||||
std::transform(algorithm_str.begin(), algorithm_str.end(), algorithm_str.begin(), ::tolower);
|
||||
std::transform(algorithm_str.begin(), algorithm_str.end(), algorithm_str.begin(), to_lower);
|
||||
AlgorithmType algorithm = AlgorithmType::Invaild;
|
||||
if (algorithm_str == "matchtemplate") {
|
||||
algorithm = AlgorithmType::MatchTemplate;
|
||||
@@ -98,7 +101,7 @@ bool asst::TaskData::parse(const json::value& json)
|
||||
task_info_ptr->algorithm = algorithm;
|
||||
task_info_ptr->name = name;
|
||||
std::string action = task_json.get("action", std::string());
|
||||
std::transform(action.begin(), action.end(), action.begin(), ::tolower);
|
||||
std::transform(action.begin(), action.end(), action.begin(), to_lower);
|
||||
if (action == "clickself") {
|
||||
task_info_ptr->action = ProcessTaskAction::ClickSelf;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ int main(int argc, char** argv)
|
||||
// }
|
||||
AsstStart(ptr);
|
||||
|
||||
ch = getchar();
|
||||
ch = static_cast<char>(getchar());
|
||||
}
|
||||
|
||||
if (ptr) {
|
||||
|
||||
Reference in New Issue
Block a user