From ec55c52a0ec804acb90fe2c18332fcae429b0cb1 Mon Sep 17 00:00:00 2001 From: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com> Date: Wed, 30 Sep 2026 22:48:12 +0300 Subject: [PATCH] Fix ctor member order in CVariantBase & minor additions --- public/variant.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/public/variant.h b/public/variant.h index 0bba06fd..b9605a07 100644 --- a/public/variant.h +++ b/public/variant.h @@ -107,12 +107,15 @@ public: CVariantBase( const Quaternion *val, bool bCopy = false ) : m_type( FIELD_QUATERNION ), m_flags( 0 ) { CopyData(*val, bCopy); } CVariantBase( const char *val, bool bCopy = false ) : m_type( FIELD_CSTRING ), m_flags( 0 ) { CopyData(val, bCopy); } - CVariantBase( const CVariantBase &variant ) : m_flags( 0 ), m_type( FIELD_VOID ) { variant.AssignTo( this ); } + CVariantBase( const CVariantBase &variant ) : m_type( FIELD_VOID ), m_flags( 0 ) { variant.AssignTo( this ); } void operator=( const CVariantBase &variant ) { variant.AssignTo( this ); } // Checks if the stored value is of type FIELD_VOID bool IsNull() const { return (m_type == FIELD_VOID ); } + operator uint8() const { Assert( m_type == FIELD_UINT8 ); return m_uint8; } + operator int16() const { Assert( m_type == FIELD_INT16 ); return m_int16; } + operator uint16() const { Assert( m_type == FIELD_UINT16 ); return m_uint16; } operator int32() const { Assert( m_type == FIELD_INT32 ); return m_int32; } operator uint32() const { Assert( m_type == FIELD_UINT32 ); return m_uint32; } operator int64() const { Assert( m_type == FIELD_INT64); return m_int64; } @@ -136,6 +139,9 @@ public: operator CUtlStringToken() const { Assert( m_type == FIELD_UTLSTRINGTOKEN); return m_utlStringToken; } operator ResourceHandle_t() const { Assert( m_type == FIELD_RESOURCE); return m_hResource; } + void operator=( uint8 i ) { Free(); m_type = FIELD_UINT8; m_uint8 = i; } + void operator=( int16 i ) { Free(); m_type = FIELD_INT16; m_int16 = i; } + void operator=( uint16 i ) { Free(); m_type = FIELD_UINT16; m_uint16 = i; } void operator=( int32 i ) { Free(); m_type = FIELD_INT32; m_int32 = i; } void operator=( uint32 u ) { Free(); m_type = FIELD_UINT32; m_uint32 = u; } void operator=( int64 i ) { Free(); m_type = FIELD_INT64; m_int64 = i; }