Jump to content

Swap system,i ask experts


Recommended Posts

Here is for char_item.cpp :

 

//search
		if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
			return false;
//change with:
		if (!IsEmptyItemGrid(DestCell, item->GetSize(), Cell.cell))
		{
			if (!SwapItemToItem(Cell, DestCell))
				return false;
			else
				return true;
		}

//after last bool you put this:
bool CHARACTER::SwapItemToItem(TItemPos srcCell, TItemPos destCell)
{
	if (!CanHandleItem())
		return false;
	BYTE bCell = srcCell.cell;
	BYTE bDestCell = destCell.cell;
	BYTE pages_count = 4;

	if (srcCell.IsDragonSoulEquipPosition() || destCell.IsDragonSoulEquipPosition())
		return false;

	if (bCell == bDestCell)
		return false;

	if (srcCell.IsEquipPosition() || destCell.IsEquipPosition())
		return false;
	if (srcCell.window_type != INVENTORY || destCell.window_type != INVENTORY || destCell.cell >= INVENTORY_MAX_NUM)
		return false;

	LPITEM item1, item2;

	item1 = GetInventoryItem(bCell);
	item2 = GetInventoryItem(bDestCell);

	if (!item1 || !item2)
		return false;
	
	if (item1 == item2)
	{
	    sys_log(0, "[WARNING][WARNING][HACK USER!] : %s %d %d", m_stName.c_str(), bCell, bDestCell);
	    return false;
	}
	if (item1->GetSize() == item2->GetSize())
	{
		BYTE bCell1 = item1->GetCell();
		BYTE bCell2 = item2->GetCell();
		
		item1->RemoveFromCharacter();
		item2->RemoveFromCharacter();

		item1->AddToCharacter(this, TItemPos(INVENTORY, bCell2));
		item2->AddToCharacter(this, TItemPos(INVENTORY, bCell1));
	}
	
	if (item1->GetSize() > item2->GetSize())
	{
		BYTE bCell1 = item1->GetCell();
		ChatPacket(CHAT_TYPE_INFO, "Slot %d", bDestCell);
		BYTE pPageDest = bDestCell / (INVENTORY_MAX_NUM / pages_count);
		BYTE pPageDest2 = (((item1->GetSize()-1) * 5) + bDestCell) / (INVENTORY_MAX_NUM / pages_count);
		if (bDestCell >= INVENTORY_MAX_NUM)
			return false;
		if (pPageDest != pPageDest2)
		{
			for (int ii = 1; ii < 4; ++ii)
			{
				pPageDest2 = (bDestCell + (5*(item1->GetSize()-1)) - (5 * ii)) / (INVENTORY_MAX_NUM / pages_count);
				if (pPageDest == pPageDest2)
				{
					bDestCell = bDestCell - (5 * ii);
					break;
				}
			}
		}
		if (pPageDest != pPageDest2)
			return false;
		item1->RemoveFromCharacter();
		for (int i = 0; i < item1->GetSize(); ++i)
		{
			BYTE bBusyCell = bDestCell + (5 * i);
			BYTE lpage = bBusyCell / (INVENTORY_MAX_NUM / pages_count);
			if (lpage != pPageDest)
				continue;
			TItemPos busyCell(INVENTORY, bBusyCell);
			LPITEM busy = GetItem(busyCell);
			if (busy)
			{
				busy->RemoveFromCharacter();
				busy->AddToCharacter(this, TItemPos(INVENTORY, bCell1 + (5 * i)));
			}
		}
		item1->AddToCharacter(this, TItemPos(INVENTORY, bDestCell));
	}

	return true;
}

 

Link to comment
Share on other sites

Does it happen only with you move an item that its size is 3 slots?(like the weapon you show).

If so, try the following:

look for 

if (busy)
			{
				busy->RemoveFromCharacter();
				busy->AddToCharacter(this, TItemPos(INVENTORY, bCell1 + (5 * i)));
			}
		}

add below

(if item1->GetSize() == 3)

    bDestCell -= 5;

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.