Jump to content

Ex Shop Sorting??


Recommended Posts

  • Honorable Member

You can sort the items by those names in Ascending or Descending, I did some (C&P)changes, but I did not test yet, so I do not know it works or not.
shop_manager.cpp

New function for sorting:

bool CompareShopItemPos(const SShopItemTable& lhs, const SShopItemTable& rhs)
{
	return (lhs.display_pos < rhs.display_pos);
}

Extended sorting statement:

	std::string stSort;
	if (!pNode->GetValue("sort", 0, stSort))
	{
		stSort = "None";
	}

	if (boost::iequals(stSort, "Asc"))
	{
		std::sort(shopItems.begin(), shopItems.end(), CompareShopItemName);
	}
	else if(boost::iequals(stSort, "Desc"))
	{
		std::sort(shopItems.rbegin(), shopItems.rend(), CompareShopItemName);
	}
	else if (boost::iequals(stSort, "Pos"))
	{
		std::sort(shopItems.begin(), shopItems.end(), CompareShopItemPos);
	}
Group B02
{
	Vnum	51
	Name	Costumes
	CoinType	SecondaryCoin
	Sort	Pos
	Group Items
	{
		#--#	Vnum	Count	Price
		1	41003	1	50
		2	41004	1	50
		3	45003	1	30
		4	45004	1	30
	}
}

 

  • Love 1
Link to comment
Share on other sites

I think it would be better, if the serial number exactly follow, and not so:

		1	10	1	1
		10	20	1	1
		11	30	1	1
		12	40	1	1
		13	50	1	1
		14	60	1	1
		15	70	1	1
		16	80	1	1
		17	90	1	1
		18	100	1	1
		19	110	1	1
		2	120	1	1
		20	130	1	1
		21	140	1	1
		22	150	1	1
		3	160	1	1
		30	170	1	1
		31	180	1	1
		32	190	1	1
		4	200	1	1
		5	210	1	1
		6	220	1	1
		7	230	1	1
		8	240	1	1
		9	250	1	1

 

But so:

		1	10	1	1
		2	120	1	1
		3	160	1	1
		4	200	1	1
		5	210	1	1
		6	220	1	1
		7	230	1	1
		8	240	1	1
		9	250	1	1
		10	20	1	1
		11	30	1	1
		12	40	1	1
		13	50	1	1
		14	60	1	1
		15	70	1	1
		16	80	1	1
		17	90	1	1
		18	100	1	1
		19	110	1	1
		20	130	1	1
		21	140	1	1
		22	150	1	1
		30	170	1	1
		31	180	1	1
		32	190	1	1

 

This can be done?

Link to comment
Share on other sites

  • 4 years later...

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.