|
@@ -57,15 +57,14 @@ namespace LOTRO_DAT {
|
|
|
}
|
|
|
|
|
|
BinaryData locale_dict_offset_data(4);
|
|
|
- dat->GetIO().ReadData(locale_dict_offset_data, 4, 300);
|
|
|
+ dat->GetIO().ReadData(locale_dict_offset_data, 4, 0x12C);
|
|
|
dict_offset_ = locale_dict_offset_data.ToNumber<4>(0);
|
|
|
|
|
|
BinaryData locale_info(16);
|
|
|
auto operation = dat->GetIO().ReadData(locale_info, 16, dict_offset_);
|
|
|
if (!operation.result) {
|
|
|
- dict_offset_ = 0;
|
|
|
- dict_size_ = 0;
|
|
|
- LOG(WARNING) << "LOCALEINIT: Locale offset is incorrect, skipping initialization.";
|
|
|
+ ClearData();
|
|
|
+ LOG(INFO) << "LOCALEINIT: Locale offset is incorrect, skipping initialization.";
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
|
}
|
|
|
|
|
@@ -75,15 +74,13 @@ namespace LOTRO_DAT {
|
|
|
long long dat_file_header_hash = locale_info.ToNumber<4>(12);
|
|
|
|
|
|
if (dict_version != DAT_LOCALE_DICT_VERSION) {
|
|
|
- dict_offset_ = 0;
|
|
|
- dict_size_ = 0;
|
|
|
+ ClearData();
|
|
|
LOG(WARNING) << "LOCALEINIT: Locale dictionary version is outdated, skipping initialization.";
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
|
}
|
|
|
|
|
|
if (dat_file_header_hash != dat->GetIO().GetHeaderHash()) {
|
|
|
- dict_offset_ = 0;
|
|
|
- dict_size_ = 0;
|
|
|
+ ClearData();
|
|
|
LOG(WARNING) << "LOCALEINIT: Locale header hash does not match real dat file header hash, skipping initialization.";
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
|
}
|
|
@@ -94,8 +91,7 @@ namespace LOTRO_DAT {
|
|
|
BinaryData hi_data = dicts_data.CutData(0, 15) + BinaryData("\0", 1);
|
|
|
std::string hi = std::string((char *) (hi_data.data()));
|
|
|
if (hi != "Hi from Gi1dor!") {
|
|
|
- dict_offset_ = 0;
|
|
|
- dict_size_ = 0;
|
|
|
+ ClearData();
|
|
|
LOG(WARNING) << "LOCALEINIT: couldn't receive Hello, skipping initialization.";
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
|
}
|
|
@@ -104,8 +100,7 @@ namespace LOTRO_DAT {
|
|
|
BinaryData current_locale_data = dicts_data.CutData(offset, offset + 4) + BinaryData("\0", 1);
|
|
|
std::string locale((char *) (current_locale_data.data()));
|
|
|
if (locale != "PATC" && locale != "ORIG") {
|
|
|
- dict_offset_ = 0;
|
|
|
- dict_size_ = 0;
|
|
|
+ ClearData();
|
|
|
LOG(WARNING) << "LOCALEINIT: locale status in dict seems incorrect, skipping initialization.";
|
|
|
return DatOperationResult<>(SUCCESS);
|
|
|
}
|
|
@@ -143,7 +138,7 @@ namespace LOTRO_DAT {
|
|
|
LOG(INFO) << "There are " << patch_dict_.size() << " files in patch locale dictionary";
|
|
|
LOG(INFO) << "There are " << orig_dict_.size() << " files in original locale dictionary";
|
|
|
LOG(INFO) << "There are " << inactive_categories.size() << " categories inactive: ";
|
|
|
- LOG(INFO) << "Finished initialising locales";
|
|
|
+ LOG(INFO) << "Successfully finished initialising locales!";
|
|
|
|
|
|
dat->GetFileSystem().patched_file_end = patched_file_end;
|
|
|
LOG(INFO) << "Locales initialisation success. Dictionary size is " << dict_size_ << ". Version is "
|
|
@@ -160,16 +155,15 @@ namespace LOTRO_DAT {
|
|
|
*/
|
|
|
|
|
|
DatOperationResult<> DatLocaleManager::SetLocale(DatLocaleManager::LOCALE locale) {
|
|
|
- if (dat->GetStatusModule().GetStatus() == DatStatus::E_FREE)
|
|
|
+ if (dat->GetStatusModule().GetStatus() == DatStatus::E_FREE) {
|
|
|
dat->GetStatusModule().SetStatus(DatStatus::E_COMMITING);
|
|
|
+ }
|
|
|
|
|
|
dat->GetStatusModule().SetDebugMessage("Changing locale to " +
|
|
|
(locale == PATCHED ? std::string(" patched version")
|
|
|
: std::string(" original version")));
|
|
|
|
|
|
LOG(INFO) << "Setting locale to " << (locale == PATCHED ? " PATCHED" : " ORIGINAL");
|
|
|
- if (!dat)
|
|
|
- return DatOperationResult<>(ERROR, "SETLOCALE: no connection with Dat (dat is nullptr)");
|
|
|
|
|
|
if (current_locale_ == locale) {
|
|
|
LOG(INFO) << "Locale is already " << locale << ", nothing to do.";
|
|
@@ -237,9 +231,6 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
DatOperationResult<> DatLocaleManager::DeInit() {
|
|
|
LOG(INFO) << "Committing locales...";
|
|
|
- if (!dat)
|
|
|
- return DatOperationResult<>(ERROR, "LOCALEDEINIT: no connection with Dat (dat is nullptr)");
|
|
|
-
|
|
|
auto result = CommitLocales();
|
|
|
ClearData();
|
|
|
return result;
|
|
@@ -340,7 +331,7 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
bool DatLocaleManager::CheckLocaleCorrect() {
|
|
|
BinaryData patch_mark_data(4);
|
|
|
- dat->GetIO().ReadData(patch_mark_data, 4, 296);
|
|
|
+ dat->GetIO().ReadData(patch_mark_data, 4, 0x128);
|
|
|
uint32_t patch_mark = patch_mark_data.ToNumber<4>(0);
|
|
|
|
|
|
BinaryData locale_offset_data(4);
|
|
@@ -365,10 +356,17 @@ namespace LOTRO_DAT {
|
|
|
}
|
|
|
|
|
|
if (patch_mark == 1) {
|
|
|
- LOG(INFO) << "CHCKLOCALECORRECT: Patch mark is original, so skipping dat locale dict correctness check";
|
|
|
+ LOG(INFO) << "CHCKLOCALECORRECT: Header is fine, patch mark is original, so skipping dat locale dict correctness check";
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ if (patch_mark != 2) {
|
|
|
+ LOG(INFO) << "CHCKLOCALECORRECT: Patch mark is invalid! Found " << patch_mark << ", expected: 0, 1 or 2!";
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
BinaryData locale_dict_header(16 + 15 + 4);
|
|
|
auto operation = dat->GetIO().ReadData(locale_dict_header, 16 + 15 + 4, locale_offset);
|
|
|
|
|
@@ -386,19 +384,12 @@ namespace LOTRO_DAT {
|
|
|
std::string locale_string = std::string((char *) (current_locale_data.data()));
|
|
|
|
|
|
if (dict_version != DAT_LOCALE_DICT_VERSION) {
|
|
|
- LOG(ERROR) << "CHCKLOCALECORRECT: Locale dict version is incorrect:" << dict_version << " expected: " << DAT_LOCALE_DICT_VERSION;
|
|
|
- return false;
|
|
|
- }
|
|
|
-
|
|
|
- if (locale_string != "PATC" && locale_string != "ORIG" && patch_mark != 2) {
|
|
|
- LOG(ERROR) << "CHCKLOCALECORRECT: Data in locales' dictionary is incorrect (current locale mark is invalid)." << locale_string;
|
|
|
+ LOG(ERROR) << "CHCKLOCALECORRECT: Locale dict version is incorrect, through patch mark shows, that file was patched. Found version:" << dict_version << " expected: " << DAT_LOCALE_DICT_VERSION;
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- LOCALE file_locale = (locale_string == "PATC" ? PATCHED : ORIGINAL);
|
|
|
-
|
|
|
- if ((file_locale == ORIGINAL && patch_mark != 1) || (file_locale == PATCHED && patch_mark != 2)) {
|
|
|
- LOG(ERROR) << "CHCKLOCALECORRECT: Locale from dictionary does not match patch mark in header!";
|
|
|
+ if (locale_string != "PATC") {
|
|
|
+ LOG(ERROR) << "CHCKLOCALECORRECT: Data in locales' dictionary is incorrect (dictionary locale mark is invalid). Found: " << locale_string << " expected: PATC";
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -412,7 +403,7 @@ namespace LOTRO_DAT {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- LOG(INFO) << "CHCKLOCALECORRECT: All checks passed successfully, no critical errors found!";
|
|
|
+ LOG(INFO) << "CHCKLOCALECORRECT: All checks passed successfully, no errors found!";
|
|
|
return true;
|
|
|
}
|
|
|
|
|
@@ -593,6 +584,8 @@ namespace LOTRO_DAT {
|
|
|
}
|
|
|
|
|
|
void DatLocaleManager::ClearData() {
|
|
|
+ dict_size_ = 0;
|
|
|
+ dict_offset_ = 0;
|
|
|
orig_dict_.clear();
|
|
|
patch_dict_.clear();
|
|
|
inactive_categories.clear();
|