本文整理汇总了C++中Directory::GetDataString方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::GetDataString方法的具体用法?C++ Directory::GetDataString怎么用?C++ Directory::GetDataString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Directory
的用法示例。
在下文中一共展示了Directory::GetDataString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetDataDArray
void Directory::GetDataDArray ( const char *dataName, DArray<int> *darray ) const
{
AppAssert( dataName );
AppAssert( darray );
//
// First try to find a directory representing this DArray
Directory *dir = GetDirectory( dataName );
if ( !dir )
{
AppReleaseAssert(false, "Failed to find DArray named %s", dataName );
return;
}
//
// Get info about the DArray
char *tID = dir->GetDataString("tID");
int size = dir->GetDataInt("Size");
if ( strcmp(tID, "DArray<int>") != 0 || size == DIRECTORY_SAFEINT)
{
AppDebugOut("Found object %s but it doesn't appear to be a DArray\n" );
}
//
// Iterate through it, loading data
darray->SetSize( size );
for ( int i = 0; i < size; ++i )
{
char indexName[16];
sprintf ( indexName, "[i %d]", i );
Directory *thisIndex = dir->GetDirectory( indexName );
if ( !thisIndex )
{
AppDebugOut("Error loading DArray %s : index %d is missing\n", dataName, i );
}
else
{
bool used = thisIndex->GetDataBool("[Used]");
if ( !used )
{
if ( darray->ValidIndex(i) )
darray->RemoveData(i);
}
else
{
int theData = thisIndex->GetDataInt("[Data]");
darray->PutData( theData, i );
}
}
}
}
示例2: GetDataLList
void Directory::GetDataLList ( const char *dataName, LList<Directory *> *llist ) const
{
AppAssert( dataName );
AppAssert( llist );
//
// First try to find a directory representing this LList
Directory *dir = GetDirectory( dataName );
if ( !dir )
{
AppDebugOut("Failed to find LList named %s\n", dataName);
return;
}
//
// Get info about the LList
char *tID = dir->GetDataString("tID");
int size = dir->GetDataInt("Size");
if ( strcmp(tID, "LList<Directory *>") != 0 || size == DIRECTORY_SAFEINT)
{
AppDebugOut("Found object %s but it doesn't appear to be a LList\n");
}
//
// Iterate through it, loading data
for ( int i = 0; i < size; ++i )
{
char indexName[16];
sprintf ( indexName, "[i %d]", i );
Directory *thisIndex = dir->GetDirectory( indexName );
if ( !thisIndex )
{
AppDebugOut("Error loading LList %s : index %d is missing\n", dataName, i);
}
else
{
if( thisIndex->m_subDirectories.ValidIndex(0) )
{
Directory *theDir = thisIndex->m_subDirectories[0];
llist->PutData( theDir );
}
else
{
AppDebugOut("Error loading LList %s : could not find directory in index %d\n", dataName, i);
}
}
}
}
示例3: RequestIdentityThread
static NetCallBackRetType RequestIdentityThread(void *ignored)
{
#ifdef WAN_PLAY_ENABLED
NetSocketListener *listener = (NetSocketListener *) ignored;
int listenerIndex = GetListenerIndex(listener);
AppAssert( listenerIndex > -1 );
s_listenersMutex.Lock();
MatchMakerListener *_listener = s_listeners[listenerIndex];
AppAssert(_listener);
s_listenersMutex.Unlock();
//
// Generate a uniqueID for this request
// So we can tell the replies apart
s_uniqueRequestMutex.Lock();
int uniqueId = s_uniqueRequestid;
++s_uniqueRequestid;
s_uniqueRequestMutex.Unlock();
_listener->m_uniqueId = uniqueId;
//
// Build our request and convert to a byte stream
// (only need to do this once and keep re-sending)
Directory request;
request.SetName( NET_MATCHMAKER_MESSAGE );
request.CreateData( NET_METASERVER_COMMAND, NET_MATCHMAKER_REQUEST_IDENTITY );
request.CreateData( NET_MATCHMAKER_UNIQUEID, uniqueId );
//
// Open a connection to the MatchMaker service
// Start sending requests for our ID every few seconds
// to ensure the connection stays open in the NAT
NetSocketSession socket( *listener, s_matchMakerIp, s_matchMakerPort );
while( true )
{
//
// Stop if We've been asked to
if( _listener->m_shutDown )
{
break;
}
//
// Update the request with the latest auth data
Directory *clientProps = MetaServer_GetClientProperties();
request.CreateData( NET_METASERVER_GAMENAME, clientProps->GetDataString(NET_METASERVER_GAMENAME) );
request.CreateData( NET_METASERVER_GAMEVERSION, clientProps->GetDataString(NET_METASERVER_GAMEVERSION) );
request.CreateData( NET_METASERVER_AUTHKEY, clientProps->GetDataString(NET_METASERVER_AUTHKEY) );
delete clientProps;
int requestSize = 0;
char *requestByteStream = request.Write(requestSize);
//
// Send the request
int numBytesWritten = 0;
NetRetCode result = socket.WriteData( requestByteStream, requestSize, &numBytesWritten );
delete [] requestByteStream;
if( result != NetOk || numBytesWritten != requestSize )
{
AppDebugOut( "MatchMaker encountered error sending data\n" );
break;
}
NetSleep( PERIOD_MATCHMAKER_REQUESTID );
}
//
// Shut down the request
s_listenersMutex.Lock();
if( s_listeners.ValidIndex(listenerIndex) &&
s_listeners[listenerIndex] == _listener )
{
s_listeners.RemoveData(listenerIndex);
}
s_listenersMutex.Unlock();
delete _listener;
//.........这里部分代码省略.........