From 65b9e1981d31e1afe1f01c49579c2391d0d5806e Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 9 Nov 2024 13:15:55 -0600 Subject: [PATCH 1/4] fix: clang-cl --- include/RE/B/BSFixedString.h | 4 ++-- include/RE/B/BSTSmartPointer.h | 2 +- include/RE/B/ButtonEvent.h | 2 +- include/RE/C/ConcreteFormFactory.h | 2 +- include/RE/G/GFxResourceWeakLib.h | 3 ++- include/RE/G/GHashNode.h | 6 +++++ include/RE/G/GHashSetBase.h | 2 +- include/RE/G/GMatrix3D.h | 6 ++--- include/RE/H/hkpContactPointEvent.h | 2 +- include/RE/H/hkpMotion.h | 2 +- include/RE/I/IVirtualMachine.h | 1 + include/RE/N/NativeLatentFunction.h | 2 +- include/RE/N/NiBillboardNode.h | 2 +- include/RE/N/NiPointLight.h | 2 +- include/RE/T/TESActionData.h | 2 +- include/RE/T/TESForm.h | 4 ++-- src/RE/B/BSLightingShaderMaterialBase.cpp | 2 +- src/RE/B/BSShaderTextureSet.cpp | 2 +- src/RE/F/FindMaxMagnitudeVisitor.cpp | 4 +--- src/RE/N/NiAVObject.cpp | 2 +- src/RE/N/NiNode.cpp | 2 +- src/RE/S/Sky.cpp | 8 +++---- src/RE/T/TESForm.cpp | 4 ++-- src/RE/T/TESObjectREFR.cpp | 4 ++-- src/RE/U/UnlinkedTypes.cpp | 2 -- xmake.lua | 29 +++++++++++++++++------ 26 files changed, 60 insertions(+), 43 deletions(-) diff --git a/include/RE/B/BSFixedString.h b/include/RE/B/BSFixedString.h index a6520f404..2f97bdc2e 100644 --- a/include/RE/B/BSFixedString.h +++ b/include/RE/B/BSFixedString.h @@ -26,7 +26,7 @@ namespace RE try_acquire(); } - inline BSFixedString(BSFixedString&& a_rhs) : + inline BSFixedString(BSFixedString&& a_rhs) noexcept : _data(a_rhs._data) { a_rhs._data = nullptr; @@ -136,7 +136,7 @@ namespace RE [[nodiscard]] inline friend bool operator==(const BSFixedString& a_lhs, const BSFixedString& a_rhs) noexcept { - return a_lhs._data == a_rhs._data || a_lhs.empty() && a_rhs.empty(); + return (a_lhs._data == a_rhs._data) || (a_lhs.empty() && a_rhs.empty()); } [[nodiscard]] inline friend bool operator!=(const BSFixedString& a_lhs, const BSFixedString& a_rhs) noexcept { return !(a_lhs == a_rhs); } diff --git a/include/RE/B/BSTSmartPointer.h b/include/RE/B/BSTSmartPointer.h index 66611082c..087a5b2dc 100644 --- a/include/RE/B/BSTSmartPointer.h +++ b/include/RE/B/BSTSmartPointer.h @@ -21,7 +21,7 @@ namespace RE template struct BSTSmartPointerAutoPtr { - constexpr static void Acquire(T* a_ptr) + constexpr static void Acquire(T*) { return; } diff --git a/include/RE/B/ButtonEvent.h b/include/RE/B/ButtonEvent.h index add125ea3..eec72f0cd 100644 --- a/include/RE/B/ButtonEvent.h +++ b/include/RE/B/ButtonEvent.h @@ -30,7 +30,7 @@ namespace RE static ButtonEvent* Create(INPUT_DEVICE a_inputDevice, const BSFixedString& a_userEvent, uint32_t a_idCode, float a_value, float a_heldDownSecs) { auto buttonEvent = malloc(sizeof(ButtonEvent)); - std::memset(buttonEvent, 0, sizeof(ButtonEvent)); + std::memset((void*)buttonEvent, 0, sizeof(ButtonEvent)); if (buttonEvent) { stl::emplace_vtable(buttonEvent); buttonEvent->device = a_inputDevice; diff --git a/include/RE/C/ConcreteFormFactory.h b/include/RE/C/ConcreteFormFactory.h index 636ca2317..364e7682e 100644 --- a/include/RE/C/ConcreteFormFactory.h +++ b/include/RE/C/ConcreteFormFactory.h @@ -42,6 +42,6 @@ namespace RE auto factory = IFormFactory::GetConcreteFormFactoryByType(); auto form = factory ? factory->Create() : nullptr; - return form ? form->As() : nullptr; + return form ? form->template As() : nullptr; } } diff --git a/include/RE/G/GFxResourceWeakLib.h b/include/RE/G/GFxResourceWeakLib.h index 7423b2332..99cf07825 100644 --- a/include/RE/G/GFxResourceWeakLib.h +++ b/include/RE/G/GFxResourceWeakLib.h @@ -39,7 +39,7 @@ namespace RE bool operator!=(const GFxResourceKey& a_src) const { - return operator!=(a_src); + return !operator==(a_src); } struct HashOp @@ -49,6 +49,7 @@ namespace RE assert(a_node.resource); GFxResourceKey key = (a_node.type == NodeType::kResource) ? a_node.resource->GetKey() : a_node.resolver->GetKey(); + return GFxResourceKey::HashOp()(key); } UPInt operator()(const GFxResourceKey& a_key) const diff --git a/include/RE/G/GHashNode.h b/include/RE/G/GHashNode.h index 73ac6c840..fb11bc30e 100644 --- a/include/RE/G/GHashNode.h +++ b/include/RE/G/GHashNode.h @@ -66,6 +66,12 @@ namespace RE second(*a_src.second) {} + void operator=(const GHashNode& a_src) + { + first = a_src.first; + second = a_src.second; + } + void operator=(const NodeRef& a_src) { first = *a_src.first; diff --git a/include/RE/G/GHashSetBase.h b/include/RE/G/GHashSetBase.h index 0eadb7252..74cf1cf29 100644 --- a/include/RE/G/GHashSetBase.h +++ b/include/RE/G/GHashSetBase.h @@ -172,7 +172,7 @@ namespace RE SetCapacity(this, a_sizeHint); } - explicit GHashSetBase(void* a_memAddr) : + explicit GHashSetBase(void*) : table(0) {} diff --git a/include/RE/G/GMatrix3D.h b/include/RE/G/GMatrix3D.h index 9e61d4d93..91d63e06a 100644 --- a/include/RE/G/GMatrix3D.h +++ b/include/RE/G/GMatrix3D.h @@ -5,9 +5,7 @@ namespace RE class GMatrix3D { public: - GMatrix3D() : - data{ 0.0 } - {} + GMatrix3D() = default; GMatrix3D& operator=(const GMatrix3D& a_rhs) { @@ -19,7 +17,7 @@ namespace RE return *this; } - float data[4][4]; // 00 + float data[4][4]{}; // 00 }; static_assert(sizeof(GMatrix3D) == 0x40); } diff --git a/include/RE/H/hkpContactPointEvent.h b/include/RE/H/hkpContactPointEvent.h index b06658c9f..9e52dde31 100644 --- a/include/RE/H/hkpContactPointEvent.h +++ b/include/RE/H/hkpContactPointEvent.h @@ -1,7 +1,7 @@ #pragma once #include "RE/H/hkpCollisionEvent.h" -#include "RE/h/hkpRigidBody.h" +#include "RE/H/hkpRigidBody.h" namespace RE { diff --git a/include/RE/H/hkpMotion.h b/include/RE/H/hkpMotion.h index 75ebd1252..8a71cc043 100644 --- a/include/RE/H/hkpMotion.h +++ b/include/RE/H/hkpMotion.h @@ -66,7 +66,7 @@ namespace RE float GetMass() const { - float massInv = inertiaAndMassInv.quad.m128_f32[3]; + float massInv = _mm_cvtss_f32(_mm_shuffle_ps(inertiaAndMassInv.quad, inertiaAndMassInv.quad, 3)); return massInv != 0.0f ? 1.0f / massInv : 0.0f; } diff --git a/include/RE/I/IVirtualMachine.h b/include/RE/I/IVirtualMachine.h index 6ce3e7463..df9208f84 100644 --- a/include/RE/I/IVirtualMachine.h +++ b/include/RE/I/IVirtualMachine.h @@ -6,6 +6,7 @@ #include "RE/B/BSTSmartPointer.h" #include "RE/E/ErrorLogger.h" #include "RE/T/TypeInfo.h" +#include "RE/T/TypeTraits.h" namespace RE { diff --git a/include/RE/N/NativeLatentFunction.h b/include/RE/N/NativeLatentFunction.h index a6b5edb9e..425eb867b 100644 --- a/include/RE/N/NativeLatentFunction.h +++ b/include/RE/N/NativeLatentFunction.h @@ -104,7 +104,7 @@ namespace RE requires is_return_convertible_v void IVirtualMachine::ReturnLatentResult(VMStackID a_stackID, V a_result) { - auto var = RE::BSScript::Variable::Variable(); + auto var = RE::BSScript::Variable(); var.Pack(a_result); ReturnFromLatent(a_stackID, var); } diff --git a/include/RE/N/NiBillboardNode.h b/include/RE/N/NiBillboardNode.h index 3b40e9cbd..7a046bfbe 100644 --- a/include/RE/N/NiBillboardNode.h +++ b/include/RE/N/NiBillboardNode.h @@ -48,7 +48,7 @@ namespace RE void SetMode(FaceMode a_mode) { - userFlags = static_cast((std::to_underlying(a_mode) << FACE_MODE_POS) | userFlags & ~FACE_MODE_MASK); + userFlags = static_cast((std::to_underlying(a_mode) << FACE_MODE_POS) | (userFlags & ~FACE_MODE_MASK)); } // members diff --git a/include/RE/N/NiPointLight.h b/include/RE/N/NiPointLight.h index 1ab2f0e3b..86a1cd461 100644 --- a/include/RE/N/NiPointLight.h +++ b/include/RE/N/NiPointLight.h @@ -25,7 +25,7 @@ namespace RE static NiPointLight* Create() { auto light = malloc(); - std::memset(light, 0, sizeof(NiPointLight)); + std::memset((void*)light, 0, sizeof(NiPointLight)); if (light) { light->Ctor(); } diff --git a/include/RE/T/TESActionData.h b/include/RE/T/TESActionData.h index afaa3d91c..59e6c64c7 100644 --- a/include/RE/T/TESActionData.h +++ b/include/RE/T/TESActionData.h @@ -24,7 +24,7 @@ namespace RE static TESActionData* Create() { auto tesActionData = malloc(); - std::memset(tesActionData, 0, sizeof(TESActionData)); + std::memset((void*)tesActionData, 0, sizeof(TESActionData)); if (tesActionData) { tesActionData->Ctor(); } diff --git a/include/RE/T/TESForm.h b/include/RE/T/TESForm.h index 21ef1a782..2f38e6a13 100644 --- a/include/RE/T/TESForm.h +++ b/include/RE/T/TESForm.h @@ -211,7 +211,7 @@ namespace RE [[nodiscard]] static TESForm* LookupByID(FormID a_formID) { const auto& [map, lock] = GetAllForms(); - const BSReadWriteLock l{ lock }; + [[maybe_unused]] const BSReadWriteLock l{ lock }; if (map) { const auto it = map->find(a_formID); return it != map->end() ? it->second : nullptr; @@ -230,7 +230,7 @@ namespace RE [[nodiscard]] static TESForm* LookupByEditorID(const std::string_view& a_editorID) { const auto& [map, lock] = GetAllFormsByEditorID(); - const BSReadWriteLock l{ lock }; + [[maybe_unused]] const BSReadWriteLock l{ lock }; if (map) { const auto it = map->find(a_editorID); return it != map->end() ? it->second : nullptr; diff --git a/src/RE/B/BSLightingShaderMaterialBase.cpp b/src/RE/B/BSLightingShaderMaterialBase.cpp index 84d2ed80c..70cb59587 100644 --- a/src/RE/B/BSLightingShaderMaterialBase.cpp +++ b/src/RE/B/BSLightingShaderMaterialBase.cpp @@ -47,7 +47,7 @@ namespace RE case Feature::kDefault: { auto material = malloc(); - std::memset(material, 0, sizeof(BSLightingShaderMaterial)); + std::memset((void*)material, 0, sizeof(BSLightingShaderMaterial)); if (material) { material->Ctor(); stl::emplace_vtable(material); diff --git a/src/RE/B/BSShaderTextureSet.cpp b/src/RE/B/BSShaderTextureSet.cpp index 40c8fe401..570ca4eb2 100644 --- a/src/RE/B/BSShaderTextureSet.cpp +++ b/src/RE/B/BSShaderTextureSet.cpp @@ -17,7 +17,7 @@ namespace RE return func(); #else auto textureset = malloc(); - std::memset(textureset, 0, sizeof(BSShaderTextureSet)); + std::memset((void*)textureset, 0, sizeof(BSShaderTextureSet)); if (textureset) { textureset->Ctor(); } diff --git a/src/RE/F/FindMaxMagnitudeVisitor.cpp b/src/RE/F/FindMaxMagnitudeVisitor.cpp index c86bdf6db..6f956c005 100644 --- a/src/RE/F/FindMaxMagnitudeVisitor.cpp +++ b/src/RE/F/FindMaxMagnitudeVisitor.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "RE/F/FindMaxMagnitudeVisitor.h" namespace RE @@ -10,4 +8,4 @@ namespace RE static REL::Relocation func{ reinterpret_cast(RELOCATION_ID(257550, 205805).address())[0x1] }; // AE address/ID untested return func(this, a_effect); } -} // namespace RE +} diff --git a/src/RE/N/NiAVObject.cpp b/src/RE/N/NiAVObject.cpp index c7e392b34..a82b16ca3 100644 --- a/src/RE/N/NiAVObject.cpp +++ b/src/RE/N/NiAVObject.cpp @@ -17,7 +17,7 @@ #include "RE/N/NiProperty.h" #include "RE/N/NiRTTI.h" #include "RE/S/State.h" -#include "RE/h/hkpRigidBody.h" +#include "RE/H/hkpRigidBody.h" namespace RE { diff --git a/src/RE/N/NiNode.cpp b/src/RE/N/NiNode.cpp index 4fbccf874..71ed272e2 100644 --- a/src/RE/N/NiNode.cpp +++ b/src/RE/N/NiNode.cpp @@ -7,7 +7,7 @@ namespace RE NiNode* NiNode::Create(std::uint16_t a_arrBufLen) { auto node = malloc(); - std::memset(node, 0, sizeof(NiNode)); + std::memset((void*)node, 0, sizeof(NiNode)); node->Ctor(a_arrBufLen); return node; } diff --git a/src/RE/S/Sky.cpp b/src/RE/S/Sky.cpp index f33decdc0..206c190f6 100644 --- a/src/RE/S/Sky.cpp +++ b/src/RE/S/Sky.cpp @@ -77,14 +77,14 @@ namespace RE bool Sky::IsRaining() const { - return currentWeather && currentWeather->data.flags.any(TESWeather::WeatherDataFlag::kRainy) && currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f) < currentWeatherPct || - lastWeather && lastWeather->data.flags.any(TESWeather::WeatherDataFlag::kRainy) && (lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f) + 0.001f) > currentWeatherPct; + return (currentWeather && currentWeather->data.flags.any(TESWeather::WeatherDataFlag::kRainy) && (currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f) < currentWeatherPct)) || + (lastWeather && lastWeather->data.flags.any(TESWeather::WeatherDataFlag::kRainy) && (lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f) + 0.001f > currentWeatherPct)); } bool Sky::IsSnowing() const { - return currentWeather && currentWeather->data.flags.any(TESWeather::WeatherDataFlag::kSnow) && currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f) < currentWeatherPct || - lastWeather && lastWeather->data.flags.any(TESWeather::WeatherDataFlag::kSnow) && (lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f) + 0.001f) > currentWeatherPct; + return (currentWeather && currentWeather->data.flags.any(TESWeather::WeatherDataFlag::kSnow) && (currentWeather->data.precipitationBeginFadeIn * (1.0f / 255.0f) < currentWeatherPct)) || + (lastWeather && lastWeather->data.flags.any(TESWeather::WeatherDataFlag::kSnow) && (lastWeather->data.precipitationEndFadeOut * (1.0f / 255.0f) + 0.001f > currentWeatherPct)); } void Sky::ReleaseWeatherOverride() diff --git a/src/RE/T/TESForm.cpp b/src/RE/T/TESForm.cpp index 0bdb6ed40..2975344e1 100644 --- a/src/RE/T/TESForm.cpp +++ b/src/RE/T/TESForm.cpp @@ -101,7 +101,7 @@ namespace RE for (const auto& keyword : a_keywords) { hasKeyword = keyword && keywordForm->HasKeyword(keyword); - if (a_matchAll && !hasKeyword || hasKeyword) { + if ((a_matchAll && !hasKeyword) || hasKeyword) { break; } } @@ -125,7 +125,7 @@ namespace RE a_keywordList->ForEachForm([&](const TESForm* a_form) { const auto keyword = a_form->As(); hasKeyword = keyword && keywordForm->HasKeyword(keyword); - if (a_matchAll && !hasKeyword || hasKeyword) { + if ((a_matchAll && !hasKeyword) || hasKeyword) { return BSContainer::ForEachResult::kStop; } return BSContainer::ForEachResult::kContinue; diff --git a/src/RE/T/TESObjectREFR.cpp b/src/RE/T/TESObjectREFR.cpp index 7dc7e2cb3..77a38f247 100644 --- a/src/RE/T/TESObjectREFR.cpp +++ b/src/RE/T/TESObjectREFR.cpp @@ -598,7 +598,7 @@ namespace RE for (const auto& keyword : a_keywords) { hasKeyword = keyword && HasKeyword(keyword); - if (a_matchAll && !hasKeyword || hasKeyword) { + if ((a_matchAll && !hasKeyword) || hasKeyword) { break; } } @@ -617,7 +617,7 @@ namespace RE a_keywordList->ForEachForm([&](TESForm* a_form) { const auto keyword = a_form->As(); hasKeyword = keyword && HasKeyword(keyword); - if (a_matchAll && !hasKeyword || hasKeyword) { + if ((a_matchAll && !hasKeyword) || hasKeyword) { return BSContainer::ForEachResult::kStop; } return BSContainer::ForEachResult::kContinue; diff --git a/src/RE/U/UnlinkedTypes.cpp b/src/RE/U/UnlinkedTypes.cpp index cb816ed6f..36f72ce86 100644 --- a/src/RE/U/UnlinkedTypes.cpp +++ b/src/RE/U/UnlinkedTypes.cpp @@ -1,5 +1,3 @@ -#pragma once - #include "RE/U/UnlinkedTypes.h" #include "RE/M/MemoryManager.h" diff --git a/xmake.lua b/xmake.lua index a62ac95ca..a05efd108 100644 --- a/xmake.lua +++ b/xmake.lua @@ -15,17 +15,17 @@ add_rules("mode.debug", "mode.releasedbg") includes("xmake-extra.lua") -- define options -option("skyrim_ae") +option("skyrim_ae", function() set_default(false) set_description("Enable support for Skyrim AE") add_defines("SKYRIM_SUPPORT_AE=1") -option_end() +end) -option("skse_xbyak") +option("skse_xbyak", function() set_default(false) set_description("Enable trampoline support for Xbyak") add_defines("SKSE_SUPPORT_XBYAK=1") -option_end() +end) -- require packages add_requires("rsm-binary-io") @@ -36,7 +36,7 @@ if has_config("skse_xbyak") then end -- define targets -target("commonlibsse") +target("commonlibsse", function() -- set target kind set_kind("static") @@ -123,11 +123,26 @@ target("commonlibsse") "cl::/wd5220" -- 'member': a non-static data member with a volatile qualified type no longer implies that compiler generated copy / move constructors and copy / move assignment operators are not trivial ) + -- add flags (clang-cl) + add_cxxflags( + "clang_cl::-fms-compatibility", + "clang_cl::-fms-extensions", + { public = true } + ) + -- add flags (clang-cl: disable warnings) add_cxxflags( "clang_cl::-Wno-delete-non-abstract-non-virtual-dtor", + "clang_cl::-Wno-deprecated-volatile", + "clang_cl::-Wno-ignored-qualifiers", "clang_cl::-Wno-inconsistent-missing-override", + "clang_cl::-Wno-invalid-offsetof", + "clang_cl::-Wno-microsoft-include", "clang_cl::-Wno-overloaded-virtual", - "clang_cl::-Wno-reinterpret-base-class" + "clang_cl::-Wno-pragma-system-header-outside-header", + "clang_cl::-Wno-reinterpret-base-class", + "clang_cl::-Wno-switch", + "clang_cl::-Wno-unused-private-field", + { public = true } ) -target_end() +end) From 25fac7a4b18cb244e15262eedf253a78a34a3423 Mon Sep 17 00:00:00 2001 From: qudix Date: Sat, 9 Nov 2024 19:16:37 +0000 Subject: [PATCH 2/4] maintenance --- src/RE/N/NiAVObject.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/RE/N/NiAVObject.cpp b/src/RE/N/NiAVObject.cpp index a82b16ca3..f148af611 100644 --- a/src/RE/N/NiAVObject.cpp +++ b/src/RE/N/NiAVObject.cpp @@ -12,12 +12,12 @@ #include "RE/B/BSXFlags.h" #include "RE/B/bhkNiCollisionObject.h" #include "RE/B/bhkRigidBody.h" +#include "RE/H/hkpRigidBody.h" #include "RE/N/NiColor.h" #include "RE/N/NiNode.h" #include "RE/N/NiProperty.h" #include "RE/N/NiRTTI.h" #include "RE/S/State.h" -#include "RE/H/hkpRigidBody.h" namespace RE { From 6cc67610c74c906962766b761aaae45f4d68b2b5 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sat, 9 Nov 2024 22:23:30 -0600 Subject: [PATCH 3/4] fix: move includes --- include/SKSE/Impl/PCH.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/SKSE/Impl/PCH.h b/include/SKSE/Impl/PCH.h index f2aadb553..a29bbdd88 100644 --- a/include/SKSE/Impl/PCH.h +++ b/include/SKSE/Impl/PCH.h @@ -58,15 +58,15 @@ static_assert( std::is_integral_v && sizeof(std::time_t) == sizeof(std::size_t), "wrap std::time_t instead"); +#include "REX/REX.h" +#include "REX/W32/KERNEL32.h" +#include "REX/W32/USER32.h" + #pragma warning(push) #include #include #pragma warning(pop) -#include "REX/REX.h" -#include "REX/W32/KERNEL32.h" -#include "REX/W32/USER32.h" - namespace SKSE { using namespace std::literals; From 35b13c80ba45301b73d4c95a7886d6793293e854 Mon Sep 17 00:00:00 2001 From: Qudix <17361645+Qudix@users.noreply.github.com> Date: Sun, 10 Nov 2024 11:58:51 -0600 Subject: [PATCH 4/4] chore: rename `extra` to `rules` --- xmake-extra.lua => xmake-rules.lua | 0 xmake.lua | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename xmake-extra.lua => xmake-rules.lua (100%) diff --git a/xmake-extra.lua b/xmake-rules.lua similarity index 100% rename from xmake-extra.lua rename to xmake-rules.lua diff --git a/xmake.lua b/xmake.lua index a05efd108..710945be0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -11,8 +11,8 @@ set_encodings("utf-8") -- add rules add_rules("mode.debug", "mode.releasedbg") --- make extras available -includes("xmake-extra.lua") +-- make custom rules available +includes("xmake-rules.lua") -- define options option("skyrim_ae", function()