本文整理汇总了C++中CUtlDict::Element方法的典型用法代码示例。如果您正苦于以下问题:C++ CUtlDict::Element方法的具体用法?C++ CUtlDict::Element怎么用?C++ CUtlDict::Element使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CUtlDict
的用法示例。
在下文中一共展示了CUtlDict::Element方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
const char *CClassMap::Lookup( const char *classname )
{
unsigned short index;
static classentry_t lookup;
index = m_ClassDict.Find( classname );
if ( index == m_ClassDict.InvalidIndex() )
return NULL;
lookup = m_ClassDict.Element( index );
return lookup.GetMapName();
}
示例2:
//-----------------------------------------------------------------------------
// Purpose:
// Input : gamematerial -
// Output : char const
//-----------------------------------------------------------------------------
char const *CDecalEmitterSystem::ImpactDecalForGameMaterial( int gamematerial )
{
char gm[ 2 ];
gm[0] = (char)gamematerial;
gm[1] = 0;
int idx = m_GameMaterialTranslation.Find( gm );
if ( idx == m_GameMaterialTranslation.InvalidIndex() )
return NULL;
return m_Decals.GetElementName( m_GameMaterialTranslation.Element(idx) );
}
示例3: __MsgFunc_PyNetworkCls
// Message handler for PyNetworkCls
void __MsgFunc_PyNetworkCls( bf_read &msg )
{
char clientClass[PYNETCLS_BUFSIZE];
char networkName[PYNETCLS_BUFSIZE];
int iType = msg.ReadByte();
msg.ReadString(clientClass, PYNETCLS_BUFSIZE);
msg.ReadString(networkName, PYNETCLS_BUFSIZE);
DbgStrPyMsg( "__MsgFunc_PyNetworkCls: Registering Python network class message %d %s %s\n", iType, clientClass, networkName );
// Get module path
const char *pch = Q_strrchr( networkName, '.' );
if( !pch )
{
Warning( "Invalid python class name %s\n", networkName );
return;
}
int n = pch - networkName + 1;
char modulePath[PYNETCLS_BUFSIZE];
Q_strncpy( modulePath, networkName, n );
// Make sure the client class is imported
SrcPySystem()->Import( modulePath );
// Read which client class we are modifying
PyClientClassBase *p = FindPyClientClass( clientClass );
if( !p )
{
Warning( "__MsgFunc_PyNetworkCls: Invalid networked class %s\n", clientClass );
return;
}
// Set type
p->SetType( iType );
SetupClientClassRecv( p, iType );
// Read network class name
Q_strncpy( p->m_strPyNetworkedClassName, networkName, PYNETCLS_BUFSIZE );
// Attach if a network class exists
unsigned short lookup = m_NetworkClassDatabase.Find( networkName );
if ( lookup != m_NetworkClassDatabase.InvalidIndex() )
{
m_NetworkClassDatabase.Element(lookup)->AttachClientClass( p );
}
else
{
Warning( "__MsgFunc_PyNetworkCls: Invalid networked class %s\n", networkName );
}
}
示例4: strdup
//-----------------------------------------------------------------------------
// Purpose: Find a free PyServerClass and claim it
// Send a message to the clients to claim a client class and set it to
// the right type.
//-----------------------------------------------------------------------------
NetworkedClass::NetworkedClass( const char *pNetworkName, boost::python::object cls_type )
{
m_pNetworkName = strdup( pNetworkName );
m_pServerClass = NULL;
PyServerClass *p;
// See if there is already an entity with this network name
unsigned short lookup = m_ServerClassInfoDatabase.Find( pNetworkName );
if ( lookup != m_ServerClassInfoDatabase.InvalidIndex() )
{
Warning("NetworkedClass: %s already added. Replacing with new data. Element name: %s\n", pNetworkName, m_ServerClassInfoDatabase.Element(lookup) );
p = FindPyServerClass( m_ServerClassInfoDatabase.Element(lookup) );
if( !p )
{
Warning("NetworkedClass: ServerClass %s not found\n", m_ServerClassInfoDatabase.Element(lookup) );
return;
}
if( p->m_pNetworkedClass )
p->m_pNetworkedClass->m_pServerClass = NULL;
}
else
{
// Find a free server class and add it to the database
p = FindFreePyServerClass();
if( !p ) {
Warning("Couldn't create PyServerClass %s: Out of free PyServerClasses\n", pNetworkName);
return;
}
lookup = m_ServerClassInfoDatabase.Insert(pNetworkName, p->GetName());
}
m_pServerClass = p;
m_PyClass = cls_type;
p->m_bFree = false;
p->m_pNetworkedClass = this;
SetupServerClass();
}
示例5: __MsgFunc_PyNetworkCls
// Message handler for PyNetworkCls
void __MsgFunc_PyNetworkCls( bf_read &msg )
{
int iClassID;
char networkName[PYNETCLS_BUFSIZE];
iClassID = msg.ReadWord();
msg.ReadString( networkName, PYNETCLS_BUFSIZE );
DbgStrPyMsg( "__MsgFunc_PyNetworkCls: Registering Python network class message %d %s\n", iClassID, networkName );
// Get module path
const char *pch = V_strrchr( networkName, '.' );
if( !pch )
{
Warning( "Invalid python class name %s\n", networkName );
return;
}
int n = pch - networkName + 1;
char modulePath[PYNETCLS_BUFSIZE];
V_strncpy( modulePath, networkName, n );
// Make sure the client class is imported
SrcPySystem()->Import( modulePath );
// Read which client class we are modifying
PyClientClassBase *p = FindPyClientClassByID( iClassID );
if( !p )
{
Warning( "__MsgFunc_PyNetworkCls: Invalid networked class %d\n", iClassID );
return;
}
// Read network class name
V_strncpy( p->m_strPyNetworkedClassName, networkName, sizeof( p->m_strPyNetworkedClassName ) );
// Attach if a network class exists
unsigned short lookup = m_NetworkClassDatabase.Find( networkName );
if ( lookup != m_NetworkClassDatabase.InvalidIndex() )
{
m_NetworkClassDatabase.Element(lookup)->AttachClientClass( p );
}
else
{
Warning( "__MsgFunc_PyNetworkCls: Invalid networked class %s\n", networkName );
}
}
示例6:
NetworkedClass::~NetworkedClass()
{
unsigned short lookup;
// Remove pointer
lookup = m_NetworkClassDatabase.Find( m_pNetworkName );
if ( lookup != m_NetworkClassDatabase.InvalidIndex() )
{
// Only remove if it's our pointer. Otherwise we are already replaced.
if( m_NetworkClassDatabase.Element( lookup ) == this )
m_NetworkClassDatabase.RemoveAt( lookup );
}
else
{
Warning("NetworkedClass destruction: invalid networkclass %s\n", m_pNetworkName);
}
if( m_pClientClass )
{
m_pClientClass->m_bFree = true;
}
free( (void *)m_pNetworkName );
m_pNetworkName = NULL;
}