Exemple #1
0
//
// DTrack::RegisterConstruction
//
// Register the construction of an item using the supplied id
//
void DTrack::RegisterConstruction(Info &info, U32 claimId)
{
  // Do error checking in a debug build
  #ifdef DEVELOPMENT

  // Is a valid id
  if (claimId < DTRACK_INITIALID)
  {
    LOG_ERR(("Tracker '%s' caught an invalid id claim (%d)", name.str, claimId));
    RegisterConstruction(info);
    return;
  }

  // Scan each block
  for (NList<Block>::Iterator b(&blocks); *b; b++)
  {
    // Check each item
    for (U32 i = 0; i < blockSize; i++)
    {
      if ((*b)->data[i] == claimId)
      {
        LOG_ERR(("Tracker '%s' Duplicate id (%d) in slot %d", name.str, claimId, i));
        RegisterConstruction(info);
        return;
      }
    }
  }

  #endif

  // Call private method using supplied id
  RegisterConstructionPrivate(info, claimId);
}
//
// Constructor
//
Record::Record(const char *name)
{
    RegisterConstruction(dTrack);

    // Save the crc of the name
    nameCrc = Crc::CalcStr(name);

    // Add to the record tree
    tree.Add(nameCrc, this);

    // Get fast find file instance
    if ((fastFind = FileSys::GetFastFind(name)) != NULL)
    {
        valid = TRUE;
    }
    else
    {
        LOG_WARN(("Sound data file not found [%s]", name));
        valid = FALSE;
    }

    // Setup default values
    freq = 0;
    lastUse = 0;
}