|
@@ -69,9 +69,9 @@ namespace LOTRO_DAT {
|
|
}
|
|
}
|
|
|
|
|
|
dict_size_ = locale_info.ToNumber<4>(0);
|
|
dict_size_ = locale_info.ToNumber<4>(0);
|
|
- long long dict_version = locale_info.ToNumber<4>(4);
|
|
|
|
- long long patched_file_end = locale_info.ToNumber<4>(8);
|
|
|
|
- long long dat_file_header_hash = locale_info.ToNumber<4>(12);
|
|
|
|
|
|
+ unsigned dict_version = locale_info.ToNumber<4>(4);
|
|
|
|
+ unsigned patched_file_end = locale_info.ToNumber<4>(8);
|
|
|
|
+ unsigned dat_file_header_hash = locale_info.ToNumber<4>(12);
|
|
|
|
|
|
if (dict_version != DAT_LOCALE_DICT_VERSION) {
|
|
if (dict_version != DAT_LOCALE_DICT_VERSION) {
|
|
ClearData();
|
|
ClearData();
|
|
@@ -531,51 +531,29 @@ namespace LOTRO_DAT {
|
|
current_size += 4;
|
|
current_size += 4;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // Updating dict offset, if current does not match prerequisites
|
|
if (binary_data.size() > dict_size_ || dict_offset_ == 0) {
|
|
if (binary_data.size() > dict_size_ || dict_offset_ == 0) {
|
|
- long long new_dict_offset = dat->GetFileSystem().patched_file_end + 16;
|
|
|
|
-
|
|
|
|
- // Updating first 16 bytes
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(std::max(binary_data.size() + 4, 20u * 1024u * 1024u)), 0);
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(DAT_LOCALE_DICT_VERSION), 4);
|
|
|
|
- binary_data.Append(
|
|
|
|
- BinaryData::FromNumber<4>(dat->GetFileSystem().patched_file_end + binary_data.size() + 20 * 1024 * 1024), 8);
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(dat->GetIO().GetHeaderHash()), 12);
|
|
|
|
- auto operation = dat->GetIO().WriteData(binary_data, binary_data.size(), new_dict_offset);
|
|
|
|
- if (operation.result != SUCCESS) {
|
|
|
|
- return DatOperationResult<>(ERROR, "LOCALEDEINIT: Cannot write locales");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- dat->GetIO().WriteData(BinaryData::FromNumber<4>(new_dict_offset), 4, 300);
|
|
|
|
-
|
|
|
|
- if (current_locale_ == ORIGINAL) {
|
|
|
|
- dat->GetIO().WriteData(BinaryData::FromNumber<4>(1), 4, 296);
|
|
|
|
- } else {
|
|
|
|
- dat->GetIO().WriteData(BinaryData::FromNumber<4>(2), 4, 296);
|
|
|
|
- }
|
|
|
|
- dat->GetFileSystem().patched_file_end += binary_data.size();
|
|
|
|
-
|
|
|
|
- LOG(INFO) << "Writing 20 mbytes to " << dat->GetFileSystem().patched_file_end;
|
|
|
|
|
|
+ dict_offset_ = dat->GetFileSystem().patched_file_end;
|
|
|
|
+ dict_size_ = std::max(binary_data.size() + 4, 20u * 1024u * 1024u);
|
|
|
|
|
|
- BinaryData nulls(unsigned(20 * 1024 * 1024));
|
|
|
|
|
|
+ BinaryData nulls(dict_size_);
|
|
dat->GetIO().WriteData(nulls, nulls.size(), dat->GetFileSystem().patched_file_end);
|
|
dat->GetIO().WriteData(nulls, nulls.size(), dat->GetFileSystem().patched_file_end);
|
|
dat->GetFileSystem().patched_file_end += nulls.size();
|
|
dat->GetFileSystem().patched_file_end += nulls.size();
|
|
- } else {
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(std::max(binary_data.size() + 4, 20u * 1024u * 1024u)), 0);
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(DAT_LOCALE_DICT_VERSION), 4);
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(dat->GetFileSystem().patched_file_end), 8);
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(dat->GetIO().GetHeaderHash()), 12);
|
|
|
|
-
|
|
|
|
- if (current_locale_ == ORIGINAL) {
|
|
|
|
- dat->GetIO().WriteData(BinaryData::FromNumber<4>(1), 4, 296);
|
|
|
|
- } else {
|
|
|
|
- dat->GetIO().WriteData(BinaryData::FromNumber<4>(2), 4, 296);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+ dat->GetIO().WriteData(BinaryData::FromNumber<4>(dict_offset_), 4, 0x12C);
|
|
|
|
+ }
|
|
|
|
|
|
- auto operation = dat->GetIO().WriteData(binary_data, binary_data.size(), dict_offset_);
|
|
|
|
|
|
+ // Updating first 16 bytes
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(dict_size_), 0);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(DAT_LOCALE_DICT_VERSION), 4);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(dat->GetFileSystem().patched_file_end), 8);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(dat->GetIO().GetHeaderHash()), 12);
|
|
|
|
+ auto operation = dat->GetIO().WriteData(binary_data, binary_data.size(), dict_offset_);
|
|
|
|
|
|
- if (operation.result != SUCCESS) {
|
|
|
|
- return DatOperationResult<>(ERROR, "LOCALEDEINIT: Cannot write locales. ERRMSG: " + operation.msg);
|
|
|
|
- }
|
|
|
|
|
|
+ if (current_locale_ == ORIGINAL) {
|
|
|
|
+ dat->GetIO().WriteData(BinaryData::FromNumber<4>(1), 4, 296);
|
|
|
|
+ } else {
|
|
|
|
+ dat->GetIO().WriteData(BinaryData::FromNumber<4>(2), 4, 296);
|
|
}
|
|
}
|
|
|
|
|
|
dat->GetStatusModule().SetDefaultStatus();
|
|
dat->GetStatusModule().SetDefaultStatus();
|