MQ2Data.cpp updates

Need help running MacroQuest2? Ask your questions about how to get things to work on your computer.

Moderator: MacroQuest Developers

PeteSampras
a snow griffon
a snow griffon
Posts: 322
Joined: Sat Dec 15, 2007 8:56 pm

MQ2Data.cpp updates

Post by PeteSampras » Wed Feb 14, 2018 1:45 am

I was looking through the FindItem TLOs and noticed they dont offer to FindItem by ID, any reason for this? If not all of the FindItem, FindItemCount, FindItemBank, and FindItemBank TLOs should be able to parse IDs via the PCONTENTS FindItemByID(int ItemID) in mq2utilities.cpp.

ie from:

Code: Select all

TLO(dataFindItem)
{
	if (!ISINDEX())
		return false;
	PCHAR pName = GETFIRST();
	BOOL bExact = false;

	if (*pName == '=')
	{
		bExact = true;
		pName++;
	}
	if (PCONTENTS pItem = FindItemByName(pName, bExact)) {
						Ret.Ptr = pItem;
						Ret.Type = pItemType;
						return true;
					}
	return false;
}
To:

Code: Select all

TLO(dataFindItem)
{
	if (!ISINDEX())
		return false;
	if (ISNUMBER()) {
		if(PCONTENTS pItem = FindItemByID(GETNUMBER())) {
			Ret.Ptr = pItem;
			Ret.Type = pItemType;
			return true;
		}
	}
	else {
		PCHAR pName = GETFIRST();
		BOOL bExact = false;

		if (*pName == '=')
		{
			bExact = true;
			pName++;
		}
		if (PCONTENTS pItem = FindItemByName(pName, bExact)) {
						Ret.Ptr = pItem;
						Ret.Type = pItemType;
						return true;
					}
		return false;
	}
}