|
@@ -28,13 +28,27 @@ QString getComponentNameFromId(int id) {
|
|
PatchInstaller::PatchInstaller(QObject *parent) : QObject(parent) {
|
|
PatchInstaller::PatchInstaller(QObject *parent) : QObject(parent) {
|
|
client_local_file_ = new LOTRO_DAT::DatFile(100);
|
|
client_local_file_ = new LOTRO_DAT::DatFile(100);
|
|
client_general_file_ = new LOTRO_DAT::DatFile(101);
|
|
client_general_file_ = new LOTRO_DAT::DatFile(101);
|
|
- connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &PatchInstaller::startPatchInstallationChain);
|
|
|
|
|
|
+ connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, [this](){startPatchInstallationChain();});
|
|
}
|
|
}
|
|
|
|
|
|
bool PatchInstaller::initialised() {
|
|
bool PatchInstaller::initialised() {
|
|
return client_general_file_->Initialized() && client_local_file_->Initialized();
|
|
return client_general_file_->Initialized() && client_local_file_->Initialized();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+void PatchInstaller::checkIfUpdatedByGame()
|
|
|
|
+{
|
|
|
|
+ const int client_local_maxiter = client_local_file_->GetDatFileMaxIteration();
|
|
|
|
+ const int client_general_maxiter = client_general_file_->GetDatFileMaxIteration();
|
|
|
|
+
|
|
|
|
+ const int client_local_saved_maxiter = _current_applied_patches_info.client_local_header_maxiter;
|
|
|
|
+ const int client_general_saved_maxiter = _current_applied_patches_info.client_general_header_maxiter;
|
|
|
|
+
|
|
|
|
+ emit updatedByGameStatusChanged(
|
|
|
|
+ (client_local_saved_maxiter != -1 && client_local_maxiter != client_local_saved_maxiter) ||
|
|
|
|
+ (client_general_saved_maxiter != -1 && client_general_maxiter != client_general_saved_maxiter)
|
|
|
|
+ );
|
|
|
|
+}
|
|
|
|
+
|
|
PatchInstaller::~PatchInstaller() {
|
|
PatchInstaller::~PatchInstaller() {
|
|
deinit();
|
|
deinit();
|
|
delete client_local_file_;
|
|
delete client_local_file_;
|
|
@@ -317,6 +331,10 @@ PatchInstaller::AppliedPatchesInfo PatchInstaller::getAppliedPatchesInfoFromDatF
|
|
result.fonts_patch_hashsum = QString(str).remove(0, 6);
|
|
result.fonts_patch_hashsum = QString(str).remove(0, 6);
|
|
} else if (str.startsWith("VIDEOS:")) {
|
|
} else if (str.startsWith("VIDEOS:")) {
|
|
result.videos_patch_hashsum = QString(str).remove(0, 7);
|
|
result.videos_patch_hashsum = QString(str).remove(0, 7);
|
|
|
|
+ } else if (str.startsWith("CLIENT_LOCAL_HEADER_MAXITER:")) {
|
|
|
|
+ result.client_local_header_maxiter = QString(str).remove(0, 28).toInt();
|
|
|
|
+ } else if (str.startsWith("CLIENT_GENERAL_HEADER_MAXITER:")) {
|
|
|
|
+ result.client_general_header_maxiter = QString(str).remove(0, 30).toInt();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (result.texts_patch_hashsum != "" || result.images_patch_hashsum != "" || result.textures_patch_hashsum != "" ||
|
|
if (result.texts_patch_hashsum != "" || result.images_patch_hashsum != "" || result.textures_patch_hashsum != "" ||
|
|
@@ -343,6 +361,12 @@ void PatchInstaller::insertPatchesInfoInDatFile(const PatchInstaller::AppliedPat
|
|
patches_info_data += "FONTS:" + info.fonts_patch_hashsum + "\n";
|
|
patches_info_data += "FONTS:" + info.fonts_patch_hashsum + "\n";
|
|
patches_info_data += "VIDEOS:" + info.videos_patch_hashsum + "\n";
|
|
patches_info_data += "VIDEOS:" + info.videos_patch_hashsum + "\n";
|
|
|
|
|
|
|
|
+ const int client_local_maxiter = client_local_file_->GetDatFileMaxIteration();
|
|
|
|
+ const int client_general_maxiter = client_general_file_->GetDatFileMaxIteration();
|
|
|
|
+
|
|
|
|
+ patches_info_data += "CLIENT_LOCAL_HEADER_MAXITER:" + QString::number(client_local_maxiter) + "\n";
|
|
|
|
+ patches_info_data += "CLIENT_GENERAL_HEADER_MAXITER:" + QString::number(client_general_maxiter) + "\n";
|
|
|
|
+
|
|
QByteArray data = QByteArray((char*)&_applied_patches_file_id, 4) + patches_info_data.toUtf8();
|
|
QByteArray data = QByteArray((char*)&_applied_patches_file_id, 4) + patches_info_data.toUtf8();
|
|
file_data.binary_data = LOTRO_DAT::BinaryData(data.data(), data.size());
|
|
file_data.binary_data = LOTRO_DAT::BinaryData(data.data(), data.size());
|
|
client_local_file_->PatchFile(file_data, _patch_files_versions, 1, true);
|
|
client_local_file_->PatchFile(file_data, _patch_files_versions, 1, true);
|
|
@@ -390,6 +414,8 @@ void PatchInstaller::init()
|
|
<< QString::fromStdString(client_local_file_->GetFilename());
|
|
<< QString::fromStdString(client_local_file_->GetFilename());
|
|
|
|
|
|
_current_applied_patches_info = getAppliedPatchesInfoFromDatFile();
|
|
_current_applied_patches_info = getAppliedPatchesInfoFromDatFile();
|
|
|
|
+ checkIfUpdatedByGame();
|
|
|
|
+
|
|
emit successfullyInitialized();
|
|
emit successfullyInitialized();
|
|
}
|
|
}
|
|
|
|
|
|
@@ -442,7 +468,7 @@ void PatchInstaller::startGame(bool remove_dat_files) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-void PatchInstaller::startPatchInstallationChain() {
|
|
|
|
|
|
+void PatchInstaller::startPatchInstallationChain(bool force_reinstall_patches) {
|
|
emit started();
|
|
emit started();
|
|
qInfo() << "PatchInstaller: Starting installation chain...";
|
|
qInfo() << "PatchInstaller: Starting installation chain...";
|
|
const QVector<QString> patches = {"text", "font", "image", "loadscreen", "texture", "sound", "video", "micro"};
|
|
const QVector<QString> patches = {"text", "font", "image", "loadscreen", "texture", "sound", "video", "micro"};
|
|
@@ -476,10 +502,13 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
hashsum_in_dat_file = _current_applied_patches_info.loadscreens_patch_hashsum;
|
|
hashsum_in_dat_file = _current_applied_patches_info.loadscreens_patch_hashsum;
|
|
}
|
|
}
|
|
|
|
|
|
- if (patch_hashsum == hashsum_in_dat_file) {
|
|
|
|
|
|
+ if (!force_reinstall_patches && patch_hashsum == hashsum_in_dat_file) {
|
|
qDebug() << "Skipping patch " << patch << " because its hashsum (" << patch_hashsum << ") is equal to hashsum in dat file (" << hashsum_in_dat_file << ")";
|
|
qDebug() << "Skipping patch " << patch << " because its hashsum (" << patch_hashsum << ") is equal to hashsum in dat file (" << hashsum_in_dat_file << ")";
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
|
|
+ if (force_reinstall_patches) {
|
|
|
|
+ qDebug() << "Forcelly installing patch " << patch << ". Its hashsum (" << patch_hashsum << "). Hashsum in dat file (" << hashsum_in_dat_file << ")";
|
|
|
|
+ }
|
|
|
|
|
|
const QString real_file_hashsum = FileSystem::fileHash(patch_filename);
|
|
const QString real_file_hashsum = FileSystem::fileHash(patch_filename);
|
|
if (!FileSystem::fileExists(patch_filename) || real_file_hashsum != patch_hashsum) {
|
|
if (!FileSystem::fileExists(patch_filename) || real_file_hashsum != patch_hashsum) {
|
|
@@ -530,7 +559,7 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
}
|
|
}
|
|
|
|
|
|
emit progressChanged(current_status);
|
|
emit progressChanged(current_status);
|
|
- for (const QString patch_name: patch_databases.keys()) {
|
|
|
|
|
|
+ for (const QString& patch_name: patch_databases.keys()) {
|
|
qInfo() << "PatchInstaller: Installing patch " << patch_name;
|
|
qInfo() << "PatchInstaller: Installing patch " << patch_name;
|
|
installPatch(patch_name, patch_databases[patch_name]);
|
|
installPatch(patch_name, patch_databases[patch_name]);
|
|
patch_databases[patch_name]->CloseDatabase();
|
|
patch_databases[patch_name]->CloseDatabase();
|
|
@@ -543,6 +572,9 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
|
|
|
insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
qInfo() << "PatchInstaller: Finished installation chain...";
|
|
qInfo() << "PatchInstaller: Finished installation chain...";
|
|
|
|
+ if (force_reinstall_patches) {
|
|
|
|
+ emit updatedByGameStatusChanged(false);
|
|
|
|
+ }
|
|
emit finished();
|
|
emit finished();
|
|
}
|
|
}
|
|
|
|
|