mirror of
https://github.com/gwdevhub/gMod.git
synced 2026-07-15 15:09:30 +00:00
1.7.0.2 (#32)
* change tpfconvert functionality to backup into backup folder * use vcpkg for more packages * update readme, bump to 1.7.0.2
This commit is contained in:
+7
-14
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
cmake_minimum_required(VERSION 3.29)
|
||||
|
||||
set(CMAKE_GENERATOR_PLATFORM win32)
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -33,7 +33,7 @@ endif()
|
||||
find_package(dxsdk-d3dx CONFIG REQUIRED)
|
||||
|
||||
target_link_libraries(TpfConvert PRIVATE
|
||||
libzippp
|
||||
libzippp::libzippp
|
||||
Microsoft::D3DX9
|
||||
d3d9
|
||||
)
|
||||
|
||||
@@ -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<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) {
|
||||
|
||||
@@ -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")
|
||||
@@ -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/")
|
||||
@@ -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/")
|
||||
@@ -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)
|
||||
@@ -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")
|
||||
@@ -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()
|
||||
+9
-1
@@ -1,5 +1,13 @@
|
||||
{
|
||||
"dependencies": [
|
||||
"dxsdk-d3dx"
|
||||
"dxsdk-d3dx",
|
||||
{
|
||||
"name": "libzippp",
|
||||
"features": [
|
||||
"encryption"
|
||||
]
|
||||
},
|
||||
"minhook",
|
||||
"ms-gsl"
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user