93 lines
2.2 KiB
C++
93 lines
2.2 KiB
C++
#include "fastfile_cod5_360.h"
|
|
#include "zonefile_cod5_360.h"
|
|
|
|
#include "utils.h"
|
|
#include "compression.h"
|
|
#include "statusbarmanager.h"
|
|
|
|
#include <QFile>
|
|
#include <QDebug>
|
|
|
|
FastFile_COD5_360::FastFile_COD5_360()
|
|
: FastFile() {
|
|
SetCompany(COMPANY_INFINITY_WARD);
|
|
SetType(FILETYPE_FAST_FILE);
|
|
SetSignage(SIGNAGE_UNSIGNED);
|
|
SetMagic(0);
|
|
SetVersion(0);
|
|
SetPlatform("360");
|
|
SetGame("COD5");
|
|
}
|
|
|
|
FastFile_COD5_360::FastFile_COD5_360(const QByteArray& aData)
|
|
: FastFile_COD5_360() {
|
|
|
|
if (!aData.isEmpty()) {
|
|
Load(aData);
|
|
}
|
|
}
|
|
|
|
FastFile_COD5_360::FastFile_COD5_360(const QString aFilePath)
|
|
: FastFile_COD5_360() {
|
|
|
|
if (!aFilePath.isEmpty()) {
|
|
Load(aFilePath);
|
|
}
|
|
}
|
|
|
|
FastFile_COD5_360::~FastFile_COD5_360() {
|
|
|
|
}
|
|
|
|
QByteArray FastFile_COD5_360::GetBinaryData() const {
|
|
return QByteArray();
|
|
}
|
|
|
|
bool FastFile_COD5_360::Load(const QString aFilePath) {
|
|
StatusBarManager::instance().updateStatus("Loading COD5 Fast File w/path", 1000);
|
|
|
|
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
|
|
QString fastFileStem = aFilePath.split('/').last().replace(".ff", "");
|
|
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_COD5_360::Load(const QByteArray aData) {
|
|
StatusBarManager::instance().updateStatus("Loading COD5 Fast File w/data", 1000);
|
|
QByteArray decompressedData;
|
|
|
|
// For COD5, simply decompress from offset 12.
|
|
decompressedData = Compression::DecompressZLIB(aData.mid(12));
|
|
|
|
Utils::ExportData(GetBaseStem() + ".zone", decompressedData);
|
|
|
|
ZoneFile_COD5_360* zoneFile = new ZoneFile_COD5_360();
|
|
zoneFile->SetStem(GetBaseStem() + ".zone");
|
|
if (!zoneFile->Load(decompressedData)) {
|
|
qWarning() << "Failed to load ZoneFile!";
|
|
return false;
|
|
}
|
|
SetZoneFile(zoneFile);
|
|
|
|
return true;
|
|
}
|