From 2306c0f8646e7683105d928a688b3b4dc6a11680 Mon Sep 17 00:00:00 2001 From: vanz696 <152704532+vanz696@users.noreply.github.com> Date: Wed, 7 Feb 2024 19:40:14 +0300 Subject: [PATCH] Update CGameEntitySystem members (#204) --- entity2/entitysystem.cpp | 3 ++- public/entity2/entitysystem.h | 13 ++++++------- public/tier1/utldict.h | 6 ++++-- public/tier1/utlrbtree.h | 34 ++++++++++++++++++++++++++++++---- public/tier1/utlsymbollarge.h | 6 ++++++ 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/entity2/entitysystem.cpp b/entity2/entitysystem.cpp index 76f89c2b..bc7bc11c 100644 --- a/entity2/entitysystem.cpp +++ b/entity2/entitysystem.cpp @@ -313,11 +313,12 @@ EntityInstanceByClassIter_t::EntityInstanceByClassIter_t(const char* szClassName } } -EntityInstanceByClassIter_t::EntityInstanceByClassIter_t(CEntityInstance* pStart, char const* szClassName, IEntityFindFilter* pFilter, EntityIterType_t eIterType) +EntityInstanceByClassIter_t::EntityInstanceByClassIter_t(CEntityInstance* pStart, const char* szClassName, IEntityFindFilter* pFilter, EntityIterType_t eIterType) { m_pCurrentEnt = pStart ? pStart->m_pEntity : nullptr; m_pFilter = pFilter; m_eIterType = eIterType; + m_hWorldGroupId = WorldGroupId_t(); m_pszClassName = szClassName; m_pEntityClass = NULL; } diff --git a/public/entity2/entitysystem.h b/public/entity2/entitysystem.h index 5aeb9567..48826bd9 100644 --- a/public/entity2/entitysystem.h +++ b/public/entity2/entitysystem.h @@ -290,10 +290,10 @@ public: public: CUtlString m_sEntSystemName; // 2696 - CUtlMap m_entClassesByCPPClassname; // 2704 - CUtlMap m_entClassesByClassname; // 2736 - CUtlMap m_entityComponentHelpers; // 2768 - CUtlMap*> m_entityNames; // 2800 + CUtlMap m_entClassesByCPPClassname; // 2704 + CUtlMap m_entClassesByClassname; // 2736 + CUtlMap m_entityComponentHelpers; // 2768 + CUtlMap*, uint16, CDefLess> m_entityNames; // 2800 CEventQueue m_EventQueue; // 2832 CUtlVectorFixedGrowable m_entityIONotifiers; // 2968 | 2984 int m_nSuppressDormancyChangeCount; // 3008 | 3024 @@ -331,7 +331,7 @@ public: CUtlHashtable m_EntityMaterialAttributes; // 5360 | 5408 }; -// Size: 0x1580 | 0x15B0 (from constructor) +// Size: 0x1570 | 0x15A0 (from constructor) class CGameEntitySystem : public CEntitySystem { struct SpawnGroupEntityFilterInfo_t @@ -356,7 +356,6 @@ public: CUtlVector m_entityListeners; // 5448 | 5496 IEntity2SaveRestore* m_pEntity2SaveRestore; // 5472 | 5520 IEntity2Networkables* m_pEntity2Networkables; // 5480 | 5528 - bool m_Unk7; // 5488 | 5536 }; abstract_class IEntityFindFilter @@ -408,7 +407,7 @@ class EntityInstanceByClassIter_t { public: EntityInstanceByClassIter_t(const char* szClassName, IEntityFindFilter* pFilter = nullptr, EntityIterType_t eIterType = ENTITY_ITER_OVER_ACTIVE); - EntityInstanceByClassIter_t(CEntityInstance* pStart, char const* szClassName, IEntityFindFilter* pFilter = nullptr, EntityIterType_t eIterType = ENTITY_ITER_OVER_ACTIVE); + EntityInstanceByClassIter_t(CEntityInstance* pStart, const char* szClassName, IEntityFindFilter* pFilter = nullptr, EntityIterType_t eIterType = ENTITY_ITER_OVER_ACTIVE); CEntityInstance* First(); CEntityInstance* Next(); diff --git a/public/tier1/utldict.h b/public/tier1/utldict.h index b70375b0..519ae80f 100644 --- a/public/tier1/utldict.h +++ b/public/tier1/utldict.h @@ -25,12 +25,14 @@ enum EDictCompareType { k_eDictCompareTypeCaseSensitive=0, k_eDictCompareTypeCaseInsensitive=1, + k_eDictCompareTypeCaseInsensitiveFast=2, k_eDictCompareTypeFilenames // Slashes and backslashes count as the same character.. }; -template struct CDictCompareTypeDeducer {}; +template struct CDictCompareTypeDeducer {}; template <> struct CDictCompareTypeDeducer { typedef CDefStringLess Type_t; }; template <> struct CDictCompareTypeDeducer { typedef CDefCaselessStringLess Type_t; }; +template <> struct CDictCompareTypeDeducer { typedef CDefFastCaselessStringLess Type_t; }; template <> struct CDictCompareTypeDeducer { typedef CDefCaselessStringLessIgnoreSlashes Type_t; }; #define FOR_EACH_DICT( dictName, iteratorName ) \ @@ -43,7 +45,7 @@ template <> struct CDictCompareTypeDeducer { typede //----------------------------------------------------------------------------- // A dictionary mapping from symbol to structure //----------------------------------------------------------------------------- -template +template class CUtlDict { public: diff --git a/public/tier1/utlrbtree.h b/public/tier1/utlrbtree.h index 0da0c061..527f9b0f 100644 --- a/public/tier1/utlrbtree.h +++ b/public/tier1/utlrbtree.h @@ -45,9 +45,26 @@ public: //------------------------------------- -inline bool StringLessThan( const char * const &lhs, const char * const &rhs) { return ( strcmp( lhs, rhs) < 0 ); } -inline bool CaselessStringLessThan( const char * const &lhs, const char * const &rhs ) { return ( V_stricmp_fast( lhs, rhs) < 0 ); } +inline bool StringLessThan( const char * const &lhs, const char * const &rhs) +{ + if ( !lhs ) return false; + if ( !rhs ) return true; + return ( strcmp( lhs, rhs ) < 0 ); +} +inline bool CaselessStringLessThan( const char * const &lhs, const char * const &rhs ) +{ + if ( !lhs ) return false; + if ( !rhs ) return true; + return ( stricmp( lhs, rhs ) < 0 ); +} + +inline bool FastCaselessStringLessThan( const char * const &lhs, const char * const &rhs ) +{ + if ( !lhs ) return false; + if ( !rhs ) return true; + return ( V_stricmp_fast( lhs, rhs ) < 0 ); +} // Same as CaselessStringLessThan, but it ignores differences in / and \. inline bool CaselessStringLessThanIgnoreSlashes( const char * const &lhs, const char * const &rhs ) @@ -97,7 +114,7 @@ class CDefStringLess public: CDefStringLess() {} CDefStringLess( int i ) {} - inline bool operator()( const char * const &lhs, const char * const &rhs ) const { return StringLessThan( lhs, rhs ); } + inline bool operator()( const char * const &lhs, const char * const &rhs ) const { return ( strcmp( lhs, rhs ) < 0 ); } inline bool operator!() const { return false; } }; @@ -106,7 +123,16 @@ class CDefCaselessStringLess public: CDefCaselessStringLess() {} CDefCaselessStringLess( int i ) {} - inline bool operator()( const char * const &lhs, const char * const &rhs ) const { return CaselessStringLessThan( lhs, rhs ); } + inline bool operator()( const char * const &lhs, const char * const &rhs ) const { return ( stricmp( lhs, rhs ) < 0 ); } + inline bool operator!() const { return false; } +}; + +class CDefFastCaselessStringLess +{ +public: + CDefFastCaselessStringLess() {} + CDefFastCaselessStringLess( int i ) {} + inline bool operator()( const char * const &lhs, const char * const &rhs ) const { return ( V_stricmp_fast( lhs, rhs ) < 0 ); } inline bool operator!() const { return false; } }; diff --git a/public/tier1/utlsymbollarge.h b/public/tier1/utlsymbollarge.h index 3a208bea..788c36ba 100644 --- a/public/tier1/utlsymbollarge.h +++ b/public/tier1/utlsymbollarge.h @@ -58,6 +58,12 @@ public: { return m_pString != src.m_pString; } + + // operator< + bool operator<( CUtlSymbolLarge const& src ) const + { + return ( intp )m_pString < ( intp )src.m_pString; + } inline const char* String() const {