diff --git a/CMakeLists.txt b/CMakeLists.txt index 8adb12f..26864c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ if(TARGET fmt::fmt) set(LIBRARIES fmt::fmt ${LIBRARIES}) else() - message("Using built-in fmt") + message("Using downloaded fmt") FetchContent_Declare( fmt @@ -41,7 +41,7 @@ if(TARGET ZLIB::ZLIB) set(LIBRARIES ZLIB::ZLIB ${LIBRARIES}) else() - message("Using built-in zlib") + message("Using downloaded zlib") FetchContent_Declare( zlib @@ -61,7 +61,21 @@ else() set(LIBRARIES zlibstatic ${LIBRARIES}) endif() -find_package(pugixml REQUIRED) +find_package(pugixml QUIET) + +if(TARGET pugixml::pugixml) + message("Using system library for zlib") +else() + message("Using downloaded pugixml") + + FetchContent_Declare( + pugixml + GIT_REPOSITORY https://github.com/zeux/pugixml.git + GIT_TAG master + ) + + FetchContent_MakeAvailable(pugixml) +endif() add_library(libxiv STATIC src/fiinparser.cpp diff --git a/src/exlparser.cpp b/src/exlparser.cpp index c385d48..d00013e 100644 --- a/src/exlparser.cpp +++ b/src/exlparser.cpp @@ -1,20 +1,20 @@ #include "exlparser.h" + #include +#include EXL readEXL(std::string_view path) { - FILE* file = fopen(path.data(), "rb"); - if(!file) { + std::fstream file; + file.open(path.data(), std::iostream::in); + + if(!file.is_open()) { throw std::runtime_error("Failed to read exl file from " + std::string(path.data())); } EXL exl; - char* data = nullptr; - size_t len = 0; - - while ((getline(&data, &len, file)) != -1) { - std::string line = data; - + std::string line; + while (std::getline(file, line)) { const size_t comma = line.find_first_of(','); std::string name = line.substr(0, comma); diff --git a/src/mdlparser.cpp b/src/mdlparser.cpp index 7b05fe5..d9ccc0c 100644 --- a/src/mdlparser.cpp +++ b/src/mdlparser.cpp @@ -7,6 +7,9 @@ #include #include +using ushort = unsigned short; +using uint = unsigned int; + // from lumina.halfextensions static float Unpack(ushort value) { uint num3;