Skip to content

Commit

Permalink
Fix CUtlStringMap header file
Browse files Browse the repository at this point in the history
  • Loading branch information
Wend4r committed Jan 2, 2025
1 parent dda7f05 commit 89447a1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions public/appframework/iappsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "interfaces/interfaces.h"
#include "tier0/interface.h"
#include "tier0/utlstring.h"
#include "tier1/UtlStringMap.h"
#include "tier1/utlstringmap.h"

//-----------------------------------------------------------------------------
// Specifies a module + interface name for initialization
Expand Down Expand Up @@ -164,7 +164,7 @@ abstract_class CAppSystemDict
CUtlVector<AppSystem_t> m_Systems;
CUtlVector<FactoryFn> m_NonAppSystemFactories;
CUtlStringList m_ModuleSearchPath;
CUtlStringMap<short unsigned int> m_SystemDict; // 104
CUtlStringMap<UtlSymId_t> m_SystemDict; // 104
int m_nExpectedShutdownLoggingStateIndex; // 256
void* m_pDefaultLoggingListener; // 264
void* m_pGameInfo; // 272
Expand Down
2 changes: 1 addition & 1 deletion public/schemasystem/schemasystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "tier0/threadtools.h"
#include "tier0/utlstring.h"
#include "tier1/convar.h"
#include "tier1/UtlStringMap.h"
#include "tier1/utlstringmap.h"
#include "tier1/utltshash.h"
#include "tier1/utlvector.h"
#include "appframework/iappsystem.h"
Expand Down
2 changes: 1 addition & 1 deletion public/tier0/utlbuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
#pragma once
#endif

#include "unitlib/unitlib.h" // just here for tests - remove before checking in!!!
// #include "unitlib/unitlib.h" // just here for tests - remove before checking in!!!

#include "platform.h"
#include "tier0/byteswap.h"
Expand Down
2 changes: 1 addition & 1 deletion public/tier1/utlbufferutil.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
#pragma once
#endif

#include "tier1/utlvector.h"
#include "tier0/utlbuffer.h"
#include "tier1/utlvector.h"


//-----------------------------------------------------------------------------
Expand Down
34 changes: 17 additions & 17 deletions public/tier1/UtlStringMap.h → public/tier1/utlstringmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@

#ifndef UTLSTRINGMAP_H
#define UTLSTRINGMAP_H

#ifdef _WIN32
#pragma once
#endif

#include "utlsymbol.h"
#include "tier0/utlsymbol.h"

template <class T>
class CUtlStringMap
{
public:
typedef UtlSymId_t IndexType_t;
CUtlStringMap( bool caseInsensitive = true, int initsize = 32 ) :
m_Vector( initsize ),
m_SymbolTable( 0, 32, caseInsensitive )
Expand All @@ -27,7 +27,7 @@ class CUtlStringMap
T& operator[]( const char *pString )
{
CUtlSymbol symbol = m_SymbolTable.AddString( pString );
int index = ( int )( UtlSymId_t )symbol;
int index = ( int )symbol;
if( m_Vector.Count() <= index )
{
m_Vector.EnsureCount( index + 1 );
Expand All @@ -36,13 +36,13 @@ class CUtlStringMap
}

// Get data by the string's symbol table ID - only used to retrieve a pre-existing symbol, not create a new one!
T& operator[]( UtlSymId_t n )
T& operator[]( CUtlSymbol n )
{
Assert( n <= m_Vector.Count() );
return m_Vector[n];
}

const T& operator[]( UtlSymId_t n ) const
const T& operator[]( CUtlSymbol n ) const
{
Assert( n <= m_Vector.Count() );
return m_Vector[n];
Expand All @@ -59,15 +59,15 @@ class CUtlStringMap
return m_SymbolTable.Find( pString ).IsValid();
}

UtlSymId_t Find( const char *pString ) const
CUtlSymbol Find( const char *pString ) const
{
return m_SymbolTable.Find( pString );
}

UtlSymId_t AddString( const char *pString, bool* created = NULL )
CUtlSymbol AddString( const char *pString, bool* created = NULL )
{
CUtlSymbol symbol = m_SymbolTable.AddString( pString, created );
int index = ( int )( UtlSymId_t )symbol;
int index = ( int )symbol;
if( m_Vector.Count() <= index )
{
m_Vector.EnsureCount( index + 1 );
Expand All @@ -79,10 +79,10 @@ class CUtlStringMap
/// its location in the same operation. Returns the
/// newly created index (or the one that was just
/// overwritten, if pString already existed.)
UtlSymId_t Insert( const char *pString, const T &item )
CUtlSymbol Insert( const char *pString, const T &item )
{
CUtlSymbol symbol = m_SymbolTable.AddString( pString );
UtlSymId_t index = symbol; // implicit coercion
CUtlSymbol index = symbol; // implicit coercion
if ( m_Vector.Count() > index )
{
// this string is already in the dictionary.
Expand All @@ -104,7 +104,7 @@ class CUtlStringMap
}

/// iterate, not in any particular order.
IndexType_t First() const
CUtlSymbol First() const
{
if ( Count() > 0 )
{
Expand All @@ -116,20 +116,20 @@ class CUtlStringMap
}
}

static UtlSymId_t InvalidIndex()
static CUtlSymbol InvalidIndex()
{
return UTL_INVAL_SYMBOL;
return {};
}

// iterators (for uniformity with other map types)
inline UtlSymId_t Head() const
inline CUtlSymbol Head() const
{
return m_SymbolTable.GetNumStrings() > 0 ? 0 : InvalidIndex();
return m_SymbolTable.GetNumStrings() > 0 ? CUtlSymbol( 0 ) : InvalidIndex();
}

inline UtlSymId_t Next( const UtlSymId_t &i ) const
inline CUtlSymbol Next( const CUtlSymbol &i ) const
{
UtlSymId_t n = i+1;
CUtlSymbol n = i+1;
return n < m_SymbolTable.GetNumStrings() ? n : InvalidIndex();
}

Expand Down

0 comments on commit 89447a1

Please sign in to comment.