mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-29 09:09:52 -06:00
Merge pull request #5522 from leoetlino/simpler-gettitleid
DiscIO: Use std::optional for GetTitleID instead of pointer
This commit is contained in:
@ -8,6 +8,7 @@
|
||||
#include <limits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -53,8 +54,8 @@ public:
|
||||
}
|
||||
virtual std::vector<Partition> GetPartitions() const { return {}; }
|
||||
virtual Partition GetGamePartition() const { return PARTITION_NONE; }
|
||||
bool GetTitleID(u64* buffer) const { return GetTitleID(buffer, GetGamePartition()); }
|
||||
virtual bool GetTitleID(u64* buffer, const Partition& partition) const { return false; }
|
||||
std::optional<u64> GetTitleID() const { return GetTitleID(GetGamePartition()); }
|
||||
virtual std::optional<u64> GetTitleID(const Partition& partition) const { return {}; }
|
||||
virtual const IOS::ES::TicketReader& GetTicket(const Partition& partition) const
|
||||
{
|
||||
return INVALID_TICKET;
|
||||
|
@ -107,9 +107,12 @@ std::string CVolumeWAD::GetMakerID(const Partition& partition) const
|
||||
return DecodeString(temp);
|
||||
}
|
||||
|
||||
bool CVolumeWAD::GetTitleID(u64* buffer, const Partition& partition) const
|
||||
std::optional<u64> CVolumeWAD::GetTitleID(const Partition& partition) const
|
||||
{
|
||||
return ReadSwapped(m_offset + 0x01DC, buffer, partition);
|
||||
u64 title_id;
|
||||
if (!ReadSwapped(m_offset + 0x01DC, &title_id, partition))
|
||||
return {};
|
||||
return title_id;
|
||||
}
|
||||
|
||||
u16 CVolumeWAD::GetRevision(const Partition& partition) const
|
||||
@ -141,11 +144,11 @@ std::vector<u32> CVolumeWAD::GetBanner(int* width, int* height) const
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
u64 title_id;
|
||||
if (!GetTitleID(&title_id))
|
||||
const std::optional<u64> title_id = GetTitleID();
|
||||
if (!title_id)
|
||||
return std::vector<u32>();
|
||||
|
||||
return GetWiiBanner(width, height, title_id);
|
||||
return GetWiiBanner(width, height, *title_id);
|
||||
}
|
||||
|
||||
BlobType CVolumeWAD::GetBlobType() const
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -33,7 +34,7 @@ public:
|
||||
~CVolumeWAD();
|
||||
bool Read(u64 offset, u64 length, u8* buffer,
|
||||
const Partition& partition = PARTITION_NONE) const override;
|
||||
bool GetTitleID(u64* buffer, const Partition& partition = PARTITION_NONE) const override;
|
||||
std::optional<u64> GetTitleID(const Partition& partition = PARTITION_NONE) const override;
|
||||
const IOS::ES::TMDReader& GetTMD(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetGameID(const Partition& partition = PARTITION_NONE) const override;
|
||||
std::string GetMakerID(const Partition& partition = PARTITION_NONE) const override;
|
||||
|
@ -181,13 +181,12 @@ Partition CVolumeWiiCrypted::GetGamePartition() const
|
||||
return m_game_partition;
|
||||
}
|
||||
|
||||
bool CVolumeWiiCrypted::GetTitleID(u64* buffer, const Partition& partition) const
|
||||
std::optional<u64> CVolumeWiiCrypted::GetTitleID(const Partition& partition) const
|
||||
{
|
||||
const IOS::ES::TicketReader& ticket = GetTicket(partition);
|
||||
if (!ticket.IsValid())
|
||||
return false;
|
||||
*buffer = ticket.GetTitleId();
|
||||
return true;
|
||||
return {};
|
||||
return ticket.GetTitleId();
|
||||
}
|
||||
|
||||
const IOS::ES::TicketReader& CVolumeWiiCrypted::GetTicket(const Partition& partition) const
|
||||
@ -289,11 +288,11 @@ std::vector<u32> CVolumeWiiCrypted::GetBanner(int* width, int* height) const
|
||||
*width = 0;
|
||||
*height = 0;
|
||||
|
||||
u64 title_id;
|
||||
if (!GetTitleID(&title_id, GetGamePartition()))
|
||||
const std::optional<u64> title_id = GetTitleID(GetGamePartition());
|
||||
if (!title_id)
|
||||
return std::vector<u32>();
|
||||
|
||||
return GetWiiBanner(width, height, title_id);
|
||||
return GetWiiBanner(width, height, *title_id);
|
||||
}
|
||||
|
||||
u64 CVolumeWiiCrypted::GetFSTSize(const Partition& partition) const
|
||||
|
@ -7,6 +7,7 @@
|
||||
#include <map>
|
||||
#include <mbedtls/aes.h>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -33,7 +34,7 @@ public:
|
||||
bool Read(u64 _Offset, u64 _Length, u8* _pBuffer, const Partition& partition) const override;
|
||||
std::vector<Partition> GetPartitions() const override;
|
||||
Partition GetGamePartition() const override;
|
||||
bool GetTitleID(u64* buffer, const Partition& partition) const override;
|
||||
std::optional<u64> GetTitleID(const Partition& partition) const override;
|
||||
const IOS::ES::TicketReader& GetTicket(const Partition& partition) const override;
|
||||
const IOS::ES::TMDReader& GetTMD(const Partition& partition) const override;
|
||||
std::string GetGameID(const Partition& partition) const override;
|
||||
|
Reference in New Issue
Block a user