Пример #1
0
///NotifyObserver전에 CInventory에있는 tagITEM을 Empty로 만들어야 한다.
bool CItemSlot::DelItem( int iInvenIdx )
{
	assert( iInvenIdx >= 0 && iInvenIdx < INVENTORY_TOTAL_SIZE );
	CItem* pItem = m_listItems[ iInvenIdx ];
	
	assert( pItem );
	if( pItem )
	{
		pItem->Clear();

		m_pEvent->SetID( CTEventItem::EID_DEL_ITEM );
		m_pEvent->SetIndex( iInvenIdx );
		m_pEvent->SetItem( pItem );

		SetChanged();
		NotifyObservers( m_pEvent );

		delete pItem;
		m_listItems[ iInvenIdx ] = NULL;
	}
	return true;
}
Пример #2
0
void CItemSlot::Clear()
{
	std::vector< CItem*	>::iterator iter;
	CItem* pItem = NULL;
	for( iter =	m_listItems.begin(); iter != m_listItems.end(); ++iter )
	{
		pItem = *iter;
		if( pItem )
		{
			pItem->Clear();

			m_pEvent->SetID( CTEventItem::EID_DEL_ITEM );
			m_pEvent->SetIndex( pItem->GetIndex() );
			m_pEvent->SetItem( pItem );

			SetChanged();
			NotifyObservers( m_pEvent );

			delete pItem;
			*iter = NULL;
		}
	}
}
Пример #3
0
bool CInArchive::ReadHeaderReal(const Byte *p, unsigned size, CItem &item)
{
  const Byte *pStart = p;

  item.Clear();
  item.Flags = m_BlockHeader.Flags;

  const unsigned kFileHeaderSize = 25;

  if (size < kFileHeaderSize)
    return false;

  item.PackSize = Get32(p);
  item.Size = Get32(p + 4);
  item.HostOS = p[8];
  item.FileCRC = Get32(p + 9);
  item.MTime.DosTime = Get32(p + 13);
  item.UnPackVersion = p[17];
  item.Method = p[18];
  unsigned nameSize = Get16(p + 19);
  item.Attrib = Get32(p + 21);

  item.MTime.LowSecond = 0;
  item.MTime.SubTime[0] =
      item.MTime.SubTime[1] =
      item.MTime.SubTime[2] = 0;

  p += kFileHeaderSize;
  size -= kFileHeaderSize;
  if ((item.Flags & NHeader::NFile::kSize64Bits) != 0)
  {
    if (size < 8)
      return false;
    item.PackSize |= ((UInt64)Get32(p) << 32);
    item.Size |= ((UInt64)Get32(p + 4) << 32);
    p += 8;
    size -= 8;
  }
  if (nameSize > size)
    return false;
  ReadName(p, nameSize, item);
  p += nameSize;
  size -= nameSize;

  /*
  // It was commented, since it's difficult to support alt Streams for solid archives.
  if (m_BlockHeader.Type == NHeader::NBlockType::kSubBlock)
  {
    if (item.HasSalt())
    {
      if (size < sizeof(item.Salt))
        return false;
      size -= sizeof(item.Salt);
      p += sizeof(item.Salt);
    }
    if (item.Name == "ACL" && size == 0)
    {
      item.IsAltStream = true;
      item.Name.Empty();
      item.UnicodeName.SetFromAscii(".ACL");
    }
    else if (item.Name == "STM" && size != 0 && (size & 1) == 0)
    {
      item.IsAltStream = true;
      item.Name.Empty();
      for (UInt32 i = 0; i < size; i += 2)
      {
        wchar_t c = Get16(p + i);
        if (c == 0)
          return false;
        item.UnicodeName += c;
      }
    }
  }
  */

  if (item.HasSalt())
  {
    if (size < sizeof(item.Salt))
      return false;
    for (unsigned i = 0; i < sizeof(item.Salt); i++)
      item.Salt[i] = p[i];
    p += sizeof(item.Salt);
    size -= sizeof(item.Salt);
  }

  // some rar archives have HasExtTime flag without field.
  if (size >= 2 && item.HasExtTime())
  {
    Byte aMask = (Byte)(p[0] >> 4);
    Byte b = p[1];
    p += 2;
    size -= 2;
    Byte mMask = (Byte)(b >> 4);
    Byte cMask = (Byte)(b & 0xF);
    if ((mMask & 8) != 0)
    {
      READ_TIME(mMask, item.MTime);
    }
    READ_TIME_2(cMask, item.CTimeDefined, item.CTime);
    READ_TIME_2(aMask, item.ATimeDefined, item.ATime);
  }