From e2554f3bcfa2947e64a980ae2032e58bfa4211c3 Mon Sep 17 00:00:00 2001 From: MistEO Date: Sat, 29 Apr 2023 01:19:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E9=94=99=E8=AF=AF=EF=BC=8C=E6=94=B9=E4=B8=80?= =?UTF-8?q?=E7=82=B9=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Config/Miscellaneous/AvatarCacheManager.cpp | 2 +- src/MaaCore/Config/Miscellaneous/TilePack.cpp | 3 ++- src/MaaCore/Config/ResourceLoader.cpp | 15 ++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/MaaCore/Config/Miscellaneous/AvatarCacheManager.cpp b/src/MaaCore/Config/Miscellaneous/AvatarCacheManager.cpp index b76ffcd3b0..bb3524b08a 100644 --- a/src/MaaCore/Config/Miscellaneous/AvatarCacheManager.cpp +++ b/src/MaaCore/Config/Miscellaneous/AvatarCacheManager.cpp @@ -84,7 +84,7 @@ void asst::AvatarCacheManager::_load(LoadItem waiting_to_load) for (const auto& [role, name_and_paths] : waiting_to_load) { for (const auto& [name, filepath] : name_and_paths) { - Log.info("load", name, filepath); + Log.trace(__FUNCTION__, name, filepath); auto avatar = asst::imread(filepath); diff --git a/src/MaaCore/Config/Miscellaneous/TilePack.cpp b/src/MaaCore/Config/Miscellaneous/TilePack.cpp index 7774857385..9461d803e3 100644 --- a/src/MaaCore/Config/Miscellaneous/TilePack.cpp +++ b/src/MaaCore/Config/Miscellaneous/TilePack.cpp @@ -25,6 +25,7 @@ bool asst::TilePack::parse(const json::value& json) { LogTraceFunction; + auto dir = m_path.parent_path(); for (const auto& [_, summary] : json.as_object()) { LevelKey level_key { .stageId = summary.at("stageId").as_string(), @@ -32,7 +33,7 @@ bool asst::TilePack::parse(const json::value& json) .levelId = summary.at("levelId").as_string(), .name = summary.get("name", "UnknownLevelName"), }; - auto filepath = m_path / utils::path(summary.at("filename").as_string()); + auto filepath = dir / utils::path(summary.at("filename").as_string()); if (!std::filesystem::exists(filepath)) { Log.error("file not exists", filepath); return false; diff --git a/src/MaaCore/Config/ResourceLoader.cpp b/src/MaaCore/Config/ResourceLoader.cpp index 29890abcf5..817a6ff42d 100644 --- a/src/MaaCore/Config/ResourceLoader.cpp +++ b/src/MaaCore/Config/ResourceLoader.cpp @@ -41,7 +41,7 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path) } #ifdef ASST_DEBUG - // DEBUG 模式下这里同步加载,并检查返回值的,方便排查问题 +// DEBUG 模式下这里同步加载,并检查返回值的,方便排查问题 #define AsyncLoadConfig(Config, Filename) LoadResourceAndCheckRet(Config, Filename) #else #define AsyncLoadConfig(Config, Filename) \ @@ -66,11 +66,10 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path) } \ } -#define LoadCacheWithoutRet(Config, Dir) \ - { \ - LogTraceScope(std::string("LoadCacheWithoutRet ") + #Config); \ - auto full_path = UserDir.get() / "cache"_p / Dir; \ - SingletonHolder::get_instance().load(full_path); \ +#define LoadCacheWithoutRet(Config, Dir) \ + { \ + auto full_path = UserDir.get() / "cache"_p / Dir; \ + SingletonHolder::get_instance().load(full_path); \ } LogTraceFunction; @@ -84,7 +83,7 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path) // 不太重要又加载的慢的资源,但不怎么占内存的,实时异步加载 // DEBUG 模式下这里还是检查返回值的,方便排查问题 AsyncLoadConfig(StageDropsConfig, "stages.json"_p); - AsyncLoadConfig(TilePack, "Arknights-Tile-Pos"_p); + AsyncLoadConfig(TilePack, "Arknights-Tile-Pos"_p / "overview.json"_p); AsyncLoadConfig(RoguelikeCopilotConfig, "roguelike"_p / "copilot.json"_p); AsyncLoadConfig(RoguelikeRecruitConfig, "roguelike"_p / "recruitment.json"_p); AsyncLoadConfig(RoguelikeShoppingConfig, "roguelike"_p / "shopping.json"_p); @@ -137,6 +136,8 @@ bool asst::ResourceLoader::load(const std::filesystem::path& path) #undef LoadCacheWithoutRet m_loaded = ranges::all_of(futures, [](auto& f) { return f.get(); }); + + Log.info(__FUNCTION__, "ret", m_loaded); return m_loaded; }