mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-15 17:30:27 +08:00
feat: 不读取旧版本的头像缓存数据
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "BattleDataConfig.h"
|
||||
#include "Utils/ImageIo.hpp"
|
||||
#include "Utils/Logger.hpp"
|
||||
#include "../TaskData.h"
|
||||
|
||||
bool asst::AvatarCacheManager::load(const std::filesystem::path& path)
|
||||
{
|
||||
@@ -15,6 +16,8 @@ bool asst::AvatarCacheManager::load(const std::filesystem::path& path)
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& [_, _, w, h] = Task.get("BattleOperAvatar")->rect_move;
|
||||
|
||||
for (const auto& entry : std::filesystem::directory_iterator(path)) {
|
||||
if (!entry.is_regular_file()) {
|
||||
continue;
|
||||
@@ -27,12 +30,19 @@ bool asst::AvatarCacheManager::load(const std::filesystem::path& path)
|
||||
Log.warn("unknown oper", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
Log.trace(filepath);
|
||||
cv::Mat avatar = asst::imread(filepath);
|
||||
|
||||
if (avatar.empty()) {
|
||||
Log.warn("failed to read", filepath);
|
||||
continue;
|
||||
}
|
||||
if (avatar.cols > w || avatar.rows > h) {
|
||||
Log.warn("avatar size too large", filepath);
|
||||
continue;
|
||||
}
|
||||
|
||||
m_avatars[role].emplace(name, std::move(avatar));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user