diff --git a/CMakeLists.txt b/CMakeLists.txt index a24c57a..370f044 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -79,8 +79,9 @@ set(Boost_USE_STATIC_LIBS ON) # ---- Dependencies ---- -add_subdirectory("extern/CommonLibSSE" CommonLibSSE) +#add_subdirectory("extern/CommonLibSSE" CommonLibSSE) +find_package(CommonLibSSE REQUIRED) find_package(spdlog REQUIRED CONFIG) # ---- Add source files ---- @@ -138,9 +139,8 @@ target_include_directories( target_link_libraries( ${PROJECT_NAME} - PRIVATE + PUBLIC CommonLibSSE::CommonLibSSE - spdlog::spdlog ) if (MSVC) diff --git a/extern/CommonLibSSE b/extern/CommonLibSSE deleted file mode 160000 index 8473887..0000000 --- a/extern/CommonLibSSE +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 84738878bc33a445edb834b008cc882380455243 diff --git a/src/Cache.h b/src/Cache.h index b177de1..6c1edd5 100644 --- a/src/Cache.h +++ b/src/Cache.h @@ -12,23 +12,23 @@ namespace Cache { //1.6 = 38590 //1.5.97 = 37637 - IsAttackingAddress = REL::ID(37637).address(); + IsAttackingAddress = REL::RelocationID(37637, 38590).address(); //1.6 = 37952 //1.5.97 = 36927 - IsBlockingAddress = REL::ID(36927).address(); + IsBlockingAddress = REL::RelocationID(36927, 37952).address(); //1.6 = 38782 //1.5.97 = 37828 - HasSpellAddress = REL::ID(37828).address(); + HasSpellAddress = REL::RelocationID(37828, 38782).address(); //1.6 = 403521 //1.5 = 517014 - PlayerSingletonAddress = REL::ID(517014).address(); + PlayerSingletonAddress = REL::RelocationID(517014, 403521).address(); - //1.6 + //1.6 = 375300 //1.5 = 505721 - fPlayerMaxResistanceAddress = { REL::ID(505721).address()}; + fPlayerMaxResistanceAddress = { REL::RelocationID(505721, 375300).address()}; } inline RE::PlayerCharacter* GetPlayerSingleton() diff --git a/src/Conditions.h b/src/Conditions.h index 683e92e..f620464 100644 --- a/src/Conditions.h +++ b/src/Conditions.h @@ -33,6 +33,7 @@ namespace Conditions static bool IsMoving(RE::PlayerCharacter* player) { - return (!static_cast(player->actorState1.movingForward) && !static_cast(player->actorState1.movingBack) && !static_cast(player->actorState1.movingLeft) && !static_cast(player->actorState1.movingRight)); + auto playerState = player->AsActorState(); + return (static_cast(playerState->actorState1.movingForward) || static_cast(playerState->actorState1.movingBack) || static_cast(playerState->actorState1.movingLeft) || static_cast(playerState->actorState1.movingRight)); } }; diff --git a/src/Hooks.h b/src/Hooks.h index 7416d69..b2eebff 100644 --- a/src/Hooks.h +++ b/src/Hooks.h @@ -2,19 +2,13 @@ namespace Hooks { - //1.6 = REL::Relocation OnFrame_Update_Hook{ REL::ID(36564), 0x6E }; - inline static REL::Relocation OnFrame_Update_Hook{ REL::ID(35565), 0x1E }; + inline static REL::Relocation OnFrame_Update_Hook{ REL::RelocationID(35565,36564), REL::Relocate(0x1E,0x6E) }; + inline static REL::Relocation Scale_Patch_Hook{ REL::RelocationID(37013,38041), REL::Relocate(0x1A,0x1F) }; - //1.6 = REL::Relocation Scale_Patch_Hook{ REL::ID(38041), 0x1F }; - inline static REL::Relocation Scale_Patch_Hook{ REL::ID(37013), 0x1A }; + inline static REL::Relocation Block_GameSetting_Hook{ REL::RelocationID(42842,44014), REL::Relocate(0x452,0x438) }; + inline static REL::Relocation fBlock_GameSetting{ REL::RelocationID(505023,374158), 0x8 }; - //1.6 = REL::Relocation Block_GameSetting_Hook{ REL::ID(44014), 0x438 }; - //1.6 = REL::Relocation fBlock_GameSetting { REL::ID(374158) }; - inline static REL::Relocation Block_GameSetting_Hook{ REL::ID(42842), 0x452 }; - inline static REL::Relocation fBlock_GameSetting{ REL::ID(505023), 0x8 }; - - // 1.6 REL::Relocation SpellCap_Hook{ REL::ID(38741), 0x55 }; - inline static REL::Relocation SpellCap_Hook{ REL::ID(37792), 0x53 }; + inline static REL::Relocation SpellCap_Hook{ REL::RelocationID(37792,38741), REL::Relocate(0x53,0x55) }; bool Install(); } diff --git a/src/UpdateManager.h b/src/UpdateManager.h index a2ffbee..154883a 100644 --- a/src/UpdateManager.h +++ b/src/UpdateManager.h @@ -96,20 +96,20 @@ class UpdateManager { player->RemoveSpell(settings->IsAttackingSpell); } - } - if (IsBlocking(player)) - { - if (!HasSpell(player, settings->IsBlockingSpell)) + if (IsBlocking(player)) { - player->AddSpell(settings->IsBlockingSpell); + if (!HasSpell(player, settings->IsBlockingSpell)) + { + player->AddSpell(settings->IsBlockingSpell); + } } - } - else - { - if (HasSpell(player, settings->IsBlockingSpell)) + else { - player->RemoveSpell(settings->IsBlockingSpell); + if (HasSpell(player, settings->IsBlockingSpell)) + { + player->RemoveSpell(settings->IsBlockingSpell); + } } } @@ -136,7 +136,8 @@ class UpdateManager auto scale = _GetScaleFunction(a1); if(skyrim_cast(a1) == RE::PlayerCharacter::GetSingleton()) { - return a1->refScale / 100.0f; + + return a1->GetReferenceRuntimeData().refScale / 100.0f; } else { @@ -148,7 +149,7 @@ class UpdateManager static bool IsBowDrawNoZoomCheck(RE::PlayerCharacter* player, RE::PlayerCamera* playerCamera) { - auto attackState = player->GetAttackState(); + auto attackState = player->AsActorState()->GetAttackState(); if (playerCamera->bowZoomedIn) { diff --git a/src/main.cpp b/src/main.cpp index 65372eb..403e300 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2,7 +2,6 @@ #include "Settings.h" #include "Cache.h" -/* 1.6 void InitLogger() { #ifndef NDEBUG @@ -39,38 +38,15 @@ extern "C" DLLEXPORT constexpr auto SKSEPlugin_Version = v.PluginName(Version::PROJECT); v.AuthorName("colinswrath and Kernalsegg"sv); v.UsesAddressLibrary(true); + v.HasNoStructUse(true); + v.UsesStructsPost629(false); return v; }(); -*/ + extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface * a_skse, SKSE::PluginInfo * a_info) { -#ifndef NDEBUG - auto sink = std::make_shared(); -#else - auto path = logger::log_directory(); - if (!path) { - return false; - } - - *path /= Version::PROJECT; - *path += ".log"sv; - auto sink = std::make_shared(path->string(), true); -#endif - - auto log = std::make_shared("global log"s, std::move(sink)); - -#ifndef NDEBUG - log->set_level(spdlog::level::trace); -#else - log->set_level(spdlog::level::info); - log->flush_on(spdlog::level::info); -#endif - - spdlog::set_default_logger(std::move(log)); - spdlog::set_pattern("%g(%#): [%^%l%$] %v"s); - - logger::info(FMT_STRING("{} v{}"), Version::PROJECT, Version::NAME); + InitLogger(); a_info->infoVersion = SKSE::PluginInfo::kVersion; a_info->name = Version::PROJECT.data(); @@ -82,7 +58,7 @@ extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Query(const SKSE::QueryInterface * } const auto ver = a_skse->RuntimeVersion(); - if (ver < SKSE::RUNTIME_1_5_39) { + if (ver < SKSE::RUNTIME_VR_1_4_15) { logger::critical(FMT_STRING("Unsupported runtime version {}"), ver.string()); return false; } @@ -105,7 +81,7 @@ void InitListener(SKSE::MessagingInterface::Message* a_msg) extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_skse) { - //InitLogger(); //1.6 + InitLogger(); //1.6 SKSE::Init(a_skse); logger::info("Loading Blade and Blunt."); @@ -126,5 +102,6 @@ extern "C" DLLEXPORT bool SKSEAPI SKSEPlugin_Load(const SKSE::LoadInterface* a_s } logger::info("Blade and Blunt loaded."); + spdlog::default_logger()->flush(); return true; } diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..154190a --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,13 @@ +{ + "registries": [ + { + "kind": "git", + "repository": "https://gitlab.com/colorglass/vcpkg-colorglass", + "baseline": "9c522a19f2e9c1127369554c61f47c686a92db98", + "packages": [ + "commonlibsse-ng", + "commonlibsse-ng-flatrim" + ] + } + ] +} \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index c896251..be1c9e3 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -8,6 +8,7 @@ "boost-stl-interfaces", "rsm-binary-io", "spdlog", - "simpleini" + "simpleini", + "commonlibsse-ng" ] }