Skip to content

Commit

Permalink
1.7.0.2 (#32)
Browse files Browse the repository at this point in the history
* change tpfconvert functionality to backup into backup folder

* use vcpkg for more packages

* update readme, bump to 1.7.0.2
  • Loading branch information
DubbleClick authored Nov 11, 2024
1 parent 485ecd1 commit 326b708
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 208 deletions.
21 changes: 7 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.16)
cmake_minimum_required(VERSION 3.29)

set(CMAKE_GENERATOR_PLATFORM win32)

Expand All @@ -9,16 +9,10 @@ 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)
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)
Expand All @@ -27,15 +21,14 @@ 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$<$<CONFIG:Debug>:Debug>")
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)

Expand All @@ -56,9 +49,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
)
Expand Down
2 changes: 2 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion TpfConvert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ endif()
find_package(dxsdk-d3dx CONFIG REQUIRED)

target_link_libraries(TpfConvert PRIVATE
libzippp
libzippp::libzippp
Microsoft::D3DX9
d3d9
)
22 changes: 15 additions & 7 deletions TpfConvert/src/TpfConvert.ixx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<std::pair<std::string, std::vector<uint8_t>>> 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) {
Expand Down
65 changes: 0 additions & 65 deletions cmake/libzip.cmake

This file was deleted.

42 changes: 0 additions & 42 deletions cmake/libzippp.cmake

This file was deleted.

16 changes: 0 additions & 16 deletions cmake/minhook.cmake

This file was deleted.

11 changes: 0 additions & 11 deletions cmake/msgsl.cmake

This file was deleted.

47 changes: 0 additions & 47 deletions cmake/zlib.cmake

This file was deleted.

9 changes: 9 additions & 0 deletions triplets/x86-windows-mixed.cmake
Original file line number Diff line number Diff line change
@@ -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()
10 changes: 9 additions & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"dependencies": [
"dxsdk-d3dx"
"dxsdk-d3dx",
{
"name": "libzippp",
"features": [
"encryption"
]
},
"minhook",
"ms-gsl"
]
}

0 comments on commit 326b708

Please sign in to comment.