diff --git a/CMakeLists.txt b/CMakeLists.txt index 67ccfbd..18f8ffb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,3 +90,12 @@ if(HEAPPATCH_SYNC_GAMEDATA) add_dependencies(HeapPatch HeapGameDataValidate) endif() install(DIRECTORY "${HEAPPATCH_GAMEDATA_DIR}/" DESTINATION svencoop/metahook/gamedata/heappatch OPTIONAL) + +# The aggregate solution owns its single LaunchGame target. +if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR) + option(METAHOOKSV_ENABLE_LAUNCH_GAME "Add the Visual Studio build/deploy/debug target" OFF) + if(METAHOOKSV_ENABLE_LAUNCH_GAME) + include(cmake/LaunchGame.cmake) + metahooksv_add_launch_game() + endif() +endif() diff --git a/README.md b/README.md index 47afae7..1d44e5c 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,20 @@ The engine's `Sys_InitMemory` caps its memory pool at a hard-coded limit that is |---|---|---| |-heaplimit_override|32~1024|heap limit in MB, default 256| +## F5 debugging (optional) + +Install MetaHook and enable this plugin in the game's `plugins.lst` first. Configure a standalone Visual Studio Win32 solution: + +```powershell +cmake -S . -B build/launch -G "Visual Studio 17 2022" -A Win32 -DMETAHOOKSV_ENABLE_LAUNCH_GAME=ON +``` + +Open the solution, select **LaunchGame** and press **F5**. **DeployGame** builds this plugin and its dependencies, stages Install, and copies plugin DLLs/PDBs/resources before the native debugger starts the existing game launcher. Root launchers/runtime files and plugin lists remain unchanged. Set VS to build before running and **Do not launch** on build errors; stop the game before redeploying. Ordinary builds do not deploy. + +`METAHOOKSV_GAME_DIRECTORY` defaults to Steam discovery; `METAHOOKSV_GAME_APPID` defaults to `225840`. Set `METAHOOKSV_GAME_MOD` for a custom mod and `METAHOOKSV_GAME_ARGUMENTS` for extra arguments. Debug and Release are supported. + +The shared module uses `METAHOOKSV_LAUNCH_GAME_MODULE_DIR`, the surrounding MetaHookSv checkout, or a pinned source archive. Without Installer sources, it downloads the self-contained CLI from GitHub `latest` (no .NET required); `METAHOOKSV_INSTALLER_RELEASE` selects a fixed tag, and `METAHOOKSV_INSTALLER_CLI_EXECUTABLE` supplies an offline EXE. Plugin mode requires v20261004c or later. Valid caches under `build/launch/launch-game/installer/` are reused without update checks; select another tag or clear that private cache to upgrade. `GH_TOKEN`/`GITHUB_TOKEN` may be supplied through the environment if GitHub API rate limits prevent the first download. The feature defaults OFF and performs no extra downloads when disabled. + # Build Requirements: Windows, Visual Studio 2022, CMake 3.21 or newer, Python 3.8 or newer. The first configure downloads VC-LTL 5.3.1 into `thirdparty/cache` and synchronizes the gamedata catalog. diff --git a/cmake/LaunchGame.cmake b/cmake/LaunchGame.cmake new file mode 100644 index 0000000..8bd22ab --- /dev/null +++ b/cmake/LaunchGame.cmake @@ -0,0 +1,24 @@ +# Shared implementation: explicit override, surrounding aggregator, pinned archive. +set(METAHOOKSV_LAUNCH_GAME_MODULE_DIR "" CACHE PATH "Directory containing the shared LaunchGame.cmake module") +if(METAHOOKSV_LAUNCH_GAME_MODULE_DIR) + set(_launch_module_dir "${METAHOOKSV_LAUNCH_GAME_MODULE_DIR}") +elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/../../../cmake/LaunchGame.cmake") + get_filename_component(_launch_module_dir "${CMAKE_CURRENT_LIST_DIR}/../../../cmake" ABSOLUTE) +else() + include(FetchContent) + if(POLICY CMP0135) + cmake_policy(SET CMP0135 NEW) + endif() + FetchContent_Declare(metahooksv_launch_module + URL https://github.com/hzqst/MetaHookSv/archive/5fec6043b590ce10cbdfd6d5416c7274be531117.tar.gz + TLS_VERIFY ON + # Populate only the modules; never configure the aggregate native project. + SOURCE_SUBDIR cmake) + FetchContent_MakeAvailable(metahooksv_launch_module) + set(_launch_module_dir "${metahooksv_launch_module_SOURCE_DIR}/cmake") +endif() +if(NOT EXISTS "${_launch_module_dir}/LaunchGame.cmake") + message(FATAL_ERROR "METAHOOKSV_LAUNCH_GAME_MODULE_DIR must contain LaunchGame.cmake: ${_launch_module_dir}") +endif() +include("${_launch_module_dir}/LaunchGame.cmake") +unset(_launch_module_dir)