Skip to content

Commit 6a70cf7

Browse files
authored
Fix CVector optional arguments - #3738 (#3782)
1 parent aa90aa5 commit 6a70cf7

File tree

3 files changed

+8
-9
lines changed

3 files changed

+8
-9
lines changed

Client/game_sa/CEntitySA.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ bool CEntitySA::GetBonePosition(eBone boneId, CVector& position)
679679
return false;
680680

681681
const RwV3d& pos = rwBoneMatrix->pos;
682-
position = {pos.x, pos.y, pos.z};
682+
position = CVector(pos.x, pos.y, pos.z);
683683
return true;
684684
}
685685

Shared/mods/deathmatch/logic/lua/CLuaFunctionParser.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ struct CLuaFunctionParserBase
561561
else if constexpr (std::is_same_v<T, CVector>)
562562
{
563563
if (lua_isnumber(L, index))
564-
return {PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index)};
564+
return CVector(PopUnsafe<float>(L, index), PopUnsafe<float>(L, index), PopUnsafe<float>(L, index));
565565

566566
int iType = lua_type(L, index);
567567
bool isLightUserData = iType == LUA_TLIGHTUSERDATA;

Shared/sdk/CVector.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,12 @@ class CVector
3030
float fY;
3131
float fZ;
3232

33-
struct NoInit{};
33+
struct NoInit {};
34+
CVector(NoInit) noexcept {}
3435

35-
CVector(NoInit) {}
36-
37-
constexpr CVector() : fX(0.0f), fY(0.0f), fZ(0.0f) {}
38-
39-
constexpr CVector(float x, float y, float z) : fX(x), fY(y), fZ(z) {}
36+
constexpr CVector() noexcept : fX(0.0f), fY(0.0f), fZ(0.0f) {}
37+
38+
constexpr explicit CVector(float x, float y = 0.0f, float z = 0.0f) noexcept : fX(x), fY(y), fZ(z) {}
4039

4140
constexpr CVector(const CVector4D& vec) noexcept : fX(vec.fX), fY(vec.fY), fZ(vec.fZ) {}
4241

@@ -187,7 +186,7 @@ class CVector
187186
{
188187
*outVec = *this + vecRay * t;
189188
if (outHitBary) { // Calculate all barycentric coords if necessary
190-
*outHitBary = { 1.f - u - v, u, v }; // For vertices A, B, C [I assume?]
189+
*outHitBary = CVector( 1.f - u - v, u, v ); // For vertices A, B, C [I assume?]
191190
}
192191
return true;
193192
}

0 commit comments

Comments
 (0)