当前位置: 首页>>代码示例>>C++>>正文


C++ Directory::GetDataInt方法代码示例

本文整理汇总了C++中Directory::GetDataInt方法的典型用法代码示例。如果您正苦于以下问题:C++ Directory::GetDataInt方法的具体用法?C++ Directory::GetDataInt怎么用?C++ Directory::GetDataInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Directory的用法示例。


在下文中一共展示了Directory::GetDataInt方法的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 );
            }
        }
    }
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:55,代码来源:directory.cpp

示例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);
            }
        }
    }
}
开发者ID:gene9,项目名称:Darwinia-and-Multiwinia-Source-Code,代码行数:51,代码来源:directory.cpp

示例3: DefconMain


//.........这里部分代码省略.........
                sprintf( notes, "SYNC ERROR at %s", g_app->GetWorld()->m_theDate.GetTheDate() );
                RestartTestBed(-1, notes );
            }

            if( g_app->m_gameRunning &&
                g_app->GetWorld()->m_theDate.m_theDate > 10 )
            {
                float estimatedLatency = g_app->GetClientToServer()->GetEstimatedLatency();
                if( estimatedLatency > 60.0f )
                {
                    RestartTestBed(-1, "Connection lost" );
                }

                if( g_app->GetServer() &&
                    g_app->GetServer()->m_clients.NumUsed() < g_app->GetGame()->GetOptionValue("MaxTeams") )
                {
                    RestartTestBed(-1, "Client lost connection" );
                }
            }
#endif


            //
            // Read latest update from Server
            Directory *letter = g_app->GetClientToServer()->GetNextLetter();

            if( letter )
            {
                if( !strcmp(letter->m_name, NET_DEFCON_MESSAGE) == 0 ||
                    !letter->HasData(NET_DEFCON_SEQID, DIRECTORY_TYPE_INT) )
                {
                    AppDebugOut( "Client received bogus message, discarded (5)\n" );
                    delete letter;
                }
                else
                {
                    int seqId = letter->GetDataInt( NET_DEFCON_SEQID );                
                    if( seqId == -1 )
                    {
                        // This letter is just for us
                        ProcessServerLetters( letter );
                        delete letter;
                    }
                    else
                    {
                        AppReleaseAssert( seqId == g_lastProcessedSequenceId + 1, "Networking broken!" );

                        bool handled = ProcessServerLetters(letter);
                        if(!handled)
                        {
                            g_app->GetClientToServer()->ProcessServerUpdates( letter );
                        }
                
                        if( g_app->m_gameRunning )
                        {
                            g_app->GetWorld()->Update();
                        }
                        else
                        {
                            HandleGameStart();
                        }

                        g_lastServerAdvance = (float)seqId * SERVER_ADVANCE_PERIOD.DoubleValue() + g_startTime;
                        g_lastProcessedSequenceId = seqId;       

                        delete letter;            
                               
                        if( seqId == 0 && g_app->GetClientToServer()->m_resynchronising > 0.0f )
                        {
                            AppDebugOut( "Client successfully began Resynchronising\n" );
                            g_app->GetClientToServer()->m_resynchronising = -1.0f;
                        }

                        unsigned char sync = GenerateSyncValue();
                        SyncRandLog( "Sync %d = %d", g_lastProcessedSequenceId, sync );
                        g_app->GetClientToServer()->SendSyncronisation( g_lastProcessedSequenceId, sync );
                    }
                }
            }

            END_PROFILE("Client Main Loop");
        }

        //
        // Render

        UpdateAdvanceTime();

        if( TimeToRender(lastRenderTime) )
        {
            lastRenderTime = GetHighResTime();
            g_app->Update();
            g_app->Render();
            g_soundSystem->Advance();
            if( g_profiler ) g_profiler->Advance();
        }
    }
	delete g_app;
	g_app = NULL;
}
开发者ID:cahocachi,项目名称:DEFCON,代码行数:101,代码来源:defcon.cpp


注:本文中的Directory::GetDataInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。