|
@@ -23,7 +23,7 @@ namespace LOTRO_DAT {
|
|
* 4 bytes for locale version
|
|
* 4 bytes for locale version
|
|
* 4 bytes for .dat file size (with patches)
|
|
* 4 bytes for .dat file size (with patches)
|
|
* 15 bytes for "Hi from Gi1dor"
|
|
* 15 bytes for "Hi from Gi1dor"
|
|
- * 4 bytes for LOCALE
|
|
|
|
|
|
+ * 4 bytes for LOCALE mark ("PATC" or "ORIG")
|
|
* 4 bytes for orig_dict.size()
|
|
* 4 bytes for orig_dict.size()
|
|
* (32 + 4) * orig_dict.size() bytes for orig_dict data
|
|
* (32 + 4) * orig_dict.size() bytes for orig_dict data
|
|
* 4 bytes for patch_dict.size()
|
|
* 4 bytes for patch_dict.size()
|
|
@@ -62,9 +62,6 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
long long dict_size = locale_info.ToNumber<4>(0);
|
|
long long dict_size = locale_info.ToNumber<4>(0);
|
|
long long dict_version = locale_info.ToNumber<4>(4);
|
|
long long dict_version = locale_info.ToNumber<4>(4);
|
|
- dat->getIO().file_size = locale_info.ToNumber<4>(8);
|
|
|
|
-
|
|
|
|
- LOG(INFO) << "Dictionary size is " << dict_size << ". Version is " << dict_version << ". Localed .dat size = " << dat->getIO().file_size;
|
|
|
|
|
|
|
|
if (dict_version != 101) {
|
|
if (dict_version != 101) {
|
|
dat->getIO().WriteData(BinaryData::FromNumber<4>(0), 4, 300);
|
|
dat->getIO().WriteData(BinaryData::FromNumber<4>(0), 4, 300);
|
|
@@ -112,7 +109,7 @@ namespace LOTRO_DAT {
|
|
for (size_t i = 0; i < patch_dict_size; i++) {
|
|
for (size_t i = 0; i < patch_dict_size; i++) {
|
|
auto file = SubFile(*dat, dicts_data.CutData(offset, offset + 32));
|
|
auto file = SubFile(*dat, dicts_data.CutData(offset, offset + 32));
|
|
file.category = dicts_data.ToNumber<4>(offset);
|
|
file.category = dicts_data.ToNumber<4>(offset);
|
|
- orig_dict_[file.file_id()] = file;
|
|
|
|
|
|
+ patch_dict_[file.file_id()] = file;
|
|
offset += 36;
|
|
offset += 36;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -120,9 +117,11 @@ namespace LOTRO_DAT {
|
|
LOG(INFO) << "There are " << orig_dict_.size() << " files in original locale dictionary";
|
|
LOG(INFO) << "There are " << orig_dict_.size() << " files in original locale dictionary";
|
|
LOG(INFO) << "Finished initialising locales";
|
|
LOG(INFO) << "Finished initialising locales";
|
|
|
|
|
|
- if (CheckLocaleCorrect())
|
|
|
|
|
|
+ if (CheckLocaleCorrect()) {
|
|
|
|
+ dat->getIO().file_size = locale_info.ToNumber<4>(8);
|
|
|
|
+ LOG(INFO) << "Locales initialisation success. Dictionary size is " << dict_size << ". Version is " << dict_version << ". Localed .dat size = " << dat->getIO().file_size;
|
|
return DatOperationResult<>(SUCCESS);
|
|
return DatOperationResult<>(SUCCESS);
|
|
- else
|
|
|
|
|
|
+ } else
|
|
return DatOperationResult<>(ERROR, "Locale dict is incorrect, through patched mark is standing. Dat file may be corrupted");
|
|
return DatOperationResult<>(ERROR, "Locale dict is incorrect, through patched mark is standing. Dat file may be corrupted");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -145,7 +144,7 @@ namespace LOTRO_DAT {
|
|
return DatOperationResult<>(SUCCESS);
|
|
return DatOperationResult<>(SUCCESS);
|
|
}
|
|
}
|
|
|
|
|
|
- auto dict = GetLocaleDictReference(locale);
|
|
|
|
|
|
+ std::map<long long, SubFile>& dict = GetLocaleDictReference(locale);
|
|
for (const auto &file : dict) {
|
|
for (const auto &file : dict) {
|
|
long long file_id = file.first;
|
|
long long file_id = file.first;
|
|
|
|
|
|
@@ -222,13 +221,9 @@ namespace LOTRO_DAT {
|
|
+ 4 + (32 + 4) * patch_dict_.size()
|
|
+ 4 + (32 + 4) * patch_dict_.size()
|
|
+ 4 + 4 * inactive_categories.size());
|
|
+ 4 + 4 * inactive_categories.size());
|
|
|
|
|
|
- size_t current_size = 0;
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(std::max(binary_data.size() + 4, 20u * 1024u * 1024u)));
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(101));
|
|
|
|
- binary_data.Append(BinaryData::FromNumber<4>(dat->getIO().file_size + binary_data.size() + 12 + 20 * 1024 * 1024));
|
|
|
|
- current_size = 12;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ // First 12 bytes will be filled just before writing data to file
|
|
|
|
+ size_t current_size = 12;
|
|
|
|
+
|
|
binary_data.Append(BinaryData("Hi from Gi1dor!", 15), current_size);
|
|
binary_data.Append(BinaryData("Hi from Gi1dor!", 15), current_size);
|
|
current_size += 15;
|
|
current_size += 15;
|
|
|
|
|
|
@@ -270,12 +265,20 @@ namespace LOTRO_DAT {
|
|
long long dict_size = dicts_data.ToNumber<4>(0);
|
|
long long dict_size = dicts_data.ToNumber<4>(0);
|
|
|
|
|
|
if (binary_data.size() > dict_size || dict_offset == 0) {
|
|
if (binary_data.size() > dict_size || dict_offset == 0) {
|
|
- auto operation = dat->getIO().WriteData(binary_data, binary_data.size(), dat->getIO().file_size + 12);
|
|
|
|
|
|
+ long long new_dict_offset = dat->getIO().file_size + 12;
|
|
|
|
+
|
|
|
|
+ // Updating first 12 bytes
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(std::max(binary_data.size() + 4, 20u * 1024u * 1024u)), 0);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(101), 4);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(dat->getIO().file_size + binary_data.size() + 20 * 1024 * 1024), 8);
|
|
|
|
+
|
|
|
|
+ auto operation = dat->getIO().WriteData(binary_data, binary_data.size(), new_dict_offset);
|
|
if (operation.result != SUCCESS)
|
|
if (operation.result != SUCCESS)
|
|
return DatOperationResult<>(ERROR, "LOCALEDEINIT: Cannot write locales");
|
|
return DatOperationResult<>(ERROR, "LOCALEDEINIT: Cannot write locales");
|
|
|
|
|
|
- dat->getIO().WriteData(BinaryData::FromNumber<4>(dat->getIO().file_size), 4, 300);
|
|
|
|
- dat->getIO().WriteData(BinaryData::FromNumber<4>(current_locale_), 4, 296, 0);
|
|
|
|
|
|
+
|
|
|
|
+ dat->getIO().WriteData(BinaryData::FromNumber<4>(new_dict_offset), 4, 300);
|
|
|
|
+ dat->getIO().WriteData(BinaryData::FromNumber<4>(current_locale_), 4, 296);
|
|
|
|
|
|
dat->getIO().file_size += binary_data.size();
|
|
dat->getIO().file_size += binary_data.size();
|
|
|
|
|
|
@@ -284,6 +287,10 @@ namespace LOTRO_DAT {
|
|
dat->getIO().WriteData(nulls, nulls.size(), dat->getIO().file_size);
|
|
dat->getIO().WriteData(nulls, nulls.size(), dat->getIO().file_size);
|
|
dat->getIO().file_size += nulls.size();
|
|
dat->getIO().file_size += nulls.size();
|
|
} else {
|
|
} else {
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(std::max(binary_data.size() + 4, 20u * 1024u * 1024u)), 0);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(101), 4);
|
|
|
|
+ binary_data.Append(BinaryData::FromNumber<4>(dat->getIO().file_size), 8);
|
|
|
|
+
|
|
dat->getIO().WriteData(BinaryData::FromNumber<4>(current_locale_), 4, 296, 0);
|
|
dat->getIO().WriteData(BinaryData::FromNumber<4>(current_locale_), 4, 296, 0);
|
|
auto operation = dat->getIO().WriteData(binary_data, binary_data.size(), dict_offset);
|
|
auto operation = dat->getIO().WriteData(binary_data, binary_data.size(), dict_offset);
|
|
if (operation.result != SUCCESS)
|
|
if (operation.result != SUCCESS)
|
|
@@ -304,7 +311,7 @@ namespace LOTRO_DAT {
|
|
*/
|
|
*/
|
|
|
|
|
|
void DatLocaleManager::UpdateLocaleFile(DatLocaleManager::LOCALE locale, const SubFile &file) {
|
|
void DatLocaleManager::UpdateLocaleFile(DatLocaleManager::LOCALE locale, const SubFile &file) {
|
|
- auto dict = GetLocaleDictReference(locale);
|
|
|
|
|
|
+ std::map<long long, SubFile>& dict = GetLocaleDictReference(locale);
|
|
dict[file.file_id()] = file;
|
|
dict[file.file_id()] = file;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -317,8 +324,8 @@ namespace LOTRO_DAT {
|
|
*/
|
|
*/
|
|
|
|
|
|
DatOperationResult<SubFile> DatLocaleManager::GetLocaleFile(long long file_id, DatLocaleManager::LOCALE locale) {
|
|
DatOperationResult<SubFile> DatLocaleManager::GetLocaleFile(long long file_id, DatLocaleManager::LOCALE locale) {
|
|
- auto dict = GetLocaleDictReference(locale);
|
|
|
|
- if (dict.count(file_id) != 0)
|
|
|
|
|
|
+ std::map<long long, SubFile>& dict = GetLocaleDictReference(locale);
|
|
|
|
+ if (dict.count(file_id) == 0)
|
|
return DatOperationResult<SubFile>(SubFile(), ERROR, "GETLOCFILE: cannot get file with id = " + std::to_string(file_id) + " from dict " + std::to_string(locale));
|
|
return DatOperationResult<SubFile>(SubFile(), ERROR, "GETLOCFILE: cannot get file with id = " + std::to_string(file_id) + " from dict " + std::to_string(locale));
|
|
return DatOperationResult<SubFile>(dict[file_id], SUCCESS);
|
|
return DatOperationResult<SubFile>(dict[file_id], SUCCESS);
|
|
}
|
|
}
|
|
@@ -410,4 +417,15 @@ namespace LOTRO_DAT {
|
|
LOCALE dat_locale = (locale == "PATC" ? PATCHED : ORIGINAL);
|
|
LOCALE dat_locale = (locale == "PATC" ? PATCHED : ORIGINAL);
|
|
return locale_status == dat_locale;
|
|
return locale_status == dat_locale;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ bool DatLocaleManager::CategoryIsInactive(long long category) {
|
|
|
|
+ return inactive_categories.count(category) > 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void DatLocaleManager::UpdateCategory(long long file_id, long long category) {
|
|
|
|
+ if (orig_dict_.count(file_id))
|
|
|
|
+ orig_dict_[file_id].category = category;
|
|
|
|
+ if (patch_dict_.count(file_id))
|
|
|
|
+ patch_dict_[file_id].category = category;
|
|
|
|
+ }
|
|
}
|
|
}
|