From 0ac0302c8e39835460f1b310c756a9d9bb65fdde Mon Sep 17 00:00:00 2001 From: GAMMACASE Date: Fri, 29 Sep 2023 13:13:00 +0300 Subject: [PATCH] Fix GCC compilation issues --- game/shared/entitylist_base.h | 2 +- public/eiface.h | 2 +- public/gametrace.h | 2 +- public/irecipientfilter.h | 2 +- public/networksystem/inetworkserializer.h | 16 ++++++++++++++-- public/tier0/threadtools.h | 4 ++-- public/tier1/bufferstring.h | 7 ++++--- public/tier1/utlsymbollarge.h | 2 +- public/variant.h | 4 ++-- public/vscript/ivscript.h | 17 +++++++++++++++++ 10 files changed, 44 insertions(+), 14 deletions(-) diff --git a/game/shared/entitylist_base.h b/game/shared/entitylist_base.h index e2fb56a8..1158f3f0 100644 --- a/game/shared/entitylist_base.h +++ b/game/shared/entitylist_base.h @@ -13,7 +13,7 @@ #include "const.h" #include "basehandle.h" -#include "utllinkedlist.h" +#include "tier1/utllinkedlist.h" #include "ihandleentity.h" diff --git a/public/eiface.h b/public/eiface.h index 1beef706..e1d2e5d1 100644 --- a/public/eiface.h +++ b/public/eiface.h @@ -13,7 +13,7 @@ #pragma once #endif -#include "convar.h" +#include "tier1/convar.h" #include "icvar.h" #include "edict.h" #include "mathlib/vplane.h" diff --git a/public/gametrace.h b/public/gametrace.h index 8db31c8e..3a27ecf7 100644 --- a/public/gametrace.h +++ b/public/gametrace.h @@ -12,7 +12,7 @@ #include "cmodel.h" -#include "utlvector.h" +#include "tier1/utlvector.h" #include "ihandleentity.h" #include "ispatialpartition.h" diff --git a/public/irecipientfilter.h b/public/irecipientfilter.h index 3d9a35c6..cb8436a4 100644 --- a/public/irecipientfilter.h +++ b/public/irecipientfilter.h @@ -25,7 +25,7 @@ public: virtual bool IsInitMessage( void ) const = 0; virtual int GetRecipientCount( void ) const = 0; - virtual CEntityIndex *GetRecipientIndex( CEntityIndex slot ) const = 0; + virtual CEntityIndex GetRecipientIndex( int slot ) const = 0; }; #endif // IRECIPIENTFILTER_H diff --git a/public/networksystem/inetworkserializer.h b/public/networksystem/inetworkserializer.h index 33b5e7f9..037a7b2f 100644 --- a/public/networksystem/inetworkserializer.h +++ b/public/networksystem/inetworkserializer.h @@ -12,8 +12,20 @@ #include #include "Color.h" -enum NetworkValidationMode_t; -enum NetworkSerializationMode_t; +enum NetworkValidationMode_t +{ + +}; + +enum NetworkSerializationMode_t +{ + NET_SERIALIZATION_MODE_0 = 0x0, + NET_SERIALIZATION_MODE_1 = 0x1, + NET_SERIALIZATION_MODE_COUNT = 0x2, + NET_SERIALIZATION_MODE_DEFAULT = 0x0, + NET_SERIALIZATION_MODE_SERVER = 0x0, + NET_SERIALIZATION_MODE_CLIENT = 0x1, +}; typedef uint16 NetworkMessageId; typedef uint8 NetworkGroupId; diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index 876f3a0e..89b6ed3e 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -892,7 +892,7 @@ template <> struct CAutoLockTypeDeducer { typed #ifdef COMPILER_GCC #define AUTO_LOCK( mutex ) \ - AUTO_LOCK_( typeof(CAutoLockTypeDeducer::Type_t), mutex ) + AUTO_LOCK_( typename CAutoLockTypeDeducer::Type_t, mutex ) #else #define AUTO_LOCK( mutex ) \ AUTO_LOCK_( CAutoLockTypeDeducer::Type_t, mutex ) @@ -1135,7 +1135,7 @@ private: class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock { public: - CThreadSpinRWLock() { COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) ); Assert( (intp)this % 8 == 0 ); memset( this, 0, sizeof( *this ) ); } + CThreadSpinRWLock() { COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) ); Assert( (intp)this % 8 == 0 ); memset( (void*)this, 0, sizeof( *this ) ); } bool TryLockForWrite(); bool TryLockForRead(); diff --git a/public/tier1/bufferstring.h b/public/tier1/bufferstring.h index fc3c0660..c79515aa 100644 --- a/public/tier1/bufferstring.h +++ b/public/tier1/bufferstring.h @@ -206,8 +206,9 @@ class CBufferStringGrowable : public CBufferString friend class CBufferString; public: - CBufferStringGrowable() : m_nTotalCount(0), m_nAllocated(STACK_ALLOCATION_MARKER | (MAX_SIZE & LENGTH_MASK)), m_Memory() + CBufferStringGrowable() : m_nTotalCount(0), m_nAllocated(STACK_ALLOCATION_MARKER | (MAX_SIZE & LENGTH_MASK)) { + memset(m_Memory.m_szString, 0, sizeof(m_Memory.m_szString)); if (AllowHeapAllocation) { m_nAllocated |= ALLOW_HEAP_ALLOCATION; @@ -272,8 +273,8 @@ private: union { - const char *m_pString; - const char m_szString[MAX_SIZE]; + char *m_pString; + char m_szString[MAX_SIZE]; } m_Memory; }; diff --git a/public/tier1/utlsymbollarge.h b/public/tier1/utlsymbollarge.h index bb3c8b7c..bb704e60 100644 --- a/public/tier1/utlsymbollarge.h +++ b/public/tier1/utlsymbollarge.h @@ -383,7 +383,7 @@ inline CUtlSymbolLarge CUtlSymbolTableLargeBase::Find // use the string passed in the context int len = Q_strlen( pString ) + 1; - CUtlSymbolTableLargeBaseTreeEntry_t *search = (CUtlSymbolTableLargeBaseTreeEntry_t *)_alloca( len + sizeof( LargeSymbolTableHashDecoration_t ) ); + CUtlSymbolTableLargeBaseTreeEntry_t *search = (CUtlSymbolTableLargeBaseTreeEntry_t *)alloca( len + sizeof( LargeSymbolTableHashDecoration_t ) ); search->m_Hash = CUtlSymbolLarge_Hash( CASEINSENSITIVE, pString, len ); Q_memcpy( (char *)&search->m_String[ 0 ], pString, len ); diff --git a/public/variant.h b/public/variant.h index a9c70500..53b30018 100644 --- a/public/variant.h +++ b/public/variant.h @@ -12,8 +12,8 @@ #include "Color.h" #include "entity2/entityidentity.h" #include "basehandle.h" -#include "bufferstring.h" -#include "utlscratchmemory.h" +#include "tier1/bufferstring.h" +#include "tier1/utlscratchmemory.h" // Forward declaration class CEntityInstance; diff --git a/public/vscript/ivscript.h b/public/vscript/ivscript.h index 21ce4296..a37ac5f9 100644 --- a/public/vscript/ivscript.h +++ b/public/vscript/ivscript.h @@ -171,6 +171,23 @@ typedef CVariant ScriptVariant_t; #define SCRIPT_VARIANT_NULL ScriptVariant_t() +template struct ScriptDeducer { /*enum { FIELD_TYPE = FIELD_TYPEUNKNOWN };*/ }; +#define DECLARE_DEDUCE_FIELDTYPE( fieldType, type ) template<> struct ScriptDeducer { enum { FIELD_TYPE = fieldType }; }; + +DECLARE_DEDUCE_FIELDTYPE( FIELD_VOID, void ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_FLOAT, float ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_CSTRING, const char * ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_CSTRING, char * ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_VECTOR, Vector ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_VECTOR, const Vector & ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_INTEGER, int ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_BOOLEAN, bool ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_CHARACTER, char ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_HSCRIPT, HSCRIPT ); +DECLARE_DEDUCE_FIELDTYPE( FIELD_VARIANT, ScriptVariant_t ); + +#define ScriptDeduceType( T ) ScriptDeducer::FIELD_TYPE + //--------------------------------------------------------- struct ScriptFuncDescriptor_t