From f78b94077e32e045d651d4592217587cca752217 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 29 Jun 2014 15:38:48 -0400 Subject: [PATCH] DiscIO: Centralize the banner pointer and validity boolean into IBannerLoader These are both used within the banner loaders, and IsValid is exactly the same. So this makes sense. --- Source/Core/DiscIO/BannerLoader.h | 13 +++++++++++-- Source/Core/DiscIO/BannerLoaderGC.cpp | 10 +--------- Source/Core/DiscIO/BannerLoaderGC.h | 5 ----- Source/Core/DiscIO/BannerLoaderWii.cpp | 7 ------- Source/Core/DiscIO/BannerLoaderWii.h | 8 +------- 5 files changed, 13 insertions(+), 30 deletions(-) diff --git a/Source/Core/DiscIO/BannerLoader.h b/Source/Core/DiscIO/BannerLoader.h index e2b8de88a9..c7dfdadefa 100644 --- a/Source/Core/DiscIO/BannerLoader.h +++ b/Source/Core/DiscIO/BannerLoader.h @@ -19,18 +19,27 @@ class IBannerLoader { public: IBannerLoader() + : m_pBannerFile(nullptr) + , m_IsValid(false) {} virtual ~IBannerLoader() {} - virtual bool IsValid() = 0; - virtual std::vector GetBanner(int* pWidth, int* pHeight) = 0; virtual std::vector GetNames() = 0; virtual std::string GetCompany() = 0; virtual std::vector GetDescriptions() = 0; + + bool IsValid() + { + return m_IsValid; + } + +protected: + bool m_IsValid; + u8* m_pBannerFile; }; IBannerLoader* CreateBannerLoader(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume *pVolume); diff --git a/Source/Core/DiscIO/BannerLoaderGC.cpp b/Source/Core/DiscIO/BannerLoaderGC.cpp index 5258eb66ab..09c675cb11 100644 --- a/Source/Core/DiscIO/BannerLoaderGC.cpp +++ b/Source/Core/DiscIO/BannerLoaderGC.cpp @@ -16,9 +16,7 @@ namespace DiscIO { CBannerLoaderGC::CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume) - : m_pBannerFile(nullptr) - , m_IsValid(false) - , m_country(volume->GetCountry()) + : m_country(volume->GetCountry()) { // load the opening.bnr size_t FileSize = (size_t) _rFileSystem.GetFileSize("opening.bnr"); @@ -49,12 +47,6 @@ CBannerLoaderGC::~CBannerLoaderGC() } } - -bool CBannerLoaderGC::IsValid() -{ - return m_IsValid; -} - std::vector CBannerLoaderGC::GetBanner(int* pWidth, int* pHeight) { std::vector Buffer; diff --git a/Source/Core/DiscIO/BannerLoaderGC.h b/Source/Core/DiscIO/BannerLoaderGC.h index fb0b1519d2..94e261699c 100644 --- a/Source/Core/DiscIO/BannerLoaderGC.h +++ b/Source/Core/DiscIO/BannerLoaderGC.h @@ -26,8 +26,6 @@ public: CBannerLoaderGC(DiscIO::IFileSystem& _rFileSystem, DiscIO::IVolume* volume); virtual ~CBannerLoaderGC(); - virtual bool IsValid() override; - virtual std::vector GetBanner(int* pWidth, int* pHeight) override; virtual std::vector GetNames() override; @@ -79,10 +77,7 @@ private: return string_decoder(std::string(data, strnlen(data, sizeof(data)))); } - u8* m_pBannerFile; - bool m_IsValid; BANNER_TYPE m_BNRType; - BANNER_TYPE getBannerType(); DiscIO::IVolume::ECountry const m_country; diff --git a/Source/Core/DiscIO/BannerLoaderWii.cpp b/Source/Core/DiscIO/BannerLoaderWii.cpp index 338169f447..dc32765b3b 100644 --- a/Source/Core/DiscIO/BannerLoaderWii.cpp +++ b/Source/Core/DiscIO/BannerLoaderWii.cpp @@ -21,8 +21,6 @@ namespace DiscIO { CBannerLoaderWii::CBannerLoaderWii(DiscIO::IVolume *pVolume) - : m_pBannerFile(nullptr) - , m_IsValid(false) { u64 TitleID; pVolume->GetTitleID((u8*)&TitleID); @@ -95,11 +93,6 @@ CBannerLoaderWii::~CBannerLoaderWii() } } -bool CBannerLoaderWii::IsValid() -{ - return m_IsValid; -} - std::vector CBannerLoaderWii::GetBanner(int* pWidth, int* pHeight) { SWiiBanner* pBanner = (SWiiBanner*)m_pBannerFile; diff --git a/Source/Core/DiscIO/BannerLoaderWii.h b/Source/Core/DiscIO/BannerLoaderWii.h index c589ab5454..1bbe077509 100644 --- a/Source/Core/DiscIO/BannerLoaderWii.h +++ b/Source/Core/DiscIO/BannerLoaderWii.h @@ -23,8 +23,6 @@ public: virtual ~CBannerLoaderWii(); - virtual bool IsValid() override; - virtual std::vector GetBanner(int* pWidth, int* pHeight) override; virtual std::vector GetNames() override; @@ -57,11 +55,7 @@ private: u16 m_Comment[2][COMMENT_SIZE]; u8 m_BannerTexture[TEXTURE_SIZE]; u8 m_IconTexture[8][ICON_SIZE]; - } ; - - u8* m_pBannerFile; - - bool m_IsValid; + }; bool GetStringFromComments(const CommentIndex index, std::string& s); };