Compare commits
No commits in common. "512842bfa5eca7b7678ff5fcc93d0fcefff477e7" and "7d152b61585363567baca8b6d3e02915a902121f" have entirely different histories.
512842bfa5
...
7d152b6158
2
.gitattributes
vendored
2
.gitattributes
vendored
@ -8,10 +8,8 @@
|
||||
*.strings filter= diff= merge= -text
|
||||
*.gitignore filter= diff= merge= text eol=lf
|
||||
*.gitattributes filter= diff= merge= text eol=lf
|
||||
*.cmake filter= diff= merge= text eol=lf
|
||||
*.xml filter= diff= merge= text eol=lf
|
||||
*.json filter= diff= merge= text eol=lf
|
||||
*.in filter= diff= merge= text eol=crlf
|
||||
*.md filter= diff= merge= text eol=crlf
|
||||
*.ini filter= diff= merge= text eol=crlf
|
||||
*.txt filter= diff= merge= text eol=crlf
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
ShowWarningOnInitFail = true
|
||||
SendAchievementsToLE = false
|
||||
TestMode = false
|
||||
ReloadSteamClient = true
|
||||
TestMode = true
|
||||
|
||||
BIN
source/Enderal DLL/cmake/patch_directxtk.cmake
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/patch_directxtk.cmake
(Stored with Git LFS)
Binary file not shown.
BIN
source/Enderal DLL/cmake/version.rc.in
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/version.rc.in
(Stored with Git LFS)
Binary file not shown.
BIN
source/Enderal DLL/cmake/write_user_presets.cmake
(Stored with Git LFS)
BIN
source/Enderal DLL/cmake/write_user_presets.cmake
(Stored with Git LFS)
Binary file not shown.
3
source/Steam DLL/.gitignore
vendored
3
source/Steam DLL/.gitignore
vendored
@ -533,9 +533,6 @@ FodyWeavers.xsd
|
||||
|
||||
build/
|
||||
|
||||
# Machine-specific, generated by build.cmd - see cmake/write_user_presets.cmake
|
||||
CMakeUserPresets.json
|
||||
|
||||
contrib/Distribution/**/*.dll
|
||||
contrib/Distribution/**/*.pdb
|
||||
contrib/Distribution/**/*.pex
|
||||
|
||||
@ -1,58 +1,31 @@
|
||||
option(ENABLE_VCPKG OFF)
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
message("Using toolchain file ${CMAKE_TOOLCHAIN_FILE}.")
|
||||
|
||||
########################################################################################################################
|
||||
## Define project
|
||||
########################################################################################################################
|
||||
|
||||
# Get current version
|
||||
set(ENDERAL_VERSION_INI "${CMAKE_CURRENT_SOURCE_DIR}/../../SKSE/Plugins/EnderalVersion.ini")
|
||||
file(READ "${ENDERAL_VERSION_INI}" CONFIG_CONTENT)
|
||||
string(REGEX MATCH "version[ \t]*=[ \t]*([0-9.]+)" _ ${CONFIG_CONTENT})
|
||||
set(VERSION_NUMBER "${CMAKE_MATCH_1}")
|
||||
|
||||
# file(READ) does not register a dependency: without this, bumping the version in
|
||||
# the INI would not re-run CMake and the DLL would keep the previous version.
|
||||
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${ENDERAL_VERSION_INI}")
|
||||
|
||||
project(
|
||||
EnderalSteam
|
||||
VERSION ${VERSION_NUMBER}
|
||||
DESCRIPTION "Enderal SE Steam Support"
|
||||
LANGUAGES CXX
|
||||
)
|
||||
|
||||
# Shown as ProductName in the version resource.
|
||||
set(PROJECT_FRIENDLY_NAME "Enderal SE")
|
||||
|
||||
# The binary FILEVERSION/PRODUCTVERSION fields need all four components;
|
||||
# PROJECT_VERSION_TWEAK is empty when the INI carries only three.
|
||||
if(NOT PROJECT_VERSION_TWEAK)
|
||||
set(PROJECT_VERSION_TWEAK 0)
|
||||
endif()
|
||||
|
||||
EnderalSteam
|
||||
VERSION 2.1.4
|
||||
DESCRIPTION "Enderal SE Steam Support"
|
||||
LANGUAGES CXX)
|
||||
set(CMAKE_CXX_STANDARD 23)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
# Link-time optimization for release builds only (debug builds stay fast).
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON)
|
||||
|
||||
# CommonLibSSE-NG requires the dynamic CRT. Dependencies used to be supplied by
|
||||
# vcpkg (which set this via a preset); now that they come from FetchContent we
|
||||
# set it here so both build.cmd and Visual Studio "Open Folder" pick it up.
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
|
||||
|
||||
add_compile_definitions(NOMINMAX _USE_MATH_DEFINES WIN32_LEAN_AND_MEAN)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
add_compile_options(/Zc:preprocessor /EHsc)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
|
||||
configure_file(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/cmake/version.rc.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/version.rc
|
||||
@ONLY
|
||||
)
|
||||
|
||||
#include(GNUInstallDirs)
|
||||
|
||||
file(
|
||||
GLOB_RECURSE
|
||||
sources
|
||||
@ -68,82 +41,81 @@ source_group(
|
||||
)
|
||||
|
||||
########################################################################################################################
|
||||
## Fetch dependencies (pinned versions, no vcpkg required)
|
||||
## Configure target DLL
|
||||
########################################################################################################################
|
||||
|
||||
|
||||
include(FetchContent)
|
||||
|
||||
# DirectXMath - required by DirectXTK.
|
||||
# DirectXMath
|
||||
FetchContent_Declare(
|
||||
DirectXMath
|
||||
URL "https://github.com/microsoft/DirectXMath/archive/refs/tags/apr2025.tar.gz"
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
EXCLUDE_FROM_ALL
|
||||
SYSTEM
|
||||
)
|
||||
FetchContent_MakeAvailable(DirectXMath)
|
||||
add_library("Microsoft::DirectXMath" ALIAS "DirectXMath")
|
||||
|
||||
# DirectXTK - required by CommonLibSSE-NG (find_package(directxtk CONFIG REQUIRED)).
|
||||
# PATCH_COMMAND fixes its shader-compile step under modern CMake (see the script).
|
||||
# DirectXTK
|
||||
FetchContent_Declare(
|
||||
DirectXTK
|
||||
URL "https://github.com/microsoft/DirectXTK/archive/refs/tags/jul2025.tar.gz"
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
EXCLUDE_FROM_ALL
|
||||
SYSTEM
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_SOURCE_DIR}/cmake/patch_directxtk.cmake"
|
||||
)
|
||||
FetchContent_MakeAvailable(DirectXTK)
|
||||
add_library("Microsoft::DirectXTK" ALIAS "DirectXTK")
|
||||
|
||||
# simpleini - used directly (Util.h).
|
||||
# simpleini
|
||||
FetchContent_Declare(
|
||||
simpleini
|
||||
URL "https://github.com/brofield/simpleini/archive/refs/tags/v4.22.tar.gz"
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
)
|
||||
FetchContent_MakeAvailable(simpleini)
|
||||
INCLUDE_DIRECTORIES(${simpleini_SOURCE_DIR})
|
||||
|
||||
# rapidcsv - header only, required by CommonLibSSE-NG (find_path "rapidcsv.h").
|
||||
# rapidcsv
|
||||
FetchContent_Declare(
|
||||
rapidcsv
|
||||
URL "https://github.com/d99kris/rapidcsv/archive/refs/tags/v8.87.tar.gz"
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
)
|
||||
FetchContent_MakeAvailable(rapidcsv)
|
||||
set(RAPIDCSV_INCLUDE_DIRS ${rapidcsv_SOURCE_DIR}/src)
|
||||
|
||||
# spdlog - used directly (PCH.h) and by CommonLibSSE-NG.
|
||||
set(SPDLOG_INSTALL ON CACHE BOOL " " FORCE)
|
||||
set(SPDLOG_USE_STD_FORMAT ON CACHE BOOL " " FORCE)
|
||||
# spdlog
|
||||
set(SPDLOG_INSTALL ON CACHE INTERNAL "Install SPDLOG for CommonLibSSE")
|
||||
set(SPDLOG_USE_STD_FORMAT ON CACHE INTERNAL "Use std::format in SPDLOG, not fmt")
|
||||
FetchContent_Declare(
|
||||
spdlog
|
||||
URL "https://github.com/gabime/spdlog/archive/refs/tags/v1.15.3.tar.gz"
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
OVERRIDE_FIND_PACKAGE
|
||||
)
|
||||
FetchContent_MakeAvailable(spdlog)
|
||||
|
||||
# xbyak - required by CommonLibSSE-NG when SKSE_SUPPORT_XBYAK is on.
|
||||
# xbyak
|
||||
FetchContent_Declare(
|
||||
xbyak
|
||||
URL "https://github.com/herumi/xbyak/archive/v7.28.tar.gz"
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP 1
|
||||
)
|
||||
FetchContent_MakeAvailable(xbyak)
|
||||
|
||||
# CommonLibSSE-NG - pinned commit (SE + AE + VR runtime support).
|
||||
# CommonLibSSE
|
||||
set(SKSE_SUPPORT_XBYAK ON CACHE BOOL " " FORCE)
|
||||
set(ENABLE_SKYRIM_SE ON CACHE BOOL " " FORCE)
|
||||
set(ENABLE_SKYRIM_AE ON CACHE BOOL " " FORCE)
|
||||
set(ENABLE_SKYRIM_VR ON CACHE BOOL " " FORCE)
|
||||
set(BUILD_TESTS OFF CACHE BOOL " " FORCE)
|
||||
message(STATUS "Fetching CommonLibSSE-NG...")
|
||||
message(STATUS "Fetching CommonLibSSE-NG (5e5417e3585c9434295e919bdda27737244e9c5a)...")
|
||||
FetchContent_Declare(
|
||||
CommonLibSSE
|
||||
GIT_REPOSITORY https://github.com/eddoursul/CommonLibVR.git
|
||||
@ -151,19 +123,15 @@ FetchContent_Declare(
|
||||
)
|
||||
FetchContent_MakeAvailable(CommonLibSSE)
|
||||
|
||||
|
||||
get_target_property(COMMONLIB_SRC_DIR CommonLibSSE SOURCE_DIR)
|
||||
|
||||
include(${COMMONLIB_SRC_DIR}/cmake/CommonLibSSE.cmake)
|
||||
|
||||
########################################################################################################################
|
||||
## Configure target DLL
|
||||
########################################################################################################################
|
||||
|
||||
add_commonlibsse_plugin(${PROJECT_NAME} SOURCES ${headers} ${sources})
|
||||
|
||||
add_library("${PROJECT_NAME}::${PROJECT_NAME}" ALIAS "${PROJECT_NAME}")
|
||||
|
||||
# Steamworks SDK import library, shipped in src/ next to the steam/ headers.
|
||||
target_link_libraries(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/steam_api64.lib)
|
||||
|
||||
target_link_libraries(CommonLibSSE PUBLIC
|
||||
@ -188,7 +156,7 @@ target_include_directories(${PROJECT_NAME}
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
)
|
||||
|
||||
|
||||
target_precompile_headers(${PROJECT_NAME}
|
||||
PRIVATE
|
||||
src/PCH.h
|
||||
@ -196,6 +164,7 @@ target_precompile_headers(${PROJECT_NAME}
|
||||
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION "${CMAKE_INSTALL_LIBDIR}")
|
||||
|
||||
|
||||
########################################################################################################################
|
||||
## Automatic plugin deployment
|
||||
########################################################################################################################
|
||||
|
||||
@ -13,6 +13,17 @@
|
||||
"CMAKE_CXX_FLAGS": "$env{COMMONLIBSSE_COMPILER} $env{COMMONLIBSSE_PLATFORM} $env{COMMONLIBSSE_TEXT}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "vcpkg",
|
||||
"hidden": true,
|
||||
"cacheVariables": {
|
||||
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
|
||||
"VCPKG_TARGET_TRIPLET": "x64-windows-skse",
|
||||
"VCPKG_HOST_TRIPLET": "x64-windows-skse",
|
||||
"VCPKG_OVERLAY_TRIPLETS": "${sourceDir}/cmake",
|
||||
"CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "win32",
|
||||
"hidden": true,
|
||||
@ -68,68 +79,100 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-tests",
|
||||
"displayName": "Build Tests",
|
||||
"hidden": true,
|
||||
"description": "Include test suites in the build.",
|
||||
"cacheVariables": {
|
||||
"BUILD_TESTS": {
|
||||
"type": "STRING",
|
||||
"value": "ON"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-release-msvc",
|
||||
"inherits": [
|
||||
"base",
|
||||
"vcpkg",
|
||||
"win32-unicode",
|
||||
"x64",
|
||||
"build-tests",
|
||||
"msvc"
|
||||
],
|
||||
"displayName": "Release (MSVC)",
|
||||
"displayName": "Release",
|
||||
"description": "Optimized release build.",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/release-msvc",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
"CMAKE_BUILD_TYPE": {
|
||||
"type": "STRING",
|
||||
"value": "Release"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-debug-msvc",
|
||||
"inherits": [
|
||||
"base",
|
||||
"vcpkg",
|
||||
"win32-unicode",
|
||||
"x64",
|
||||
"build-tests",
|
||||
"msvc"
|
||||
],
|
||||
"displayName": "Debug (MSVC)",
|
||||
"displayName": "Debug",
|
||||
"description": "Debug build for testing.",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/debug-msvc",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-release-clang-cl",
|
||||
"inherits": [
|
||||
"base",
|
||||
"win32-unicode",
|
||||
"x64",
|
||||
"clang-cl"
|
||||
],
|
||||
"displayName": "Release (Clang)",
|
||||
"description": "Optimized release build.",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/release-clang",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Release"
|
||||
"CMAKE_BUILD_TYPE": {
|
||||
"type": "STRING",
|
||||
"value": "Debug"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-debug-clang-cl",
|
||||
"inherits": [
|
||||
"base",
|
||||
"vcpkg",
|
||||
"win32-unicode",
|
||||
"x64",
|
||||
"build-tests",
|
||||
"clang-cl"
|
||||
],
|
||||
"displayName": "Debug (Clang)",
|
||||
"displayName": "Debug",
|
||||
"description": "Debug build for testing.",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/debug-clang",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": "Debug"
|
||||
"CMAKE_BUILD_TYPE": {
|
||||
"type": "STRING",
|
||||
"value": "Debug"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "build-release-clang-cl",
|
||||
"inherits": [
|
||||
"base",
|
||||
"vcpkg",
|
||||
"win32-unicode",
|
||||
"x64",
|
||||
"build-tests",
|
||||
"clang-cl"
|
||||
],
|
||||
"displayName": "Release",
|
||||
"description": "Optimized release build.",
|
||||
"generator": "Ninja",
|
||||
"binaryDir": "${sourceDir}/build/release-clang",
|
||||
"cacheVariables": {
|
||||
"CMAKE_BUILD_TYPE": {
|
||||
"type": "STRING",
|
||||
"value": "Release"
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
@ -158,5 +201,52 @@
|
||||
"configurePreset": "build-debug-clang-cl",
|
||||
"description": "Debug build for testing."
|
||||
}
|
||||
],
|
||||
"testPresets": [
|
||||
{
|
||||
"name": "tests-all",
|
||||
"displayName": "All Tests",
|
||||
"configurePreset": "build-debug-msvc",
|
||||
"output": {
|
||||
"outputOnFailure": true
|
||||
},
|
||||
"execution": {
|
||||
"noTestsAction": "error",
|
||||
"stopOnFailure": false
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tests-unit",
|
||||
"displayName": "Unit Tests",
|
||||
"description": "Runs tests that do not require any Skyrim module loaded into the process.",
|
||||
"inherits": "tests-all",
|
||||
"filter": {
|
||||
"exclude": {
|
||||
"label": "[integration],[e2e]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tests-integration",
|
||||
"displayName": "Integration Tests",
|
||||
"description": "Runs tests that interact with a Skyrim module at rest (do not require the Skyrim module to have run any main function).",
|
||||
"inherits": "tests-all",
|
||||
"filter": {
|
||||
"include": {
|
||||
"label": "[integration]"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "tests-e2e",
|
||||
"displayName": "End-to-End Tests",
|
||||
"description": "Runs test that depend on a fully running Skyrim engine in the process.",
|
||||
"inherits": "tests-all",
|
||||
"filter": {
|
||||
"include": {
|
||||
"label": "[e2e]"
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@ -1,47 +0,0 @@
|
||||
@echo off
|
||||
rem ---------------------------------------------------------------------------
|
||||
rem Command-line build wrapper.
|
||||
rem
|
||||
rem Sets up the MSVC x64 environment (the piece Visual Studio configures for you
|
||||
rem automatically) and then drives the exact same CMake presets that Visual
|
||||
rem Studio uses, so both build paths stay in sync.
|
||||
rem
|
||||
rem Usage: build.cmd [preset]
|
||||
rem preset defaults to "release-msvc". Other options: debug-msvc,
|
||||
rem release-clang-cl, debug-clang-cl (must match a name in CMakePresets.json).
|
||||
rem ---------------------------------------------------------------------------
|
||||
setlocal
|
||||
|
||||
set "PRESET=%~1"
|
||||
if "%PRESET%"=="" set "PRESET=release-msvc"
|
||||
set "CONFIGURE_PRESET=build-%PRESET%"
|
||||
|
||||
cd /d "%~dp0"
|
||||
|
||||
rem --- Locate Visual Studio (or the C++ Build Tools) ---
|
||||
set "VSWHERE=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
|
||||
if not exist "%VSWHERE%" (
|
||||
echo [ERROR] vswhere.exe not found. Install Visual Studio 2022 or the C++ Build Tools.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
set "VSINSTALL="
|
||||
for /f "usebackq delims=" %%i in (`"%VSWHERE%" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do set "VSINSTALL=%%i"
|
||||
if not defined VSINSTALL (
|
||||
echo [ERROR] No Visual Studio installation with the C++ toolset was found.
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
rem --- Import the MSVC x64 developer environment ---
|
||||
call "%VSINSTALL%\VC\Auxiliary\Build\vcvars64.bat" || exit /b 1
|
||||
|
||||
rem --- Point Visual Studio at this same CMake, so the two drivers can share the
|
||||
rem build tree incrementally (see cmake\write_user_presets.cmake) ---
|
||||
cmake -P cmake\write_user_presets.cmake || exit /b 1
|
||||
|
||||
rem --- Configure and build using the shared presets ---
|
||||
cmake --preset %CONFIGURE_PRESET% || exit /b 1
|
||||
cmake --build --preset %PRESET% || exit /b 1
|
||||
|
||||
echo.
|
||||
echo [OK] Built preset "%PRESET%". Plugin deployed to SKSE\Plugins\.
|
||||
@ -1,23 +0,0 @@
|
||||
# Patch applied to DirectXTK's CMakeLists.txt via FetchContent PATCH_COMMAND.
|
||||
#
|
||||
# DirectXTK compiles its HLSL shaders by running Src/Shaders/CompileShaders.cmd
|
||||
# through `cmake -E env ... CompileShaders.cmd` (a bare script name, relying on
|
||||
# the custom command's WORKING_DIRECTORY). Modern CMake no longer resolves a
|
||||
# bare command name against the working directory, so the step fails with
|
||||
# "no such file or directory" and the whole build stops.
|
||||
#
|
||||
# Rewrite that single invocation to an absolute path. WORKING_DIRECTORY is left
|
||||
# untouched so the script still runs with Src/Shaders as its CWD. The replace is
|
||||
# idempotent: after patching, the original "CompileShaders.cmd ARGS" substring is
|
||||
# gone, so re-running the patch is a no-op. It also targets only the COMMAND line
|
||||
# (the MAIN_DEPENDENCY reference already uses a full path and is not matched).
|
||||
set(_dxtk_cmakelists "CMakeLists.txt")
|
||||
|
||||
file(READ "${_dxtk_cmakelists}" _dxtk_content)
|
||||
string(REPLACE
|
||||
"CompileShaders.cmd ARGS"
|
||||
"\"\${PROJECT_SOURCE_DIR}/Src/Shaders/CompileShaders.cmd\" ARGS"
|
||||
_dxtk_content "${_dxtk_content}")
|
||||
file(WRITE "${_dxtk_cmakelists}" "${_dxtk_content}")
|
||||
|
||||
message(STATUS "Patched DirectXTK CompileShaders.cmd invocation to use an absolute path.")
|
||||
BIN
source/Steam DLL/cmake/version.rc.in
(Stored with Git LFS)
BIN
source/Steam DLL/cmake/version.rc.in
(Stored with Git LFS)
Binary file not shown.
@ -1,116 +0,0 @@
|
||||
# Generates CMakeUserPresets.json, pinning "cmakeExecutable" to the CMake that is
|
||||
# running this script - i.e. the one build.cmd itself uses.
|
||||
#
|
||||
# Why: both drivers share one binaryDir per configuration, so build.cmd and Visual
|
||||
# Studio write the same Ninja tree. Visual Studio otherwise uses its own bundled
|
||||
# CMake, and two CMake versions generating one tree emit different compile command
|
||||
# lines, which makes Ninja rebuild everything on every switch. See CLAUDE.md.
|
||||
#
|
||||
# Why generated rather than committed: Visual Studio resolves "cmakeExecutable"
|
||||
# against the current directory only - a bare "cmake" is not looked up on PATH - so
|
||||
# the value must be an absolute path, which is machine-specific and cannot live in
|
||||
# the committed CMakePresets.json.
|
||||
#
|
||||
# Run as: cmake -P cmake/write_user_presets.cmake
|
||||
|
||||
cmake_minimum_required(VERSION 3.21)
|
||||
|
||||
# Marks the file as ours, so a hand-written one is never clobbered.
|
||||
set(GENERATED_MARKER "local-cmake")
|
||||
|
||||
set(TEMPLATE [==[
|
||||
{
|
||||
"version": 2,
|
||||
"configurePresets": [
|
||||
{
|
||||
"name": "local-cmake",
|
||||
"hidden": true,
|
||||
"cmakeExecutable": "@CMAKE_COMMAND@"
|
||||
},
|
||||
{
|
||||
"name": "build-release-msvc-local",
|
||||
"inherits": [
|
||||
"local-cmake",
|
||||
"build-release-msvc"
|
||||
],
|
||||
"displayName": "Release (MSVC) [local CMake]",
|
||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
||||
},
|
||||
{
|
||||
"name": "build-debug-msvc-local",
|
||||
"inherits": [
|
||||
"local-cmake",
|
||||
"build-debug-msvc"
|
||||
],
|
||||
"displayName": "Debug (MSVC) [local CMake]",
|
||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
||||
},
|
||||
{
|
||||
"name": "build-release-clang-cl-local",
|
||||
"inherits": [
|
||||
"local-cmake",
|
||||
"build-release-clang-cl"
|
||||
],
|
||||
"displayName": "Release (Clang) [local CMake]",
|
||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
||||
},
|
||||
{
|
||||
"name": "build-debug-clang-cl-local",
|
||||
"inherits": [
|
||||
"local-cmake",
|
||||
"build-debug-clang-cl"
|
||||
],
|
||||
"displayName": "Debug (Clang) [local CMake]",
|
||||
"description": "Select this in Visual Studio: same build tree as build.cmd, pinned to the same CMake. Generated by build.cmd - do not edit."
|
||||
}
|
||||
],
|
||||
"buildPresets": [
|
||||
{
|
||||
"name": "release-msvc-local",
|
||||
"configurePreset": "build-release-msvc-local",
|
||||
"displayName": "Release (MSVC) [local CMake]"
|
||||
},
|
||||
{
|
||||
"name": "debug-msvc-local",
|
||||
"configurePreset": "build-debug-msvc-local",
|
||||
"displayName": "Debug (MSVC) [local CMake]"
|
||||
},
|
||||
{
|
||||
"name": "release-clang-cl-local",
|
||||
"configurePreset": "build-release-clang-cl-local",
|
||||
"displayName": "Release (Clang) [local CMake]"
|
||||
},
|
||||
{
|
||||
"name": "debug-clang-cl-local",
|
||||
"configurePreset": "build-debug-clang-cl-local",
|
||||
"displayName": "Debug (Clang) [local CMake]"
|
||||
}
|
||||
]
|
||||
}
|
||||
]==])
|
||||
|
||||
string(CONFIGURE "${TEMPLATE}" CONTENT @ONLY)
|
||||
|
||||
get_filename_component(OUTPUT_FILE "${CMAKE_CURRENT_LIST_DIR}/../CMakeUserPresets.json" ABSOLUTE)
|
||||
|
||||
if(EXISTS "${OUTPUT_FILE}")
|
||||
file(READ "${OUTPUT_FILE}" EXISTING)
|
||||
|
||||
# Unchanged: leave the timestamp alone, or Visual Studio reloads the presets
|
||||
# after every command-line build.
|
||||
if(EXISTING STREQUAL CONTENT)
|
||||
return()
|
||||
endif()
|
||||
|
||||
string(FIND "${EXISTING}" "\"${GENERATED_MARKER}\"" MARKER_POS)
|
||||
if(MARKER_POS EQUAL -1)
|
||||
message(WARNING
|
||||
"CMakeUserPresets.json was not generated by build.cmd - leaving it untouched.\n"
|
||||
"Delete it to let build.cmd manage it, or add \"cmakeExecutable\": \"${CMAKE_COMMAND}\" to it yourself."
|
||||
)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(WRITE "${OUTPUT_FILE}" "${CONTENT}")
|
||||
message(STATUS "Wrote CMakeUserPresets.json (cmakeExecutable: ${CMAKE_COMMAND})")
|
||||
BIN
source/Steam DLL/cmake/x64-windows-skse.cmake
(Stored with Git LFS)
Normal file
BIN
source/Steam DLL/cmake/x64-windows-skse.cmake
(Stored with Git LFS)
Normal file
Binary file not shown.
@ -1,182 +1,66 @@
|
||||
#include "Achievements.h"
|
||||
#include "Util.h"
|
||||
#include "steam/steam_api.h"
|
||||
#include <cstdlib>
|
||||
#include <string>
|
||||
#include <processenv.h>
|
||||
|
||||
namespace Achievements {
|
||||
|
||||
namespace {
|
||||
// Enderal's own AppIDs. Skyrim SE is 489830.
|
||||
constexpr const char* APPID_ENDERAL_SE = "976620";
|
||||
constexpr const char* APPID_ENDERAL_LE = "933480";
|
||||
|
||||
bool bInitFailed = false;
|
||||
bool bWarnOnInitFail = true;
|
||||
|
||||
constexpr const char* STEAMCLIENT_MODULE = "steamclient64.dll";
|
||||
|
||||
// Which app a process is registered as is decided by steamclient64.dll, and
|
||||
// these variables are how it is told. It latches them when the module is
|
||||
// *loaded* into the process - not when a pipe is created - so changing them
|
||||
// afterwards does nothing at all. steam_api never reads them back either, it
|
||||
// asks ISteamUtils::GetAppID(). (steam_appid.txt is no help: only
|
||||
// SteamAPI_RestartAppIfNecessary reads it, and Skyrim does not call that.)
|
||||
void setAppIdEnvironment(const char* appId)
|
||||
{
|
||||
SetEnvironmentVariableA("SteamAppId", appId);
|
||||
SetEnvironmentVariableA("SteamGameId", appId);
|
||||
SetEnvironmentVariableA("SteamOverlayGameId", appId);
|
||||
}
|
||||
|
||||
void logEnvironment(const char* label)
|
||||
{
|
||||
static const char* const vars[] = { "SteamAppId", "SteamGameId", "SteamOverlayGameId", "SteamClientLaunch" };
|
||||
for (const char* name : vars) {
|
||||
char value[64] = "<unset>";
|
||||
GetEnvironmentVariableA(name, value, sizeof(value));
|
||||
logger::info("[{}] {} = {}", label, name, value);
|
||||
}
|
||||
}
|
||||
|
||||
void logModuleState(const char* label)
|
||||
{
|
||||
logger::info("[{}] steam_api64={}, {}={}, GameOverlayRenderer64={}",
|
||||
label,
|
||||
GetModuleHandleA("steam_api64.dll") ? "loaded" : "absent",
|
||||
STEAMCLIENT_MODULE,
|
||||
GetModuleHandleA(STEAMCLIENT_MODULE) ? "loaded" : "absent",
|
||||
GetModuleHandleA("GameOverlayRenderer64.dll") ? "loaded" : "absent");
|
||||
}
|
||||
|
||||
// Drop every outstanding reference to steamclient64.dll so that the
|
||||
// SteamAPI_Init() below loads a fresh copy, which then picks up the AppID we
|
||||
// just put in the environment. Something loads it before SKSE gets control
|
||||
// (the SteamStub DRM wrapper is the only candidate that runs that early) and
|
||||
// leaves it resident with Skyrim's AppID latched in.
|
||||
//
|
||||
// SteamAPI_Shutdown() has to run first: it releases steam_api's own reference
|
||||
// and clears its cached module handle, so it will not later FreeLibrary a
|
||||
// handle we already invalidated.
|
||||
bool unloadSteamClient()
|
||||
{
|
||||
constexpr int MAX_REFERENCES = 32;
|
||||
|
||||
int released = 0;
|
||||
while (auto* module = GetModuleHandleA(STEAMCLIENT_MODULE)) {
|
||||
if (released >= MAX_REFERENCES) {
|
||||
logger::error("{} is still loaded after releasing {} references, giving up", STEAMCLIENT_MODULE, released);
|
||||
return false;
|
||||
}
|
||||
FreeLibrary(module);
|
||||
++released;
|
||||
}
|
||||
|
||||
if (released > 0) {
|
||||
logger::info("Unloaded {} after releasing {} reference(s)", STEAMCLIENT_MODULE, released);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
bool steamInitFailed()
|
||||
{
|
||||
return bInitFailed;
|
||||
}
|
||||
|
||||
bool shouldWarnOnInitFail()
|
||||
{
|
||||
return bWarnOnInitFail;
|
||||
}
|
||||
|
||||
void startSteam()
|
||||
{
|
||||
std::map<std::string, bool> settings{
|
||||
{ "SendAchievementsToLE", false },
|
||||
{ "TestMode", false },
|
||||
{ "ShowWarningOnInitFail", true },
|
||||
{ "ReloadSteamClient", true }
|
||||
{ "ShowWarningOnInitFail", true }
|
||||
};
|
||||
LoadINI(&settings, "Data/SKSE/Plugins/EnderalSteam.ini");
|
||||
|
||||
AchievementsEnabled(!settings.at("TestMode"));
|
||||
bWarnOnInitFail = settings.at("ShowWarningOnInitFail");
|
||||
|
||||
if (settings.at("TestMode")) {
|
||||
logger::info("{}", "TestMode is on, leaving the Steam session alone");
|
||||
return;
|
||||
}
|
||||
|
||||
if (SteamInstance() != nullptr) {
|
||||
logger::info("{}", "Already initialized steam api, skipping it");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const char* appId = settings.at("SendAchievementsToLE") ? APPID_ENDERAL_LE : APPID_ENDERAL_SE;
|
||||
if (SteamInstance() == nullptr) {
|
||||
SteamAPI_Shutdown();
|
||||
|
||||
logModuleState("BEFORE");
|
||||
logEnvironment("BEFORE");
|
||||
logger::info("[BEFORE] HSteamUser = {}", SteamAPI_GetHSteamUser());
|
||||
|
||||
// This runs from SKSEPluginLoad, i.e. after the CRT global initializers but
|
||||
// before WinMain. Skyrim opens its own Steam session much later, from
|
||||
// BSWin32SystemUtility, so we get here first and its SteamAPI_Init() then
|
||||
// returns early because ours is already up.
|
||||
//
|
||||
// Being first is not enough on its own, though - see unloadSteamClient().
|
||||
SteamAPI_Shutdown();
|
||||
|
||||
if (settings.at("ReloadSteamClient")) {
|
||||
unloadSteamClient();
|
||||
}
|
||||
|
||||
setAppIdEnvironment(appId);
|
||||
|
||||
if (!SteamAPI_Init()) {
|
||||
bInitFailed = true;
|
||||
logger::error("{}", "Error while initializing the steam api");
|
||||
return;
|
||||
}
|
||||
|
||||
logger::info("Steam api init was successfull, requested AppID {}", appId);
|
||||
|
||||
// The AppID the Steam client actually gave us. Anything other than the one
|
||||
// requested above means the session still belongs to another app - Enderal's
|
||||
// achievement names would not resolve there - so treat it like a failed init:
|
||||
// leave achievements unwired and let the main-menu warning fire.
|
||||
if (auto* utils = SteamUtils()) {
|
||||
const uint32 sessionAppId = utils->GetAppID();
|
||||
logger::info("Steam session is registered as AppID {}", sessionAppId);
|
||||
if (sessionAppId != static_cast<uint32>(std::strtoul(appId, nullptr, 10))) {
|
||||
bInitFailed = true;
|
||||
logger::error("{}", "Session kept a foreign AppID, not wiring up achievements");
|
||||
return;
|
||||
if (settings.at("SendAchievementsToLE")) {
|
||||
SetEnvironmentVariable(L"SteamAppID", L"933480");
|
||||
SetEnvironmentVariable(L"SteamGameId", L"933480");
|
||||
} else {
|
||||
SetEnvironmentVariable(L"SteamAppID", L"976620");
|
||||
SetEnvironmentVariable(L"SteamGameId", L"976620");
|
||||
}
|
||||
} else {
|
||||
logger::warn("{}", "ISteamUtils is unavailable, cannot verify the session AppID");
|
||||
|
||||
bool success = SteamAPI_Init();
|
||||
|
||||
if (success) {
|
||||
logger::info("{}", "Steam api init was successfull");
|
||||
} else {
|
||||
logger::error("{}", "Error while initializing the steam api");
|
||||
if (settings.at("ShowWarningOnInitFail")) {
|
||||
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
||||
}
|
||||
}
|
||||
|
||||
SteamInstance(new AchievementHolder());
|
||||
}
|
||||
else {
|
||||
logger::info("{}", "Already initialized steam api, skipping it");
|
||||
}
|
||||
|
||||
auto* holder = new AchievementHolder();
|
||||
SteamInstance(holder);
|
||||
|
||||
// Steam wants the user's stats downloaded before achievements can be set.
|
||||
// Nothing used to call this, so UserStatsReceived_t never fired.
|
||||
holder->start();
|
||||
}
|
||||
catch (const std::exception& ex) {
|
||||
bInitFailed = true;
|
||||
std::string msg = "Exception while initializing the Steam API, steam achievements will not be available: " + std::string(ex.what());
|
||||
logger::error("{}", msg.c_str());
|
||||
if (settings.at("ShowWarningOnInitFail")) {
|
||||
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AchievementHolder::AchievementHolder() : stats(SteamUserStats()), callback(this, &AchievementHolder::onUserStatsReceived)
|
||||
{
|
||||
if (!this->stats) {
|
||||
logger::error("{}", "ISteamUserStats is unavailable, achievements will not be unlocked");
|
||||
}
|
||||
}
|
||||
|
||||
void AchievementHolder::onUserStatsReceived(UserStatsReceived_t * event) {
|
||||
@ -196,11 +80,6 @@ namespace Achievements {
|
||||
|
||||
bool AchievementHolder::setAchievementUnlocked(const char * achievementName)
|
||||
{
|
||||
if (!this->stats) {
|
||||
logger::error("{}", "Cannot unlock achievement, ISteamUserStats is unavailable");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string msg = "Unlocking achievement: " + std::string(achievementName);
|
||||
logger::info("{}", msg.c_str());
|
||||
bool success = this->stats->SetAchievement(achievementName);
|
||||
@ -217,12 +96,6 @@ namespace Achievements {
|
||||
|
||||
void AchievementHolder::start()
|
||||
{
|
||||
if (!this->stats) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this->stats->RequestCurrentStats()) {
|
||||
logger::error("{}", "RequestCurrentStats failed, achievements may not unlock");
|
||||
}
|
||||
this->stats->RequestCurrentStats();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
//Steam API version 1.55, matching Skyrim SE 1.6.1170 (pre-1.6.1130 shipped 1.31)
|
||||
//Steam API Version 1.31 matches the Skyrim Steam API version
|
||||
#include "steam/steam_api.h"
|
||||
#include <memory>
|
||||
|
||||
namespace Achievements {
|
||||
|
||||
@ -17,11 +18,7 @@ namespace Achievements {
|
||||
bool setAchievementUnlocked(const char * achievementName);
|
||||
};
|
||||
|
||||
// Opens the Steam session under Enderal's AppID. Must run before the game
|
||||
// opens its own - see the comment inside.
|
||||
void startSteam();
|
||||
static std::unique_ptr<AchievementHolder> singleton(nullptr);
|
||||
|
||||
// Result of startSteam(), so the warning can be shown once a UI exists.
|
||||
bool steamInitFailed();
|
||||
bool shouldWarnOnInitFail();
|
||||
}
|
||||
void startSteam();
|
||||
}
|
||||
@ -20,12 +20,8 @@ auto EventListener::ProcessEvent(
|
||||
{
|
||||
if (a_event->opening && a_event->menuName == "Main Menu") {
|
||||
RE::UI::GetSingleton()->RemoveEventSink<RE::MenuOpenCloseEvent>(GetSingleton());
|
||||
|
||||
// Steam is started at plugin load, long before there is a UI to complain to,
|
||||
// so the warning waits until the main menu is up.
|
||||
if (Achievements::steamInitFailed() && Achievements::shouldWarnOnInitFail()) {
|
||||
RE::DebugMessageBox("Unable to initialize Steam achievements. Try to restart the game and the Steam client. This warning can be disabled in SKSE\\Plugins\\EnderalSteam.ini.");
|
||||
}
|
||||
logger::info("{}", "Main menu opened, trying to init steam API.");
|
||||
Achievements::startSteam();
|
||||
}
|
||||
|
||||
return RE::BSEventNotifyControl::kContinue;
|
||||
|
||||
@ -38,11 +38,6 @@ SKSEPluginLoad(const LoadInterface* skse) {
|
||||
|
||||
Init(skse);
|
||||
|
||||
// Has to happen here, not from a game event: the game opens its own Steam session
|
||||
// from BSWin32SystemUtility during WinMain, and whichever session is opened first
|
||||
// decides which AppID the process stays registered as.
|
||||
Achievements::startSteam();
|
||||
|
||||
EventListener::Install();
|
||||
|
||||
GetPapyrusInterface()->Register(Papyrus::Bind);
|
||||
|
||||
@ -8,12 +8,7 @@ namespace Papyrus::PapyrusFunctions
|
||||
bool CallUnlockAchievement(RE::StaticFunctionTag* tag, RE::BSFixedString achievement)
|
||||
{
|
||||
if (AchievementsEnabled()) {
|
||||
auto* steam = SteamInstance();
|
||||
if (!steam) {
|
||||
logger::error("Steam is not initialized, cannot unlock achievement: {}", achievement.c_str());
|
||||
return false;
|
||||
}
|
||||
return steam->setAchievementUnlocked(achievement.c_str());
|
||||
return SteamInstance()->setAchievementUnlocked(achievement.c_str());
|
||||
} else {
|
||||
RE::DebugNotification(std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
||||
logger::info("{}", std::format("Achievement unlocked: {}", achievement.c_str()).c_str());
|
||||
|
||||
@ -2,7 +2,6 @@
|
||||
|
||||
#include "Achievements.h"
|
||||
#include <SimpleIni.h>
|
||||
#include <optional>
|
||||
|
||||
inline const SKSE::LoadInterface* GetLoadInterface(const SKSE::LoadInterface* loadInterface = nullptr)
|
||||
{
|
||||
@ -22,11 +21,11 @@ inline Achievements::AchievementHolder* SteamInstance(Achievements::AchievementH
|
||||
return singleton;
|
||||
}
|
||||
|
||||
inline bool AchievementsEnabled(std::optional<bool> bEnabled = std::nullopt)
|
||||
inline bool AchievementsEnabled(bool bEnabled = NULL)
|
||||
{
|
||||
static bool value = false;
|
||||
if (bEnabled.has_value()) {
|
||||
value = *bEnabled;
|
||||
static bool value;
|
||||
if (bEnabled != NULL) {
|
||||
value = bEnabled;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
@ -69,7 +68,7 @@ inline void LoadINI(std::map<std::string, bool>* settings, const char* iniPath)
|
||||
}
|
||||
|
||||
if (bUpdateINI) {
|
||||
logger::info("New settings detected, updating {}", iniPath);
|
||||
logger::info("New settings detected, adding to ArtifactTracker.ini");
|
||||
ini.SaveFile(iniPath);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user