summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/VolumeVerifier.cpp
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2022-08-04 22:20:08 +0200
committerGitHub <noreply@github.com>2022-08-04 22:20:08 +0200
commit5508c52a952557728f6a594686e4b637fa2b2766 (patch)
tree0ab11c263c4ffda0a6ce17f5fd38faf5428c10b5 /Source/Core/DiscIO/VolumeVerifier.cpp
parentceae42b754c479dd60461323afa5a8bc90a4dfc2 (diff)
parent6fc3bbbdd9caa53157ea850f19fa0f8d5da7c3f7 (diff)
Merge pull request #10932 from JosJuice/nfs
DiscIO: Add support for the NFS format
Diffstat (limited to 'Source/Core/DiscIO/VolumeVerifier.cpp')
-rw-r--r--Source/Core/DiscIO/VolumeVerifier.cpp80
1 files changed, 54 insertions, 26 deletions
diff --git a/Source/Core/DiscIO/VolumeVerifier.cpp b/Source/Core/DiscIO/VolumeVerifier.cpp
index c4c5539fe2..50cfb2a17f 100644
--- a/Source/Core/DiscIO/VolumeVerifier.cpp
+++ b/Source/Core/DiscIO/VolumeVerifier.cpp
@@ -62,7 +62,7 @@ void RedumpVerifier::Start(const Volume& volume)
m_revision = volume.GetRevision().value_or(0);
m_disc_number = volume.GetDiscNumber().value_or(0);
- m_size = volume.GetSize();
+ m_size = volume.GetDataSize();
const DiscIO::Platform platform = volume.GetVolumeType();
@@ -364,7 +364,7 @@ VolumeVerifier::VolumeVerifier(const Volume& volume, bool redump_verification,
m_hashes_to_calculate(hashes_to_calculate),
m_calculating_any_hash(hashes_to_calculate.crc32 || hashes_to_calculate.md5 ||
hashes_to_calculate.sha1),
- m_max_progress(volume.GetSize())
+ m_max_progress(volume.GetDataSize()), m_data_size_type(volume.GetDataSizeType())
{
if (!m_calculating_any_hash)
m_redump_verification = false;
@@ -403,9 +403,8 @@ void VolumeVerifier::Start()
m_is_tgc = m_volume.GetBlobType() == BlobType::TGC;
m_is_datel = m_volume.IsDatelDisc();
- m_is_not_retail =
- (m_volume.GetVolumeType() == Platform::WiiDisc && !m_volume.IsEncryptedAndHashed()) ||
- IsDebugSigned();
+ m_is_not_retail = (m_volume.GetVolumeType() == Platform::WiiDisc && !m_volume.HasWiiHashes()) ||
+ IsDebugSigned();
const std::vector<Partition> partitions = CheckPartitions();
@@ -492,7 +491,7 @@ std::vector<Partition> VolumeVerifier::CheckPartitions()
Common::GetStringT("The update partition is not at its normal position."));
}
- const u64 normal_data_offset = m_volume.IsEncryptedAndHashed() ? 0xF800000 : 0x838000;
+ const u64 normal_data_offset = m_volume.HasWiiHashes() ? 0xF800000 : 0x838000;
if (m_volume.GetPartitionType(partition) == PARTITION_DATA &&
partition.offset != normal_data_offset && !has_channel_partition && !has_install_partition)
{
@@ -593,14 +592,14 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
}
}
- if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
+ if (m_volume.HasWiiHashes() && !m_volume.CheckH3TableIntegrity(partition))
{
AddProblem(Severity::Low,
Common::FmtFormatT("The H3 hash table for the {0} partition is not correct.", name));
}
// Prepare for hash verification in the Process step
- if (m_volume.SupportsIntegrityCheck())
+ if (m_volume.HasWiiHashes())
{
const u64 data_size =
m_volume.ReadSwappedAndShifted(partition.offset + 0x2bc, PARTITION_NONE).value_or(0);
@@ -759,11 +758,10 @@ bool VolumeVerifier::ShouldBeDualLayer() const
void VolumeVerifier::CheckVolumeSize()
{
- u64 volume_size = m_volume.GetSize();
+ u64 volume_size = m_volume.GetDataSize();
const bool is_disc = IsDisc(m_volume.GetVolumeType());
const bool should_be_dual_layer = is_disc && ShouldBeDualLayer();
- const bool is_size_accurate = m_volume.IsSizeAccurate();
- bool volume_size_roughly_known = is_size_accurate;
+ bool volume_size_roughly_known = m_data_size_type != DiscIO::DataSizeType::UpperBound;
if (should_be_dual_layer && m_biggest_referenced_offset <= SL_DVD_R_SIZE)
{
@@ -774,13 +772,13 @@ void VolumeVerifier::CheckVolumeSize()
"This problem generally only exists in illegal copies of games."));
}
- if (!is_size_accurate)
+ if (m_data_size_type != DiscIO::DataSizeType::Accurate)
{
AddProblem(Severity::Low,
Common::GetStringT("The format that the disc image is saved in does not "
"store the size of the disc image."));
- if (m_volume.SupportsIntegrityCheck())
+ if (!volume_size_roughly_known && m_volume.HasWiiHashes())
{
volume_size = m_biggest_verified_offset;
volume_size_roughly_known = true;
@@ -804,7 +802,10 @@ void VolumeVerifier::CheckVolumeSize()
return;
}
- if (is_disc && is_size_accurate && !m_is_tgc)
+ // The reason why this condition is checking for m_data_size_type != UpperBound instead of
+ // m_data_size_type == Accurate is because we want to show the warning about input recordings and
+ // NetPlay for NFS disc images (which are the only disc images that have it set to LowerBound).
+ if (is_disc && m_data_size_type != DiscIO::DataSizeType::UpperBound && !m_is_tgc)
{
const Platform platform = m_volume.GetVolumeType();
const bool should_be_gc_size = platform == Platform::GameCubeDisc || m_is_datel;
@@ -1118,7 +1119,7 @@ void VolumeVerifier::Process()
ASSERT(m_started);
ASSERT(!m_done);
- if (m_progress == m_max_progress)
+ if (m_progress >= m_max_progress)
return;
IOS::ES::Content content{};
@@ -1166,13 +1167,21 @@ void VolumeVerifier::Process()
if (m_progress + bytes_to_read > m_max_progress)
{
const u64 bytes_over_max = m_progress + bytes_to_read - m_max_progress;
- bytes_to_read -= bytes_over_max;
- if (excess_bytes < bytes_over_max)
- excess_bytes = 0;
+
+ if (m_data_size_type == DataSizeType::LowerBound)
+ {
+ // Disc images in NFS format can have the last referenced block be past m_max_progress.
+ // For NFS, reading beyond m_max_progress doesn't return an error, so let's read beyond it.
+ excess_bytes = std::max(excess_bytes, bytes_over_max);
+ }
else
- excess_bytes -= bytes_over_max;
- content_read = false;
- group_read = false;
+ {
+ // Don't read beyond the end of the disc.
+ bytes_to_read -= bytes_over_max;
+ excess_bytes -= std::min(excess_bytes, bytes_over_max);
+ content_read = false;
+ group_read = false;
+ }
}
const bool is_data_needed = m_calculating_any_hash || content_read || group_read;
@@ -1376,8 +1385,18 @@ void VolumeVerifier::Finish()
if (m_result.redump.status == RedumpVerifier::Status::BadDump &&
highest_severity <= Severity::Low)
{
- m_result.summary_text = Common::GetStringT(
- "This is a bad dump. This doesn't necessarily mean that the game won't run correctly.");
+ if (m_volume.GetBlobType() == BlobType::NFS)
+ {
+ m_result.summary_text =
+ Common::GetStringT("Compared to the Wii disc release of the game, this is a bad dump. "
+ "Despite this, it's possible that this is a good dump compared to the "
+ "Wii U eShop release of the game. Dolphin can't verify this.");
+ }
+ else
+ {
+ m_result.summary_text = Common::GetStringT(
+ "This is a bad dump. This doesn't necessarily mean that the game won't run correctly.");
+ }
}
else
{
@@ -1402,9 +1421,18 @@ void VolumeVerifier::Finish()
}
break;
case Severity::Low:
- m_result.summary_text =
- Common::GetStringT("Problems with low severity were found. They will most "
- "likely not prevent the game from running.");
+ if (m_volume.GetBlobType() == BlobType::NFS)
+ {
+ m_result.summary_text = Common::GetStringT(
+ "Compared to the Wii disc release of the game, problems of low severity were found. "
+ "Despite this, it's possible that this is a good dump compared to the Wii U eShop "
+ "release of the game. Dolphin can't verify this.");
+ }
+ else
+ {
+ Common::GetStringT("Problems with low severity were found. They will most "
+ "likely not prevent the game from running.");
+ }
break;
case Severity::Medium:
m_result.summary_text +=