2025-05-17 22:56:57 -04:00
|
|
|
#include "fastfile_cod7_pc.h"
|
|
|
|
|
#include "zonefile_cod7_pc.h"
|
|
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "compression.h"
|
|
|
|
|
#include "encryption.h"
|
|
|
|
|
|
|
|
|
|
#include <QFile>
|
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
|
|
FastFile_COD7_PC::FastFile_COD7_PC()
|
|
|
|
|
: FastFile() {
|
|
|
|
|
SetCompany(COMPANY_INFINITY_WARD);
|
|
|
|
|
SetType(FILETYPE_FAST_FILE);
|
|
|
|
|
SetSignage(SIGNAGE_UNSIGNED);
|
|
|
|
|
SetMagic(0);
|
|
|
|
|
SetVersion(0);
|
|
|
|
|
SetGame("COD7");
|
|
|
|
|
SetPlatform("PC");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FastFile_COD7_PC::FastFile_COD7_PC(const QByteArray& aData)
|
|
|
|
|
: FastFile_COD7_PC() {
|
|
|
|
|
|
|
|
|
|
if (!aData.isEmpty()) {
|
|
|
|
|
Load(aData);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FastFile_COD7_PC::FastFile_COD7_PC(const QString aFilePath)
|
|
|
|
|
: FastFile_COD7_PC() {
|
|
|
|
|
|
|
|
|
|
if (!aFilePath.isEmpty()) {
|
|
|
|
|
Load(aFilePath);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FastFile_COD7_PC::~FastFile_COD7_PC() {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QByteArray FastFile_COD7_PC::GetBinaryData() {
|
|
|
|
|
return QByteArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FastFile_COD7_PC::Load(const QString aFilePath) {
|
|
|
|
|
if (aFilePath.isEmpty()) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check fastfile can be read
|
|
|
|
|
QFile *file = new QFile(aFilePath);
|
|
|
|
|
if (!file->open(QIODevice::ReadOnly)) {
|
|
|
|
|
qDebug() << QString("Error: Failed to open FastFile: %1!").arg(aFilePath);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Decompress fastfile and close
|
|
|
|
|
const QString fastFileStem = aFilePath.section("/", -1, -1);
|
|
|
|
|
SetStem(fastFileStem);
|
|
|
|
|
if (!Load(file->readAll())) {
|
|
|
|
|
qDebug() << "Error: Failed to load fastfile: " << fastFileStem;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
file->close();
|
|
|
|
|
|
|
|
|
|
// Open zone file after decompressing ff and writing
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool FastFile_COD7_PC::Load(const QByteArray aData) {
|
|
|
|
|
QByteArray decompressedData;
|
|
|
|
|
|
|
|
|
|
// Create a QDataStream on the input data.
|
|
|
|
|
QDataStream fastFileStream(aData);
|
|
|
|
|
fastFileStream.setByteOrder(QDataStream::LittleEndian);
|
|
|
|
|
|
|
|
|
|
// Parse header values.
|
|
|
|
|
SetCompany(pParseFFCompany(&fastFileStream));
|
|
|
|
|
SetType(pParseFFFileType(&fastFileStream));
|
|
|
|
|
SetSignage(pParseFFSignage(&fastFileStream));
|
|
|
|
|
SetMagic(pParseFFMagic(&fastFileStream));
|
|
|
|
|
quint32 version = pParseFFVersion(&fastFileStream);
|
|
|
|
|
SetVersion(version);
|
2025-07-10 00:10:49 -04:00
|
|
|
SetPlatform("360");
|
2025-05-17 22:56:57 -04:00
|
|
|
SetGame("COD7");
|
|
|
|
|
|
|
|
|
|
// Load the zone file with the decompressed data (using an Xbox platform flag).
|
|
|
|
|
ZoneFile_COD7_PC zoneFile;
|
2025-06-04 22:25:12 -04:00
|
|
|
zoneFile.SetStem(GetBaseStem() + ".zone");
|
2025-05-17 22:56:57 -04:00
|
|
|
|
2025-07-10 00:10:49 -04:00
|
|
|
// Assume the first 12 bytes are a header; the rest is zlib-compressed zone data.
|
|
|
|
|
const QByteArray compressedData = aData.mid(12);
|
|
|
|
|
decompressedData = Compression::DecompressZLIB(compressedData);
|
2025-05-17 22:56:57 -04:00
|
|
|
|
2025-07-10 00:10:49 -04:00
|
|
|
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
|
2025-05-17 22:56:57 -04:00
|
|
|
|
|
|
|
|
zoneFile.Load(decompressedData);
|
|
|
|
|
|
|
|
|
|
SetZoneFile(std::make_shared<ZoneFile_COD7_PC>(zoneFile));
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|