feat: 清理 map 中的 png 类型截图

This commit is contained in:
uye
2025-06-05 12:59:39 +08:00
parent 4c66e31eaa
commit 1a085f3319

View File

@@ -711,6 +711,7 @@ bool asst::BattleHelper::check_and_use_skill(const Point& loc, bool& has_error,
return true;
}
void asst::BattleHelper::save_map(const cv::Mat& image)
{
LogTraceFunction;
@@ -718,6 +719,21 @@ void asst::BattleHelper::save_map(const cv::Mat& image)
using namespace asst::utils::path_literals;
const auto& MapRelativeDir = "debug"_p / "map"_p;
// 清理旧的 PNG 文件
static bool clean_png = true;
if (clean_png) {
for (const auto& entry : std::filesystem::directory_iterator(MapRelativeDir)) {
if (entry.path().extension() == ".png") {
std::error_code ec;
std::filesystem::remove(entry.path(), ec);
if (ec) {
LogWarn << "Failed to remove png: " << entry.path() << ", " << ec.message();
}
}
}
clean_png = false;
}
auto draw = image.clone();
for (const auto& [loc, info] : m_normal_tile_info) {