From 6b0a60d2ee24f3a7dde6eb97f22623696807651e Mon Sep 17 00:00:00 2001 From: JosJuice Date: Tue, 1 Aug 2017 19:21:38 +0200 Subject: [PATCH] DirectoryBlob: Don't add DiscContents with size 0 Having DiscContents with size 0 would mean that some DiscContents might not get added to the std::set because of them comparing identically to another DiscContent. This replaces an older piece of code in WriteDirectory that ensures that no two files have the same starting offset. (We now care about the ending offset, not the starting offset. The new solution both ensures that no two files have the same ending offset and that no two files have the same starting offset.) --- Source/Core/DiscIO/DirectoryBlob.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/DiscIO/DirectoryBlob.cpp b/Source/Core/DiscIO/DirectoryBlob.cpp index bca7c66a9b..dfdc87ffb0 100644 --- a/Source/Core/DiscIO/DirectoryBlob.cpp +++ b/Source/Core/DiscIO/DirectoryBlob.cpp @@ -122,12 +122,14 @@ bool DiscContent::Read(u64* offset, u64* length, u8** buffer) const void DiscContentContainer::Add(u64 offset, u64 size, const std::string& path) { - m_contents.emplace(offset, size, path); + if (size != 0) + m_contents.emplace(offset, size, path); } void DiscContentContainer::Add(u64 offset, u64 size, const u8* data) { - m_contents.emplace(offset, size, data); + if (size != 0) + m_contents.emplace(offset, size, data); } u64 DiscContentContainer::CheckSizeAndAdd(u64 offset, const std::string& path) @@ -761,7 +763,7 @@ void DirectoryBlobPartition::WriteDirectory(const File::FSTEntry& parent_entry, m_contents.Add(*data_offset, entry.size, entry.physicalName); // 32 KiB aligned - many games are fine with less alignment, but not all - *data_offset = Common::AlignUp(*data_offset + std::max(entry.size, 1ull), 0x8000ull); + *data_offset = Common::AlignUp(*data_offset + entry.size, 0x8000ull); } } }