|
@@ -13,6 +13,11 @@
|
|
#include <locale>
|
|
#include <locale>
|
|
#include <algorithm>
|
|
#include <algorithm>
|
|
|
|
|
|
|
|
+#ifdef WIN32
|
|
|
|
+#define fseek _fseeki64
|
|
|
|
+#define ftell _ftelli64
|
|
|
|
+#endif
|
|
|
|
+
|
|
extern "C++"
|
|
extern "C++"
|
|
{
|
|
{
|
|
namespace LOTRO_DAT {
|
|
namespace LOTRO_DAT {
|
|
@@ -332,9 +337,9 @@ namespace LOTRO_DAT {
|
|
/// Returns BinaryData, which contains of subfile data, made from parts of file in DatFile
|
|
/// Returns BinaryData, which contains of subfile data, made from parts of file in DatFile
|
|
|
|
|
|
BinaryData DatFile::GetFileData(const Subfile *file, long long int offset) {
|
|
BinaryData DatFile::GetFileData(const Subfile *file, long long int offset) {
|
|
- BinaryData mfile_id(4);
|
|
|
|
- ReadData(mfile_id, 4, file->file_offset() + 8);
|
|
|
|
- if (file->file_id() != mfile_id.ToNumber<4>(0))
|
|
|
|
|
|
+ BinaryData mfile_id(20);
|
|
|
|
+ ReadData(mfile_id, 20, file->file_offset() + 8);
|
|
|
|
+ if (!mfile_id.CheckCompression() && file->file_id() != mfile_id.ToNumber<4>(0))
|
|
throw DatException("Bad DatFile::GetFileData() - file_id in Subfile doesn't match to file_id in DatFile.", READ_EXCEPTION);
|
|
throw DatException("Bad DatFile::GetFileData() - file_id in Subfile doesn't match to file_id in DatFile.", READ_EXCEPTION);
|
|
|
|
|
|
BinaryData data((unsigned)(file->file_size() + (8 - offset)));
|
|
BinaryData data((unsigned)(file->file_size() + (8 - offset)));
|
|
@@ -463,7 +468,7 @@ namespace LOTRO_DAT {
|
|
throw DatException(err.c_str(), READ_EXCEPTION);
|
|
throw DatException(err.c_str(), READ_EXCEPTION);
|
|
}
|
|
}
|
|
|
|
|
|
- _fseeki64(file_handler_, offset, SEEK_SET);
|
|
|
|
|
|
+ fseek(file_handler_, offset, SEEK_SET);
|
|
fread(data.data() + data_offset, unsigned(size), 1, file_handler_);
|
|
fread(data.data() + data_offset, unsigned(size), 1, file_handler_);
|
|
data.CheckCompression();
|
|
data.CheckCompression();
|
|
}
|
|
}
|
|
@@ -472,7 +477,7 @@ namespace LOTRO_DAT {
|
|
if (dat_state_ < READY)
|
|
if (dat_state_ < READY)
|
|
throw DatException("Bad DatFile::WriteData() - DatFile isn't in valid state!", WRITE_EXCEPTION);
|
|
throw DatException("Bad DatFile::WriteData() - DatFile isn't in valid state!", WRITE_EXCEPTION);
|
|
|
|
|
|
- _fseeki64(file_handler_, offset, SEEK_SET);
|
|
|
|
|
|
+ fseek(file_handler_, offset, SEEK_SET);
|
|
if (data_offset + size > data.size())
|
|
if (data_offset + size > data.size())
|
|
throw DatException("Bad DatFile::WriteData - trying to write more than BinaryData size", WRITE_EXCEPTION);
|
|
throw DatException("Bad DatFile::WriteData - trying to write more than BinaryData size", WRITE_EXCEPTION);
|
|
|
|
|
|
@@ -657,7 +662,10 @@ namespace LOTRO_DAT {
|
|
|
|
|
|
void DatFile::InitLocales() {
|
|
void DatFile::InitLocales() {
|
|
std::cout << "Initialising locales..." << std::endl;
|
|
std::cout << "Initialising locales..." << std::endl;
|
|
- BinaryData dicts_data = GetFileData(dictionary_[2013266257]);
|
|
|
|
|
|
+ BinaryData dicts_data;
|
|
|
|
+
|
|
|
|
+ if (dictionary_.count(2013266257) != 0)
|
|
|
|
+ dicts_data = GetFileData(dictionary_[2013266257]);
|
|
|
|
|
|
if (dicts_data.size() < 29) {
|
|
if (dicts_data.size() < 29) {
|
|
fprintf(stderr, "WARNING: DatFile::InitLocales() - locales file is empty.. Initialising locale dicts as empty\n");
|
|
fprintf(stderr, "WARNING: DatFile::InitLocales() - locales file is empty.. Initialising locale dicts as empty\n");
|