|
@@ -1,7 +1,9 @@
|
|
|
#include "patchinstaller.h"
|
|
|
+#include "legacyapplication.h"
|
|
|
#include "models/patchdownloader.h"
|
|
|
#include "models/filesystem.h"
|
|
|
#include "models/settings.h"
|
|
|
+#include "models/datoriginalfilesdatabase.h"
|
|
|
|
|
|
#include <QDebug>
|
|
|
#include <QProcess>
|
|
@@ -23,9 +25,7 @@ QString getComponentNameFromId(int id) {
|
|
|
return "none";
|
|
|
}
|
|
|
|
|
|
-PatchInstaller::PatchInstaller(QObject *parent)
|
|
|
- : QObject(parent)
|
|
|
- , orig_files_db(QSqlDatabase::addDatabase("QSQLITE")) {
|
|
|
+PatchInstaller::PatchInstaller(QObject *parent) : QObject(parent) {
|
|
|
client_local_file_ = new LOTRO_DAT::DatFile(100);
|
|
|
client_general_file_ = new LOTRO_DAT::DatFile(101);
|
|
|
connect(&PatchDownloader::instance(), &PatchDownloader::finished, this, &PatchInstaller::startPatchInstallationChain);
|
|
@@ -58,7 +58,6 @@ bool PatchInstaller::datPathIsRelevant() {
|
|
|
}
|
|
|
|
|
|
void PatchInstaller::deinit() {
|
|
|
- orig_files_db.close();
|
|
|
client_local_file_->Deinit();
|
|
|
client_general_file_->Deinit();
|
|
|
emit deinitialized();
|
|
@@ -79,11 +78,7 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (patch_name == "micro" && !Settings::getValue("Components/micropatch").toBool()) {
|
|
|
- Settings::setValue("DatabaseNeedInstall/micropatch", false);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
+ DatOriginalFilesDatabase orig_files_db(QApplication::applicationDirPath() + "/data/" + patch_name + "_orig.db");
|
|
|
LOTRO_DAT::SubfileData file;
|
|
|
qDebug() << "Total files in database " << database->CountRows();
|
|
|
qDebug() << "Patching all files from database..." << database;
|
|
@@ -108,20 +103,25 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
|
|
|
|
|
|
const int file_id = file.options["fid"].as<int>();
|
|
|
int file_version = -1;
|
|
|
-
|
|
|
+ int file_iteration = -1;
|
|
|
|
|
|
if (dat_id == E_CLIENT_LOCAL) {
|
|
|
file_version = client_local_file_->GetFileVersion(file_id);
|
|
|
} else if (dat_id == E_CLIENT_GENERAL) {
|
|
|
- file_version = client_local_file_->GetFileVersion(file_id);
|
|
|
+ file_version = client_general_file_->GetFileVersion(file_id);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+ if (file_version != _patch_files_versions && file_version != 0) {
|
|
|
+ LOTRO_DAT::SubfileData data;
|
|
|
+ if (dat_id == E_CLIENT_LOCAL) {
|
|
|
+ data = client_local_file_->GetFile(file_id);
|
|
|
+ } else if (dat_id == E_CLIENT_GENERAL) {
|
|
|
+ data = client_general_file_->GetFile(file_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ orig_files_db.addFile(file_id, dat_id, file_version, file_iteration, data);
|
|
|
+ }
|
|
|
|
|
|
if (dat_id == E_CLIENT_LOCAL) {
|
|
|
client_local_file_->PatchFile(file, _patch_files_versions);
|
|
@@ -142,19 +142,12 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
|
|
|
} else if (patch_name == "font") {
|
|
|
_current_applied_patches_info.fonts_patch_hashsum = hashsum;
|
|
|
}
|
|
|
+ orig_files_db.closeDatabase();
|
|
|
insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
|
- Settings::setValue("DatabaseNeedInstall/" + patch_name, false);
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
void PatchInstaller::installLoadscreens(LOTRO_DAT::Database* database) {
|
|
|
- if (!Settings::getValue("Components/loadscreens").toBool()) {
|
|
|
- current_status.finished_parts += database->CountRows();
|
|
|
- emit progressChanged(current_status);
|
|
|
- Settings::setValue("DatabaseNeedInstall/loadscreen", false);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
QString locale_prefix = Settings::getValue("Lotro/original_locale").toString();
|
|
|
|
|
|
const QStringList loadscreens_filenames = {
|
|
@@ -191,7 +184,6 @@ void PatchInstaller::installLoadscreens(LOTRO_DAT::Database* database) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- Settings::setValue("DatabaseNeedInstall/loadscreen", false);
|
|
|
_current_applied_patches_info.has_no_patch_mark = false;
|
|
|
_current_applied_patches_info.loadscreens_patch_hashsum = Settings::getValue("PatchDatabases/loadscreen/hashsum").toString();
|
|
|
insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
@@ -205,11 +197,6 @@ void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
|
|
|
download_video_total_videos = database->CountRows();
|
|
|
download_video_finished_videos = 0;
|
|
|
|
|
|
- if (!Settings::getValue("Components/videos").toBool()) {
|
|
|
- Settings::setValue("DatabaseNeedInstall/video", false);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
LOTRO_DAT::SubfileData file;
|
|
|
while (!(file = database->GetNextFile()).Empty()) {
|
|
|
if (!file.options["name"] || !file.options["url"] || !file.options["hash"] || !file.options["folder"]) {
|
|
@@ -250,7 +237,6 @@ void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
|
|
|
_current_applied_patches_info.has_no_patch_mark = false;
|
|
|
_current_applied_patches_info.videos_patch_hashsum = Settings::getValue("PatchDatabases/video/hashsum").toString();
|
|
|
insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
|
- Settings::setValue("DatabaseNeedInstall/video", false);
|
|
|
}
|
|
|
|
|
|
PatchInstaller::AppliedPatchesInfo PatchInstaller::getAppliedPatchesInfoFromDatFile() {
|
|
@@ -342,16 +328,6 @@ void PatchInstaller::init()
|
|
|
if (!FileSystem::fileExists(database_path)) {
|
|
|
FileSystem::createFilePath(database_path);
|
|
|
}
|
|
|
- orig_files_db.setDatabaseName(database_path);
|
|
|
- if (!orig_files_db.open()) {
|
|
|
- qCritical() << "Initializing PatchInstaller - Cannot open backup database!!!!!!! " << database_path;
|
|
|
- }
|
|
|
- orig_files_db.exec(create_table_query);
|
|
|
- orig_files_db.exec("PRAGMA synchronous = OFF");
|
|
|
- orig_files_db.exec("PRAGMA count_changes = OFF");
|
|
|
- orig_files_db.exec("PRAGMA journal_mode = MEMORY");
|
|
|
- orig_files_db.exec("PRAGMA temp_store = MEMORY");
|
|
|
- orig_files_db.exec("PRAGMA encoding = \"UTF-8\";");
|
|
|
|
|
|
qDebug() << "LotroDatManager initialisation successfull! Dat files: "
|
|
|
<< QString::fromStdString(client_general_file_->GetFilename())
|
|
@@ -361,10 +337,7 @@ void PatchInstaller::init()
|
|
|
emit successfullyInitialized();
|
|
|
}
|
|
|
|
|
|
-void PatchInstaller::startGame(bool freeze_updates) {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+void PatchInstaller::startGame() {
|
|
|
QString game_folder = Settings::getValue("Lotro/game_path").toString();
|
|
|
|
|
|
if (game_folder == "none") {
|
|
@@ -377,45 +350,12 @@ void PatchInstaller::startGame(bool freeze_updates) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (freeze_updates) {
|
|
|
- QFile::remove(game_folder + "/lotro_ru.exe");
|
|
|
- if (!QFile::copy(QApplication::applicationDirPath() + "/LotroLauncher.exe", game_folder + "/lotro_ru.exe")) {
|
|
|
- qCritical() << __FUNCTION__ << "Starting game FAILED - cannot copy LotroLauncher to lotro_ru.exe!!";
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- QFile::remove(game_folder + "/LotroLauncher.exe");
|
|
|
- if (!QFile::copy(QApplication::applicationDirPath() + "/Launcher.exe", game_folder + "/LotroLauncher.exe")) {
|
|
|
- qCritical() << __FUNCTION__ << "Starting game FAILED - cannot copy GameLauncher to LotroLauncher!!";
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- QFile file(game_folder + "/legacy_path.txt");
|
|
|
- file.open(QIODevice::WriteOnly);
|
|
|
- QTextStream out(&file);
|
|
|
- out << QApplication::applicationDirPath() + "/LegacyLauncher.exe";
|
|
|
- file.close();
|
|
|
- } else {
|
|
|
- QFile::remove(game_folder + "/LotroLauncher.exe");
|
|
|
- if (!QFile::copy(QApplication::applicationDirPath() + "/LotroLauncher.exe", game_folder + "/LotroLauncher.exe")) {
|
|
|
- qCritical() << __FUNCTION__ << "Starting game FAILED - cannot copy LotroLauncher from working dir to LotroLauncher in lotro dir!!";
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
QStringList args;
|
|
|
- if (freeze_updates) {
|
|
|
- args << "gamelaunch" << "-disablePatch";
|
|
|
- }
|
|
|
-
|
|
|
- if (Settings::getValue("Lotro/skip_raw_download").toBool()) {
|
|
|
+ args << "-nosplashscreen";
|
|
|
+ if (_current_applied_patches_info.loadscreens_patch_hashsum != "") {
|
|
|
args << "-skiprawdownload";
|
|
|
}
|
|
|
|
|
|
- if (Settings::getValue("Lotro/no_splash_screen").toBool()) {
|
|
|
- args << "-nosplashscreen";
|
|
|
- }
|
|
|
-
|
|
|
client_general_file_->Deinit();
|
|
|
client_local_file_->Deinit();
|
|
|
|
|
@@ -434,10 +374,10 @@ void PatchInstaller::startGame(bool freeze_updates) {
|
|
|
if (f.fileName().contains(" ")) {
|
|
|
f.setFileName("\"" + f.fileName() + "\"");
|
|
|
}
|
|
|
-
|
|
|
+ deinit();
|
|
|
process.startDetached(f.fileName(), args);
|
|
|
process.waitForFinished(-1);
|
|
|
- QApplication::quit();
|
|
|
+ QMetaObject::invokeMethod(&LegacyApplication::instance(), &LegacyApplication::close, Qt::QueuedConnection);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -452,6 +392,22 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
|
|
|
for (const QString& patch: patches) {
|
|
|
if (!Settings::getValue("DatabaseDownload/" + patch).toBool()) {
|
|
|
+ if (patch == "text") {
|
|
|
+ _current_applied_patches_info.texts_patch_hashsum = "";
|
|
|
+ } else if (patch == "image") {
|
|
|
+ _current_applied_patches_info.images_patch_hashsum = "";
|
|
|
+ } else if (patch == "sound") {
|
|
|
+ _current_applied_patches_info.sounds_patch_hashsum = "";
|
|
|
+ } else if (patch == "texture") {
|
|
|
+ _current_applied_patches_info.textures_patch_hashsum = "";
|
|
|
+ } else if (patch == "font") {
|
|
|
+ _current_applied_patches_info.fonts_patch_hashsum = "";
|
|
|
+ } else if (patch == "video") {
|
|
|
+ _current_applied_patches_info.videos_patch_hashsum = "";
|
|
|
+ } else if (patch == "loadscreen") {
|
|
|
+ _current_applied_patches_info.loadscreens_patch_hashsum = "";
|
|
|
+ }
|
|
|
+
|
|
|
qDebug() << "Skipping patch " << patch << " because its disabled";
|
|
|
continue;
|
|
|
}
|
|
@@ -470,6 +426,10 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
hashsum_in_dat_file = _current_applied_patches_info.textures_patch_hashsum;
|
|
|
} else if (patch == "font") {
|
|
|
hashsum_in_dat_file = _current_applied_patches_info.fonts_patch_hashsum;
|
|
|
+ } else if (patch == "video") {
|
|
|
+ hashsum_in_dat_file = _current_applied_patches_info.videos_patch_hashsum;
|
|
|
+ } else if (patch == "loadscreen") {
|
|
|
+ hashsum_in_dat_file = _current_applied_patches_info.loadscreens_patch_hashsum;
|
|
|
}
|
|
|
|
|
|
if (patch_hashsum == hashsum_in_dat_file) {
|
|
@@ -500,6 +460,7 @@ void PatchInstaller::startPatchInstallationChain() {
|
|
|
delete patch_databases[patch_name];
|
|
|
}
|
|
|
|
|
|
+ insertPatchesInfoInDatFile(_current_applied_patches_info);
|
|
|
qInfo() << "PatchInstaller: Finished installation chain...";
|
|
|
emit finished();
|
|
|
}
|