diff --git a/CMakeLists.txt b/CMakeLists.txt index 698772f4..76dc6113 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,7 +77,6 @@ include(FetchContent) include("${RED4EXT_CMAKE_DEPS_DIR}/Detours.cmake") include("${RED4EXT_CMAKE_DEPS_DIR}/Fmt.cmake") -include("${RED4EXT_CMAKE_DEPS_DIR}/OrderedMap.cmake") include("${RED4EXT_CMAKE_DEPS_DIR}/RED4extSdk.cmake") include("${RED4EXT_CMAKE_DEPS_DIR}/Redscript.cmake") include("${RED4EXT_CMAKE_DEPS_DIR}/Simdjson.cmake") @@ -88,6 +87,10 @@ include("${RED4EXT_CMAKE_DEPS_DIR}/Wil.cmake") # ------------------------------------------------------------------------------ # Toolchain settings for this project only # ------------------------------------------------------------------------------ +add_compile_definitions( + NOMINMAX +) + add_compile_options( /GS /sdl diff --git a/cmake/deps/Detours.cmake b/cmake/deps/Detours.cmake index 3217ba0c..e9b15089 100644 --- a/cmake/deps/Detours.cmake +++ b/cmake/deps/Detours.cmake @@ -1,7 +1,7 @@ FetchContent_Declare( Detours GIT_REPOSITORY https://github.com/microsoft/Detours.git - GIT_TAG 4b8c659f549b0ab21cf649377c7a84eb708f5e68 + GIT_TAG 9764cebcb1a75940e68fa83d6730ffaf0f669401 ) FetchContent_MakeAvailable(Detours) diff --git a/cmake/deps/Fmt.cmake b/cmake/deps/Fmt.cmake index 2b12e8d7..fbaffb0c 100644 --- a/cmake/deps/Fmt.cmake +++ b/cmake/deps/Fmt.cmake @@ -1,9 +1,7 @@ -option(FMT_INSTALL "" OFF) - FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 10.1.1 + GIT_TAG 12.1.0 GIT_SHALLOW ON ) FetchContent_MakeAvailable(fmt) @@ -15,19 +13,17 @@ set_target_properties( ) mark_as_advanced( - FMT_CMAKE_DIR FMT_CUDA_TEST FMT_DEBUG_POSTFIX FMT_DOC FMT_FUZZ FMT_INC_DIR FMT_INSTALL - FMT_LIB_DIR FMT_MODULE FMT_OS FMT_PEDANTIC - FMT_PKGCONFIG_DIR FMT_SYSTEM_HEADERS FMT_TEST + FMT_UNICODE FMT_WERROR ) diff --git a/cmake/deps/OrderedMap.cmake b/cmake/deps/OrderedMap.cmake deleted file mode 100644 index f9803832..00000000 --- a/cmake/deps/OrderedMap.cmake +++ /dev/null @@ -1,13 +0,0 @@ -FetchContent_Declare( - ordered_map - GIT_REPOSITORY https://github.com/Tessil/ordered-map.git - GIT_TAG 5bbd64709218b9f9fc92bf2bbbf7cae6f5e067b6 - EXCLUDE_FROM_ALL # The project does not have any INSTALL options. -) -FetchContent_MakeAvailable(ordered_map) - -target_compile_definitions( - ordered_map - INTERFACE - NOMINMAX -) diff --git a/cmake/deps/RED4extSdk.cmake b/cmake/deps/RED4extSdk.cmake index a797dda2..9132d4d5 100644 --- a/cmake/deps/RED4extSdk.cmake +++ b/cmake/deps/RED4extSdk.cmake @@ -4,7 +4,7 @@ option(RED4EXT_USE_PCH "" ON) FetchContent_Declare( RED4ext.SDK GIT_REPOSITORY https://github.com/wopss/RED4ext.SDK.git - GIT_TAG 5e5d4fba9917a58a9622c72c4c902dfd27f553b8 + GIT_TAG 4ea14b652a8b52e8bda4efc7ab5e4a030d60407c ) FetchContent_MakeAvailable(RED4ext.SDK) diff --git a/cmake/deps/Simdjson.cmake b/cmake/deps/Simdjson.cmake index 54eedd0b..f2c33d23 100644 --- a/cmake/deps/Simdjson.cmake +++ b/cmake/deps/Simdjson.cmake @@ -1,9 +1,10 @@ option(SIMDJSON_BASH "" OFF) +set(SIMDJSON_CXX_STANDARD "${CMAKE_CXX_STANDARD}" CACHE STRING "") FetchContent_Declare( simdjson GIT_REPOSITORY https://github.com/simdjson/simdjson.git - GIT_TAG v3.6.4 + GIT_TAG v4.3.1 GIT_SHALLOW ON EXCLUDE_FROM_ALL # The project does not have any INSTALL options. ) @@ -16,6 +17,7 @@ set_target_properties( ) mark_as_advanced( + CMAKE_EXPORT_COMPILE_COMMANDS SIMDJSON_AVX512_ALLOWED SIMDJSON_BASH SIMDJSON_BUILD_STATIC_LIB @@ -31,10 +33,12 @@ mark_as_advanced( SIMDJSON_IMPLEMENTATION SIMDJSON_LIB_SOVERSION SIMDJSON_LIB_VERSION + SIMDJSON_MINUS_ZERO_AS_FLOAT SIMDJSON_SANITIZE SIMDJSON_SANITIZE_MEMORY SIMDJSON_SANITIZE_UNDEFINED SIMDJSON_SKIPUTF8VALIDATION + SIMDJSON_STATIC_REFLECTION SIMDJSON_STRUCTURAL_INDEXER_STEP SIMDJSON_VERBOSE_LOGGING SIMDJSON_VISUAL_STUDIO_BUILD_WITH_DEBUG_INFO_FOR_PROFILING diff --git a/cmake/deps/Spdlog.cmake b/cmake/deps/Spdlog.cmake index c52d2e23..e7334c8f 100644 --- a/cmake/deps/Spdlog.cmake +++ b/cmake/deps/Spdlog.cmake @@ -1,14 +1,14 @@ -option(SPDLOG_ENABLE_PCH "" ON) option(SPDLOG_DISABLE_DEFAULT_LOGGER "" ON) +option(SPDLOG_ENABLE_PCH "" ON) option(SPDLOG_FMT_EXTERNAL "" ON) -option(SPDLOG_NO_THREAD_ID "" OFF) +option(SPDLOG_WCHAR_CONSOLE "" ON) option(SPDLOG_WCHAR_FILENAMES "" ON) option(SPDLOG_WCHAR_SUPPORT "" ON) FetchContent_Declare( spdlog GIT_REPOSITORY https://github.com/gabime/spdlog.git - GIT_TAG v1.12.0 + GIT_TAG v1.17.0 GIT_SHALLOW ON ) FetchContent_MakeAvailable(spdlog) @@ -30,20 +30,26 @@ mark_as_advanced( SPDLOG_BUILD_TESTS_HO SPDLOG_BUILD_WARNINGS SPDLOG_CLOCK_COARSE + SPDLOG_DEBUG_POSTFIX SPDLOG_DISABLE_DEFAULT_LOGGER SPDLOG_ENABLE_PCH SPDLOG_FMT_EXTERNAL SPDLOG_FMT_EXTERNAL_HO + SPDLOG_FWRITE_UNLOCKED SPDLOG_INSTALL + SPDLOG_MSVC_UTF8 SPDLOG_NO_ATOMIC_LEVELS SPDLOG_NO_EXCEPTIONS SPDLOG_NO_THREAD_ID SPDLOG_NO_TLS + SPDLOG_NO_TZ_OFFSET SPDLOG_PREVENT_CHILD_FD SPDLOG_SANITIZE_ADDRESS + SPDLOG_SANITIZE_THREAD SPDLOG_SYSTEM_INCLUDES SPDLOG_TIDY SPDLOG_USE_STD_FORMAT + SPDLOG_WCHAR_CONSOLE SPDLOG_WCHAR_FILENAMES SPDLOG_WCHAR_SUPPORT ) diff --git a/cmake/deps/Toml11.cmake b/cmake/deps/Toml11.cmake index a2be7f68..f61fc68c 100644 --- a/cmake/deps/Toml11.cmake +++ b/cmake/deps/Toml11.cmake @@ -1,19 +1,15 @@ -option(toml11_INSTALL "" OFF) +option(BUILD_TESTING "" OFF) FetchContent_Declare( toml11 GIT_REPOSITORY https://github.com/ToruNiina/toml11.git - GIT_TAG v3.8.0 + GIT_TAG v4.4.0 GIT_SHALLOW ON ) FetchContent_MakeAvailable(toml11) mark_as_advanced( - CMAKE_CXX_EXTENSIONS - CMAKE_CXX_STANDARD_REQUIRED - toml11_BUILD_TEST - toml11_INSTALL - toml11_TEST_WITH_ASAN - toml11_TEST_WITH_UBSAN - TOML11_USE_UNRELEASED_TOML_FEATURES + BUILD_TESTING + TOML11_ENABLE_ACCESS_CHECK + TOML11_PRECOMPILE ) diff --git a/cmake/deps/Wil.cmake b/cmake/deps/Wil.cmake index 97f43990..0d938f11 100644 --- a/cmake/deps/Wil.cmake +++ b/cmake/deps/Wil.cmake @@ -4,7 +4,7 @@ option(WIL_BUILD_TESTS "" OFF) FetchContent_Declare( WIL GIT_REPOSITORY https://github.com/microsoft/wil.git - GIT_TAG ff206266eddc3d1f788e11db472d9f28d799e08f + GIT_TAG 3ecba603d9789435b0661be7b7154d45c195ef98 EXCLUDE_FROM_ALL # The project does not have any INSTALL options. ) FetchContent_MakeAvailable(WIL) @@ -13,4 +13,6 @@ mark_as_advanced( FAST_BUILD WIL_BUILD_PACKAGING WIL_BUILD_TESTS + WIL_ENABLE_ASAN + WIL_ENABLE_UBSAN ) diff --git a/src/dll/CMakeLists.txt b/src/dll/CMakeLists.txt index 79bd482f..9b079250 100644 --- a/src/dll/CMakeLists.txt +++ b/src/dll/CMakeLists.txt @@ -70,6 +70,5 @@ target_link_libraries( simdjson::simdjson spdlog::spdlog toml11::toml11 - tsl::ordered_map WIL::WIL ) diff --git a/src/dll/Config.cpp b/src/dll/Config.cpp index ab5ddca1..0a72f08c 100644 --- a/src/dll/Config.cpp +++ b/src/dll/Config.cpp @@ -1,7 +1,21 @@ -#include "stdafx.hpp" #include "Config.hpp" +#include "Paths.hpp" #include "Utils.hpp" +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + #define DEFAULT_TOML_EXCEPTION_MSG L"An exception occured while parsing the config file:\n\n{}\n\nFile: {}" Config::Config(const Paths& aPaths) @@ -91,20 +105,18 @@ void Config::Save(const std::filesystem::path& aFile) { try { - using ordered_value = toml::basic_value; - auto logLevel = spdlog::level::to_string_view(m_logging.level).data(); auto flushOn = spdlog::level::to_string_view(m_logging.flushOn).data(); - ordered_value config{ + toml::ordered_value config{toml::ordered_table{ {"version", LatestVersion}, - {"logging", ordered_value{{"level", logLevel}, - {"flush_on", flushOn}, - {"max_files", m_logging.maxFiles}, - {"max_file_size", m_logging.maxFileSize}}}, + {"logging", toml::ordered_table{{"level", logLevel}, + {"flush_on", flushOn}, + {"max_files", m_logging.maxFiles}, + {"max_file_size", m_logging.maxFileSize}}}, - {"plugins", ordered_value{{"enabled", m_plugins.isEnabled}, {"ignored", std::vector{}}}}, - {"dev", ordered_value{{"console", m_dev.hasConsole}, {"wait_for_debugger", m_dev.waitForDebugger}}}}; + {"plugins", toml::ordered_table{{"enabled", m_plugins.isEnabled}, {"ignored", std::vector{}}}}, + {"dev", toml::ordered_table{{"console", m_dev.hasConsole}, {"wait_for_debugger", m_dev.waitForDebugger}}}}}; config.comments().push_back( " See https://docs.red4ext.com/getting-started/configuration for more options or information."); diff --git a/src/dll/Hooks/ValidateScripts.cpp b/src/dll/Hooks/ValidateScripts.cpp index bb7301a8..0bbde8a6 100644 --- a/src/dll/Hooks/ValidateScripts.cpp +++ b/src/dll/Hooks/ValidateScripts.cpp @@ -4,7 +4,23 @@ #include "Detail/AddressHashes.hpp" #include "Hook.hpp" #include "RED4ext/Scripting/ScriptReport.hpp" +#include "ScriptValidationError.hpp" +#include "Systems/PluginSystem.hpp" #include "Systems/ScriptCompilationSystem.hpp" +#include "Utils.hpp" + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include namespace { diff --git a/src/dll/Systems/PluginSystem.cpp b/src/dll/Systems/PluginSystem.cpp index 0aab4cf2..ba7d08fc 100644 --- a/src/dll/Systems/PluginSystem.cpp +++ b/src/dll/Systems/PluginSystem.cpp @@ -1,9 +1,33 @@ #include "PluginSystem.hpp" +#include "Config.hpp" +#include "ESystemType.hpp" #include "Image.hpp" +#include "Paths.hpp" +#include "PluginBase.hpp" #include "Utils.hpp" #include "Version.hpp" #include "v0/Plugin.hpp" +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include + #define MINIMUM_API_VERSION RED4EXT_API_VERSION_0 #define LATEST_API_VERSION RED4EXT_API_VERSION_LATEST @@ -263,7 +287,7 @@ void PluginSystem::Load(const std::filesystem::path& aPath, bool aUseAlteredSear { spdlog::warn( L"{} (version: {}) is incompatible with the current patch. The requested runtime of the plugin is {}", - pluginName, std::to_wstring(pluginVersion), requestedRuntime); + pluginName, std::to_wstring(pluginVersion), std::to_wstring(requestedRuntime)); m_incompatiblePlugins.emplace_back(pluginName); return; diff --git a/src/dll/Systems/ScriptCompilationSystem.cpp b/src/dll/Systems/ScriptCompilationSystem.cpp index 24d45b98..54d87440 100644 --- a/src/dll/Systems/ScriptCompilationSystem.cpp +++ b/src/dll/Systems/ScriptCompilationSystem.cpp @@ -1,6 +1,25 @@ #include "ScriptCompilationSystem.hpp" +#include "ESystemType.hpp" +#include "Paths.hpp" +#include "PluginBase.hpp" +#include "SourceRefRepository.hpp" #include "Utils.hpp" +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + ScriptCompilationSystem::ScriptCompilationSystem(const Paths& aPaths) : m_paths(aPaths) , m_hasScriptsBlob(false) @@ -117,26 +136,32 @@ bool ScriptCompilationSystem::Add(std::shared_ptr aPlugin, const wch std::wstring ScriptCompilationSystem::GetCompilationArgs(const FixedWString& aOriginal) { fmt::wmemory_buffer buffer; + if (m_hasScriptsBlob) { spdlog::info("Using scriptsBlobPath"); - format_to(std::back_inserter(buffer), LR"(-compile "{}" "{}")", m_paths.GetR6Scripts(), m_scriptsBlobPath); + fmt::format_to(std::back_inserter(buffer), LR"(-compile "{}" "{}")", m_paths.GetR6Scripts(), m_scriptsBlobPath); } else { - format_to(std::back_inserter(buffer), aOriginal.str); + fmt::format_to(std::back_inserter(buffer), L"{}", aOriginal.str); } + spdlog::info("Adding paths to redscript compilation:"); + auto pathsFilePath = m_paths.GetRedscriptPathsFile(); std::wofstream pathsFile(pathsFilePath, std::ios::out); + for (const auto& [plugin, path] : m_scriptPaths) { spdlog::info(L"{}: '{}'", plugin->GetName(), path); pathsFile << path.wstring() << std::endl; } + spdlog::info(L"Paths written to: '{}'", pathsFilePath); - format_to(std::back_inserter(buffer), LR"( -compilePathsFile "{}")", pathsFilePath); - return fmt::to_string(buffer); + fmt::format_to(std::back_inserter(buffer), LR"( -compilePathsFile "{}")", pathsFilePath); + + return fmt::to_wstring(buffer); } const ScriptCompilationSystem::Map_t& ScriptCompilationSystem::GetScriptPaths() const diff --git a/src/dll/Utils.hpp b/src/dll/Utils.hpp index cd0962f2..3aebb237 100644 --- a/src/dll/Utils.hpp +++ b/src/dll/Utils.hpp @@ -1,5 +1,19 @@ #pragma once +#include + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include + class Config; class DevConsole; class Paths; @@ -54,23 +68,12 @@ template struct fmt::formatter : formatter, Char> { template - auto format(const std::filesystem::path& path, FormatContext& ctx) + auto format(const std::filesystem::path& path, FormatContext& ctx) const { return formatter, Char>::format(path.c_str(), ctx); } }; -template -struct fmt::formatter : formatter, Char> -{ - template - auto format(const RED4ext::FileVer& aFileVersion, FormatContext& ctx) - { - return fmt::format_to(ctx.out(), "{}.{}.{}.{}", aFileVersion.major, aFileVersion.minor, aFileVersion.build, - aFileVersion.revision); - } -}; - #ifndef SHOW_LAST_ERROR_MESSAGE_FILE_LINE #define SHOW_LAST_ERROR_MESSAGE_FILE_LINE(additionalText, ...) \ Utils::ShowLastErrorMessage(MB_ICONWARNING | MB_OK, additionalText L"\n\n{}:{}", ##__VA_ARGS__, TEXT(__FILE__), \ diff --git a/src/dll/stdafx.hpp b/src/dll/stdafx.hpp index e723f96b..b04a1d31 100644 --- a/src/dll/stdafx.hpp +++ b/src/dll/stdafx.hpp @@ -32,6 +32,5 @@ #include #include #include -#include #include