Jump to content

thespeedy

Inactive Member
  • Posts

    190
  • Joined

  • Last visited

  • Days Won

    1
  • Feedback

    0%

Posts posted by thespeedy

  1. vor 19 Minuten schrieb xP3NG3Rx:

    Here is the code for old compilers:

    
    struct s_sort {
    	bool operator() (LPITEM src, LPITEM dst) { return (src->GetVnum()<dst->GetVnum()); }
    } _sort;
    
    ACMD(do_sort_inventory)
    {
    	std::vector<LPITEM> collectItems;
    	std::vector<WORD> oldCells;
    	int totalSize = 0;
    	for (WORD i = 0; i < INVENTORY_MAX_NUM; ++i)
    	{
    		LPITEM item = ch->GetInventoryItem(i);
    		if (item)
    		{
    			totalSize += item->GetSize();
    			oldCells.push_back(item->GetCell());
    			collectItems.push_back(item);
    		}
    	}
    	if (totalSize - 3 >= INVENTORY_MAX_NUM)
    	{
    		ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("INVENTORY_FULL_CANNOT_SORT"));
    		return;
    	}
    
    	std::vector<LPITEM>::iterator it = collectItems.begin(), end = collectItems.end();
    	for (; it != end; ++it)
    		((LPITEM)*it)->RemoveFromCharacter();
    
    	std::sort(collectItems.begin(), collectItems.end(), _sort);
    
    	std::vector<LPITEM>::iterator it1 = collectItems.begin(), end1 = collectItems.end();
    	for (; it1 != end1; ++it1)
    	{
    		WORD cell = ch->GetEmptyInventory(((LPITEM)*it1)->GetSize());
    		((LPITEM)*it1)->AddToCharacter(ch, TItemPos(INVENTORY, cell)/*, isNew=false*/);
    	}
    }

     

    with auto stack or not? <3

    • Love 1
×
×
  • 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.