From d424cfb935237e7f6f74b5ab6e84d6fbec076970 Mon Sep 17 00:00:00 2001 From: MistEO Date: Fri, 31 Dec 2021 23:19:49 +0800 Subject: [PATCH] =?UTF-8?q?fix.=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bwarning?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/MeoAssistant/AbstractTask.cpp | 2 +- src/MeoAssistant/AbstractTask.h | 4 +- src/MeoAssistant/Assistant.cpp | 16 ++++++- src/MeoAssistant/AsstMsg.h | 2 +- src/MeoAssistant/AsstUtils.hpp | 42 +++++++++---------- src/MeoAssistant/Controller.cpp | 21 +++++----- src/MeoAssistant/CreditShopImageAnalyzer.cpp | 1 - src/MeoAssistant/InfrastProductionTask.cpp | 3 +- src/MeoAssistant/MatchImageAnalyzer.cpp | 2 +- src/MeoAssistant/MatchImageAnalyzer.h | 2 +- src/MeoAssistant/MeoAssistant.vcxproj | 4 +- src/MeoAssistant/ProcessTask.cpp | 10 ++--- src/MeoAsstGui/Helper/AsstProxy.cs | 6 +-- src/MeoAsstGui/Helper/ViewStatusStorage.cs | 2 +- src/MeoAsstGui/ViewModels/RecruitViewModel.cs | 4 +- src/MeoAsstGui/ViewModels/RootViewModel.cs | 4 +- .../ViewModels/SettingsViewModel.cs | 6 +-- .../ViewModels/TaskQueueViewModel.cs | 4 +- .../ViewModels/VersionUpdateViewModel.cs | 8 ++-- tools/TestCaller/TestCaller.vcxproj | 6 ++- .../TransparentImageCvt.vcxproj | 3 +- 21 files changed, 81 insertions(+), 71 deletions(-) diff --git a/src/MeoAssistant/AbstractTask.cpp b/src/MeoAssistant/AbstractTask.cpp index 4ddffcd09c..2bbe48f57d 100644 --- a/src/MeoAssistant/AbstractTask.cpp +++ b/src/MeoAssistant/AbstractTask.cpp @@ -84,7 +84,7 @@ bool AbstractTask::save_image(const cv::Mat image, const std::string& dir) bool asst::AbstractTask::need_exit() const { - return m_exit_flag != NULL && *m_exit_flag == true; + return m_exit_flag != nullptr && *m_exit_flag == true; } void asst::AbstractTask::click_return_button() diff --git a/src/MeoAssistant/AbstractTask.h b/src/MeoAssistant/AbstractTask.h index 25dff967cf..aa94f09f6f 100644 --- a/src/MeoAssistant/AbstractTask.h +++ b/src/MeoAssistant/AbstractTask.h @@ -38,8 +38,8 @@ namespace asst virtual void click_return_button(); AsstCallback m_callback; - void* m_callback_arg = NULL; - bool* m_exit_flag = NULL; + void* m_callback_arg = nullptr; + bool* m_exit_flag = nullptr; std::string m_task_chain; int m_cur_retry = 0; int m_retry_times = RetryTimesDefault; diff --git a/src/MeoAssistant/Assistant.cpp b/src/MeoAssistant/Assistant.cpp index a5b39d22e4..8677772280 100644 --- a/src/MeoAssistant/Assistant.cpp +++ b/src/MeoAssistant/Assistant.cpp @@ -231,12 +231,24 @@ bool asst::Assistant::append_fight(const std::string& stage, int mecidine, int s bool asst::Assistant::append_award(bool only_append) { - return append_process_task("AwardBegin", "Award"); + append_process_task("AwardBegin", "Award"); + + if (!only_append) { + return start(false); + } + + return true; } bool asst::Assistant::append_visit(bool only_append) { - return append_process_task("VisitBegin", "Visit"); + append_process_task("VisitBegin", "Visit"); + + if (!only_append) { + return start(false); + } + + return true; } bool asst::Assistant::append_mall(bool with_shopping, bool only_append) diff --git a/src/MeoAssistant/AsstMsg.h b/src/MeoAssistant/AsstMsg.h index bb92ee2466..09af748e6a 100644 --- a/src/MeoAssistant/AsstMsg.h +++ b/src/MeoAssistant/AsstMsg.h @@ -52,7 +52,7 @@ namespace asst FacilityInfo, // 当前设施信息 }; - static std::ostream& operator<<(std::ostream& os, const AsstMsg& type) + inline std::ostream& operator<<(std::ostream& os, const AsstMsg& type) { static const std::unordered_map _type_name = { { AsstMsg::PtrIsNull, "PtrIsNull" }, diff --git a/src/MeoAssistant/AsstUtils.hpp b/src/MeoAssistant/AsstUtils.hpp index ba7f091b29..fc805d5367 100644 --- a/src/MeoAssistant/AsstUtils.hpp +++ b/src/MeoAssistant/AsstUtils.hpp @@ -19,7 +19,7 @@ namespace asst { namespace utils { - static std::string string_replace_all(const std::string& src, const std::string& old_value, const std::string& new_value) + inline std::string string_replace_all(const std::string& src, const std::string& old_value, const std::string& new_value) { std::string str = src; for (std::string::size_type pos(0); pos != std::string::npos; pos += new_value.length()) { @@ -31,7 +31,7 @@ namespace asst return str; } - static std::vector string_split(const std::string& str, const std::string& delimiter) + inline std::vector string_split(const std::string& str, const std::string& delimiter) { std::string::size_type pos1 = 0; std::string::size_type pos2 = str.find(delimiter); @@ -49,7 +49,7 @@ namespace asst return result; } - static std::string get_format_time() + inline std::string get_format_time() { char buff[128] = { 0 }; #ifdef _WIN32 @@ -66,7 +66,7 @@ namespace asst #else // ! _WIN32 struct timeval tv = { 0 }; - gettimeofday(&tv, NULL); + gettimeofday(&tv, nullptr); time_t nowtime = tv.tv_sec; struct tm* tm_info = localtime(&nowtime); strftime(buff, sizeof(buff), "%Y-%m-%d %H:%M:%S", tm_info); @@ -75,18 +75,18 @@ namespace asst return buff; } - static std::string gbk_2_utf8(const std::string& gbk_str) + inline std::string gbk_2_utf8(const std::string& gbk_str) { #ifdef _WIN32 const char* src_str = gbk_str.c_str(); - int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, NULL, 0); + int len = MultiByteToWideChar(CP_ACP, 0, src_str, -1, nullptr, 0); wchar_t* wstr = new wchar_t[len + 1]; memset(wstr, 0, len + 1); MultiByteToWideChar(CP_ACP, 0, src_str, -1, wstr, len); - len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL); + len = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, nullptr, 0, nullptr, nullptr); char* str = new char[len + 1]; memset(str, 0, len + 1); - WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, NULL, NULL); + WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, len, nullptr, nullptr); std::string strTemp = str; if (wstr) delete[] wstr; @@ -98,18 +98,18 @@ namespace asst #endif } - static std::string utf8_to_gbk(const std::string& utf8_str) + inline std::string utf8_to_gbk(const std::string& utf8_str) { #ifdef _WIN32 const char* src_str = utf8_str.c_str(); - int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, NULL, 0); + int len = MultiByteToWideChar(CP_UTF8, 0, src_str, -1, nullptr, 0); wchar_t* wszGBK = new wchar_t[len + 1]; memset(wszGBK, 0, len * 2 + 2); MultiByteToWideChar(CP_UTF8, 0, src_str, -1, wszGBK, len); - len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, NULL, 0, NULL, NULL); + len = WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, nullptr, 0, nullptr, nullptr); char* szGBK = new char[len + 1]; memset(szGBK, 0, len + 1); - WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, NULL, NULL); + WideCharToMultiByte(CP_ACP, 0, wszGBK, -1, szGBK, len, nullptr, nullptr); std::string strTemp(szGBK); if (wszGBK) delete[] wszGBK; @@ -127,7 +127,7 @@ namespace asst return RetTy{ rect.x, rect.y, rect.width, rect.height }; } - static std::string load_file_without_bom(const std::string& filename) + inline std::string load_file_without_bom(const std::string& filename) { std::ifstream ifs(filename, std::ios::in); if (!ifs.is_open()) { @@ -150,7 +150,7 @@ namespace asst return str; } - static int hamming(std::string hash1, std::string hash2) + inline int hamming(std::string hash1, std::string hash2) { constexpr static int HammingFlags = 64; @@ -158,7 +158,7 @@ namespace asst hash2.insert(hash2.begin(), HammingFlags - hash2.size(), '0'); int dist = 0; for (int i = 0; i < HammingFlags; i = i + 16) { - unsigned long long x = strtoull(hash1.substr(i, 16).c_str(), NULL, 16) ^ strtoull(hash2.substr(i, 16).c_str(), NULL, 16); + unsigned long long x = strtoull(hash1.substr(i, 16).c_str(), nullptr, 16) ^ strtoull(hash2.substr(i, 16).c_str(), nullptr, 16); while (x) { dist++; x = x & (x - 1); @@ -167,7 +167,7 @@ namespace asst return dist; } - static std::string callcmd(const std::string& cmdline) + inline std::string callcmd(const std::string& cmdline) { constexpr int BuffSize = 4096; std::string pipe_str; @@ -189,14 +189,14 @@ namespace asst PROCESS_INFORMATION pi = { 0 }; - BOOL p_ret = CreateProcessA(NULL, const_cast(cmdline.c_str()), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &si, &pi); + BOOL p_ret = CreateProcessA(nullptr, const_cast(cmdline.c_str()), nullptr, nullptr, TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &si, &pi); if (p_ret) { DWORD read_num = 0; DWORD std_num = 0; do { - while (::PeekNamedPipe(pipe_read, NULL, 0, NULL, &read_num, NULL) && read_num > 0) { + while (::PeekNamedPipe(pipe_read, nullptr, 0, nullptr, &read_num, nullptr) && read_num > 0) { char* pipe_buffer = new char[read_num]; - BOOL read_ret = ::ReadFile(pipe_read, pipe_buffer, read_num, &std_num, NULL); + BOOL read_ret = ::ReadFile(pipe_read, pipe_buffer, read_num, &std_num, nullptr); if (read_ret) { pipe_str.append(pipe_buffer, pipe_buffer + std_num); } @@ -238,7 +238,7 @@ namespace asst close(pipe_out[PIPE_READ]); close(pipe_out[PIPE_WRITE]); - exit_ret = execlp("sh", "sh", "-c", cmdline.c_str(), NULL); + exit_ret = execlp("sh", "sh", "-c", cmdline.c_str(), nullptr); exit(exit_ret); } else if (child > 0) { @@ -257,7 +257,7 @@ namespace asst pipe_str.append(pipe_buffer.get(), pipe_buffer.get() + read_num); read_num = read(pipe_out[PIPE_READ], pipe_buffer.get(), BuffSize); }; - } while (::waitpid(child, NULL, WNOHANG) == 0); + } while (::waitpid(child, nullptr, WNOHANG) == 0); close(pipe_in[PIPE_WRITE]); close(pipe_out[PIPE_READ]); diff --git a/src/MeoAssistant/Controller.cpp b/src/MeoAssistant/Controller.cpp index 22f31de485..62ae498c96 100644 --- a/src/MeoAssistant/Controller.cpp +++ b/src/MeoAssistant/Controller.cpp @@ -23,7 +23,7 @@ #include "UserConfiger.h" asst::Controller::Controller() - : m_rand_engine(std::chrono::system_clock::now().time_since_epoch().count()) + : m_rand_engine(time(nullptr)) { LogTraceFunction; @@ -96,7 +96,7 @@ asst::Controller::~Controller() close(m_pipe_out[PIPE_READ]); close(m_pipe_out[PIPE_WRITE]); #endif - } +} bool asst::Controller::connect_adb(const std::string & address) { @@ -400,17 +400,17 @@ std::pair> asst::Controller::call_command(const #ifdef _WIN32 PROCESS_INFORMATION process_info = { 0 }; // 进程信息结构体 - ::CreateProcessA(NULL, const_cast(cmd.c_str()), NULL, NULL, TRUE, CREATE_NO_WINDOW, NULL, NULL, &m_child_startup_info, &process_info); + ::CreateProcessA(nullptr, const_cast(cmd.c_str()), nullptr, nullptr, TRUE, CREATE_NO_WINDOW, nullptr, nullptr, &m_child_startup_info, &process_info); do { //DWORD write_num = 0; - //WriteFile(parent_write, cmd.c_str(), cmd.size(), &write_num, NULL); + //WriteFile(parent_write, cmd.c_str(), cmd.size(), &write_num, nullptr); DWORD read_num = 0; DWORD std_num = 0; - while (::PeekNamedPipe(m_pipe_read, NULL, 0, NULL, &read_num, NULL) && read_num > 0) { + while (::PeekNamedPipe(m_pipe_read, nullptr, 0, nullptr, &read_num, nullptr) && read_num > 0) { uchar* pipe_buffer = new uchar[read_num]; - BOOL read_ret = ::ReadFile(m_pipe_read, pipe_buffer, read_num, &std_num, NULL); + BOOL read_ret = ::ReadFile(m_pipe_read, pipe_buffer, read_num, &std_num, nullptr); if (read_ret) { pipe_data.insert(pipe_data.end(), pipe_buffer, pipe_buffer + std_num); } @@ -421,7 +421,7 @@ std::pair> asst::Controller::call_command(const } } while (::WaitForSingleObject(process_info.hProcess, 0) == WAIT_TIMEOUT); - DWORD exit_ret = -1; + DWORD exit_ret = 255; ::GetExitCodeProcess(process_info.hProcess, &exit_ret); ::CloseHandle(process_info.hProcess); @@ -445,7 +445,7 @@ std::pair> asst::Controller::call_command(const // close(m_pipe_out[PIPE_READ]); // close(m_pipe_out[PIPE_WRITE]); - exit_ret = execlp("sh", "sh", "-c", cmd.c_str(), NULL); + exit_ret = execlp("sh", "sh", "-c", cmd.c_str(), nullptr); exit(exit_ret); } else if (m_child > 0) { @@ -461,7 +461,7 @@ std::pair> asst::Controller::call_command(const 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(), BuffSize); }; - } while (::waitpid(m_child, NULL, WNOHANG) == 0); + } while (::waitpid(m_child, nullptr, WNOHANG) == 0); } else { // failed to create child process @@ -537,8 +537,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( - std::chrono::steady_clock::now().time_since_epoch().count()); + static std::default_random_engine rand_engine(time(nullptr)); static std::uniform_int_distribution rand_uni( opt.control_delay_lower, opt.control_delay_upper); diff --git a/src/MeoAssistant/CreditShopImageAnalyzer.cpp b/src/MeoAssistant/CreditShopImageAnalyzer.cpp index 3c14458359..02ee00c654 100644 --- a/src/MeoAssistant/CreditShopImageAnalyzer.cpp +++ b/src/MeoAssistant/CreditShopImageAnalyzer.cpp @@ -64,7 +64,6 @@ bool asst::CreditShopImageAnalyzer::whether_to_buy_analyze() //因为是不买的,有识别结果说明这个商品不买,直接跳过 continue; } - const auto& ocr_res = ocr_analyzer.get_result(); #ifdef LOG_TRACE cv::rectangle(m_image_draw, utils::make_rect(commodity), cv::Scalar(0, 0, 255), 2); diff --git a/src/MeoAssistant/InfrastProductionTask.cpp b/src/MeoAssistant/InfrastProductionTask.cpp index 33f727cb20..2259d333aa 100644 --- a/src/MeoAssistant/InfrastProductionTask.cpp +++ b/src/MeoAssistant/InfrastProductionTask.cpp @@ -144,7 +144,6 @@ bool asst::InfrastProductionTask::opers_detect_with_swipe() LogTraceFunction; m_all_available_opers.clear(); - int first_number = 0; while (true) { if (need_exit()) { return false; @@ -294,7 +293,7 @@ bool asst::InfrastProductionTask::optimal_calc() // 遍历所有组合,找到效率最高的 auto& all_group = Resrc.infrast().get_skills_group(m_facility); for (const infrast::SkillsGroup& group : all_group) { - LogTraceScope(group.desc); + Log.trace(group.desc); auto cur_available_opers = all_avaliable_combs; bool group_unavailable = false; std::vector cur_combs; diff --git a/src/MeoAssistant/MatchImageAnalyzer.cpp b/src/MeoAssistant/MatchImageAnalyzer.cpp index 44c2f505d1..caeb992e8a 100644 --- a/src/MeoAssistant/MatchImageAnalyzer.cpp +++ b/src/MeoAssistant/MatchImageAnalyzer.cpp @@ -4,7 +4,7 @@ #include "Logger.hpp" #include "Resource.h" -asst::MatchImageAnalyzer::MatchImageAnalyzer(const cv::Mat image, const Rect& roi, std::string templ_name, double templ_thres, double hist_thres) +asst::MatchImageAnalyzer::MatchImageAnalyzer(const cv::Mat image, const Rect& roi, std::string templ_name, double templ_thres) : AbstractImageAnalyzer(image, roi), m_templ_name(std::move(templ_name)), m_templ_thres(templ_thres) diff --git a/src/MeoAssistant/MatchImageAnalyzer.h b/src/MeoAssistant/MatchImageAnalyzer.h index c6589997c0..834be2c0d4 100644 --- a/src/MeoAssistant/MatchImageAnalyzer.h +++ b/src/MeoAssistant/MatchImageAnalyzer.h @@ -7,7 +7,7 @@ namespace asst { public: using AbstractImageAnalyzer::AbstractImageAnalyzer; - MatchImageAnalyzer(const cv::Mat image, const Rect& roi, std::string templ_name, double templ_thres = 0.0, double hist_thres = 0.0); + MatchImageAnalyzer(const cv::Mat image, const Rect& roi, std::string templ_name, double templ_thres = 0.0); virtual ~MatchImageAnalyzer() = default; virtual bool analyze() override; diff --git a/src/MeoAssistant/MeoAssistant.vcxproj b/src/MeoAssistant/MeoAssistant.vcxproj index bf071be629..27959467df 100644 --- a/src/MeoAssistant/MeoAssistant.vcxproj +++ b/src/MeoAssistant/MeoAssistant.vcxproj @@ -156,7 +156,7 @@ $(TargetDir);$(SolutionDir)\3rdparty\lib;$(LibraryPath) - true + false $(SolutionDir)include;$(SolutionDir)3rdparty\include;$(IncludePath) $(TargetDir);$(SolutionDir)\3rdparty\lib;$(LibraryPath) @@ -215,7 +215,7 @@ xcopy /e /y /i /c $(SolutionDir)3rdparty\resource $(TargetDir)resource stdc11 MultiThreaded Disabled - false + true EnableFastChecks /utf-8 /MP %(AdditionalOptions) diff --git a/src/MeoAssistant/ProcessTask.cpp b/src/MeoAssistant/ProcessTask.cpp index 420c529958..94caec9db7 100644 --- a/src/MeoAssistant/ProcessTask.cpp +++ b/src/MeoAssistant/ProcessTask.cpp @@ -18,14 +18,12 @@ using namespace asst; asst::ProcessTask::ProcessTask(const AbstractTask& abs, std::vector tasks_name) : AbstractTask(abs), m_cur_tasks_name(std::move(tasks_name)) -{ -} +{} asst::ProcessTask::ProcessTask(AbstractTask&& abs, std::vector tasks_name) noexcept : AbstractTask(std::move(abs)), m_cur_tasks_name(std::move(tasks_name)) -{ -} +{} bool ProcessTask::_run() { @@ -142,7 +140,7 @@ bool ProcessTask::_run() ++exec_times; - Status.set("Last" + cur_name, time(NULL)); + Status.set("Last" + cur_name, time(nullptr)); // 减少其他任务的执行次数 // 例如,进入吃理智药的界面了,相当于上一次点蓝色开始行动没生效 @@ -190,7 +188,7 @@ void asst::ProcessTask::exec_stage_drops() if (m_rear_delay.find("StartButton2") == m_rear_delay.cend()) { int64_t start_times = Status.get("LastStartButton2"); if (start_times > 0) { - int64_t duration = time(NULL) - start_times; + int64_t duration = time(nullptr) - start_times; int64_t delay = duration * 1000 - m_cur_task_ptr->rear_delay; m_rear_delay["StartButton2"] = delay; } diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index 71407d90c1..be2d0b6a09 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -59,7 +59,7 @@ namespace MeoAsstGui //[DllImport("MeoAssistant.dll")] private static extern bool AsstSetParam(IntPtr p_asst, string type, string param, string value); - private CallbackDelegate _callback; + private readonly CallbackDelegate _callback; public AsstProxy(IContainer container, IWindowManager windowManager) { @@ -92,8 +92,8 @@ namespace MeoAsstGui }); } - private IWindowManager _windowManager; - private IContainer _container; + private readonly IWindowManager _windowManager; + private readonly IContainer _container; private IntPtr _ptr; private void proc_msg(AsstMsg msg, JObject detail) diff --git a/src/MeoAsstGui/Helper/ViewStatusStorage.cs b/src/MeoAsstGui/Helper/ViewStatusStorage.cs index 35c4a66275..c3ff5d824b 100644 --- a/src/MeoAsstGui/Helper/ViewStatusStorage.cs +++ b/src/MeoAsstGui/Helper/ViewStatusStorage.cs @@ -19,7 +19,7 @@ namespace MeoAsstGui // 界面设置存储(读写json文件) public class ViewStatusStorage { - private static string _configFilename = System.Environment.CurrentDirectory + "\\gui.json"; + private static readonly string _configFilename = System.Environment.CurrentDirectory + "\\gui.json"; private static JObject _viewStatus = new JObject(); public static string Get(string key, string defalut_value) diff --git a/src/MeoAsstGui/ViewModels/RecruitViewModel.cs b/src/MeoAsstGui/ViewModels/RecruitViewModel.cs index 5a10247f40..b47bc05778 100644 --- a/src/MeoAsstGui/ViewModels/RecruitViewModel.cs +++ b/src/MeoAsstGui/ViewModels/RecruitViewModel.cs @@ -18,8 +18,8 @@ namespace MeoAsstGui { public class RecruitViewModel : Screen { - private IWindowManager _windowManager; - private IContainer _container; + private readonly IWindowManager _windowManager; + private readonly IContainer _container; public RecruitViewModel(IContainer container, IWindowManager windowManager) { diff --git a/src/MeoAsstGui/ViewModels/RootViewModel.cs b/src/MeoAsstGui/ViewModels/RootViewModel.cs index c573336686..b9b39db2f7 100644 --- a/src/MeoAsstGui/ViewModels/RootViewModel.cs +++ b/src/MeoAsstGui/ViewModels/RootViewModel.cs @@ -17,8 +17,8 @@ namespace MeoAsstGui { public class RootViewModel : Conductor.Collection.OneActive { - private IContainer _container; - private IWindowManager _windowManager; + private readonly IContainer _container; + private readonly IWindowManager _windowManager; public RootViewModel(IContainer container, IWindowManager windowManager) { diff --git a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs index fc327d12b8..fb21fc972d 100644 --- a/src/MeoAsstGui/ViewModels/SettingsViewModel.cs +++ b/src/MeoAsstGui/ViewModels/SettingsViewModel.cs @@ -21,12 +21,12 @@ namespace MeoAsstGui { public class SettingsViewModel : Screen { - private IWindowManager _windowManager; - private IContainer _container; + private readonly IWindowManager _windowManager; + private readonly IContainer _container; [DllImport("MeoAssistant.dll")] private static extern IntPtr AsstGetVersion(); - private string _versionInfo = "版本号:" + Marshal.PtrToStringAnsi(AsstGetVersion()); + private readonly string _versionInfo = "版本号:" + Marshal.PtrToStringAnsi(AsstGetVersion()); public string VersionInfo { diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index d5f52b4a15..3315833b91 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -20,8 +20,8 @@ namespace MeoAsstGui { public class TaskQueueViewModel : Screen { - private IWindowManager _windowManager; - private IContainer _container; + private readonly IWindowManager _windowManager; + private readonly IContainer _container; public ObservableCollection TaskItemViewModels { get; set; } public ObservableCollection LogItemViewModels { get; set; } diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 3cb7ac9012..ec2cabb3f8 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -27,8 +27,8 @@ namespace MeoAsstGui { public class VersionUpdateViewModel : Screen { - private IWindowManager _windowManager; - private IContainer _container; + private readonly IWindowManager _windowManager; + private readonly IContainer _container; public VersionUpdateViewModel(IContainer container, IWindowManager windowManager) { @@ -38,7 +38,7 @@ namespace MeoAsstGui [DllImport("MeoAssistant.dll")] private static extern IntPtr AsstGetVersion(); - private string _curVersion = Marshal.PtrToStringAnsi(AsstGetVersion()); + private readonly string _curVersion = Marshal.PtrToStringAnsi(AsstGetVersion()); private string _latestVersion; private string _updateTag = ViewStatusStorage.Get("VersionUpdate.name", string.Empty); @@ -348,7 +348,7 @@ namespace MeoAsstGui processTemp.WaitForExit(); exit_code = processTemp.ExitCode; } - catch (Exception ex) + catch (Exception) { return false; } diff --git a/tools/TestCaller/TestCaller.vcxproj b/tools/TestCaller/TestCaller.vcxproj index 4268e9ebf1..31cd4668a5 100644 --- a/tools/TestCaller/TestCaller.vcxproj +++ b/tools/TestCaller/TestCaller.vcxproj @@ -54,13 +54,13 @@ $(TargetDir);$(LibraryPath) - true + false $(SolutionDir)\include $(TargetDir);$(LibraryPath) - Level3 + Level4 true true true @@ -69,6 +69,7 @@ stdcpp17 stdc11 MultiThreaded + /utf-8 /MP %(AdditionalOptions) Console @@ -91,6 +92,7 @@ stdc11 MultiThreaded Disabled + /utf-8 /MP %(AdditionalOptions) Console diff --git a/tools/TransparentImageCvt/TransparentImageCvt.vcxproj b/tools/TransparentImageCvt/TransparentImageCvt.vcxproj index d7ef4b1991..f3b6a494a6 100644 --- a/tools/TransparentImageCvt/TransparentImageCvt.vcxproj +++ b/tools/TransparentImageCvt/TransparentImageCvt.vcxproj @@ -70,13 +70,14 @@ - Level3 + Level4 true true true NDEBUG;_CONSOLE;%(PreprocessorDefinitions) true stdcpp17 + /utf-8 /MP %(AdditionalOptions) Console