summaryrefslogtreecommitdiff
path: root/Source/Core/DiscIO/Volume.cpp
diff options
context:
space:
mode:
authorLéo Lam <leo@leolam.fr>2021-10-24 00:57:54 +0200
committerGitHub <noreply@github.com>2021-10-24 00:57:54 +0200
commit5d5f01992135920170a5c75f7f77ad9c3aba7bce (patch)
tree01c39b5d7e63871240c2b5c0343c10362d1cb855 /Source/Core/DiscIO/Volume.cpp
parentb997048cfee870449e875a8e6752288013c10853 (diff)
parent4f8281084598d2dc3bf2e15abd84d9c490e033c9 (diff)
Merge pull request #10127 from AdmiralCurtiss/riivolution
HLE Riivolution patch support
Diffstat (limited to 'Source/Core/DiscIO/Volume.cpp')
-rw-r--r--Source/Core/DiscIO/Volume.cpp40
1 files changed, 27 insertions, 13 deletions
diff --git a/Source/Core/DiscIO/Volume.cpp b/Source/Core/DiscIO/Volume.cpp
index c1b1400876..bf7ef4e019 100644
--- a/Source/Core/DiscIO/Volume.cpp
+++ b/Source/Core/DiscIO/Volume.cpp
@@ -85,8 +85,11 @@ std::map<Language, std::string> Volume::ReadWiiNames(const std::vector<char16_t>
return names;
}
-static std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader>& reader)
+static std::unique_ptr<VolumeDisc> TryCreateDisc(std::unique_ptr<BlobReader>& reader)
{
+ if (!reader)
+ return nullptr;
+
if (reader->ReadSwapped<u32>(0x18) == WII_DISC_MAGIC)
return std::make_unique<VolumeWii>(std::move(reader));
@@ -97,14 +100,21 @@ static std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader>& reade
return nullptr;
}
+std::unique_ptr<VolumeDisc> CreateDisc(std::unique_ptr<BlobReader> reader)
+{
+ return TryCreateDisc(reader);
+}
+
std::unique_ptr<VolumeDisc> CreateDisc(const std::string& path)
{
- std::unique_ptr<BlobReader> reader(CreateBlobReader(path));
- return reader ? CreateDisc(reader) : nullptr;
+ return CreateDisc(CreateBlobReader(path));
}
-static std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader>& reader)
+static std::unique_ptr<VolumeWAD> TryCreateWAD(std::unique_ptr<BlobReader>& reader)
{
+ if (!reader)
+ return nullptr;
+
// Check for WAD
// 0x206962 for boot2 wads
const std::optional<u32> wad_magic = reader->ReadSwapped<u32>(0x02);
@@ -115,27 +125,31 @@ static std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader>& reader)
return nullptr;
}
-std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
+std::unique_ptr<VolumeWAD> CreateWAD(std::unique_ptr<BlobReader> reader)
{
- std::unique_ptr<BlobReader> reader(CreateBlobReader(path));
- return reader ? CreateWAD(reader) : nullptr;
+ return TryCreateWAD(reader);
}
-std::unique_ptr<Volume> CreateVolume(const std::string& path)
+std::unique_ptr<VolumeWAD> CreateWAD(const std::string& path)
{
- std::unique_ptr<BlobReader> reader(CreateBlobReader(path));
- if (reader == nullptr)
- return nullptr;
+ return CreateWAD(CreateBlobReader(path));
+}
- std::unique_ptr<VolumeDisc> disc = CreateDisc(reader);
+std::unique_ptr<Volume> CreateVolume(std::unique_ptr<BlobReader> reader)
+{
+ std::unique_ptr<VolumeDisc> disc = TryCreateDisc(reader);
if (disc)
return disc;
- std::unique_ptr<VolumeWAD> wad = CreateWAD(reader);
+ std::unique_ptr<VolumeWAD> wad = TryCreateWAD(reader);
if (wad)
return wad;
return nullptr;
}
+std::unique_ptr<Volume> CreateVolume(const std::string& path)
+{
+ return CreateVolume(CreateBlobReader(path));
+}
} // namespace DiscIO