Kaynağa Gözat

Fixed bug with closing .dat file which caused problems with reopening

Ivan Arkhipov 6 yıl önce
ebeveyn
işleme
d94026ad38
5 değiştirilmiş dosya ile 17 ekleme ve 3 silme
  1. 1 1
      CMakeLists.txt
  2. 1 1
      include/DatFile.h
  3. BIN
      lib/libLotroDat.dll.a
  4. BIN
      lib/libLotroDat_static.a
  5. 15 1
      src/DatFile.cpp

+ 1 - 1
CMakeLists.txt

@@ -5,7 +5,7 @@ set(CMAKE_CXX_STANDARD 11)
 set(PROJECT_BINARY_DIR bin)
 set(PROJECT_VERSION 0.1.0)
 
-SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
+SET(CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -O2" )
 SET(CMAKE_EXE_LINKER_FLAGS  "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
 
 if (MSVS)

+ 1 - 1
include/DatFile.h

@@ -157,7 +157,7 @@ namespace LOTRO_DAT {
 
         std::unordered_map<long long, Subfile*> orig_dict_;
         std::unordered_map<long long, Subfile*> patch_dict_;
-        std::unordered_map<long long, Subfile*> ru_pending_patch_;
+        std::unordered_map<long long, Subfile*> pending_patch_;
 
     private:
         FILE *file_handler_;

BIN
lib/libLotroDat.dll.a


BIN
lib/libLotroDat_static.a


+ 15 - 1
src/DatFile.cpp

@@ -25,6 +25,7 @@ namespace LOTRO_DAT {
         dat_id_ = dat_id;
         dat_state_ = CLOSED;
         root_directory_ = nullptr;
+        file_handler_ = nullptr;
 
         filename_ = filename;
 
@@ -418,10 +419,12 @@ namespace LOTRO_DAT {
         if (dat_state_ != SUCCESS_DIRECTORIES)
             throw DatException("Bad DatFile::MakeDictionary() - DatFile isn't in valid state!", INIT_EXCEPTION);
         try {
+            if (root_directory_ == nullptr)
+                throw DatException("Bad DatFile::MakeDictionary() - root_directory is nullptr!", INIT_EXCEPTION);
+
             root_directory_->MakeDictionary(dictionary_);
         } catch (std::exception &e) {
             fprintf(stderr, "Caught %s exception.", e.what());
-
             fprintf(stderr, "Bad DatFile::MakeDictionary() - File is corrupted?\n");
             return;
         }
@@ -582,11 +585,22 @@ namespace LOTRO_DAT {
             CommitChanges();
         }
 
+        orig_dict_.clear();
+        patched_list.clear();
+        pending_patch_.clear();
+
+        current_locale_ = ORIGINAL;
+        filename_.clear();
+
         if (file_handler_ != nullptr)
             fclose(file_handler_);
         delete file_handler_;
 
         delete root_directory_;
+
+        patched_list.clear();
+        dictionary_.clear();
+
         dat_state_ = CLOSED;
     }