|
@@ -19,12 +19,15 @@ namespace LOTRO_DAT {
|
|
DatOperationResult<> DatPatcher::PatchFile(const SubfileData &data) {
|
|
DatOperationResult<> DatPatcher::PatchFile(const SubfileData &data) {
|
|
auto file_id = data.options["fid"].as<long long>();
|
|
auto file_id = data.options["fid"].as<long long>();
|
|
|
|
|
|
|
|
+ dat->GetStatusModule().UpdateStatusText("Применение патча");
|
|
|
|
+ dat->GetStatusModule().UpdateAdditionalMessage("Применение файла " + std::to_string(file_id));
|
|
|
|
+
|
|
auto getfile_operation = dat->GetFileSystem().GetFile(file_id);
|
|
auto getfile_operation = dat->GetFileSystem().GetFile(file_id);
|
|
if (getfile_operation.result == ERROR)
|
|
if (getfile_operation.result == ERROR)
|
|
return DatOperationResult<>(ERROR,
|
|
return DatOperationResult<>(ERROR,
|
|
"PATCHSUBFILEDATA: Unable to find file with id " + std::to_string(file_id));
|
|
"PATCHSUBFILEDATA: Unable to find file with id " + std::to_string(file_id));
|
|
|
|
|
|
- auto& file = getfile_operation.value;
|
|
|
|
|
|
+ auto &file = getfile_operation.value;
|
|
|
|
|
|
// If file has inactive category, then we should set it to patched state in order to commit patch and
|
|
// If file has inactive category, then we should set it to patched state in order to commit patch and
|
|
// then in ApplyFilePatch() function, if new category is still inactive, return dictionary to its original state;
|
|
// then in ApplyFilePatch() function, if new category is still inactive, return dictionary to its original state;
|
|
@@ -44,7 +47,7 @@ namespace LOTRO_DAT {
|
|
if (getdata_operation.result == ERROR)
|
|
if (getdata_operation.result == ERROR)
|
|
return DatOperationResult<>(ERROR,
|
|
return DatOperationResult<>(ERROR,
|
|
"PATCHSUBFILEDATA: can't get file data for id = " + std::to_string(file_id));
|
|
"PATCHSUBFILEDATA: can't get file data for id = " + std::to_string(file_id));
|
|
- auto& file_data = getdata_operation.value;
|
|
|
|
|
|
+ auto &file_data = getdata_operation.value;
|
|
|
|
|
|
BinaryData patch_data = file->MakeForImport(file_data, data);
|
|
BinaryData patch_data = file->MakeForImport(file_data, data);
|
|
|
|
|
|
@@ -53,6 +56,8 @@ namespace LOTRO_DAT {
|
|
return DatOperationResult<>(ERROR,
|
|
return DatOperationResult<>(ERROR,
|
|
"PATCHSUBFILEDATA: applyfilepatch failed for id = " + std::to_string(file_id));
|
|
"PATCHSUBFILEDATA: applyfilepatch failed for id = " + std::to_string(file_id));
|
|
|
|
|
|
|
|
+ dat->GetStatusModule().UpdateAdditionalMessage("Применение файла " + std::to_string(file_id) + " завершено");
|
|
|
|
+
|
|
return DatOperationResult<>(SUCCESS);
|
|
return DatOperationResult<>(SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -69,19 +74,30 @@ namespace LOTRO_DAT {
|
|
if (!db)
|
|
if (!db)
|
|
return DatOperationResult<int>(0, ERROR, "PATCHALLDATABASE: db is nullptr");
|
|
return DatOperationResult<int>(0, ERROR, "PATCHALLDATABASE: db is nullptr");
|
|
|
|
|
|
|
|
+ dat->GetStatusModule().UpdateStatusText("Применение патча");
|
|
|
|
+
|
|
SubfileData data;
|
|
SubfileData data;
|
|
data = db->GetNextFile();
|
|
data = db->GetNextFile();
|
|
|
|
|
|
int successfully_patched = 0;
|
|
int successfully_patched = 0;
|
|
|
|
+ unsigned db_rows = db->CountRows();
|
|
|
|
|
|
- while (!data.Empty()) {
|
|
|
|
|
|
+ for (unsigned i = 0; i < db_rows; ++i) {
|
|
auto operation = PatchFile(data);
|
|
auto operation = PatchFile(data);
|
|
if (operation.result == SUCCESS)
|
|
if (operation.result == SUCCESS)
|
|
successfully_patched++;
|
|
successfully_patched++;
|
|
|
|
|
|
|
|
+ if (dat->GetStatusModule().GetPercentage() != i * 100 / db_rows)
|
|
|
|
+ dat->GetStatusModule().UpdatePercentage(i * 100 / db_rows);
|
|
|
|
+
|
|
data = db->GetNextFile();
|
|
data = db->GetNextFile();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ dat->GetStatusModule().RemoveStatusText();
|
|
|
|
+ dat->GetStatusModule().UpdateAdditionalMessage("Применение патча закончено. Успешно применено " +
|
|
|
|
+ std::to_string(successfully_patched) + " из " +
|
|
|
|
+ std::to_string(db_rows) + " файлов");
|
|
|
|
+
|
|
LOG(INFO) << "Successfully patched whole database";
|
|
LOG(INFO) << "Successfully patched whole database";
|
|
return DatOperationResult<int>(successfully_patched, SUCCESS);
|
|
return DatOperationResult<int>(successfully_patched, SUCCESS);
|
|
}
|
|
}
|
|
@@ -104,7 +120,7 @@ namespace LOTRO_DAT {
|
|
dat->GetLocaleManager().SetLocale(DatLocaleManager::PATCHED);
|
|
dat->GetLocaleManager().SetLocale(DatLocaleManager::PATCHED);
|
|
}
|
|
}
|
|
|
|
|
|
- LOG(INFO) << "Patching file with id = " << file_id;
|
|
|
|
|
|
+ //LOG(INFO) << "Patching file with id = " << file_id;
|
|
|
|
|
|
if (dat->GetLocaleManager().GetLocaleFile(file_id, DatLocaleManager::ORIGINAL).result == ERROR)
|
|
if (dat->GetLocaleManager().GetLocaleFile(file_id, DatLocaleManager::ORIGINAL).result == ERROR)
|
|
dat->GetLocaleManager().UpdateLocaleFile(DatLocaleManager::ORIGINAL, SubFile(*file));
|
|
dat->GetLocaleManager().UpdateLocaleFile(DatLocaleManager::ORIGINAL, SubFile(*file));
|
|
@@ -125,11 +141,13 @@ namespace LOTRO_DAT {
|
|
data.Append(BinaryData::FromNumber<4>(0), 0); // set additional fragments count to zero
|
|
data.Append(BinaryData::FromNumber<4>(0), 0); // set additional fragments count to zero
|
|
|
|
|
|
if (file_id != data.ToNumber<4>(8))
|
|
if (file_id != data.ToNumber<4>(8))
|
|
- LOG(WARNING) << "Created data's file_id " << file_id << "doesn't match to original: " << data.ToNumber<4>(8);
|
|
|
|
|
|
+ LOG(WARNING) << "Created data's file_id " << file_id << "doesn't match to original: "
|
|
|
|
+ << data.ToNumber<4>(8);
|
|
|
|
|
|
auto operation = dat->GetIO().WriteData(data, data.size(), new_file.file_offset());
|
|
auto operation = dat->GetIO().WriteData(data, data.size(), new_file.file_offset());
|
|
if (operation.result == ERROR)
|
|
if (operation.result == ERROR)
|
|
- return DatOperationResult<>(ERROR, "APPLYPATCHFILE: Unable to write data for file with id " + std::to_string(file_id));
|
|
|
|
|
|
+ return DatOperationResult<>(ERROR, "APPLYPATCHFILE: Unable to write data for file with id " +
|
|
|
|
+ std::to_string(file_id));
|
|
|
|
|
|
|
|
|
|
dat->GetFileSystem().UpdateFileInfo(new_file);
|
|
dat->GetFileSystem().UpdateFileInfo(new_file);
|
|
@@ -138,10 +156,11 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
// If file category is inactive, then return file header data in dictionary to original state
|
|
// If file category is inactive, then return file header data in dictionary to original state
|
|
if (dat->GetLocaleManager().CategoryIsInactive(new_file.category))
|
|
if (dat->GetLocaleManager().CategoryIsInactive(new_file.category))
|
|
- dat->GetFileSystem().UpdateFileInfo(dat->GetLocaleManager().GetLocaleFile(file_id, DatLocaleManager::ORIGINAL).value);
|
|
|
|
|
|
+ dat->GetFileSystem().UpdateFileInfo(
|
|
|
|
+ dat->GetLocaleManager().GetLocaleFile(file_id, DatLocaleManager::ORIGINAL).value);
|
|
|
|
|
|
dat->GetLocaleManager().UpdateCategory(file_id, new_file.category);
|
|
dat->GetLocaleManager().UpdateCategory(file_id, new_file.category);
|
|
- LOG(INFO) << "Successfully patched file with id = " << file_id;
|
|
|
|
|
|
+ //LOG(INFO) << "Successfully patched file with id = " << file_id;
|
|
|
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
return DatOperationResult<>(SUCCESS);
|
|
}
|
|
}
|