Page 1 of 1

MQ2Data.cpp updates

Posted: Wed Feb 14, 2018 1:45 am
by PeteSampras
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;
	}
}

Re: MQ2Data.cpp updates

Posted: Sun Jan 18, 2026 9:15 am
by xyilla