diff --git a/CMakeLists.txt b/CMakeLists.txt index cc73e90..4ca2d2c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,7 @@ add_library(gMod SHARED) file(GLOB SOURCES "header/*.h" "source/*.cpp" - "source/*.ixx" + "modules/*.ixx" ${VERSION_RC} ) diff --git a/header/FileLoader.h b/header/FileLoader.h deleted file mode 100644 index 3137fc7..0000000 --- a/header/FileLoader.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once - -#include -#include -#include - -struct TexEntry { - std::vector data{}; - HashType crc_hash = 0; // hash value - std::string ext{}; -}; - -class FileLoader { - std::string file_name; - const std::string TPF_PASSWORD{ - 0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, static_cast(0xA6), static_cast(0xBD), - 0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F, - 0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74, - 0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41, - 0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B, - 0x46, 0x6F - }; - -public: - FileLoader(const std::string& fileName); - - std::vector GetContents(); - -private: - - std::vector GetTpfContents(); - - std::vector GetFileContents(); - - void LoadEntries(libzippp::ZipArchive& archive, std::vector& entries); -}; diff --git a/header/TextureClient.h b/header/TextureClient.h index 9ffa321..1ad9ddf 100644 --- a/header/TextureClient.h +++ b/header/TextureClient.h @@ -1,12 +1,16 @@ #pragma once -#include "FileLoader.h" #include "uMod_IDirect3DTexture9.h" #include #include extern unsigned int gl_ErrorState; +struct TexEntry { + std::vector data{}; + HashType crc_hash = 0; // hash value + std::string ext{}; +}; struct TextureFileStruct { std::vector data{}; HashType crc_hash = 0; // hash value diff --git a/source/FileLoader.cpp b/modules/ModfileLoader.ixx similarity index 78% rename from source/FileLoader.cpp rename to modules/ModfileLoader.ixx index f843b39..ca7e729 100644 --- a/source/FileLoader.cpp +++ b/modules/ModfileLoader.ixx @@ -1,16 +1,50 @@ -#include -#include -#include -#include -#include "FileLoader.h" -#include "TpfReader.h" - -FileLoader::FileLoader(const std::string& fileName) +module; + +#include "Main.h" +#include "Defines.h" + +export module ModfileLoader; + +import ; +import ; +import ; +import ; +import ; +import ; +import ; +import ModfileLoader.TpfReader; + +export class ModfileLoader { + std::string file_name; + const std::string TPF_PASSWORD{ + 0x73, 0x2A, 0x63, 0x7D, 0x5F, 0x0A, static_cast(0xA6), static_cast(0xBD), + 0x7D, 0x65, 0x7E, 0x67, 0x61, 0x2A, 0x7F, 0x7F, + 0x74, 0x61, 0x67, 0x5B, 0x60, 0x70, 0x45, 0x74, + 0x5C, 0x22, 0x74, 0x5D, 0x6E, 0x6A, 0x73, 0x41, + 0x77, 0x6E, 0x46, 0x47, 0x77, 0x49, 0x0C, 0x4B, + 0x46, 0x6F + }; + +public: + ModfileLoader(const std::string& fileName); + + std::vector GetContents(); + +private: + + std::vector GetTpfContents(); + + std::vector GetFileContents(); + + void LoadEntries(libzippp::ZipArchive& archive, std::vector& entries); +}; + +ModfileLoader::ModfileLoader(const std::string& fileName) { file_name = std::filesystem::absolute(fileName).string(); } -std::vector FileLoader::GetContents() +std::vector ModfileLoader::GetContents() { try { return file_name.ends_with(".tpf") ? GetTpfContents() : GetFileContents(); @@ -21,7 +55,7 @@ std::vector FileLoader::GetContents() return {}; } -std::vector FileLoader::GetTpfContents() +std::vector ModfileLoader::GetTpfContents() { std::vector entries; auto tpf_reader = TpfReader(file_name); @@ -43,7 +77,7 @@ std::vector FileLoader::GetTpfContents() return entries; } -std::vector FileLoader::GetFileContents() +std::vector ModfileLoader::GetFileContents() { std::vector entries; @@ -131,7 +165,7 @@ void ParseTexmodArchive(std::vector& lines, libzippp::ZipArchive& a } } -void FileLoader::LoadEntries(libzippp::ZipArchive& archive, std::vector& entries) +void ModfileLoader::LoadEntries(libzippp::ZipArchive& archive, std::vector& entries) { const auto def_file = archive.getEntry("texmod.def"); if (def_file.isNull() || !def_file.isFile()) { diff --git a/header/TpfReader.h b/modules/ModfileLoader_TpfReader.ixx similarity index 92% rename from header/TpfReader.h rename to modules/ModfileLoader_TpfReader.ixx index d391b09..f17ddf3 100644 --- a/header/TpfReader.h +++ b/modules/ModfileLoader_TpfReader.ixx @@ -1,9 +1,10 @@ -#pragma once +export module ModfileLoader.TpfReader; -#include -#include +import ; +import ; +import ; -class TpfReader { +export class TpfReader { public: TpfReader(const std::string& path) { diff --git a/source/TextureFunction.ixx b/modules/TextureFunction.ixx similarity index 100% rename from source/TextureFunction.ixx rename to modules/TextureFunction.ixx diff --git a/source/TextureClient.cpp b/source/TextureClient.cpp index a8ee05a..c093ed0 100644 --- a/source/TextureClient.cpp +++ b/source/TextureClient.cpp @@ -1,6 +1,7 @@ #include "Main.h" import TextureFunction; +import ModfileLoader; TextureClient::TextureClient(IDirect3DDevice9* device) { @@ -134,7 +135,7 @@ void TextureClient::LoadModsFromFile(const char* source) // Remove newline character line.erase(std::ranges::remove(line, '\n').begin(), line.end()); - auto file_loader = FileLoader(line); + auto file_loader = ModfileLoader(line); auto entries = file_loader.GetContents(); if (loaded_size > 1'000'000'000) { Message("LoadModsFromFile: Loaded %d bytes, aborting!!!\n", loaded_size);