From 046517e7180c060df0c98a4c35c71d2244205cc6 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 11 Nov 2024 22:30:31 +0700 Subject: [PATCH 01/10] change tpfconvert functionality to backup into backup folder --- TpfConvert/src/TpfConvert.ixx | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/TpfConvert/src/TpfConvert.ixx b/TpfConvert/src/TpfConvert.ixx index 561f1a5..cc9a883 100644 --- a/TpfConvert/src/TpfConvert.ixx +++ b/TpfConvert/src/TpfConvert.ixx @@ -85,7 +85,8 @@ namespace { int main(int argc, char* argv[]) { - const std::filesystem::path path = argc > 1 ? argv[1] : GetExecutablePath() / "plugins"; + const std::filesystem::path path = argc > 1 ? argv[1] : GetExecutablePath(); + const auto backup_path = path / "backup"; if (!InitializeDirect3D()) { return -1; @@ -95,28 +96,35 @@ int main(int argc, char* argv[]) return 1; } + if (!std::filesystem::exists(backup_path)) { + std::filesystem::create_directory(backup_path); + } + for (const auto& modfile : std::filesystem::directory_iterator(path)) { if (modfile.is_regular_file() && (modfile.path().extension() == ".tpf" || modfile.path().extension() == ".zip")) { const auto mod_path = modfile.path(); - if (mod_path.extension() == ".zip" && mod_path.stem().string().ends_with("_")) { + const auto backup_file = backup_path / mod_path.filename(); + + if (std::filesystem::exists( backup_file)) { std::print("Skipping previous TpfConvert output: {}\n", mod_path.filename().string()); continue; } else { std::print("Processing: {}\n", mod_path.filename().string()); + std::error_code ec; + std::filesystem::rename(mod_path, backup_file, ec); } - const auto zip_filename = mod_path.parent_path() / (mod_path.stem().string() + "_.zip"); + const auto zip_filename = path / (mod_path.stem().string() + ".zip"); if (std::filesystem::exists(zip_filename)) { - std::print("{} was already processed\n", mod_path.filename().string()); - continue; + std::filesystem::remove(zip_filename); } - libzippp::ZipArchive zip_archive(zip_filename.string()); - ModfileLoader loader(mod_path); + ModfileLoader loader(backup_file); std::vector>> data_entries; const auto entries = loader.GetContents(); + libzippp::ZipArchive zip_archive(zip_filename.string()); zip_archive.open(libzippp::ZipArchive::Write); for (const auto& entry : entries) { From 0d3180414343f0e0b5a11bda3932a9bf006346b2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 11 Nov 2024 12:20:44 +0700 Subject: [PATCH 02/10] use vcpkg for more packages --- CMakeLists.txt | 16 +++----- CMakePresets.json | 2 + TpfConvert/CMakeLists.txt | 2 +- cmake/libzip.cmake | 65 -------------------------------- cmake/libzippp.cmake | 42 --------------------- cmake/minhook.cmake | 16 -------- cmake/msgsl.cmake | 11 ------ cmake/zlib.cmake | 47 ----------------------- triplets/x86-windows-mixed.cmake | 9 +++++ vcpkg.json | 10 ++++- 10 files changed, 26 insertions(+), 194 deletions(-) delete mode 100644 cmake/libzip.cmake delete mode 100644 cmake/libzippp.cmake delete mode 100644 cmake/minhook.cmake delete mode 100644 cmake/msgsl.cmake delete mode 100644 cmake/zlib.cmake create mode 100644 triplets/x86-windows-mixed.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 023a348..7133d0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,12 +9,6 @@ if(NOT(CMAKE_SIZEOF_VOID_P EQUAL 4)) message(FATAL_ERROR "You are configuring a non 32-bit build, this is not supported. Run cmake with `-A Win32`") endif() -option(CLEAN "Cleans third party libraries and recompiles them" OFF) -if(${CLEAN} MATCHES "ON") - message("Removing directory: ${PROJECT_SOURCE_DIR}/bin/install") - file(REMOVE_RECURSE ${PROJECT_SOURCE_DIR}/bin/install) -endif() - set(VERSION_MAJOR 1) set(VERSION_MINOR 7) set(VERSION_PATCH 0) @@ -32,10 +26,10 @@ set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/bin/install) add_compile_options(/MP /permissive-) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -include(libzippp) -include(minhook) +find_package(libzippp CONFIG REQUIRED) +find_package(minhook CONFIG REQUIRED) +find_package(Microsoft.GSL CONFIG REQUIRED) include(dxtk) -include(msgsl) add_library(gMod SHARED) @@ -56,9 +50,9 @@ target_compile_options(gMod PRIVATE /W4 /WX) target_link_libraries(gMod PRIVATE dxguid - libzippp + libzippp::libzippp psapi - minhook + minhook::minhook directxtex Microsoft.GSL::GSL ) diff --git a/CMakePresets.json b/CMakePresets.json index 4fd8e25..572f381 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -7,6 +7,8 @@ "architecture": "Win32", "binaryDir": "${sourceDir}/build", "cacheVariables": { + "VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/triplets", + "VCPKG_TARGET_TRIPLET": "x86-windows-mixed", "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" } } diff --git a/TpfConvert/CMakeLists.txt b/TpfConvert/CMakeLists.txt index 1891f65..6548fdc 100644 --- a/TpfConvert/CMakeLists.txt +++ b/TpfConvert/CMakeLists.txt @@ -33,7 +33,7 @@ endif() find_package(dxsdk-d3dx CONFIG REQUIRED) target_link_libraries(TpfConvert PRIVATE - libzippp + libzippp::libzippp Microsoft::D3DX9 d3d9 ) diff --git a/cmake/libzip.cmake b/cmake/libzip.cmake deleted file mode 100644 index d5ee320..0000000 --- a/cmake/libzip.cmake +++ /dev/null @@ -1,65 +0,0 @@ -include_guard() -include(FetchContent) -include(zlib) - -FetchContent_Declare( - libzip - GIT_REPOSITORY https://github.com/nih-at/libzip - GIT_TAG v1.10.1) -FetchContent_GetProperties(libzip) - -if (libzip_POPULATED) - message(STATUS "Skipping libzip download") - return() -endif() - -FetchContent_Populate(libzip) -if(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/zip.lib) - message(STATUS "Skipping libzip build") - return() -endif() - -set(OPTIONS - "-A" "Win32" - "-DZLIB_LIBRARY:PATH=${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib" - "-DZLIB_INCLUDE_DIR:PATH=${CMAKE_INSTALL_PREFIX}/include" - "-DENABLE_COMMONCRYPTO=OFF" - "-DENABLE_GNUTLS=OFF" - "-DENABLE_MBEDTLS=OFF" - "-DENABLE_OPENSSL=OFF" - "-DENABLE_WINDOWS_CRYPTO=ON" - "-DENABLE_FDOPEN=OFF" - "-DENABLE_BZIP2=OFF" - "-DENABLE_LZMA=OFF" - "-DENABLE_ZSTD=OFF" - "-DBUILD_TOOLS=OFF" - "-DBUILD_REGRESS=OFF" - "-DBUILD_EXAMPLES=OFF" - "-DBUILD_DOC=OFF" - "-DLIBZIP_DO_INSTALL=ON" - "-DBUILD_SHARED_LIBS=OFF" - "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" - "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}" - ) - -message("Building libzip with OPTIONS:\n${OPTIONS}") - -# Patch CMakeLists.txt to require version 3.15 - otherwise cmake ignores MSVC_RUNTIME_LIBRARY -file(READ ${libzip_SOURCE_DIR}/CMakeLists.txt FILE_CONTENT) -string(REPLACE "VERSION 3.5.0" "VERSION 3.15.0" UPDATED_CONTENT "${FILE_CONTENT}") -file(WRITE ${libzip_SOURCE_DIR}/CMakeLists.txt "${UPDATED_CONTENT}") - -execute_process( - COMMAND ${CMAKE_COMMAND} ${OPTIONS} . - WORKING_DIRECTORY ${libzip_SOURCE_DIR} -) -execute_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release - WORKING_DIRECTORY ${libzip_SOURCE_DIR} -) -execute_process( - COMMAND ${CMAKE_COMMAND} --install . --config Release - WORKING_DIRECTORY ${libzip_SOURCE_DIR} -) - -message(STATUS "Finished libzip build") diff --git a/cmake/libzippp.cmake b/cmake/libzippp.cmake deleted file mode 100644 index 3472d13..0000000 --- a/cmake/libzippp.cmake +++ /dev/null @@ -1,42 +0,0 @@ -include_guard() -include(FetchContent) -include(libzip) - -find_library(ZLIB_LIBRARY REQUIRED - NAMES zlibstatic - PATHS ${CMAKE_INSTALL_PREFIX}/lib -) -find_library(LIBZIP_LIBRARY REQUIRED - NAMES zip - PATHS ${CMAKE_INSTALL_PREFIX}/lib -) - -FetchContent_Declare( - libzippp - GIT_REPOSITORY https://github.com/ctabin/libzippp - GIT_TAG libzippp-v7.0-1.10.1) -FetchContent_GetProperties(libzippp) - -if (NOT libzippp_POPULATED) - FetchContent_Populate(libzippp) -endif() - -add_library(libzippp STATIC) - -set(SOURCES - "${libzippp_SOURCE_DIR}/src/libzippp.h" - "${libzippp_SOURCE_DIR}/src/libzippp.cpp" - ) -source_group(TREE ${libzippp_SOURCE_DIR} FILES ${SOURCES}) -target_sources(libzippp PRIVATE ${SOURCES}) -target_include_directories(libzippp PUBLIC "${libzippp_SOURCE_DIR}/src") -target_include_directories(libzippp PRIVATE "${CMAKE_INSTALL_PREFIX}/include") -target_compile_definitions(libzippp PUBLIC - LIBZIPPP_WITH_ENCRYPTION - ) -target_link_libraries(libzippp PRIVATE - ${LIBZIP_LIBRARY} - ${ZLIB_LIBRARY} - ) - -set_target_properties(libzippp PROPERTIES FOLDER "Dependencies/") diff --git a/cmake/minhook.cmake b/cmake/minhook.cmake deleted file mode 100644 index d1da7ca..0000000 --- a/cmake/minhook.cmake +++ /dev/null @@ -1,16 +0,0 @@ -include_guard() -include(FetchContent) - -FetchContent_Declare( - minhook - GIT_REPOSITORY https://github.com/TsudaKageyu/minhook - GIT_TAG master) -FetchContent_GetProperties(minhook) - -if (NOT minhook_POPULATED) - FetchContent_Populate(minhook) -endif() - -add_subdirectory(${minhook_SOURCE_DIR} EXCLUDE_FROM_ALL) - -set_target_properties(minhook PROPERTIES FOLDER "Dependencies/") diff --git a/cmake/msgsl.cmake b/cmake/msgsl.cmake deleted file mode 100644 index 1455239..0000000 --- a/cmake/msgsl.cmake +++ /dev/null @@ -1,11 +0,0 @@ -cmake_minimum_required(VERSION 3.14) - -include(FetchContent) - -FetchContent_Declare(GSL - GIT_REPOSITORY "https://github.com/microsoft/GSL" - GIT_TAG "v4.0.0" - GIT_SHALLOW ON -) - -FetchContent_MakeAvailable(GSL) diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake deleted file mode 100644 index 523301e..0000000 --- a/cmake/zlib.cmake +++ /dev/null @@ -1,47 +0,0 @@ -include_guard() -include(FetchContent) - -# Fetch zlib using FetchContent -FetchContent_Declare( - zlib - GIT_REPOSITORY https://github.com/madler/zlib - GIT_TAG v1.3 -) - -FetchContent_GetProperties(zlib) - -if(zlib_POPULATED) - message(STATUS "Skipping zlib download") - return() -endif() - -FetchContent_Populate(zlib) - -if(EXISTS ${CMAKE_INSTALL_PREFIX}/lib/zlibstatic.lib) - message(STATUS "Skipping zlib build") - return() -endif() - -set(OPTIONS - "-A" "Win32" - "-DBUILD_SHARED_LIBS=OFF" - "-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}" - "-DCMAKE_MSVC_RUNTIME_LIBRARY=${CMAKE_MSVC_RUNTIME_LIBRARY}" -) - -message("Building zlib with OPTIONS:\n${OPTIONS}") - -execute_process( - COMMAND ${CMAKE_COMMAND} ${OPTIONS} . - WORKING_DIRECTORY ${zlib_SOURCE_DIR} -) -execute_process( - COMMAND ${CMAKE_COMMAND} --build . --config Release - WORKING_DIRECTORY ${zlib_SOURCE_DIR} -) -execute_process( - COMMAND ${CMAKE_COMMAND} --install . --config Release - WORKING_DIRECTORY ${zlib_SOURCE_DIR} -) - -message(STATUS "Finished zlib build") diff --git a/triplets/x86-windows-mixed.cmake b/triplets/x86-windows-mixed.cmake new file mode 100644 index 0000000..a44daab --- /dev/null +++ b/triplets/x86-windows-mixed.cmake @@ -0,0 +1,9 @@ +set(VCPKG_TARGET_ARCHITECTURE x86) + +if(PORT MATCHES "dxsdk-d3dx") + set(VCPKG_CRT_LINKAGE dynamic) + set(VCPKG_LIBRARY_LINKAGE dynamic) +else() + set(VCPKG_CRT_LINKAGE static) + set(VCPKG_LIBRARY_LINKAGE static) +endif() diff --git a/vcpkg.json b/vcpkg.json index bacf0fa..a1c7ea7 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -1,5 +1,13 @@ { "dependencies": [ - "dxsdk-d3dx" + "dxsdk-d3dx", + { + "name": "libzippp", + "features": [ + "encryption" + ] + }, + "minhook", + "ms-gsl" ] } From 65740403ba407c25d5a38887729b496083b0b6e2 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Mon, 11 Nov 2024 23:26:41 +0700 Subject: [PATCH 03/10] update readme, bump to 1.7.0.2 --- CMakeLists.txt | 5 ++--- README.md | 7 +++---- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7133d0b..455eaaa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.29) set(CMAKE_GENERATOR_PLATFORM win32) @@ -12,7 +12,7 @@ endif() set(VERSION_MAJOR 1) set(VERSION_MINOR 7) set(VERSION_PATCH 0) -set(VERSION_TWEAK 1) +set(VERSION_TWEAK 2) set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY) @@ -21,7 +21,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_SOURCE_DIR}/bin") set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -set(CMAKE_INSTALL_PREFIX ${PROJECT_SOURCE_DIR}/bin/install) add_compile_options(/MP /permissive-) diff --git a/README.md b/README.md index 5ec39a9..3c12f2a 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,6 @@ Compile: **TpfConvert** Small utility to convert old .tpf files with invalid images into .zip files with working images. Usage: -- put TpfConvert.exe and d3dx9.dll anywhere -- create a folder "plugins" in that folder and put your .tpf/.zip files with invalid images there -- run TpfConvert.exe, My_Texmod.tpf is fixed and copied into My_Texmod_.zip -- copy My_Texmod_.zip into your GW Launcher plugins folder, delete My_Texmod.tpf from it, if it still exists +- Put TpfConvert.exe and d3dx9.dll in the folder where you have your old, broken texmods with invalid images. +- Run TpfConvert.exe, all *.tpf and *.zip files are processed. The originals are saved into a newly created backup folder. +- Done. From 7917d3fe4b21a04c8be20751dd46c0b284617631 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 4 Jul 2025 11:55:10 +0700 Subject: [PATCH 04/10] rework dll path --- header/Main.h | 1 + modules/TextureClient.ixx | 10 +++++----- modules/TextureFunction.ixx | 9 ++++----- source/dll_main.cpp | 3 +++ 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/header/Main.h b/header/Main.h index c08cbb5..e45e3a0 100644 --- a/header/Main.h +++ b/header/Main.h @@ -32,3 +32,4 @@ extern unsigned int gl_ErrorState; extern HINSTANCE gl_hThisInstance; +inline std::filesystem::path gmod_dll_path; diff --git a/modules/TextureClient.ixx b/modules/TextureClient.ixx index 1155abf..90a358c 100644 --- a/modules/TextureClient.ixx +++ b/modules/TextureClient.ixx @@ -154,16 +154,16 @@ int TextureClient::UnlockMutex() return RETURN_OK; } -gsl::owner AddFile(TexEntry& entry, const bool compress, const std::filesystem::path& dll_path) +gsl::owner AddFile(TexEntry& entry, const bool compress) { const auto texture_file_struct = new TextureFileStruct(); texture_file_struct->crc_hash = entry.crc_hash; - const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress, dll_path); + const auto dds_blob = TextureFunction::ConvertToCompressedDDS(entry, compress); texture_file_struct->data.assign(static_cast(dds_blob.GetBufferPointer()), static_cast(dds_blob.GetBufferPointer()) + dds_blob.GetBufferSize()); return texture_file_struct; } -std::vector> ProcessModfile(const std::filesystem::path& modfile, const std::filesystem::path& dll_path, const bool compress) +std::vector> ProcessModfile(const std::filesystem::path& modfile, const bool compress) { const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (FAILED(hr)) return {}; @@ -179,7 +179,7 @@ std::vector> ProcessModfile(const std::filesystem texture_file_structs.reserve(entries.size()); unsigned file_bytes_loaded = 0; for (auto& tpf_entry : entries) { - const auto tex_file_struct = AddFile(tpf_entry, compress, dll_path); + const auto tex_file_struct = AddFile(tpf_entry, compress); texture_file_structs.push_back(tex_file_struct); file_bytes_loaded += texture_file_structs.back()->data.size(); } @@ -218,7 +218,7 @@ void TextureClient::LoadModsFromModlist(std::pair modf } std::vector>>> futures; for (const auto modfile : modfiles) { - futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, dll_path, files_size > 400'000'000)); + futures.emplace_back(std::async(std::launch::async, ProcessModfile, modfile, files_size > 400'000'000)); } auto loaded_size = 0u; for (auto& future : futures) { diff --git a/modules/TextureFunction.ixx b/modules/TextureFunction.ixx index 32b2e66..7b09302 100644 --- a/modules/TextureFunction.ixx +++ b/modules/TextureFunction.ixx @@ -338,10 +338,10 @@ export namespace TextureFunction { return compressed_image; } - void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry, const std::filesystem::path& dll_path) + void ImageSave(const DirectX::ScratchImage& image, const TexEntry& entry) { const auto file_name = std::format("0x{:x}.dds", entry.crc_hash); - const auto file_out = dll_path / "textures" / file_name; + const auto file_out = gmod_dll_path.parent_path() / "textures" / file_name; try { if (std::filesystem::exists(file_out)) { return; @@ -361,11 +361,10 @@ export namespace TextureFunction { } catch (const std::exception& e) { Warning("SaveDDSImageToDisk (%#lX%s): %s\n", entry.crc_hash, entry.ext.c_str(), e.what()); - return; } } - DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress, [[maybe_unused]] const std::filesystem::path& dll_path) + DirectX::Blob ConvertToCompressedDDS(TexEntry& entry, const bool compress) { DirectX::ScratchImage image; HRESULT hr = 0; @@ -408,7 +407,7 @@ export namespace TextureFunction { } #ifdef _DEBUG - ImageSave(compressed_image, entry, dll_path); + ImageSave(compressed_image, entry); #endif return dds_blob; } diff --git a/source/dll_main.cpp b/source/dll_main.cpp index 56e9eb1..5de38a2 100644 --- a/source/dll_main.cpp +++ b/source/dll_main.cpp @@ -185,6 +185,9 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD ul_reason_for_call, LPVOID lpReserv switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: { #ifdef _DEBUG + wchar_t dllFilePath[512 + 1]{}; + GetModuleFileNameW(hModule, dllFilePath, 512); + gmod_dll_path = dllFilePath; AllocConsole(); SetConsoleTitleA("gMod Console"); freopen_s(&stdout_proxy, "CONOUT$", "w", stdout); From 6671262fa49255aaaca6a82a279af8cabafd676f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 09:22:21 +0700 Subject: [PATCH 05/10] https://github.com/gwdevhub/gMod/issues/33 --- modules/TextureClient.ixx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/TextureClient.ixx b/modules/TextureClient.ixx index 90a358c..787bcb5 100644 --- a/modules/TextureClient.ixx +++ b/modules/TextureClient.ixx @@ -198,6 +198,9 @@ void TextureClient::LoadModsFromModlist(std::pair modf std::string line; std::vector modfiles; while (std::getline(file, line)) { + if (line.starts_with("//") || line.starts_with("#") || line.empty()) { + continue; + } // Remove newline character line.erase(std::ranges::remove(line, '\r').begin(), line.end()); line.erase(std::ranges::remove(line, '\n').begin(), line.end()); From 16b7dac6b53ea6418a59e54ad23209edd3b5e650 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 18 Jul 2025 09:24:28 +0700 Subject: [PATCH 06/10] v1.7.0.3 --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 455eaaa..86b9342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ endif() set(VERSION_MAJOR 1) set(VERSION_MINOR 7) set(VERSION_PATCH 0) -set(VERSION_TWEAK 2) +set(VERSION_TWEAK 3) set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY) From 773512a3012ed9417bade7057da468849cad9f96 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Thu, 8 Jan 2026 23:56:28 +0100 Subject: [PATCH 07/10] debug mode enabled --- header/Defines.h | 8 ++++---- modules/TextureClient.ixx | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/header/Defines.h b/header/Defines.h index 89e9dae..5171552 100644 --- a/header/Defines.h +++ b/header/Defines.h @@ -37,20 +37,20 @@ struct TextureFileStruct { inline void Message([[maybe_unused]] const char* format, ...) { #ifdef _DEBUG -#if 0 + //const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + //[[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 0); // white va_list args; va_start(args, format); vprintf(format, args); va_end(args); #endif -#endif } inline void Info([[maybe_unused]] const char* format, ...) { #ifdef _DEBUG - const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); - [[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 0); // white + //const HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); + //[[maybe_unused]] const auto success = SetConsoleTextAttribute(hConsole, 0); // white va_list args; va_start(args, format); vprintf(format, args); diff --git a/modules/TextureClient.ixx b/modules/TextureClient.ixx index 787bcb5..de1e2c7 100644 --- a/modules/TextureClient.ixx +++ b/modules/TextureClient.ixx @@ -167,7 +167,7 @@ std::vector> ProcessModfile(const std::filesystem { const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (FAILED(hr)) return {}; - Message("Initialize: loading file %s... ", modfile.c_str()); + Message("Initialize: loading file %s... ", modfile.string().c_str()); auto file_loader = ModfileLoader(modfile); auto entries = file_loader.GetContents(); if (entries.empty()) { @@ -319,7 +319,7 @@ int TextureClient::RemoveTexture(uModTexturePtr auto pTexture) int TextureClient::LookUpToMod(uModTexturePtr auto pTexture) { - Message("TextureClient::LookUpToMod( %p): hash: %#lX, %p\n", pTexture, pTexture->Hash, this); + Message("TextureClient::LookUpToMod( %p): hash: %#lX\n", pTexture, pTexture->Hash); int ret = RETURN_OK; if (pTexture->CrossRef_D3Dtex != nullptr) From 31c5eb9e9941b2841b66cdba456011832dc3304f Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 9 Jan 2026 00:34:27 +0100 Subject: [PATCH 08/10] fix... something... somehow??? @STL can you explain this??? --- TpfConvert/src/ModfileLoader.ixx | 7 ++++--- modules/ModfileLoader.ixx | 6 ++++-- modules/TextureClient.ixx | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/TpfConvert/src/ModfileLoader.ixx b/TpfConvert/src/ModfileLoader.ixx index 31c2c75..908db9b 100644 --- a/TpfConvert/src/ModfileLoader.ixx +++ b/TpfConvert/src/ModfileLoader.ixx @@ -14,7 +14,7 @@ export struct TexEntry { namespace { HashType GetCrcFromFilename(const std::string& filename) { - const static std::regex re(R"(0x[0-9a-f]{4,16})", std::regex::optimize | std::regex::icase); + const static std::regex re(R"(0x[0-9a-fA-F]{4,16})", std::regex::optimize); std::smatch match; if (!std::regex_search(filename, match, re)) { return 0; @@ -117,13 +117,14 @@ void ParseSimpleArchive(const libzippp::ZipArchive& archive, std::vector(entry.readAsBinary()); const auto size = entry.getSize(); std::vector vec(data_ptr, data_ptr + size); - std::filesystem::path tex_name(entry.getName()); + std::filesystem::path tex_name(entry_name); entries.emplace_back(std::move(vec), crc_hash, tex_name.extension().string()); delete[] data_ptr; } diff --git a/modules/ModfileLoader.ixx b/modules/ModfileLoader.ixx index c953479..9659daf 100644 --- a/modules/ModfileLoader.ixx +++ b/modules/ModfileLoader.ixx @@ -14,7 +14,7 @@ namespace { bool use_64_bit_crc = false; HashType GetCrcFromFilename(const std::string& filename) { - const static std::regex re(R"(0x[0-9a-f]{4,16})", std::regex::optimize | std::regex::icase); + const static std::regex re(R"(0x[0-9a-fA-F]{4,16})", std::regex::optimize); std::smatch match; if (!std::regex_search(filename, match, re)) { return 0; @@ -143,8 +143,10 @@ void ParseTexmodArchive(std::vector& lines, libzippp::ZipArchive& a // match[1] | match[2] const static auto address_file_regex = std::regex(R"(^[\\/.]*([^|]+)\|([^\r\n]+))", std::regex::optimize); std::smatch match; - if (!std::regex_search(line, match, address_file_regex)) + if (!std::regex_search(line, match, address_file_regex)) { + Warning("Failed to parse texmod.def archive line: %s - %s", line.c_str(), line.c_str()); continue; + } const auto address_string = match[1].str(); const auto file_path = match[2].str(); diff --git a/modules/TextureClient.ixx b/modules/TextureClient.ixx index de1e2c7..a69859b 100644 --- a/modules/TextureClient.ixx +++ b/modules/TextureClient.ixx @@ -238,7 +238,7 @@ void TextureClient::LoadModsFromModlist(std::pair modf } should_update = true; } - Message("Finished loading mods from %s: Loaded %u bytes (%u mb)", modfile_tuple.first.c_str(), loaded_size, loaded_size / 1024 / 1024); + Message("Finished loading mods from %s: Loaded %u bytes (%u mb)\n", modfile_tuple.first.c_str(), loaded_size, loaded_size / 1024 / 1024); } void TextureClient::Initialize() From 8eda5fdf2132908e19412bbb2ebe3f37716e70b0 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 9 Jan 2026 00:36:00 +0100 Subject: [PATCH 09/10] safety --- modules/TextureClient.ixx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/TextureClient.ixx b/modules/TextureClient.ixx index a69859b..3e8af03 100644 --- a/modules/TextureClient.ixx +++ b/modules/TextureClient.ixx @@ -167,7 +167,8 @@ std::vector> ProcessModfile(const std::filesystem { const auto hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); if (FAILED(hr)) return {}; - Message("Initialize: loading file %s... ", modfile.string().c_str()); + const auto modfile_str = modfile.string(); + Message("Initialize: loading file %s... ", modfile_str.c_str()); auto file_loader = ModfileLoader(modfile); auto entries = file_loader.GetContents(); if (entries.empty()) { From 5b601bb591686af9e9d84f676864393580a0a8e3 Mon Sep 17 00:00:00 2001 From: DubbleClick Date: Fri, 9 Jan 2026 00:43:07 +0100 Subject: [PATCH 10/10] 1.8.0.0 --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 86b9342..9b9c5ea 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.29) +cmake_minimum_required(VERSION 3.29) set(CMAKE_GENERATOR_PLATFORM win32) @@ -10,9 +10,9 @@ if(NOT(CMAKE_SIZEOF_VOID_P EQUAL 4)) endif() set(VERSION_MAJOR 1) -set(VERSION_MINOR 7) +set(VERSION_MINOR 8) set(VERSION_PATCH 0) -set(VERSION_TWEAK 3) +set(VERSION_TWEAK 0) set(VERSION_RC "${CMAKE_CURRENT_BINARY_DIR}/version.rc") configure_file("${CMAKE_CURRENT_SOURCE_DIR}/version.rc.in" "${VERSION_RC}" @ONLY)