|
@@ -247,10 +247,24 @@ namespace LOTRO_DAT {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if (data.options["cat"].IsDefined())
|
|
|
|
|
|
+ // If file has inactive category, then we should set it to patched state in order to commit patch and
|
|
|
|
+ // then in ApplyFilePatch(), if new category is still inactive, return dictionary to its original state;
|
|
|
|
+
|
|
|
|
+ if (inactive_categories.count(file->category) != 0 && patch_dict_.count(file_id) != 0) {
|
|
|
|
+ dictionary_[file_id]->file_offset_ = patch_dict_[file_id]->file_offset_;
|
|
|
|
+ dictionary_[file_id]->file_size_ = patch_dict_[file_id]->file_size_;
|
|
|
|
+ dictionary_[file_id]->block_size_ = patch_dict_[file_id]->block_size_;
|
|
|
|
+ dictionary_[file_id]->timestamp_ = patch_dict_[file_id]->timestamp_;
|
|
|
|
+ dictionary_[file_id]->version_ = patch_dict_[file_id]->version_;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (data.options["cat"].IsDefined()) {
|
|
file->category = data.options["cat"].as<long long>();
|
|
file->category = data.options["cat"].as<long long>();
|
|
- else
|
|
|
|
- fprintf(stderr, "WARNING DatFile::PatchFile() - category option 'cat' was not set in patch subfile with id = %lld\n", file_id);
|
|
|
|
|
|
+ } else {
|
|
|
|
+ fprintf(stderr, "WARNING DatFile::PatchFile() - category option 'cat' was not "
|
|
|
|
+ "set in patch subfile with id = %lld. Setting it to 1\n", file_id);
|
|
|
|
+ file->category = 1;
|
|
|
|
+ }
|
|
|
|
|
|
BinaryData old_data = GetFileData(file);
|
|
BinaryData old_data = GetFileData(file);
|
|
BinaryData patch_data = file->MakeForImport(old_data, data);
|
|
BinaryData patch_data = file->MakeForImport(old_data, data);
|
|
@@ -468,18 +482,20 @@ namespace LOTRO_DAT {
|
|
/// Special functions used by patch process.
|
|
/// Special functions used by patch process.
|
|
/// Shouldn't be used by any external class.
|
|
/// Shouldn't be used by any external class.
|
|
void DatFile::ApplyFilePatch(Subfile *file, const BinaryData &data, bool rewrite_original) {
|
|
void DatFile::ApplyFilePatch(Subfile *file, const BinaryData &data, bool rewrite_original) {
|
|
- if (patched_list.count(file->file_id()) != 0) {
|
|
|
|
|
|
+ auto file_id = file->file_id();
|
|
|
|
+ if (patched_list.count(file_id) != 0) {
|
|
fprintf(stderr, "Warning: DatFile::ApplyFilePatch - found 2 files in patch with the same file_id = %lld. Passing last...\n", file->file_id());
|
|
fprintf(stderr, "Warning: DatFile::ApplyFilePatch - found 2 files in patch with the same file_id = %lld. Passing last...\n", file->file_id());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
if (current_locale() != PATCHED && !rewrite_original) {
|
|
if (current_locale() != PATCHED && !rewrite_original) {
|
|
std::cout << "Changing locale to RU in order to patch file" << std::endl;
|
|
std::cout << "Changing locale to RU in order to patch file" << std::endl;
|
|
SetLocale(PATCHED);
|
|
SetLocale(PATCHED);
|
|
}
|
|
}
|
|
dat_state_ = UPDATED;
|
|
dat_state_ = UPDATED;
|
|
|
|
|
|
- if (orig_dict_.count(file->file_id()) == 0 && !rewrite_original) {
|
|
|
|
- orig_dict_[file->file_id()] = new Subfile(this, file->MakeHeaderData());
|
|
|
|
|
|
+ if (orig_dict_.count(file_id) == 0 && !rewrite_original) {
|
|
|
|
+ orig_dict_[file_id] = new Subfile(this, file->MakeHeaderData());
|
|
}
|
|
}
|
|
|
|
|
|
auto journal = GetFragmentationJournal();
|
|
auto journal = GetFragmentationJournal();
|
|
@@ -489,7 +505,7 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
file->file_size_ = data.size() - 8;
|
|
file->file_size_ = data.size() - 8;
|
|
|
|
|
|
- if ((patch_dict_.count(file->file_id()) == 0 && !rewrite_original) || data.size() > file->block_size()) {
|
|
|
|
|
|
+ if ((patch_dict_.count(file_id) == 0 && !rewrite_original) || data.size() > file->block_size()) {
|
|
file->file_offset_ = journal[0].second;
|
|
file->file_offset_ = journal[0].second;
|
|
file->block_size_ = std::max(data.size(), 256u);
|
|
file->block_size_ = std::max(data.size(), 256u);
|
|
|
|
|
|
@@ -506,13 +522,12 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
BinaryData file_data = fragments_count + data.CutData(4);
|
|
BinaryData file_data = fragments_count + data.CutData(4);
|
|
|
|
|
|
- if (file->file_id() != file_data.ToNumber<4>(8))
|
|
|
|
|
|
+ if (file_id != file_data.ToNumber<4>(8))
|
|
throw DatException("Bad DatFile::ApplyFilePatch() - Created data's file_id doesn't match to original! "
|
|
throw DatException("Bad DatFile::ApplyFilePatch() - Created data's file_id doesn't match to original! "
|
|
"Patch wasn't written to .dat file");
|
|
"Patch wasn't written to .dat file");
|
|
|
|
|
|
WriteData(file_data, file_data.size(), file->file_offset());
|
|
WriteData(file_data, file_data.size(), file->file_offset());
|
|
|
|
|
|
- auto file_id = file->file_id();
|
|
|
|
patched_list.insert(file_id);
|
|
patched_list.insert(file_id);
|
|
|
|
|
|
if (!rewrite_original) {
|
|
if (!rewrite_original) {
|