Example #1
0
//
// DTrack::RegisterDestruction
//
// Register the destruction of the item 'info'
//
void DTrack::RegisterDestruction(Info &info)
{
  // Never registered, or has died - perhaps deleting twice?
  if (!info.IsSetup())
  {
    ERR_FATAL(("Invalid destruction : Item is NOT setup! (Tracker %s)", name.str));
  }
  
  // Different id, something bad has happened - perhaps bad memory?
  if (*info.trackPos != info.id)
  {
    ERR_FATAL(("Invalid destruction : Different Id (Tracker %s, %d, %d)", name.str, *info.trackPos, info.id));
  }

  // Set item as empty
  *info.trackPos = DTRACK_EMPTY;

  // Add to cache
  CacheAdd(info.trackPos);

  // Info is no longer setup
  info.Clear();

  ASSERT(stateInfo.items);

  // Decrease number of items
  stateInfo.items--;
}