ソースを参照

Rev. 16.06.2020

Ivan Arkhipov 4 年 前
コミット
dab4e5c469

+ 1 - 1
CMakeLists.txt

@@ -6,7 +6,7 @@ set(PROJECT_BINARY_DIR bin)
 set(PROJECT_VERSION 8.0.0)
 # SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -Wall -Wextra -O2")
 SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} -Wall -Wextra -O0")
-set(CMAKE_CXX_FLAGS_RELEASE "-O0")
+set(CMAKE_CXX_FLAGS_RELEASE "-O0 -DNDEBUG") # !IMPORTANT: O0 should be used because of using of dynamic library!
 
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib)

+ 0 - 1
Third_party/EasyLogging++/easylogging++.h

@@ -18,7 +18,6 @@
 #define EASYLOGGINGPP_H
 
 #define ELPP_HANDLE_SIGABRT 
-#define ELPP_UNICODE
 #define ELPP_NO_DEFAULT_LOG_FILE
 
 // Compilers and C++0x/C++11 Evaluation

+ 3 - 2
include/database.h

@@ -1,9 +1,10 @@
 #ifndef LOTRO_DAT_DATABASE_H
 #define LOTRO_DAT_DATABASE_H
 
-#include <SQLite/sqlite3.h>
 #include <string>
-#include <yaml-cpp/yaml.h>
+
+struct sqlite3;
+struct sqlite3_stmt;
 
 extern "C++" {
 namespace LOTRO_DAT {

+ 1 - 1
include/subfiledata.h

@@ -25,7 +25,7 @@ namespace LOTRO_DAT {
         }
 
         bool Empty() const {
-            return binary_data.size() == 0 && text_data.length() == 0;
+            return binary_data.size() == 0 && text_data.length() == 0 && options.IsNull();
         }
 
         bool operator == (const SubfileData &other) {

+ 15 - 10
src/database.cpp

@@ -1,7 +1,10 @@
 #include "database.h"
 #include "binarydata.h"
 #include "subfiledata.h"
-#include "EasyLogging++/easylogging++.h"
+
+#include <EasyLogging++/easylogging++.h>
+#include <SQLite/sqlite3.h>
+#include <yaml-cpp/yaml.h>
 
 
 namespace LOTRO_DAT {
@@ -11,17 +14,19 @@ Database::Database() {
 }
 
 bool Database::CloseDatabase() {
+  if (db_ == nullptr) {
+    return true;
+  }
+
   LOG(DEBUG) << "Closing database.";
 
-  if (db_ != nullptr) {
-    ExecSql("COMMIT TRANSACTION");
-    sqlite3_finalize(insert_request_);
-    sqlite3_finalize(fetch_one_request_);
-    sqlite3_finalize(get_rows_number_request_);
-    if (sqlite3_close_v2(db_) != SQLITE_OK)
-        LOG(ERROR) << "Database error when closing: " << sqlite3_errmsg(db_);
-    db_ = nullptr;
-  }
+  ExecSql("COMMIT TRANSACTION");
+  sqlite3_finalize(insert_request_);
+  sqlite3_finalize(fetch_one_request_);
+  sqlite3_finalize(get_rows_number_request_);
+  if (sqlite3_close_v2(db_) != SQLITE_OK)
+      LOG(ERROR) << "Database error when closing: " << sqlite3_errmsg(db_);
+  db_ = nullptr;
 
   LOG(DEBUG) << "Database successfully closed.";
   return true;

+ 1 - 0
src/datfile.cpp

@@ -66,6 +66,7 @@ void DatFile::LoadAllFilesInfo() {
 void DatFile::Deinit() {
     if (initialized_) {
         api_.CloseDatFile(file_handle_);
+        initialized_ = false;
     }
 }
 

+ 0 - 1
src/subfiles/textsubfile.cpp

@@ -3,7 +3,6 @@
 #include "EasyLogging++/easylogging++.h"
 
 #include <codecvt>
-#include <locale>
 
 std::u16string to_utf16(long long x) {
     std::u16string res;

+ 1 - 1
src/utils/inserter.cpp

@@ -86,7 +86,7 @@ int main() {
     while (true) {
         std::cout << "Please, choose, what should I do. I can patch datfile from database to .dat file (enter 1) or exit (enter -1)\n";
 
-        std::cout << "Enter number of command (1-10): ";
+        std::cout << "Enter number of command (1 or -1): ";
         std::string command;
         std::getline(std::cin, command);
         int cmd = -10;

+ 1 - 1
src/utils/single_file_import_export.cpp

@@ -8,7 +8,7 @@ int main() {
     std::string target_file_path;
     int file_id;
     int is_import;
-    FILE_TYPE file_type;
+    FILE_TYPE file_type = FILE_TYPE::UNKNOWN;
 
     std::cout << "Enter path to .dat file: ";
     std::cin >> dat_file_path;