From 0adfaeba42fe1009cd9d982849564a5b5d0e918e Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:06:01 +0200 Subject: [PATCH 1/6] Update CVector.h --- Shared/sdk/CVector.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Shared/sdk/CVector.h b/Shared/sdk/CVector.h index 5c2ddde7a6..4414054f39 100644 --- a/Shared/sdk/CVector.h +++ b/Shared/sdk/CVector.h @@ -30,13 +30,9 @@ class CVector float fY; float fZ; - struct NoInit{}; - - CVector(NoInit) {} - constexpr CVector() : fX(0.0f), fY(0.0f), fZ(0.0f) {} - constexpr CVector(float x, float y, float z) : fX(x), fY(y), fZ(z) {} + constexpr CVector(float x, float y = 0, float z = 0) : fX(x), fY(y), fZ(z) {} constexpr CVector(const CVector4D& vec) noexcept : fX(vec.fX), fY(vec.fY), fZ(vec.fZ) {} From e91727299b45f90ce013611ffe5ade19e517435f Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Tue, 8 Oct 2024 21:41:27 +0200 Subject: [PATCH 2/6] Update CPedSync.cpp --- Client/mods/deathmatch/logic/CPedSync.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Client/mods/deathmatch/logic/CPedSync.cpp b/Client/mods/deathmatch/logic/CPedSync.cpp index 8461ac1a87..a0d3169b11 100644 --- a/Client/mods/deathmatch/logic/CPedSync.cpp +++ b/Client/mods/deathmatch/logic/CPedSync.cpp @@ -179,7 +179,7 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream) unsigned char ucFlags = 0; BitStream.Read(ucFlags); - CVector vecPosition{ CVector::NoInit{} }, vecMoveSpeed{ CVector::NoInit{} }; + CVector vecPosition{}, vecMoveSpeed{}; float fRotation, fHealth, fArmor; bool bOnFire; bool bIsInWater; From 64f1724c790ac29ee103a881305c5e958519a6e3 Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sat, 12 Oct 2024 21:58:25 +0200 Subject: [PATCH 3/6] Updated according to reviews --- Client/mods/deathmatch/logic/CPedSync.cpp | 2 +- Shared/sdk/CVector.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Client/mods/deathmatch/logic/CPedSync.cpp b/Client/mods/deathmatch/logic/CPedSync.cpp index a0d3169b11..8461ac1a87 100644 --- a/Client/mods/deathmatch/logic/CPedSync.cpp +++ b/Client/mods/deathmatch/logic/CPedSync.cpp @@ -179,7 +179,7 @@ void CPedSync::Packet_PedSync(NetBitStreamInterface& BitStream) unsigned char ucFlags = 0; BitStream.Read(ucFlags); - CVector vecPosition{}, vecMoveSpeed{}; + CVector vecPosition{ CVector::NoInit{} }, vecMoveSpeed{ CVector::NoInit{} }; float fRotation, fHealth, fArmor; bool bOnFire; bool bIsInWater; diff --git a/Shared/sdk/CVector.h b/Shared/sdk/CVector.h index 4414054f39..5f8be49dfd 100644 --- a/Shared/sdk/CVector.h +++ b/Shared/sdk/CVector.h @@ -30,9 +30,12 @@ class CVector float fY; float fZ; - constexpr CVector() : fX(0.0f), fY(0.0f), fZ(0.0f) {} + struct NoInit {}; + constexpr CVector(NoInit) noexcept {} - constexpr CVector(float x, float y = 0, float z = 0) : fX(x), fY(y), fZ(z) {} + constexpr CVector() noexcept : fX(0.0f), fY(0.0f), fZ(0.0f) {} + + constexpr explicit CVector(float x, float y = 0.0f, float z = 0.0f) noexcept : fX(x), fY(y), fZ(z) {} constexpr CVector(const CVector4D& vec) noexcept : fX(vec.fX), fY(vec.fY), fZ(vec.fZ) {} From fba3201bfa7483ccfb6e53f5568b5bfae8d4fe4f Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sat, 12 Oct 2024 22:46:23 +0200 Subject: [PATCH 4/6] Update CVector.h --- Shared/sdk/CVector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/sdk/CVector.h b/Shared/sdk/CVector.h index 5f8be49dfd..d6b1901641 100644 --- a/Shared/sdk/CVector.h +++ b/Shared/sdk/CVector.h @@ -31,7 +31,7 @@ class CVector float fZ; struct NoInit {}; - constexpr CVector(NoInit) noexcept {} + CVector(NoInit) noexcept {} constexpr CVector() noexcept : fX(0.0f), fY(0.0f), fZ(0.0f) {} From 313ccb60b5b75b299cff9347245b7925886ef669 Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sun, 13 Oct 2024 10:14:02 +0200 Subject: [PATCH 5/6] Update CVector.h --- Shared/sdk/CVector.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shared/sdk/CVector.h b/Shared/sdk/CVector.h index 5f8be49dfd..1b8e278a33 100644 --- a/Shared/sdk/CVector.h +++ b/Shared/sdk/CVector.h @@ -186,7 +186,7 @@ class CVector { *outVec = *this + vecRay * t; if (outHitBary) { // Calculate all barycentric coords if necessary - *outHitBary = { 1.f - u - v, u, v }; // For vertices A, B, C [I assume?] + *outHitBary = CVector( 1.f - u - v, u, v ); // For vertices A, B, C [I assume?] } return true; } From 1eb4687cf2e49405d200a60e8c0b6070c133edda Mon Sep 17 00:00:00 2001 From: Tracer <43095317+TracerDS@users.noreply.github.com> Date: Sun, 13 Oct 2024 11:42:27 +0200 Subject: [PATCH 6/6] Fixed build issues --- Client/game_sa/CEntitySA.cpp | 2 +- Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Client/game_sa/CEntitySA.cpp b/Client/game_sa/CEntitySA.cpp index 02a9f00380..9053910737 100644 --- a/Client/game_sa/CEntitySA.cpp +++ b/Client/game_sa/CEntitySA.cpp @@ -679,7 +679,7 @@ bool CEntitySA::GetBonePosition(eBone boneId, CVector& position) return false; const RwV3d& pos = rwBoneMatrix->pos; - position = {pos.x, pos.y, pos.z}; + position = CVector(pos.x, pos.y, pos.z); return true; } diff --git a/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h b/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h index fef13d708b..8f3615f3bd 100644 --- a/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h +++ b/Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h @@ -561,7 +561,7 @@ struct CLuaFunctionParserBase else if constexpr (std::is_same_v) { if (lua_isnumber(L, index)) - return {PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index)}; + return CVector(PopUnsafe(L, index), PopUnsafe(L, index), PopUnsafe(L, index)); int iType = lua_type(L, index); bool isLightUserData = iType == LUA_TLIGHTUSERDATA;