From 0576fb5bd47fb0cc6282bfb8c3a8bc1eb763d09c Mon Sep 17 00:00:00 2001 From: = Date: Wed, 4 Jun 2025 22:33:02 -0400 Subject: [PATCH] Switch all to fastfile factory. --- libs/fastfile/fastfile.cpp | 47 +++++--------------------------- libs/fastfile/fastfile.h | 1 + libs/fastfile/fastfile_factory.h | 35 +++++++++++++++++------- 3 files changed, 33 insertions(+), 50 deletions(-) diff --git a/libs/fastfile/fastfile.cpp b/libs/fastfile/fastfile.cpp index 33a7687..dd8f34b 100644 --- a/libs/fastfile/fastfile.cpp +++ b/libs/fastfile/fastfile.cpp @@ -44,6 +44,10 @@ QString FastFile::GetStem() const { return mStem; } +QString FastFile::GetBaseStem() const { + return mStem.split('.').first(); +} + FF_FILETYPE FastFile::GetType() const { return mType; } @@ -257,50 +261,13 @@ std::shared_ptr FastFile::Open(const QString &aFilePath) { LogManager::instance().addEntry("Contents read in"); LogManager::instance().addEntry(QString("- Size: %1 B").arg(data.size())); - LogManager::instance().addEntry("File closed"); file->close(); + LogManager::instance().addEntry("File closed"); - // Create a QDataStream on the input data. - QDataStream fastFileStream(data); - fastFileStream.setByteOrder(QDataStream::LittleEndian); - - quint32 companyInt; - FF_COMPANY company = pParseFFCompany(&fastFileStream, companyInt); - qDebug() << "Company: " << company; - FF_FILETYPE fileType; - FF_SIGNAGE signage; - QString magic; - quint32 version; - QString platform; - QString game; - - if ((company == COMPANY_NONE) && (companyInt == 0)) { - company = COMPANY_INFINITY_WARD; - game = "COD2"; - platform = "360"; - } else { - fileType = pParseFFFileType(&fastFileStream); - signage = pParseFFSignage(&fastFileStream); - magic = pParseFFMagic(&fastFileStream); - version = pParseFFVersion(&fastFileStream); - platform = pCalculateFFPlatform(version); - game = pCalculateFFGame(version); - - LogManager::instance().addEntry(QString("Type: %1").arg(fileType)); - LogManager::instance().addEntry(QString("Signage: %1").arg(signage)); - LogManager::instance().addEntry(QString("Magic: %1").arg(magic)); - LogManager::instance().addEntry(QString("Version: %1").arg(version)); - } - LogManager::instance().addEntry(QString("Company: %1").arg(company)); - LogManager::instance().addEntry(QString("Game: %1").arg(game)); - LogManager::instance().addEntry(QString("Platform: %1").arg(platform)); - - const QString fastFileStem = aFilePath.section("/", -1, -1).section('.', 0, 0); + const QString fastFileStem = aFilePath.section("/", -1, -1); LogManager::instance().addEntry(QString("Stem: %1").arg(fastFileStem)); - std::shared_ptr fastFile = FastFileFactory::Create(data); - - fastFile->SetCompany(company); + std::shared_ptr fastFile = FastFileFactory::Create(data); fastFile->SetStem(fastFileStem); return fastFile; diff --git a/libs/fastfile/fastfile.h b/libs/fastfile/fastfile.h index 553f4ec..a960917 100644 --- a/libs/fastfile/fastfile.h +++ b/libs/fastfile/fastfile.h @@ -25,6 +25,7 @@ public: virtual QByteArray GetBinaryData() = 0; virtual QString GetStem() const; + virtual QString GetBaseStem() const; virtual FF_FILETYPE GetType() const; virtual FF_COMPANY GetCompany() const; virtual FF_SIGNAGE GetSignage() const; diff --git a/libs/fastfile/fastfile_factory.h b/libs/fastfile/fastfile_factory.h index 7707b25..2eb04b6 100644 --- a/libs/fastfile/fastfile_factory.h +++ b/libs/fastfile/fastfile_factory.h @@ -35,7 +35,9 @@ #include "PC/fastfile_cod11_pc.h" #include "PC/fastfile_cod12_pc.h" -#include "Wii//fastfile_cod7_wii.h" +#include "Wii/fastfile_cod4_wii.h" +#include "Wii/fastfile_cod7_wii.h" +#include "Wii/fastfile_cod8_wii.h" #include "WiiU/fastfile_cod9_wiiu.h" #include "WiiU/fastfile_cod10_wiiu.h" @@ -153,8 +155,12 @@ public: resultFF = std::make_shared(newPath); } } else if (platform == PLATFORM_WII) { - if (game == GAME_COD7) { + if (game == GAME_COD4) { + resultFF = std::make_shared(newPath); + } else if (game == GAME_COD7) { resultFF = std::make_shared(newPath); + } else if (game == GAME_COD8) { + resultFF = std::make_shared(newPath); } } else if (platform == PLATFORM_WIIU) { if (game == GAME_COD9) { @@ -233,8 +239,12 @@ public: resultFF = std::make_shared(aData); } } else if (platform == PLATFORM_WII) { - if (game == GAME_COD7) { + if (game == GAME_COD4) { + resultFF = std::make_shared(aData); + } else if (game == GAME_COD7) { resultFF = std::make_shared(aData); + } else if (game == GAME_COD8) { + resultFF = std::make_shared(aData); } } else if (platform == PLATFORM_WIIU) { if (game == GAME_COD9) { @@ -269,9 +279,10 @@ private: if (sections[0] == "0000") { return PLATFORM_360; } else if (sections[4] == "0000") { - if (sections[5] == "0001" && sections[6] == "78DA") { return PLATFORM_360; + } else if (sections[5] == "0001" && sections[6] == "4957") { + return PLATFORM_360; } else if (sections[5] == "0183" && sections[6] == "7801") { return PLATFORM_360; } else if (sections[6] == "0101" && sections[7] == "CA3E") { @@ -288,12 +299,16 @@ private: return PLATFORM_360; } else if (sections[2] == "3030" && sections[3] == "3030") { return PLATFORM_360; + } else if (sections[5] == "01A2" && sections[6] == "7801") { + return PLATFORM_WII; + } else if (sections[5] == "01DD" && sections[6] == "7801") { + return PLATFORM_WII; + } else if (sections[5] == "006B") { + return PLATFORM_WII; } } else if (sections[5] == "0000") { return PLATFORM_PC; - } else if (sections[5] == "01DD" && sections[6] == "7801") { - return PLATFORM_WII; - } else if (sections[5] == "0094" || sections[6] == "0100") { + }else if (sections[5] == "0094" || sections[6] == "0100") { return PLATFORM_WIIU; } return PLATFORM_PS3; @@ -303,15 +318,15 @@ private: const QStringList sections = pGetDataSections(aData); if (sections[0] == "0000") { return GAME_COD2; - } else if (sections[4] == "0500" || sections[5] == "0001") { + } else if (sections[4] == "0500" || sections[5] == "01A2" || sections[5] == "0001") { return GAME_COD4; } else if (sections[4] == "8301" || sections[5] == "0183") { return GAME_COD5; } else if (sections[4] == "1401" || sections[5] == "010D") { return GAME_COD6; - } else if (sections[4] == "D901" || sections[5] == "01D9") { + } else if (sections[4] == "D901" || sections[5] == "01DD" || sections[5] == "01D9") { return GAME_COD7; - } else if (sections[4] == "0100" || sections[5] == "0070") { + } else if (sections[4] == "0100" || sections[5] == "006B" || sections[5] == "0070") { return GAME_COD8; } else if (sections[4] == "9300" || sections[5] == "0092" || sections[5] == "0094") {