Browse Source

Added support for video change locale

Ivan Arkhipov 4 years ago
parent
commit
ad04550188
1 changed files with 23 additions and 20 deletions
  1. 23 20
      src/Legacy/models/patchinstaller.cpp

+ 23 - 20
src/Legacy/models/patchinstaller.cpp

@@ -68,21 +68,15 @@ PatchInstaller::AppliedPatchesInfo PatchInstaller::getPatchesInfo() {
 }
 
 void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* database) {
-    if (patch_name == "loadscreen") {
-        installLoadscreens(database);
-        return;
-    }
-
-    if (patch_name == "video") {
-        installVideos(database);
-        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;
     while (!(file = database->GetNextFile()).Empty()) {
+        if (!file.options["fid"]) {
+            continue;
+        }
 
         current_status.finished_parts++;
         if (current_status.finished_parts * 100 / current_status.total_parts !=
@@ -91,10 +85,6 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
             emit progressChanged(current_status);
         }
 
-        if (!file.options["fid"]) {
-            continue;
-        }
-
         const int dat_id = file.options["did"] ? file.options["did"].as<int>() : E_CLIENT_LOCAL;
         if (dat_id != E_CLIENT_LOCAL && dat_id != E_CLIENT_GENERAL) {
             qWarning() << "Unknown dat id parameter for file " << file.options["fid"].as<long long>() << " (dat id value = " << dat_id << "), SKIPPING!";
@@ -129,22 +119,33 @@ void PatchInstaller::installPatch(QString patch_name, LOTRO_DAT::Database* datab
             client_general_file_->PatchFile(file, _patch_files_versions);
         }
     }
-    _current_applied_patches_info.has_no_patch_mark = false;
     const QString hashsum = Settings::getValue("PatchDatabases/" + patch_name + "/hashsum").toString();
     if (patch_name == "text") {
+        _current_applied_patches_info.has_no_patch_mark = false;
         _current_applied_patches_info.texts_patch_hashsum = hashsum;
     } else if (patch_name == "image") {
+        _current_applied_patches_info.has_no_patch_mark = false;
         _current_applied_patches_info.images_patch_hashsum = hashsum;
     } else if (patch_name == "sound") {
+        _current_applied_patches_info.has_no_patch_mark = false;
         _current_applied_patches_info.sounds_patch_hashsum = hashsum;
-    } else if (patch_name == "texture") {
-        _current_applied_patches_info.textures_patch_hashsum = hashsum;
     } else if (patch_name == "font") {
+        _current_applied_patches_info.has_no_patch_mark = false;
         _current_applied_patches_info.fonts_patch_hashsum = hashsum;
-    } else if (patch_name == "video") {
-        _current_applied_patches_info.videos_patch_hashsum = hashsum;
+    } else if (patch_name == "texture") {
+        _current_applied_patches_info.has_no_patch_mark = false;
+        _current_applied_patches_info.textures_patch_hashsum = hashsum;
     }
     orig_files_db.closeDatabase();
+    if (patch_name == "video") {
+        installVideos(database);
+    }
+
+    if (patch_name == "loadscreen") {
+        installLoadscreens(database);
+        return;
+    }
+
     insertPatchesInfoInDatFile(_current_applied_patches_info);
     return;
 }
@@ -219,6 +220,10 @@ void PatchInstaller::installLoadscreens(LOTRO_DAT::Database* database) {
 
     for (size_t i = 0; i < qMin(size_t(loadscreens_filenames.size()), database->CountRows()); ++i) {
         data = database->GetNextFile();
+        if (data.options["did"].as<int>() != -1) {
+            continue;
+        }
+
         QFile::remove(logo_path + loadscreens_filenames[i]);
 
         if (!data.binary_data.WriteToFile((logo_path + loadscreens_filenames[i]).toLocal8Bit())) {
@@ -239,7 +244,6 @@ void PatchInstaller::installLoadscreens(LOTRO_DAT::Database* database) {
 }
 
 void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
-
     current_status.finished_parts += database->CountRows();
     emit progressChanged(current_status);
 
@@ -249,7 +253,6 @@ void PatchInstaller::installVideos(LOTRO_DAT::Database* database) {
     LOTRO_DAT::SubfileData file;
     while (!(file = database->GetNextFile()).Empty()) {
         if (!file.options["name"] || !file.options["url"] || !file.options["hash"] || !file.options["folder"]) {
-            download_video_finished_videos++;
             continue;
         }