Kaynağa Gözat

Fixed bug with always adding space in dat file

Function UpdateBufferIfNeeded was writing empty buffer data to dat file
in case when data to be written shouldn't be written after end of file.
This caused permanent dat file growth in every iteration of writing data
Ivan Arkhipov 5 yıl önce
ebeveyn
işleme
3def9a2944

BIN
bin/LotRO_dat_extractor.exe


BIN
bin/LotRO_dat_patcher.exe


BIN
lib/libLotroDat.dll.a


BIN
lib/libLotroDat_static.a


+ 7 - 4
src/DatSubsystems/DatIO.cpp

@@ -3,10 +3,10 @@
 #include "EasyLogging++/easylogging++.h"
 #include <DatOperationResult.h>
 
-#include "DatSubsystems/DatIO.h"
 #include <algorithm>
 #include <locale>
 #include <DatSubsystems/DatIO.h>
+#include <zconf.h>
 
 
 #ifdef WIN32
@@ -238,7 +238,8 @@ namespace LOTRO_DAT {
         if (data_offset + size > data.size())
             return DatOperationResult<>(ERROR, "IOWRITEDATA: writing more than BinaryData size.");
 
-        UpdateBufferIfNeeded(size);
+        if (offset + size > actual_dat_size_)
+            UpdateBufferIfNeeded(offset + size - actual_dat_size_);
 
         if (offset != ftell(file_handler_))
             fseek(file_handler_, offset, SEEK_SET);
@@ -260,9 +261,10 @@ namespace LOTRO_DAT {
      */
 
     DatOperationResult<> DatIO::DeInit() {
-        if (file_handler_ != nullptr) {
+        if (file_handler_ != nullptr)
             fclose(file_handler_);
-        }
+
+        truncate64(filename_.c_str(), actual_dat_size_);
 
         filename_ = "none";
         file_handler_ = nullptr;
@@ -276,6 +278,7 @@ namespace LOTRO_DAT {
         fragmentation_journal_end = 0;
         root_directory_offset = 0;
         fragmentation_journal_offset = 0;
+        elapsed_eof_buffer_ = 0;
 
         return DatOperationResult<>(SUCCESS, "File deinitialisation successfull");
     }

+ 4 - 4
src/Subfiles/TextSubFile.cpp

@@ -373,10 +373,10 @@ namespace LOTRO_DAT {
         // Moving &offset pointer in &data
         GetArgumentReferenceData(data, offset);
 
-        if (file_id_ == 620757423 && new_data.fragment_id == 96627013) {
-            std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> codecvt;
-            std::cout << "ARG_REFS: " << new_data.args << std::endl;
-        }
+//        if (file_id_ == 620757423 && new_data.fragment_id == 96627013) {
+//            std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> codecvt;
+//            std::cout << "ARG_REFS: " << new_data.args << std::endl;
+//        }
 
         // If there are no args - making 4 null-bytes and return;
         if (new_data.args.empty()) {