예제 #1
0
파일: Container.cpp 프로젝트: Nupper/AscEmu
void Container::SwapItems(int8 SrcSlot, int8 DstSlot)
{
    Item* temp;
    if (SrcSlot < 0 || SrcSlot >= (int8)m_itemProto->ContainerSlots)
        return;

    if (DstSlot < 0 || DstSlot >= (int8)m_itemProto->ContainerSlots)
        return;

    uint32 destMaxCount = (m_owner->ItemStackCheat) ? 0x7fffffff : ((m_Slot[DstSlot]) ? m_Slot[DstSlot]->GetProto()->MaxCount : 0);
    if (m_Slot[DstSlot] && m_Slot[SrcSlot] && m_Slot[DstSlot]->GetEntry() == m_Slot[SrcSlot]->GetEntry() && m_Slot[SrcSlot]->wrapped_item_id == 0 && m_Slot[DstSlot]->wrapped_item_id == 0 && destMaxCount > 1)
    {
        uint32 total = m_Slot[SrcSlot]->GetStackCount() + m_Slot[DstSlot]->GetStackCount();
        m_Slot[DstSlot]->m_isDirty = m_Slot[SrcSlot]->m_isDirty = true;
        if (total <= destMaxCount)
        {
            m_Slot[DstSlot]->ModStackCount(m_Slot[SrcSlot]->GetStackCount());
            SafeFullRemoveItemFromSlot(SrcSlot);
            return;
        }
        else
        {
            if (m_Slot[DstSlot]->GetStackCount() == destMaxCount)
            {

            }
            else
            {
                int32 delta = destMaxCount - m_Slot[DstSlot]->GetStackCount();
                m_Slot[DstSlot]->SetStackCount(destMaxCount);
                m_Slot[SrcSlot]->ModStackCount(-delta);
                return;
            }
        }
    }

    temp = m_Slot[SrcSlot];
    m_Slot[SrcSlot] = m_Slot[DstSlot];
    m_Slot[DstSlot] = temp;

    if (m_Slot[DstSlot])
    {
        SetSlot(DstSlot, m_Slot[DstSlot]->GetGUID());
        m_Slot[DstSlot]->m_isDirty = true;
    }
    else
    {
        SetSlot(DstSlot, 0);
    }

    if (m_Slot[SrcSlot])
    {
        SetSlot(SrcSlot, m_Slot[SrcSlot]->GetGUID());
        m_Slot[SrcSlot]->m_isDirty = true;
    }
    else
    {
        SetSlot(SrcSlot, 0);
    }
}
예제 #2
0
void Container::SwapItems(int8 SrcSlot, int8 DstSlot)
{
	Item *temp;
	if( SrcSlot < 0 || SrcSlot >= (int8)m_itemProto->ContainerSlots )
		return;
	
	if( DstSlot < 0 || DstSlot >= (int8)m_itemProto->ContainerSlots )
		return;

	uint32 destMaxCount = (m_owner->ItemStackCheat) ? 0x7fffffff : ((m_Slot[DstSlot]) ? m_Slot[DstSlot]->GetProto()->MaxCount : 0);
	if( m_Slot[DstSlot] &&  m_Slot[SrcSlot]&&m_Slot[DstSlot]->GetEntry() == m_Slot[SrcSlot]->GetEntry() && m_Slot[SrcSlot]->wrapped_item_id == 0 && m_Slot[DstSlot]->wrapped_item_id == 0 && destMaxCount > 1 )
	{
		uint32 total=m_Slot[SrcSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT)+m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
		m_Slot[DstSlot]->m_isDirty = m_Slot[SrcSlot]->m_isDirty = true;
		if( total <= destMaxCount )
		{
			m_Slot[DstSlot]->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT,m_Slot[SrcSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT));
			SafeFullRemoveItemFromSlot(SrcSlot);
			return;
		}
		else
		{
			if( m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT) == destMaxCount )
			{

			}
			else
			{
				int32 delta = destMaxCount - m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
				m_Slot[DstSlot]->SetUInt32Value(ITEM_FIELD_STACK_COUNT,destMaxCount);
				m_Slot[SrcSlot]->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT,-delta);
				return;
			}
		}
	}

	temp = m_Slot[SrcSlot];
	m_Slot[SrcSlot] = m_Slot[DstSlot];
	m_Slot[DstSlot] = temp;

	if( m_Slot[DstSlot])
	{
		SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (DstSlot*2),  m_Slot[DstSlot]->GetGUID()  );
		m_Slot[DstSlot]->m_isDirty = true;
	}
	else
	{
		SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (DstSlot*2), 0 );
	}

	if( m_Slot[SrcSlot])
	{
		SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (SrcSlot*2), m_Slot[SrcSlot]->GetGUID() );
		m_Slot[SrcSlot]->m_isDirty = true;
	}
	else
	{
		SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (SrcSlot*2), 0 );
	}
}
예제 #3
0
void Container::SwapItems(int8 SrcSlot, int8 DstSlot)
{
    Item *temp;
    if(m_Slot[DstSlot] &&  m_Slot[SrcSlot]&&m_Slot[DstSlot]->GetEntry()==m_Slot[SrcSlot]->GetEntry() && m_Slot[DstSlot]->GetProto()->MaxCount>1)
    {
        uint32 total=m_Slot[SrcSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT)+m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
        if(total<=m_Slot[DstSlot]->GetProto()->MaxCount)
        {
            m_Slot[DstSlot]->ModUInt32Value(ITEM_FIELD_STACK_COUNT,m_Slot[SrcSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT));
            SafeFullRemoveItemFromSlot(SrcSlot);
            return;
        }
        else
        {
            if(m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT) == m_Slot[DstSlot]->GetProto()->MaxCount)
            {

            }
            else
            {
                int32 delta=m_Slot[DstSlot]->GetProto()->MaxCount-m_Slot[DstSlot]->GetUInt32Value(ITEM_FIELD_STACK_COUNT);
                m_Slot[DstSlot]->SetUInt32Value(ITEM_FIELD_STACK_COUNT,m_Slot[DstSlot]->GetProto()->MaxCount);
                m_Slot[SrcSlot]->ModUInt32Value(ITEM_FIELD_STACK_COUNT,-delta);
                return;
            }
        }
    }
   
    temp = m_Slot[SrcSlot];
    m_Slot[SrcSlot] = m_Slot[DstSlot];
    m_Slot[DstSlot] = temp;

    if( m_Slot[DstSlot])
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (DstSlot*2),  m_Slot[DstSlot]->GetGUID()  );
    }
    else
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (DstSlot*2), 0 );
    }

    if( m_Slot[SrcSlot])
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (SrcSlot*2), m_Slot[SrcSlot]->GetGUID() );
    }
    else
    {
        SetUInt64Value(CONTAINER_FIELD_SLOT_1  + (SrcSlot*2), 0 );
    }
}