From 608f0c9d7b42948ab31454ea73ea4df80e01f7f6 Mon Sep 17 00:00:00 2001 From: = Date: Fri, 4 Apr 2025 20:37:07 -0400 Subject: [PATCH] Update zonefile class logic. --- libs/zonefile/zonefile_cod2.cpp | 54 +++++++-------------------------- libs/zonefile/zonefile_cod2.h | 6 ++-- libs/zonefile/zonefile_cod5.cpp | 27 +++++++++++------ libs/zonefile/zonefile_cod5.h | 10 ++++-- libs/zonefile/zonefile_cod7.cpp | 36 ++++++++++++++++------ libs/zonefile/zonefile_cod7.h | 6 ++-- libs/zonefile/zonefile_cod9.cpp | 14 ++++++--- libs/zonefile/zonefile_cod9.h | 6 ++-- 8 files changed, 82 insertions(+), 77 deletions(-) diff --git a/libs/zonefile/zonefile_cod2.cpp b/libs/zonefile/zonefile_cod2.cpp index 9e39056..d27599e 100644 --- a/libs/zonefile/zonefile_cod2.cpp +++ b/libs/zonefile/zonefile_cod2.cpp @@ -14,9 +14,7 @@ ZoneFile_COD2::~ZoneFile_COD2() } -bool ZoneFile_COD2::Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) { - SetStem(aStem); - +bool ZoneFile_COD2::Load(const QByteArray aFileData, FF_PLATFORM aPlatform) { // Open zone file as little endian stream QDataStream zoneFileStream(aFileData); if (aPlatform == FF_PLATFORM_PC) { @@ -26,14 +24,14 @@ bool ZoneFile_COD2::Load(const QByteArray aFileData, const QString aStem, FF_PLA } // Parse data from zone file header - pParseZoneHeader(&zoneFileStream); + pParseZoneHeader(&zoneFileStream, aPlatform); SetRecords(pParseZoneIndex(&zoneFileStream, GetRecordCount())); SetAssetMap(pParseAssets(&zoneFileStream, GetRecords())); return true; } -void ZoneFile_COD2::pParseZoneHeader(QDataStream *aZoneFileStream) { +void ZoneFile_COD2::pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) { SetTagCount(pParseZoneTagCount(aZoneFileStream)); pParseZoneUnknownsB(aZoneFileStream); pParseZoneUnknownsC(aZoneFileStream); @@ -1080,44 +1078,14 @@ StringTable ZoneFile_COD2::pParseAsset_StringTable(QDataStream *aZoneFileStream) QString ZoneFile_COD2::AssetTypeToString(const QString aAssetType) { const QString cleanedType = aAssetType.toUpper(); - if (cleanedType == "00000012") { // localized string PARTIALLY VERIFIED - return "LOCAL STRING"; - } else if (cleanedType == "00000010") { // raw_file PARTIALLY VERIFIED - return "RAW FILE"; - } else if (cleanedType == "0000000E") { // fx PARTIALLY VERIFIED - return "EFFECT"; - } else if (cleanedType == "00000004") { // loaded_sound PARTIALLY VERIFIED - return "SOUND"; - } else if (cleanedType == "04000000") { // x_anim PARTIALLY VERIFIED - return "ANIMATION"; - } else if (cleanedType == "0C000000") { // collision_map PARTIALLY VERIFIED - return "COLLISION MAP"; - } else if (cleanedType == "21000000") { // string_table PARTIALLY VERIFIED - return "STRING TABLE"; - } else if (cleanedType == "0000000B") { // menu_file PARTIALLY VERIFIED - return "MENU"; - } else if (cleanedType == "07000000") { // tech set PARTIALLY VERIFIED - return "TECH SET"; - } else if (cleanedType == "0000000D") { // weapon PARTIALLY VERIFIED - return "WEAPON"; - } else if (cleanedType == "11000000") { // gfx map PARTIALLY VERIFIED - return "GFX MAP"; - } else if (cleanedType == "12000000") { // light_def PARTIALLY VERIFIED - return "LIGHT DEF"; - } else if (cleanedType == "00000009") { // font PARTIALLY VERIFIED - return "FONT"; - } else if (cleanedType == "00000001") { // xmodel PARTIALLY VERIFIED - return "MODEL"; - } else if (cleanedType == "0D000000") { // d3dbsp PARTIALLY VERIFIED - return "D3DBSP"; - } else if (cleanedType == "00000002") { // material PARTIALLY VERIFIED - return "MATERIAL"; - } else if (cleanedType == "00000003") { // material PARTIALLY VERIFIED - return "IMAGE"; - } else if (cleanedType == "0E000000") { // game map sp PARTIALLY VERIFIED - return "GAME MAP SP"; - } else if (cleanedType == "0B000000") { // col map sp PARTIALLY VERIFIED - return "COL MAP SP"; + if (cleanedType == "") { // localized string PARTIALLY VERIFIED + return ""; } return aAssetType; } + +QByteArray ZoneFile_COD2::GetBinaryData() { + QByteArray result; + + return result; +} diff --git a/libs/zonefile/zonefile_cod2.h b/libs/zonefile/zonefile_cod2.h index 220bdea..9d560f7 100644 --- a/libs/zonefile/zonefile_cod2.h +++ b/libs/zonefile/zonefile_cod2.h @@ -9,11 +9,13 @@ public: ZoneFile_COD2(); ~ZoneFile_COD2(); - bool Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) override; + bool Load(const QByteArray aFileData, FF_PLATFORM aPlatform) override; QString AssetTypeToString(const QString aAssetType); + QByteArray GetBinaryData() override; + protected: - void pParseZoneHeader(QDataStream *aZoneFileStream) override; + void pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) override; quint32 pParseZoneSize(QDataStream *aZoneFileStream) override; void pParseZoneUnknownsA(QDataStream *aZoneFileStream) override; quint32 pParseZoneTagCount(QDataStream *aZoneFileStream) override; diff --git a/libs/zonefile/zonefile_cod5.cpp b/libs/zonefile/zonefile_cod5.cpp index 5d190e9..ed96244 100644 --- a/libs/zonefile/zonefile_cod5.cpp +++ b/libs/zonefile/zonefile_cod5.cpp @@ -5,18 +5,15 @@ #include ZoneFile_COD5::ZoneFile_COD5() -{ + : ZoneFile() { } -ZoneFile_COD5::~ZoneFile_COD5() -{ +ZoneFile_COD5::~ZoneFile_COD5() { } -bool ZoneFile_COD5::Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) { - SetStem(aStem); - +bool ZoneFile_COD5::Load(const QByteArray aFileData, FF_PLATFORM aPlatform) { // Open zone file as little endian stream QDataStream zoneFileStream(aFileData); if (aPlatform == FF_PLATFORM_PC) { @@ -26,14 +23,14 @@ bool ZoneFile_COD5::Load(const QByteArray aFileData, const QString aStem, FF_PLA } // Parse data from zone file header - pParseZoneHeader(&zoneFileStream); + pParseZoneHeader(&zoneFileStream, aPlatform); SetRecords(pParseZoneIndex(&zoneFileStream, GetRecordCount())); SetAssetMap(pParseAssets(&zoneFileStream, GetRecords())); return true; } -void ZoneFile_COD5::pParseZoneHeader(QDataStream *aZoneFileStream) { +void ZoneFile_COD5::pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) { SetSize(pParseZoneSize(aZoneFileStream)); pParseZoneUnknownsA(aZoneFileStream); @@ -1047,9 +1044,9 @@ StringTable ZoneFile_COD5::pParseAsset_StringTable(QDataStream *aZoneFileStream) QString ZoneFile_COD5::AssetTypeToString(const QString aAssetType) { const QString cleanedType = aAssetType.toUpper(); if (cleanedType == "17000000") { // localized string PARTIALLY VERIFIED - return "LOCAL STRING"; - } else if (cleanedType == "20000000") { // raw_file PARTIALLY VERIFIED return "RAW FILE"; + } else if (cleanedType == "20000000") { // raw_file PARTIALLY VERIFIED + return "GSC FILE"; } else if (cleanedType == "1A000000") { // fx PARTIALLY VERIFIED return "EFFECT"; } else if (cleanedType == "09000000") { // loaded_sound PARTIALLY VERIFIED @@ -1082,6 +1079,16 @@ QString ZoneFile_COD5::AssetTypeToString(const QString aAssetType) { return "GAME MAP SP"; } else if (cleanedType == "0B000000") { // col map sp PARTIALLY VERIFIED return "COL MAP SP"; + } else if (cleanedType == "01000000") { // physics preset PARTIALLY VERIFIED + return "PHYS PRESET"; + } else if (cleanedType == "03000000") { // destructible def PARTIALLY VERIFIED + return "DESTRUCTIBLE"; } return aAssetType; } + +QByteArray ZoneFile_COD5::GetBinaryData() { + QByteArray result; + + return result; +} diff --git a/libs/zonefile/zonefile_cod5.h b/libs/zonefile/zonefile_cod5.h index 880025f..b7294fb 100644 --- a/libs/zonefile/zonefile_cod5.h +++ b/libs/zonefile/zonefile_cod5.h @@ -1,6 +1,8 @@ #ifndef ZONEFILE_COD5_H #define ZONEFILE_COD5_H +#include + #include "zonefile.h" class ZoneFile_COD5 : public ZoneFile @@ -9,11 +11,13 @@ public: ZoneFile_COD5(); ~ZoneFile_COD5(); - bool Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) override; - QString AssetTypeToString(const QString aAssetType); + bool Load(const QByteArray aFileData, FF_PLATFORM aPlatform) override; + QString AssetTypeToString(const QString aAssetType) override; + + QByteArray GetBinaryData() override; private: - void pParseZoneHeader(QDataStream *aZoneFileStream) override; + void pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) override; quint32 pParseZoneSize(QDataStream *aZoneFileStream) override; void pParseZoneUnknownsA(QDataStream *aZoneFileStream) override; quint32 pParseZoneTagCount(QDataStream *aZoneFileStream) override; diff --git a/libs/zonefile/zonefile_cod7.cpp b/libs/zonefile/zonefile_cod7.cpp index 080d1ff..a6d6988 100644 --- a/libs/zonefile/zonefile_cod7.cpp +++ b/libs/zonefile/zonefile_cod7.cpp @@ -14,9 +14,7 @@ ZoneFile_COD7::~ZoneFile_COD7() } -bool ZoneFile_COD7::Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) { - SetStem(aStem); - +bool ZoneFile_COD7::Load(const QByteArray aFileData, FF_PLATFORM aPlatform) { // Open zone file as little endian stream QDataStream zoneFileStream(aFileData); if (aPlatform == FF_PLATFORM_PC) { @@ -26,23 +24,35 @@ bool ZoneFile_COD7::Load(const QByteArray aFileData, const QString aStem, FF_PLA } // Parse data from zone file header - pParseZoneHeader(&zoneFileStream); + pParseZoneHeader(&zoneFileStream, aPlatform); + zoneFileStream.device()->seek(zoneFileStream.device()->pos() - 1); SetRecords(pParseZoneIndex(&zoneFileStream, GetRecordCount())); SetAssetMap(pParseAssets(&zoneFileStream, GetRecords())); return true; } -void ZoneFile_COD7::pParseZoneHeader(QDataStream *aZoneFileStream) { - SetSize(pParseZoneSize(aZoneFileStream)); - pParseZoneUnknownsA(aZoneFileStream); +void ZoneFile_COD7::pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) { + quint32 size = pParseZoneSize(aZoneFileStream); + SetSize(size); + + if (aPlatform == FF_PLATFORM_WII) { + aZoneFileStream->skipRawData(36); + } else { + pParseZoneUnknownsA(aZoneFileStream); + } + + quint32 tagCount = pParseZoneTagCount(aZoneFileStream); + SetTagCount(tagCount); + if (aPlatform == FF_PLATFORM_WII) { + SetTagCount(GetTagCount() - 1); + } - SetTagCount(pParseZoneTagCount(aZoneFileStream)); pParseZoneUnknownsB(aZoneFileStream); - SetRecordCount(pParseZoneRecordCount(aZoneFileStream)); + quint32 recordCount = pParseZoneRecordCount(aZoneFileStream); + SetRecordCount(recordCount); - quint32 tagCount = GetTagCount(); if (tagCount) { pParseZoneUnknownsC(aZoneFileStream); SetTags(pParseZoneTags(aZoneFileStream, tagCount)); @@ -1085,3 +1095,9 @@ QString ZoneFile_COD7::AssetTypeToString(const QString aAssetType) { } return aAssetType; } + +QByteArray ZoneFile_COD7::GetBinaryData() { + QByteArray result; + + return result; +} diff --git a/libs/zonefile/zonefile_cod7.h b/libs/zonefile/zonefile_cod7.h index 87339f5..6509b4e 100644 --- a/libs/zonefile/zonefile_cod7.h +++ b/libs/zonefile/zonefile_cod7.h @@ -9,11 +9,13 @@ public: ZoneFile_COD7(); ~ZoneFile_COD7(); - bool Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) override; + bool Load(const QByteArray aFileData, FF_PLATFORM aPlatform) override; QString AssetTypeToString(const QString aAssetType); + QByteArray GetBinaryData() override; + protected: - void pParseZoneHeader(QDataStream *aZoneFileStream) override; + void pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) override; quint32 pParseZoneSize(QDataStream *aZoneFileStream) override; void pParseZoneUnknownsA(QDataStream *aZoneFileStream) override; quint32 pParseZoneTagCount(QDataStream *aZoneFileStream) override; diff --git a/libs/zonefile/zonefile_cod9.cpp b/libs/zonefile/zonefile_cod9.cpp index 3784c56..a4ab4cd 100644 --- a/libs/zonefile/zonefile_cod9.cpp +++ b/libs/zonefile/zonefile_cod9.cpp @@ -14,9 +14,7 @@ ZoneFile_COD9::~ZoneFile_COD9() } -bool ZoneFile_COD9::Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) { - SetStem(aStem); - +bool ZoneFile_COD9::Load(const QByteArray aFileData, FF_PLATFORM aPlatform) { // Open zone file as little endian stream QDataStream zoneFileStream(aFileData); if (aPlatform == FF_PLATFORM_PC) { @@ -26,14 +24,14 @@ bool ZoneFile_COD9::Load(const QByteArray aFileData, const QString aStem, FF_PLA } // Parse data from zone file header - pParseZoneHeader(&zoneFileStream); + pParseZoneHeader(&zoneFileStream, aPlatform); SetRecords(pParseZoneIndex(&zoneFileStream, GetRecordCount())); SetAssetMap(pParseAssets(&zoneFileStream, GetRecords())); return true; } -void ZoneFile_COD9::pParseZoneHeader(QDataStream *aZoneFileStream) { +void ZoneFile_COD9::pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) { SetSize(pParseZoneSize(aZoneFileStream)); pParseZoneUnknownsA(aZoneFileStream); @@ -1085,3 +1083,9 @@ QString ZoneFile_COD9::AssetTypeToString(const QString aAssetType) { } return aAssetType; } + +QByteArray ZoneFile_COD9::GetBinaryData() { + QByteArray result; + + return result; +} diff --git a/libs/zonefile/zonefile_cod9.h b/libs/zonefile/zonefile_cod9.h index accdf2b..a77aa9a 100644 --- a/libs/zonefile/zonefile_cod9.h +++ b/libs/zonefile/zonefile_cod9.h @@ -9,11 +9,13 @@ public: ZoneFile_COD9(); ~ZoneFile_COD9(); - bool Load(const QByteArray aFileData, const QString aStem, FF_PLATFORM aPlatform) override; + bool Load(const QByteArray aFileData, FF_PLATFORM aPlatform) override; QString AssetTypeToString(const QString aAssetType); + QByteArray GetBinaryData() override; + protected: - void pParseZoneHeader(QDataStream *aZoneFileStream) override; + void pParseZoneHeader(QDataStream *aZoneFileStream, FF_PLATFORM aPlatform) override; quint32 pParseZoneSize(QDataStream *aZoneFileStream) override; void pParseZoneUnknownsA(QDataStream *aZoneFileStream) override; quint32 pParseZoneTagCount(QDataStream *aZoneFileStream) override;