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


C++ NList::GetCount方法代码示例

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


在下文中一共展示了NList::GetCount方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SaveTasks

  //
  // Save
  //
  // Save a list of tasks
  //
  void SaveTasks(FScope *fScope, const char *name, const NList<Task> &tasks)
  {
    // Save nothing if no tasks in list
    if (tasks.GetCount())
    {
      // Write the name given
      fScope = fScope->AddFunction(name);

      // For each task in the list 
      for (NList<Task>::Iterator t(&tasks); *t; t++)
      {
        SaveTask(fScope, "Task", **t);
      }
    }
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:20,代码来源:taskctrl.cpp

示例2: Init

  //
  // Init
  //
  // Initialize system
  //
  void Init()
  {
    ASSERT(!initialized)
    ASSERT(!items.GetCount())

    PTree pTree;

    // Process the configuration
    if (pTree.AddFile(configName))
    {
      FScope *fScope = pTree.GetGlobalScope();
      FScope *sScope;

      while ((sScope = fScope->NextFunction()) != NULL)
      {
        switch (sScope->NameCrc())
        {
          case 0x64FFFFD7: // "Place"
          {
            // Load the data
            const char *type = StdLoad::TypeString(sScope);
            F32 direction = StdLoad::TypeCompassAngle(sScope);
            F32 distance = StdLoad::TypeF32(sScope);
            F32 orientation = StdLoad::TypeCompassAngle(sScope);

            // Create the item
            items.Append(new Item(type, direction, distance, orientation));
            break;
          }
        }
      }
    }

    // System now initialized
    initialized = TRUE;
  }
开发者ID:ZhouWeikuan,项目名称:darkreign2,代码行数:41,代码来源:sideplacement.cpp

示例3: Request

      //
      // Request
      //
      // Request sound effect data from the cache
      //
      Item * Request(Record *record)
      {
        ASSERT(Initialized());
        ASSERT(record);
        ASSERT(record->valid);
        ASSERT(record->fastFind);

        // Is this effect too large for the cache
        if (record->fastFind->Size() > maxCacheSize)
        {
          LOG_WARN(("File '%s' is too large for the cache", record->Name()));
          record->valid = FALSE;
          return (NULL);      
        }

        // Record if first time being played
        if (!record->freq)
        {
          actuallyUsed++;
        }

        // Increment the frequency of this effect
        record->freq++;

        // Step through each cache item
        for (NList<Item>::Iterator i(&items); *i; i++)
        {
          // Is this the one we're after
          if ((*i)->record == record)
          {
            cacheHits++;
            return (*i);
          }
        }

        // Record a cache miss
        cacheMisses++;
 
        // Make space for this new effect (will also shrink cache if max size decreased)
        while (items.GetCount() && (maxCacheSize - curCacheSize < record->fastFind->Size()))
        {
          // Try and remove a sound effect out of the cache
          if (!FlushItem())
          {
            // Unable to remove any effects
            return (NULL);
          }
        }

        ASSERT(maxCacheSize - curCacheSize >= record->fastFind->Size());

        // Open the file
        FileSys::DataFile *dFile = FileSys::Open(record->fastFind);

        // Should be found since already checked
        if (!dFile)
        {
          LOG_WARN(("File '%s' has vanished!", record->Name()));
          record->valid = FALSE;
          return (NULL);
        }

        // Let's just be extra careful, someone might swap data files on a server
        if (dFile->Size() != record->fastFind->Size())
        {
          LOG_WARN(("File '%s' has changed size!", record->Name()));
          record->valid = FALSE;
          return (NULL);
        }
  
        // Allocate memory for file data
        void *data = AIL_mem_alloc_lock(record->fastFind->Size());

        if (!data)
        {
          return (NULL);
        }

        // Read the data from disk
        if (dFile->Read(data, record->fastFind->Size()) != record->fastFind->Size())
        {
          // Free the memory we just allocated
          AIL_mem_free_lock(data);

          // Close the file
          FileSys::Close(dFile);

          // We won't try this one again
          record->valid = FALSE;

          LOG_WARN(("Error reading effect '%s' into cache", record->Name()));
          return (NULL);
        }

        // Close the file
//.........这里部分代码省略.........
开发者ID:grasmanek94,项目名称:darkreign2,代码行数:101,代码来源:sound_digital_cache.cpp


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