-
Notifications
You must be signed in to change notification settings - Fork 187
Update hash staff & engine sync #303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: cs2
Are you sure you want to change the base?
Conversation
Update `CUtlSymbolLarge` container
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall thanks for the work, highly appreciate it!
CUtlSymbol Insert( const char *pString, const T &item ) | ||
{ | ||
CUtlSymbol symbol = m_SymbolTable.AddString( pString ); // implicit coercion | ||
if ( m_Vector.Count() > symbol ) | ||
{ | ||
// this string is already in the dictionary. | ||
|
||
} | ||
else if ( m_Vector.Count() == symbol ) | ||
{ | ||
// this is the expected case when we've added one more to the tail. | ||
m_Vector.AddToTail( item ); | ||
} | ||
else // ( m_Vector.Count() < symbol ) | ||
{ | ||
// this is a strange shouldn't-happen case. | ||
AssertMsg( false, "CUtlStringMap insert unexpected entries." ); | ||
m_Vector.EnsureCount( symbol + 1 ); | ||
m_Vector[symbol] = item; | ||
} | ||
return symbol; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no real need in such a method as utlstringmap expects you to do insertions directly by a key, example:
stringmap[newkey] = newvalue;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to add a new string key & insert it into the expanded utlvector.
CUtlStringMap
's operators are desiged for getting/setting an existing key.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are tho, how else would you expect new entries to be added there? You can test yourself these with adding new keys. This code in particular handles that
hl2sdk/public/tier1/UtlStringMap.h
Lines 30 to 39 in c6ac506
T& operator[]( const char *pString ) | |
{ | |
CUtlSymbol symbol = m_SymbolTable.AddString( pString ); | |
int index = ( int )symbol; | |
if( m_Vector.Count() <= index ) | |
{ | |
m_Vector.EnsureCount( index + 1 ); | |
} | |
return m_Vector[index]; | |
} |
// Remove once symbol element. | ||
// @Wend4r: The table is not designed for that. | ||
void Remove( CUtlSymbol id ) { m_HashTable.Remove( id ); m_MemBlocks[ id ] = MEMBLOCKHANDLE_INVALID; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As per your note, container isn't designed for such removals, so no need to hack them in and potentially hurting other code relying on such behavior, please, revert this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is necessary for gsplugins to remove game system factory from &IGameSystem::sm_GameSystemFactories
for safe unloading a meta plugin & map changing. Are you sure?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If all you need is to remove entry from a stringmap, just empty it like you did in the method but do that externally, there's no need for such methods just to satisfy that particular feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, I'll think about it, how to do it without the Remove
method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well since all you do in a stringmap::Remove method is vec[symbol] = {}, you can achieve the same with stringmap[key] = {}
@@ -1758,6 +1837,40 @@ void CKeyValues3Table::CopyFrom( KeyValues3 *parent, const CKeyValues3Table* src | |||
EnableFastSearch(); | |||
} | |||
|
|||
void CKeyValues3Table::RenameMember( KeyValues3 *parent, KV3MemberId_t id, const CKV3MemberName &newName ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While you at it, how about adding an assert to ensure the id is within valid range, for this method and any other that take id (like RemoveMember)
#include <string.h> | ||
#include "bufferstring.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These includes introduce cyclic include dependency issues which causes some parts of the code to fail. As per the comments below these are better removed from here anyway!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Solved it in the slightly different way
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think what you did is sane enough, moving stuff around like that to satisfy the needs isn't ideal especially for stuff that always been there, please, just remove the utlstring and bufferstring from stringtoken as that will fix every issue related to this.
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Use `DefaultHashFunctor< CUtlStringToken >` instead Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
…alue` back Update hash value type Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
Co-authored-by: GAMMACASE <31375974+GAMMACASE@users.noreply.github.com>
To prevent non-kv3(array/table) values into a loop body
It works fine with CS2Fixes-based plugin (on SteamRT side), but I'll continue to work on this PR |
Preparing changes before Source 2 Engine sync (HLX branch) into Counter-Strike 2. The methods/definitions were added carefully for compatibility with the current game code (so far).
Sync HL2SDK (CS2)
CBufferStringN
Purge
ofCBufferStringN
.CUtlStringToken
constexpr
constructor to inline the hash value.CUtlStringTokenHashMethod
class to pass the compare function intoCUtlHash
.MakeStringToken
capabilities.MakeStringToken2
function to calculate a runtime hash withCBufferStringN
.CUtlSymbolTable
FOR_EACH_SYMBOL
(_BACK
) macro to iterate by the table.Hash
methods to get a hash by the sybmol.Remove
method to remove the symbol (is needed to remove the pluginself game system factory for safe unloading).CUtlStringMap
FOR_EACH_STRING_MAP
macro to iterate by the map.FindAndRemove
method (for gsplugin's safe unloading)CUtlSymbolTableLargeBase
FOR_EACH_SYMBOL_LARGE
(_BACK
) macro to iterate by the table.String
,Hash
&GetNumString
methods public to get the symbol large data.CKV3MemberName
CUtlStringToken
inherit for the child methods & compare operators.constexpr
constructor to inline the hash value & string.Make
method & constructors to calculate a runtime hash.KeyValues3
FOR_EACH_KV3_ARRAY
(_BACK
) macro to iterate by the kv3array.FOR_EACH_KV3_TABLE
(_BACK
) macro to iterate by the kv3table.CKV3MemberNameWithStorage
container (Pulse thing)CKV3MemberNameSet
definition (Pulse thing; akaKeyValues3
withKV_TYPE_ARRAY
)CKeyValues3StringAndHash
definition (oldCKV3MemberName
name).KeyValues3LowercaseHash_t
definition (akaCUtlStringToken
).IsArray
/GetArray
method.IsTable
/GetTable
method.Internal_FindMember
method (also in the kv3table).GetMemberNameEx
toGetKV3MemberName
(like-in the engine).HasInvalidMemberNames
&SetHasInvalidMemberNames
methods (also in/of the kv3table; used for unserialize an ekv).RenameMember
method.OverlayKeysFrom
method.PrepareForType
arguments to pass ones intoAlloc
.Changes that will affect the current SDK's works
0
) that usually uses together store Vulkan or animgraph containers (@gishi523 or more engine research; not to be confused with non-addedCUtlVectorBase<T, I, A>
; important for the named signatures of platform-overloaded functions)ICvar
& convar structures (in thedota
branch)