Jelajahi Sumber

Ver 6.0.0 tmp

Ivan Arkhipov 6 tahun lalu
induk
melakukan
12780a3788

+ 1 - 2
CMakeLists.txt

@@ -3,7 +3,7 @@ project(LotRO_dat_library)
 
 set(CMAKE_CXX_STANDARD 14)
 set(PROJECT_BINARY_DIR bin)
-set(PROJECT_VERSION 0.1.0)
+set(PROJECT_VERSION 5.2.0)
 
 SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -O2 -Wall -Wextra")
 SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
@@ -26,7 +26,6 @@ SET(LIBRARY_OUTPUT_PATH ${CMAKE_OUTPUT_DIR})
 set(HEADER_FILES
     ${CMAKE_SOURCE_DIR}/include/BinaryData.h
     ${CMAKE_SOURCE_DIR}/include/Database.h
-    ${CMAKE_SOURCE_DIR}/include/DatException.h
     ${CMAKE_SOURCE_DIR}/include/DatFile.h
     ${CMAKE_SOURCE_DIR}/include/LotroDat.h
     ${CMAKE_SOURCE_DIR}/include/SubDirectory.h

TEMPAT SAMPAH
bin/LotRO_dat_extractor.exe


TEMPAT SAMPAH
bin/LotRO_dat_patcher.exe


+ 2 - 0
include/BinaryData.h

@@ -2,6 +2,8 @@
 // Created by Иван_Архипов on 31.10.2017.
 //
 
+#include <vector>
+
 #ifndef LOTRO_DAT_PATCHER_BINARYDATA_H
 #define LOTRO_DAT_PATCHER_BINARYDATA_H
 

+ 4 - 6
include/DatFile.h

@@ -95,6 +95,8 @@ namespace LOTRO_DAT {
 
         DAT_STATE DatFileState() const;
 
+        DAT_RESULT PerformDictionaryCheck();
+
         ~DatFile();
 
         // EXTRACT BASE SECTION
@@ -134,8 +136,6 @@ namespace LOTRO_DAT {
 
         DAT_RESULT MakeDictionary();
 
-        DAT_RESULT ClearFragmentationJournal();
-
         DAT_RESULT ModifyFragmentationJournal();
 
         // READ-WRITE SECTION
@@ -189,10 +189,6 @@ namespace LOTRO_DAT {
 
         bool CheckIfUpdatedByGame();
 
-        DAT_RESULT RepairPatches(Database *db);
-
-        DAT_RESULT FinishRepairingPatches();
-
         DAT_RESULT WriteUnorderedDictionary(std::string path) const;
 
         bool CheckIfNotPatched();
@@ -238,9 +234,11 @@ namespace LOTRO_DAT {
         long long fragmentation_journal_offset_;
         long long free_dat_size_;
 
+        long long actual_dat_size_;
         DAT_STATE dat_state_;
 
         int dat_id_;
+        bool dat_without_patches_;
     };
 }
 }

TEMPAT SAMPAH
lib/libLotroDat.dll.a


TEMPAT SAMPAH
lib/libLotroDat_static.a


+ 1 - 0
src/BinaryData.cpp

@@ -232,6 +232,7 @@ namespace LOTRO_DAT {
 
         if (last > size()) {
             LOG(ERROR) << "Unable to cut data - parameter last is out of range";
+            return BinaryData(0);
         }
 
         BinaryData newdata(unsigned(last - first));

File diff ditekan karena terlalu besar
+ 651 - 510
src/DatFile.cpp


+ 3 - 3
src/Examples/extractor_example.cpp

@@ -31,7 +31,7 @@ bool exportUnknownToDb = false;
 // There is no need to change anything else
 
 int main() {
-    std::cout << "Gi1dor's LotRO .dat extractor ver. 5.1.1" << std::endl;
+    std::cout << "Gi1dor's LotRO .dat extractor ver. 5.2.0" << std::endl;
 
     std::cout << "Hello! I'm a basic shell version of .dat file extractor. I can open .dat file directly, "
             "if you write path to it (with name of file) in file \"dat_file_path.txt\"\n";
@@ -82,10 +82,10 @@ int main() {
     int cmd = 0;
     while (true) {
         std::cout << "Please, choose, what should I do. I can extract .dat file to files (press 1), "
-                    "open another .dat file (press 2), choose, what to extract or exit (press -1)\n";
+                    "open another .dat file (press 2), or configure, what should I extract. Choose, what to do or exit (press -1)\n";
 
         if (cmd != 3) {
-            std::cout << "Enter number of command (1-2): ";
+            std::cout << "Enter number of command (1-3): ";
             std::cin >> cmd;
 
             std::string tmp;

+ 5 - 1
src/Examples/patcher_example.cpp

@@ -15,7 +15,7 @@ using namespace LOTRO_DAT;
 using namespace std;
 
 int main() {
-    std::cout << "Gi1dor's LotRO .dat patcher ver. 5.1.1" << std::endl;
+    std::cout << "Gi1dor's LotRO .dat patcher ver. 5.2.0" << std::endl;
     freopen("patcher_errors.log", "w", stderr);
 
     setbuf(stdout, nullptr);
@@ -62,6 +62,8 @@ int main() {
     }
 
     std::cout << "Great! File initialised successfully!\n";
+    file.WriteUnorderedDictionary("");
+
     if (file.CheckIfNotPatched())
         std::cout << "MESSAGE: Dat file is new and haven't been patched yet\n";
 
@@ -112,11 +114,13 @@ int main() {
                     std::cout << "Unfortunately, I cannot open this database. Could you try again please?\n";
                     continue;
                 };
+
                 if (db.CountRows() == 0) {
                     std::cout << "There are no files in database or database doesn't exist. "
                             "Please, try again!\n";
                     continue;
                 }
+
                 std::cout << "There are " << db.CountRows() << " files in database." << std::endl;
 
                 std::cout << "Successfully opened database! Beginning patching...\n";

+ 9 - 8
src/SubDirectory.cpp

@@ -94,7 +94,7 @@ namespace LOTRO_DAT {
 
         auto subfiles_number = data.ToNumber<4>(0);
         if (subfiles_number >= 64) {
-            LOG(ERROR) << "Incorrect directory at offset " << offset_;
+            LOG(ERROR) << "Incorrect directory (subfiles_num >= 64) at offset " << offset_;
             return false;
         }
 
@@ -103,7 +103,7 @@ namespace LOTRO_DAT {
             dat_->ReadData(header, 32, offset_ + 63 * 8 + 4 + 32 * i);
 
             if (header.Empty()) {
-                LOG(ERROR) << "(READ ERROR) Incorrect directory at offset " << offset_;
+                LOG(ERROR) << "(READ ERROR) Incorrect directory (unable to read subfile data) at offset " << offset_;
                 return false;
             }
 
@@ -122,12 +122,12 @@ namespace LOTRO_DAT {
                     header.ToNumber<4>(28) // unknown2 - must be zero??
             );
 
-            if (dat_->CorrectSubfile(subfile)) {
+//            if (dat_->CorrectSubfile(subfile)) {
                 subfiles_.emplace_back(subfile);
-            } else {
-                LOG(WARNING) << "Incorrect Subfile in directory at offset " << offset_ + 63 * 8 + 4 + 32 * i << " (id = " << subfile->file_id() << ");";
-                break;
-            }
+//            } else {
+//                LOG(WARNING) << "Incorrect Subfile in directory at offset " << offset_ + 63 * 8 + 4 + 32 * i << " (id = " << subfile->file_id() << ");";
+//                break;
+//            }
         }
         return true;
     }
@@ -137,7 +137,8 @@ namespace LOTRO_DAT {
             if (dict.count(i->file_id() != 0)) {
                 LOG(WARNING) << "Found multiple instances of file " << i->file_id() << " at dictionary offset "
                              << i->dictionary_offset() << ". Base offset = " << dict[i->file_id()]->dictionary_offset();
-                continue;
+                if (!dat_->CorrectSubfile(i) || dat_->CorrectSubfile(dict[i->file_id_]))
+                    continue;
             }
             dict[i->file_id()] = i;
         }

+ 2 - 2
src/Subfile.cpp

@@ -114,7 +114,7 @@ namespace LOTRO_DAT {
     ///  3) field options - YAML field, which consists of some parameters of file such as file_id, extension and so on.
     /// Returns true if preparation was success. Otherwise returns false;
 
-    SubfileData Subfile::PrepareForExport(const BinaryData &file_data) {
+    SubfileData Subfile::PrepareForExport(const BinaryData &) {
         LOG(ERROR) << "INCORRECT IMPLEMENTATION!";
         return SubfileData();
     }
@@ -128,7 +128,7 @@ namespace LOTRO_DAT {
     ///  3) const field options - YAML field, which consists of some parameters of file such as file_id, extension and so on.
     /// Returns BinaryData - bytes array, prepared for writing in .dat file
 
-    BinaryData Subfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) {
+    BinaryData Subfile::MakeForImport(const BinaryData &, const SubfileData &) {
         LOG(ERROR) << "INCORRECT IMPLEMENTATION!";
         return BinaryData(0);
     }

+ 6 - 2
src/Subfiles/DdsSubfile.cpp

@@ -28,6 +28,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData DdsSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty() || file_data.size() < 256) {
+            return SubfileData();
+        }
+
         BinaryData data = file_data;
         if (data.CheckCompression())
             data = data.DecompressData(4);
@@ -132,7 +136,7 @@ namespace LOTRO_DAT {
                 ddsData[109] = 16;
                 break;
             default:
-                LOG(ERROR) << "unknown header format.";
+                LOG(ERROR) << "Unknown header format.";
                 return SubfileData();
         }
 
@@ -146,7 +150,7 @@ namespace LOTRO_DAT {
     BinaryData DdsSubfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) {
         if (!data.options["ext"] || data.options["ext"].as<std::string>() != Extension() ||
             !data.options["fid"] || data.options["fid"].as<long long>() != file_id()) {
-            LOG(ERROR) << "invalid options data!";
+            LOG(ERROR) << "Invalid options data!";
             return BinaryData(0);
         }
         // TODO: COMPRESSED TEXTURES

+ 5 - 1
src/Subfiles/FontSubfile.cpp

@@ -28,6 +28,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData FontSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         result.binary_data = file_data;
         result.options["fid"] = file_id();
@@ -41,6 +45,6 @@ namespace LOTRO_DAT {
             LOG(ERROR) << "invalid options data!";
             return BinaryData(0);
         }
-        return old_data.CutData(0, 8) + data.binary_data;
+        return old_data.CutData(0, 16) + data.binary_data.CutData(8);
     }
 };

+ 4 - 0
src/Subfiles/JpgSubfile.cpp

@@ -27,6 +27,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData JpgSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         result.binary_data = file_data.CutData(24);
         result.options["fid"] = file_id();

+ 4 - 0
src/Subfiles/OggSubfile.cpp

@@ -28,6 +28,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData OggSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         result.binary_data = file_data.CutData(8);
         result.options["fid"] = file_id();

+ 5 - 2
src/Subfiles/TextSubfile.cpp

@@ -66,6 +66,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData TextSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         long long offset = 9; // first 4 bytes - file_id, then 4 bytes - unknown, then 1 byte - unknown
 
@@ -356,8 +360,7 @@ namespace LOTRO_DAT {
         return result;
     }
 
-    BinaryData TextSubfile::BuildArgumentStrings(const BinaryData &data, const SubfileData &new_data,
-                                                 long long &offset) {
+    BinaryData TextSubfile::BuildArgumentStrings(const BinaryData &data, const SubfileData &, long long &offset) {
         LOG(DEBUG) << "Started building argument strings";
         LOG(DEBUG) << "Built arg strings successfully";
         return GetArgumentStringsData(data, offset);

+ 5 - 1
src/Subfiles/UnknownSubfile.cpp

@@ -28,6 +28,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData UnknownSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         result.binary_data = file_data;
         result.options["fid"] = file_id();
@@ -35,7 +39,7 @@ namespace LOTRO_DAT {
         return result;
     }
 
-    BinaryData UnknownSubfile::MakeForImport(const BinaryData &old_data, const SubfileData &data) {
+    BinaryData UnknownSubfile::MakeForImport(const BinaryData &, const SubfileData &data) {
         if (!data.options["ext"] || data.options["ext"].as<std::string>() != Extension() ||
             !data.options["fid"] || data.options["fid"].as<long long>() != file_id()) {
             LOG(ERROR) << "invalid options data!";

+ 4 - 0
src/Subfiles/WavSubfile.cpp

@@ -28,6 +28,10 @@ namespace LOTRO_DAT {
     }
 
     SubfileData WavSubfile::PrepareForExport(const BinaryData &file_data) {
+        if (file_data.Empty()) {
+            return SubfileData();
+        }
+
         SubfileData result;
         result.binary_data = file_data.CutData(8);
         result.options["fid"] = file_id();

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini