From bdd5f8d16a963939f25433f8cd91c6505ba97433 Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Fri, 16 Dec 2022 21:19:52 +0000 Subject: [PATCH] Supress hash collision warnings for known cases It'll always happen for Fallout 4's official BA2s so there's no point showing the warnings, they'd just be noise in the log. --- src/api/bsa.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/api/bsa.cpp b/src/api/bsa.cpp index f23deb31..0edfcdf4 100644 --- a/src/api/bsa.cpp +++ b/src/api/bsa.cpp @@ -230,6 +230,18 @@ std::map> GetAssetsInBA2(std::istream& in, } } +// Fallout4.esm and DLCUltraHighResolution.esm from Fallout 4 have the +// same file path appearing in multiple BA2 files, so ignore hash +// collision warnings for those files as otherwise they cause a lot of +// noise in the logs. +bool ShouldWarnAboutHashCollisions(const std::filesystem::path& archivePath) { + const auto filename = archivePath.filename().u8string(); + + return !boost::iends_with(filename, ".ba2") || + (!boost::istarts_with(filename, "Fallout4 - ") && + !boost::istarts_with(filename, "DLCUltraHighResolution - ")); +} + bool DoFileNameHashSetsIntersect(const std::set& left, const std::set& right) { auto leftIt = left.begin(); @@ -309,6 +321,9 @@ std::map> GetAssetsInBethesdaArchives( archivePath.u8string()); } + const auto warnAboutHashCollisions = + ShouldWarnAboutHashCollisions(archivePath); + const auto assets = GetAssetsInBethesdaArchive(archivePath); for (const auto& asset : assets) { const auto folderResult = archiveAssets.insert(asset); @@ -323,7 +338,7 @@ std::map> GetAssetsInBethesdaArchives( for (const auto& fileNameHash : asset.second) { const auto fileResult = folderResult.first->second.insert(fileNameHash); - if (!fileResult.second && logger) { + if (!fileResult.second && warnAboutHashCollisions && logger) { logger->warn( "The folder and file with hashes {:x} and {:x} in \"{}\" are " "present in another BSA.",