feat: 不读取旧版本的头像缓存数据

This commit is contained in:
MistEO
2023-01-16 17:56:38 +08:00
parent 652b95b942
commit 99c345e80d

View File

@@ -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));
}