diff --git a/CMakeLists.txt b/CMakeLists.txt index a3b8507..c32a841 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,11 @@ cmake_minimum_required(VERSION 3.27) -######################################################################################################################## -## Define project -######################################################################################################################## project( PluginName VERSION 0.0.1 LANGUAGES CXX ) + set(CMAKE_CXX_STANDARD 23) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON) @@ -16,10 +14,11 @@ set(CMAKE_OPTIMIZE_DEPENDENCIES ON) include(GNUInstallDirs) +# CPM include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/CPM.cmake) - set(CPM_SOURCE_CACHE ${CMAKE_CURRENT_BINARY_DIR}/.cpm) +# Dependencies CPMAddPackage("gh:Starfield-Reverse-Engineering/CommonLibSF#main") CPMAddPackage("gh:brofield/simpleini@4.20") @@ -31,30 +30,25 @@ configure_file( @ONLY ) -set(PUBLIC_HEADER_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/${PROJECT_NAME}) - -set( +# Add headers +file( + GLOB_RECURSE headers - include/Utility.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h + ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp ) +list(REMOVE_ITEM headers ${CMAKE_CURRENT_SOURCE_DIR}/include/PCH.h) -set( +# Add sources +file( + GLOB_RECURSE sources - src/Main.cpp - src/Settings.cpp - src/Hooks.cpp - + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cc ${CMAKE_CURRENT_BINARY_DIR}/version.rc ) -source_group( - TREE ${CMAKE_CURRENT_SOURCE_DIR} - FILES ${headers} ${sources} -) - -######################################################################################################################## -## Configure target DLL -######################################################################################################################## +# Create plugin add_commonlibsf_plugin( ${PROJECT_NAME} AUTHOR AuthorName @@ -69,7 +63,7 @@ target_include_directories( $ $ $ - ${SimpleIni_SOURCE_DIR} + $ PUBLIC $ ) @@ -81,19 +75,11 @@ target_precompile_headers( ${SimpleIni_SOURCE_DIR}/SimpleIni.h ) -install( - DIRECTORY ${PUBLIC_HEADER_DIR} - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} -) - install( TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR} ) -######################################################################################################################## -## Automatic plugin deployment -######################################################################################################################## if(CMAKE_BUILD_TYPE STREQUAL Debug) set(BUILD_NAME Debug) else() @@ -113,8 +99,8 @@ add_custom_command( ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Config/${PROJECT_NAME}.ini ${CMAKE_CURRENT_SOURCE_DIR}/contrib/Plugin${BUILD_NAME}/sfse/plugins ) -file(GLOB_RECURSE OUTPUT_DLLS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.dll) -file(GLOB_RECURSE OUTPUT_PDBS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/**/*.pdb) +file(GLOB_RECURSE OUTPUT_DLLS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/*.dll) +file(GLOB_RECURSE OUTPUT_PDBS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/*.pdb) set_property( TARGET ${PROJECT_NAME} diff --git a/CMakePresets.json b/CMakePresets.json index 01c1937..8753320 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -9,37 +9,25 @@ { "name": "base", "hidden": true, - "cacheVariables": { - "CMAKE_CXX_FLAGS": "$env{COMMONLIBSF_COMPILER} $env{COMMONLIBSF_PLATFORM} $penv{CXXFLAGS}", - "CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}", - "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreaded$<$:Debug>DLL" - } - }, - { - "name": "win32", - "hidden": true, "environment": { - "COMMONLIBSF_PLATFORM": "-DWIN32_LEAN_AND_MEAN -DNOMINMAX" - } - }, - { - "name": "x64", - "hidden": true, - "architecture": { - "value": "x64", - "strategy": "external" - } + "WINDOWS_FLAGS": "-DWIN32_LEAN_AND_MEAN -DNOMINMAX" + }, + "cacheVariables": { + "CMAKE_CXX_FLAGS": "/cgthreads8 /EHsc /fp:contract /fp:except- /W4 /Zc:__cplusplus $env{COMPILER_FLAGS} $env{WINDOWS_FLAGS} $penv{CXXFLAGS}", + "CMAKE_SHARED_LINKER_FLAGS": "$env{COMMONLIBSF_LINKER} $penv{SHARED_LINKER_FLAGS}" + }, + "cmakeExecutable": "C:/Program Files/CMake/bin/", + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}" }, { "name": "clang-cl", "hidden": true, - "generator": "Ninja", - "cmakeExecutable": "C:/Program Files/CMake/bin/", "cacheVariables": { "CMAKE_CXX_COMPILER": "clang-cl" }, "environment": { - "COMMONLIBSF_COMPILER": "/cgthreads8 /diagnostics:caret /EHsc /fp:contract /fp:except- /guard:cf- /permissive- /sdl /W4 /Zc:__cplusplus /Zc:rvalueCast /Zc:ternary -Wno-unused-private-field -Wno-unused-parameter -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-unused-command-line-argument" + "COMPILER_FLAGS": "-fms-extensions -fdelayed-template-parsing -Wno-unused-private-field -Wno-unused-parameter -Wno-overloaded-virtual -Wno-delete-non-abstract-non-virtual-dtor -Wno-unused-command-line-argument" }, "vendor": { "microsoft.com/VisualStudioSettings/CMake/1.0": { @@ -53,9 +41,8 @@ "name": "msvc", "hidden": true, "generator": "Ninja", - "cmakeExecutable": "C:/Program Files/CMake/bin/", "environment": { - "COMMONLIBSF_COMPILER": "/cgthreads8 /diagnostics:caret /EHsc /fp:contract /fp:except- /guard:cf- /MP /permissive- /sdl /W4 /Zc:__cplusplus /Zc:enumTypes /Zc:lambda /Zc:preprocessor /Zc:referenceBinding /Zc:rvalueCast /Zc:templateScope /Zc:ternary", + "COMPILER_FLAGS": "/favor:blend /Zc:enumTypes /Zc:preprocessor /Zc:templateScope", "COMMONLIBSF_LINKER": "/CGTHREADS:8 /MACHINE:x64 /DEBUG:FULL" }, "vendor": { @@ -67,72 +54,60 @@ }, { "name": "build-release-clang-cl", - "inherits": ["base", "win32", "x64", "clang-cl"], + "inherits": ["base", "clang-cl"], "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2" - }, - "displayName": "Release", - "description": "Optimized release build.", - "binaryDir": "${sourceDir}/build/release-clang-cl" + } }, { "name": "build-debug-clang-cl", - "inherits": ["base", "win32", "x64", "clang-cl"], + "inherits": ["base", "clang-cl"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug" - }, - "displayName": "Debug", - "description": "Debug build.", - "binaryDir": "${sourceDir}/build/debug-clang-cl" + } }, { "name": "build-release-msvc", - "inherits": ["base", "win32", "x64", "msvc"], + "inherits": ["base", "msvc"], "cacheVariables": { "CMAKE_BUILD_TYPE": "RelWithDebInfo", "CMAKE_CXX_FLAGS_RELWITHDEBINFO": "/fp:fast /GR- /Gw /O2 /Ob3 /Qpar", "CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO": "/LTCG:INCREMENTAL /OPT:ICF=4" - }, - "displayName": "Release", - "description": "Optimized release build.", - "binaryDir": "${sourceDir}/build/release-msvc" + } }, { "name": "build-debug-msvc", - "inherits": ["base", "win32", "x64", "msvc"], + "inherits": ["base", "msvc"], "cacheVariables": { "CMAKE_BUILD_TYPE": "Debug", "CMAKE_SHARED_LINKER_FLAGS_DEBUG": "/DEBUGTYPE:FIXUP" - }, - "displayName": "Debug", - "description": "Debug build.", - "binaryDir": "${sourceDir}/build/debug-msvc" + } } ], "buildPresets": [ { - "name": "release-clang-cl", - "displayName": "1. Release (clang-cl)", - "configurePreset": "build-release-clang-cl", + "name": "release-msvc", + "displayName": "1. Release (MSVC)", + "configurePreset": "build-release-msvc", "description": "Optimized release build." }, { - "name": "debug-clang-cl", - "displayName": "2. Debug (clang-cl)", - "configurePreset": "build-debug-clang-cl", + "name": "debug-msvc", + "displayName": "2. Debug (MSVC)", + "configurePreset": "build-debug-msvc", "description": "Debug build." }, { - "name": "release-msvc", - "displayName": "3. Release (MSVC)", - "configurePreset": "build-release-msvc", + "name": "release-clang-cl", + "displayName": "3. Release (clang-cl)", + "configurePreset": "build-release-clang-cl", "description": "Optimized release build." }, { - "name": "debug-msvc", - "displayName": "4. Debug (MSVC)", - "configurePreset": "build-debug-msvc", + "name": "debug-clang-cl", + "displayName": "4. Debug (clang-cl)", + "configurePreset": "build-debug-clang-cl", "description": "Debug build." } ] diff --git a/include/PCH.h b/include/PCH.h index 3a9f95b..7a72dd7 100644 --- a/include/PCH.h +++ b/include/PCH.h @@ -160,6 +160,7 @@ class Singleton public: constexpr Singleton(const Singleton&) = delete; constexpr Singleton(Singleton&&) = delete; + constexpr auto operator=(const Singleton&) = delete; constexpr auto operator=(Singleton&&) = delete; diff --git a/src/Main.cpp b/src/Main.cpp index 5d30351..b4b0097 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -4,13 +4,19 @@ // SFSE message listener, use this to do stuff at specific moments during runtime void Listener(SFSE::MessagingInterface::Message* message) noexcept { - if (message->type <=> SFSE::MessagingInterface::kPostLoad == 0) { + switch (message->type) { + case SFSE::MessagingInterface::kPostLoad: { } - if (message->type <=> SFSE::MessagingInterface::kPostPostLoad == 0) { + case SFSE::MessagingInterface::kPostPostLoad: { + } + case SFSE::MessagingInterface::kPostDataLoad: { Settings::LoadSettings(); Hooks::Install(); } - if (message->type <=> SFSE::MessagingInterface::kPostDataLoad == 0) { + case SFSE::MessagingInterface::kPostPostDataLoad: { + } + default: { + } } }